Description Usage Arguments Details See Also Examples
Add interactive quiz questions to a tutorial. Each quiz question is executed within a shiny runtime to provide more flexibility in the types of questions offered. There are three default types of quiz questions:
learnr_radio
Radio button question. This question type will only allow for a single answer submission by the user. An answer must be marked for the user to submit their answer.
learnr_checkbox
Check box question. This question type will allow for one or more answers to be submitted by the user. At least one answer must be marked for the user to submit their answer.
learnr_text
Text box question. This question type will allow for free form text to be submitted by the user. At least one non-whitespace character must be added for the user to submit their answer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | quiz(..., caption = "Quiz")
question(
text,
...,
type = c("auto", "single", "multiple", "learnr_radio", "learnr_checkbox",
"learnr_text"),
correct = "Correct!",
incorrect = "Incorrect",
try_again = incorrect,
message = NULL,
post_message = NULL,
loading = c("**Loading:** ", text, "<br/><br/><br/>"),
submit_button = "Submit Answer",
try_again_button = "Try Again",
allow_retry = FALSE,
random_answer_order = FALSE,
options = list()
)
answer(text, correct = FALSE, message = NULL)
|
... |
One or more questions or answers |
caption |
Optional quiz caption (defaults to "Quiz") |
text |
Question or option text |
type |
Type of quiz question. Typically this can be automatically determined
based on the provided answers. Pass |
correct |
For |
incorrect |
Text to print for an incorrect answer (defaults to "Incorrect")
when |
try_again |
Text to print for an incorrect answer (defaults to "Incorrect")
when |
message |
Additional message to display along with correct/incorrect feedback. This message is always displayed after a question submission. |
post_message |
Additional message to display along with correct/incorrect feedback.
If |
loading |
Loading text to display as a placeholder while the question is loaded |
submit_button |
Label for the submit button. Defaults to |
try_again_button |
Label for the try again button. Defaults to |
allow_retry |
Allow retry for incorrect answers. Defaults to |
random_answer_order |
Display answers in a random order. |
options |
Extra options to be stored in the question object. |
Note, the print behavior has changed as the runtime is now Shiny based. If question
s and quiz
es are printed in the console, the S3 structure and information will be displayed.
For more information and question type extension examples, please see the help documentation for question_methods
and view the question_type
tutorial: learnr::run_tutorial("question_type", "learnr")
.
random_praise
, random_encouragement
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | quiz(
question("What number is the letter A in the alphabet?",
answer("8"),
answer("14"),
answer("1", correct = TRUE),
answer("23"),
incorrect = "See [here](https://en.wikipedia.org/wiki/English_alphabet) and try again.",
allow_retry = TRUE
),
question("Where are you right now? (select ALL that apply)",
answer("Planet Earth", correct = TRUE),
answer("Pluto"),
answer("At a computing device", correct = TRUE),
answer("In the Milky Way", correct = TRUE),
incorrect = paste0("Incorrect. You're on Earth, ",
"in the Milky Way, at a computer.")
)
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.