mark_as_correct_incorrect: Question is correct value

Description Usage Arguments Examples

Description

Helper method to return

Usage

1
2
3
4
5
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

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

Example output



learnr documentation built on March 26, 2020, 7:45 p.m.