-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support answer-functions #657
Conversation
The answer's value is a function that's evaluated on the user's submitted value. It signals a final answer via `mark_as()`
|
- Also adds expect_marked_as() test helper - Document that mark_as() doesn't do md -> html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks good to me! My only suggestion would be to add more documentation with examples of answer_fn
s in actions. I think it's particularly hard to understand how answer_fn
works in checkbox questions right now.
E.g. lifecycle::deprecated()
otherwise rmarkdown::render() swallows the warnings in RStudio's render pane
👏 |
Hello! `DataIn <- data.frame(x = c(65,34,48,72,58,63,26,80), y = c(74,49,45,80,63,72,12,75)) question_numeric( if not, could I request that as a feature? Or I guess I could find a way to get the variable recognised in the global environment? |
Adds
answer_fn()
, as a complimentary function toanswer()
. Whereanswer()
provides an option and a single value against which the student's response is compared,answer_fn()
provides a function that is evaluated on the submission and is not visible to the user. If the function returns a marked answer viamark_as()
orcorrect()
orincorrect()
, that mark determines the overall question correctness.The most obvious use cases are for text and numeric answers where
answer_fn()
could be used to evaluate the submission to use regular expressions or check that it falls within a range. Both of those actions are difficult to do currently. Since text and numeric questions don't present answer options to the user, the question answers are evaluated in the order they were written. (Note we now disablerandom_answer_order
in text questions.)For checkbox questions, the submission is checked against function-type answers before checking against regular answers. Additionally, function-type answers are not shown to the user. This enables scenarios like "pick 2 of 3 correct answers" or "any answer is correct". If
random_answer_order = TRUE
and the question usesanswer_fn()
answers, the function-type answers will be checked first, but their internal order will be randomized.Function-type answers are not allowed in radio questions since the user is forced to select only one answer option. Trying to use
answer_fn()
insidequestion_radio()
will throw an error at render.Here's a really basic toy example showing how
answer_fn()
could be used to apply regular expressions in a text question.