It will return the already parsed data in node.data.parsedValue:
{
"metadata":{
"author":"catalin",
...
}
}
Question
compilers.question(node,'key')
This compiler is used for both "Practice" and "Revision" questions. Apart from the ast, this compiler takes another argument key:
question(ast,key){/* ... */}
Given a question AST node as input and a key:
{
"type":"section",
"name":"Revision"||"Practice",
"children":[...]
}
It will return:
{
"key":{
"rawText":"question with two gaps ??? ???\n* answer1\n*answer2\nanswer3",
"question":"question with two gaps ??? ???",
"answers":[
{
"text":"answer1",
"correct":true,
"correctIndex":0
},
{
"text":"answer2",
"correct":true,
"correctIndex":1
},
{
"text":"answer3",
"correct":false,
"correctIndex":null
}
]
}
}
Each answer will have its text, a correct flag indicating if it's one of the correct answers of the question and a correctIndex integer which indicates the index of the question gap it should match.
Quiz
compilers.quiz(node)
This compiler is similar to the question compiler. In addition, it returns a headline field specific to quizzes.
Because quiz question don't have question gaps ???, the first answer will be marked as correct (from within the parser).
"content":"This is a sample paragraph.[1]\n\nThis is a sample list[2]:\n\n* item one\n* item `two`\n\nSample code[3]:\n\n```javascript\nconsole.log('sample code')\n```\n",
"gameContent":"Sample game content\n",
"exercise":"Sample exercise\n",
"practice":{
"rawText":"This is a sample question with one gap:\n\n???\n\n* correct\n* incorrect\n* not a chance\n",
"question":"This is a sample question with one gap:\n\n???\n",
"answers":[
{
"text":"correct",
"correct":true,
"correctIndex":0
},
{
"text":"incorrect",
"correct":true,
"correctIndex":1
},
{
"text":"not a chance",
"correct":true,
"correctIndex":2
}
]
},
"revision":{
"rawText":"This is a sample question with two gaps:\n\n???\n\n???\n\n* correct\n* also correct\n* nah bro\n* fam, just no\n",
"question":"This is a sample question with two gaps:\n\n???\n\n???\n",
"answers":[
{
"text":"correct",
"correct":true,
"correctIndex":0
},
{
"text":"also correct",
"correct":false,
"correctIndex":null
},
{
"text":"nah bro",
"correct":false,
"correctIndex":null
},
{
"text":"fam, just no",
"correct":false,
"correctIndex":null
}
]
},
"quiz":{
"rawText":"### Quiz title\n\n\nSample quiz question\n\n* correct\n* *incorrect*\n* not a `chance`\n* nope\n",
"headline":"Quiz title",
"question":"Sample quiz question\n",
"answers":[
{
"text":"correct",
"correct":true,
"correctIndex":0
},
{
"text":"*incorrect*",
"correct":false,
"correctIndex":null
},
{
"text":"not a `chance`",
"correct":false,
"correctIndex":null
},
{
"text":"nope",
"correct":false,
"correctIndex":null
}
]
},
"footnotes":{
"rawText":"[1: Paragraph]\nSample explanation\n\n[2: List]\nSample list\n\n[3: Code]\nSample code\n\n```javascript\nvar x = 10\n```\n",
"items":[
{
"number":"1",
"name":" Paragraph",
"text":"\nSample explanation\n\n"
},
{
"number":"2",
"name":" List",
"text":"\nSample list\n\n"
},
{
"number":"3",
"name":" Code",
"text":"\nSample code\n\n```javascript\nvar x = 10\n```\n"