Creating Quizzes¶
Perhaps surprisingly, tools to support the creation of interactive quiz related content in Jupyter notebooks is rather scarce.
One of the few packages available for creating quizzes is jmshea/jupyterquiz
.
jupyterquiz
¶
The jmshea/jupyterquiz
package allows you to create and embed simple multiple choice questions (1 from N correct, M from N correct) in Jupyter notebooks and Jupyter Book outputs.
Questions and answers can be included in the notebook pulled in from a JSON file stored locally or an a remote server.
example = [{
"question": "Which of these are used to create formatted text in Jupyter notebooks?",
"type": "multiple_choice",
"answers": [
{
"answer": "Wiki markup",
"correct": False,
"feedback": "False."
},
{
"answer": "SVG",
"correct": False,
"feedback": "False."
},
{
"answer": "Markdown",
"correct": True,
"feedback": "Correct."
},
{
"answer": "Rich Text",
"correct": False,
"feedback": "False."
}
]
}]
Note
The actual code defining the quiz question and answer could be inlcuded in a remove-input
rather than hide-input
tagged cell in the source document. Removing the input would mean that the answers would not be directly viewable in the rendered Jupyter Book output, although they could be cribbed by viewing the JavaScript source of the quiz.
from jupyterquiz import display_quiz
display_quiz(example)
When publishing content via a Jupyter Book output, any cells defining the questions, and more importantly, the answers, can be kept secret by defining the question and answer dictionary in a cell that is removed fom the rendered HTML book view.
Where students have access to the source notebook, however, this means that students would be able to look up the answers via the question and answer source code. In such a case, the question and answer can be encoded into a base-64 encoding that is not directly human readable.
Note
If we tag the question defining cell, for example using a tag such as jupyterquiz-src
, it is not hard to imagine a simple document processor that could encode the plain text contents of such a cell in base-64 form for release to students.