diff --git a/misc/logseq/src/index.ts b/misc/logseq/src/index.ts index 5c0a394..86ed293 100644 --- a/misc/logseq/src/index.ts +++ b/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) } });