learnr (version 0.9.2.1)

quiz: Tutorial quiz questions

Description

Add interative multiple choice quiz questions to a tutorial.

Usage

quiz(..., caption = "Quiz")

question(text, ..., type = c("auto", "single", "multiple"), correct = "Correct!", incorrect = "Incorrect.", allow_retry = FALSE, random_answer_order = FALSE)

answer(text, correct = FALSE, message = NULL)

Arguments

...

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 "single" to indicate that even though multiple correct answers are specified that inputs which include only one correct answer are still correct. Pass "multiple" to force the use of checkboxes (as opposed to radio buttons) even though only once correct answer was provided.

correct

For question, text to print for a correct answer (defaults to "Correct!"). For answer, a boolean indicating whether this answer is correct.

incorrect

Text to print for an incorrect answer (defaults to "Incorrect.")

allow_retry

Allow retry for incorrect answers.

random_answer_order

Display answers in a random order.

message

Additional message to display along with correct/incorrect feedback.

Examples

Run this code
# NOT RUN {
question("What number is the letter A in the alphabet?",
  answer("8"),
  answer("14"),
  answer("1", correct = TRUE),
  answer("23")
)

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.")
)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab