Andrea Fazzi пре 1 година
родитељ
комит
d5d6fd2e08
1 измењених фајлова са 8 додато и 13 уклоњено
  1. 8 13
      misc/logseq/src/index.ts

+ 8 - 13
misc/logseq/src/index.ts

@@ -57,23 +57,18 @@ const main = () => {
 		logseq.provideModel({
 			async createOrUpdateQuiz() {
 			    const parentBlock = await logseq.Editor.getBlock(payload.uuid, { includeChildren: true });
-			    					const answers = child.children.map((answer: BlockEntity, i: number) => {
-						return { text: answer.content, correct: (i == 0) ? true : false }
-					})
+			    const answers = parentBlock.children.map((answer: BlockEntity, i: number) => {
+				return { text: answer.content, correct: (i == 0) ? true : false }
+			    })
 
 			    const quiz = {
-				question: {text: parentBlock.children[0].content },
+				question: {text: parentBlock.content },
 				answers: answers
 			    }
-					const question = { text: child.content }
-					return { question: question, answers: answers, uuid: child.uuid }
-				});
-				quizzes.forEach(async (quiz, i) => {
-					const res = await fetch(endpoint+'/create', { method: 'POST', body: JSON.stringify(quiz) })
-					const data = await res.json();
-					const block = await logseq.Editor.getBlock(quiz.uuid)
-					await logseq.Editor.upsertBlockProperty(parentBlock.uuid, `probo-quiz-uuid`, data.content.ID)
-				})
+
+			    const res = await fetch(endpoint+'/create', { method: 'POST', body: JSON.stringify(quiz) })
+			    const data = await res.json();
+			    await logseq.Editor.upsertBlockProperty(parentBlock.uuid, `probo-quiz-uuid`, data.content.ID)
 
 			}
 		});