Question answer optionsSource:
Create options for users when used in
question_radio() learnr questions. For
question_numeric(), the individual answers aren't directly presented to
students, but their values can be used in determining if the student
submitted the correct answer. For flexible feedback from checkbox, text, and
answer_fn() can be used to provide a function that
evaluates the student's submission and returns a custom result.
The answer text or value; for selection-type questions this value is shown to the user.
Logical value indicating whether the
answer()corresponds to a correct or incorrect option.
A custom message shown when this answer is selected and when the overall question result matches the state of this answer. For example, the
messageof a correct solution is not shown when the entire submission is incorrect, but will be shown when the user both picks this answer option and the question is correct.
The label shown when the option is presented to the user.
A function used to evaluate the submitted answer. The function is called with the student's submitted value as the first argument, so the function should take at least one argument where the user's value will be passed to the first argument. Inline purrr-style lambda functions are allowed, see
rlang::as_function()for complete details on the syntax.
In the body of the function, you can perform arbitrary calculations to decide if the submitted answer is or is not correct and to compose the message presented to the user. To signal a final answer, call
mark_as()or its helper functions
incorrect(). All other return values are ignored; e.g. by returning
NULLyou may yield the submission evaluation to other
answer_fn()options for the question.