Skip to main content

Quizify

Description

This plugin can be used to transform quiz content. As of now, it supports parsing quizes in Markdown format and outputting iframes to be embedded into a Docusaurus website. This is customizable, both by implementing a custom quiz parser and by creating custom templates for quiz output.

Options

parametertyperequireddefaultdescription
locationslist[str]trueN/AA list of glob patterns that expand to the locations of the files that link to quizzes. These are where the final output of this plugin will be embedded.
parser_typestrtrueN/APossible options: regex or python. This options specifies how the quiz is parsed. regex parsing is not implemented yet.
parserstrtrueN/AIf parser_type is python, this value specifies the path to the Python file that implements the parsing. This path can be relative to the location of the quizify.py file, inside the quizify_parsers folder or absolute. TBD for regex.
quiz_typestrtrueN/Alink or regex. link expects the quiz_regex option to be a regex with a single capture group for the path of the quiz. regex not implemented yet.
quiz_regexstrtrueN/ARegex with a single capturing group for the path of the quiz.
quiz_embedstrtrueN/Aiframe_link, replace or iframe_inline. iframe_link not implemented yet. replace option will replace the quiz link with the parsed quiz content. iframe_inline will replace the quiz with an iframe that uses the srcdoc attribute for content.
iframe_templatestrfalsedocusaurus_iframeIn case one of the iframe options has been chosen for quiz_embed, this option specifies the Jinja2 template for the generated iframe.
templatestrtrueN/AThis specifies the Jinja2 template used for generating the final quiz content.

Parsers

Parsers can be developed to fit any type of quiz, using Python. In order to implement a parser, you need to write a Python file that has a parse_quiz function with the following signature:

def parse_quiz(content, **kwargs):

The above function is expected to return a dictionary with the following keys: question, wrong (only the wrong answers), answer (the correct answer), feedback (optional)

The quizify plugin will call this function and provide the content of the quiz (the content parameter) alongside some metadata. For now, the metadata contains the path of the quiz and the line that matched when searching for the quiz. In order to account for future changes to the metadata, the **kwargs construct is used.

md_parser.py

The md_parser.py parser will parse quizes that are in the following format:

## Question Text

Is this a question?

## Question Answers

- this is a wrong answer
- this is also a wrong answer
+ this is a correct answer

## Feedback

Here is some optional feedback regarding the question.

The output of the parser is HTML.

The parser supports images inside a quiz, but they will be embedded as an <img> HTML tag, using base64 encoding. The parser also supports code sections with proper formatting, but they will be converted to an image using the https://kod.so API.

Templates

Quiz templates

Quiz templates will receive a dictionary with the following structure as an input:

{
"question": {
"text": "Is this a question?",
"id": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"feedback": "Here is some optional feedback regarding the question",
},
"answers": [
{
"text": "this is a wrong answer",
"id": "1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed"
},
{
"text": "this is also a wrong answer",
"id": "6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b"
},
{
"text": "this is a correct answer",
"id": "ddeb27fb-d9a0-4624-be4d-4615062daed4"
},
],
"answer_id": "ddeb27fb-d9a0-4624-be4d-4615062daed4",
}

Depending on the way you want to present the quiz, you may, or may not need the ids.

Iframe templates

Iframe templates will receive a dictionary with the following structure:

{
"iframe_id": "1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed",
"quiz_content": "<here will be the output of the quiz template>",
}

All ids generated by the quizify plugin are UUIDv4.