Learn R Programming

learnr (version 0.10.1)

correct: Question is correct value

Description

Helper method to return

Usage

correct(messages = NULL)

incorrect(messages = NULL)

mark_as(correct, messages = NULL)

Arguments

messages

a vector of messages to be displayed. The type of message will be determined by the correct value.

correct

boolean that determines if a question answer is correct

Examples

Run this code
# NOT RUN {
# Radio button question implementation of `question_is_correct`
question_is_correct.radio <- function(question, value, ...) {
  for (ans in question$answers) {
    if (as.character(ans$option) == value) {
      return(mark_as(
        ans$correct,
        ans$message
      ))
    }
  }
  mark_as(FALSE, NULL)
}
# }

Run the code above in your browser using DataLab