Add interactive fill in the blank tasks to your learnr
tutorials.
You must include at least one single blank line ___ in the question text.
A blank is created by typing 3 underscores.
Usage
question_blank(
text,
...,
type = "blank",
correct = "Correct!",
incorrect = "Incorrect",
try_again = incorrect,
allow_retry = FALSE,
random_answer_order = FALSE,
placeholder = "Enter answer here...",
trim = TRUE,
rows = NULL,
cols = NULL,
options = list()
)
Arguments
- text
Question or option text
- ...
parameters passed onto learnr answer.
- type
Type of quiz question. Typically this can be automatically determined based on the provided answers. Pass
"radio"
to indicate that even though multiple correct answers are specified that inputs which include only one correct answer are still correct. Pass"checkbox"
to force the use of checkboxes (as opposed to radio buttons) even though only one correct answer was provided.- correct
For
question
, text to print for a correct answer (defaults to "Correct!"). Foranswer
, a boolean indicating whether this answer is correct.- incorrect
Text to print for an incorrect answer (defaults to "Incorrect") when
allow_retry
isFALSE
.- try_again
Text to print for an incorrect answer when
allow_retry
isTRUE
. Defaults to "Incorrect. Be sure to select every correct answer." for checkbox questions and "Incorrect" for non-checkbox questions.- allow_retry
Allow retry for incorrect answers. Defaults to
FALSE
.- random_answer_order
Display answers in a random order.
- placeholder
Sample text to appear in blank.
- trim
Logical to determine if whitespace before and after the answer should be removed. Defaults to
TRUE
.- rows, cols
Defines the size of the text input area in terms of the number of rows or character columns visible to the user. If either
rows
orcols
are provided, the quiz input will useshiny::textAreaInput()
for the text input, otherwise the default input element is a single-lineshiny::textInput()
.- options
Extra options to be stored in the question object. This is useful when using custom question types. See
sortable::question_rank()
for an example question implementation that uses theoptions
parameter.
Details
The text utilizes HTML for further display customization, which can be used to insert an image or line break.
Examples
question_blank(
"3 + ___ = 5 <br/>
___ - 4 = 4",
learnr::answer("2", correct = TRUE),
learnr::answer("8", correct = TRUE),
allow_retry = TRUE
)
#> Question: "3 + ___ = 5 <br/>
#> ___ - 4 = 4"
#> type: "blank"
#> allow_retry: TRUE
#> random_answer_order: FALSE
#> answers:
#> ✔: "2"
#> ✔: "8"
#> messages:
#> correct: "Correct!"
#> incorrect: "Incorrect"
#> try_again: "Incorrect"
#> Options:
#> placeholder: "Enter answer here..."
#> trim: TRUE