correct | R Documentation |
Helper method to communicate that the user's submission was correct or
incorrect. These functions were originally designed for developers to create
question_is_correct()
methods for custom question types, but they can also
be called inside the functions created by answer_fn()
to dynamically
determine the result and message provided to the user.
correct(messages = NULL)
incorrect(messages = NULL)
mark_as(correct, messages = NULL)
messages |
A vector of messages to be displayed. The type of message
will be determined by the |
correct |
Logical: is the question answer is correct |
Returns a list with class learnr_mark_as
to be returned from the
question_is_correct()
method for the learnr question type.
answer_fn()
# 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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.