8 Interactive Multiple Choice Questions
This page demonstrates the setup of an naquiz
multiple-choice quiz. The advantage of this extension is that we don’t need to use a Shiny server.
8.1 Multiple Choice Questions
8.1.1 Basic MCQ
A simple naquiz
example looks something like the question below to the reader (click the Markdown
tab to see how to write the markdown for it).
Bill Gates was the founder of:
✗Apple
✓Microsoft
:::::{.question}
Bill Gates was the founder of:
::::{.choices}
:::{.choice}
Apple
:::
:::{.choice .correct-choice}
Microsoft
:::
:::{.choice}
Facebook
:::
:::{.choice}
Google
:::
:::: :::::
The nested colon dividers and their counts can look confusing on the page, and missed/extra colons can break the layout of your page.
- The
{.question}
divider gets five colons. - The
{.choices}
divider that surrounds the choices presented to the reader gets four colons. - Each individual
{.choice}
divider gets three colons.
It presents a series of radio buttons from which the reader can choose one option. On clicking the option, the reader receives very basic feedback: a red cross (incorrect) or green tick (correct).
8.1.5 Placing an MCQ in a custom callout
We have created a custom callout called callout-question
which can be used to make MCQ stand out a bit more, with a consistent visual style.
Bill Gates was the founder of:
✗Apple
✓Microsoft
::: { .callout-question }
:::::{.question}
Bill Gates was the founder of:
::::{.choices}
:::{.choice}
Apple
:::
:::{.choice .correct-choice}
Microsoft
:::
:::{.choice}
Facebook
:::
:::{.choice}
Google
:::
:::{.button-clear title="Clear answer" button-class="btn btn-xs"}
:::
::::
:::::
::::{.btn-group}
:::{.button-hint title="Show hint" button-class="btn btn-xs"}
The company name starts with an 'M'...
:::
:::{.button-answer title="Show Answer" button-class="btn btn-xs"}
Bill Gates and Paul Allen founded Microsoft on April 4, 1975.
:::
::::
:::
8.1.6 Randomising question values
We can use R
or Python
to generate random values that can be used to compose questions that are different each time the page is rendered, by inserting a suitable R
/Python
code block and using the values in the question.
What is the sum of 7 and 13?
✗-6
✓20
✗6
✗91
::: { .callout-question }
:::::{.question}`r x_val` and `r y_val`?
What is the sum of
::::{.choices}
:::{.choice}`r x_val - y_val`
:::
:::{.choice .correct-choice}`r x_val + y_val`
:::
:::{.choice}`r y_val - x_val`
:::
:::{.choice}`r y_val * x_val`
:::
:::{.button-clear title="Clear answer" button-class="btn btn-xs"}
:::
::::
:::::
::::{.btn-group}
:::{.button-hint title="Show hint" button-class="btn btn-xs"}`r x_val` and `r y_val`
You need to add the two numbers
:::
:::{.button-answer title="Show Answer" button-class="btn btn-xs"}`r x_val` + `r y_val` = `r x_val + y_val`
:::
::::
:::
#| show: false
#| echo: false
<- sample(1:10, 1)
x_val <- sample(11:20, 1) y_val