quiz: Tutorial quiz questions

Description Usage Arguments Examples

View source: R/quiz.R

Description

Add interative multiple choice quiz questions to a tutorial.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 
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.")
)

## End(Not run)

quantargo/qlearn documentation built on Jan. 25, 2022, 12:35 a.m.