R/question-types.R

#' Multipe-Choice Question
#'
#' Wrapper around [learnr::question] with sensible defaults for multiple choice questions.
#' @param ...,type,allow_retry,random_answer_order see [learnr::question] for these parameters
#' @param correct a vector of strings to be displayed for correct answers. One of these strings is chosen at random.
#' @importFrom learnr question
#' @export
mcquestion <- function (..., type = 'learnr_checkbox', allow_retry = TRUE, random_answer_order = TRUE,
                        correct = c('Perfect!', 'Nice!', 'Well done!', 'Good job!', 'Great!', 'Correct!', 'Exactly!')) {
  question(...,
           type = 'learnr_checkbox',
           allow_retry = TRUE,
           correct = sample(correct, 1),
           random_answer_order = TRUE)
}
dakep/stat305templates documentation built on Nov. 27, 2022, 8:23 a.m.