-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add initial support for multiple solutions #286
Conversation
@gadenbuie I'm curious about the incorrect answer in the reprex. It seems like we should only be including the alternative feedback, since the first feedback message is pointing away from a valid answer. |
@rossellhayes It's not doing anything smart. At this stage, handling multiple solutions is entirely manual and the grading code in that example just shows all of the feedback available if the submission didn't pass. The goal of this PR is just to make multiple solutions available in the grading code and to pre-process them so that they're manageable and consistent. |
It's a little more "all-in-one" which gives us portability since I want to use a similar function in learnr
TODO: Replace with staticimport
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.
Initial support looks great to me! Should we include the code feedback logic in another PR, or add it here?
Overview
This PR adds initial support for multiple solutions. Solutions can be written in the
-solution
chunk, using# <name/description> ----
comments as separators. (In RStudio you can add a solution heading using the Insert a new code section action, or Ctrl + Shift + R.)The solutions become available in the
.solution_code_all
list in the check environment. The name or description in the code section separator becomes the name of the list. We also give the solutions list an internal class with print methods.The
.solution_code
and.solution
objects are still populated as previously using the last solution in the chunk, andmock_this_exercise()
handles the solution code as expected.To make the above work and to consolidate logic, I refactored
mock_this_exercise()
to useprepare_check_env()
, meaning that bothgradethis_exercise_checker()
andmock_this_exercise()
follow a similar code path when preparing the check env. (There are a few things that are duplicated but different on either side, of course.)Example exercise
Here's an example exercise borrowed from Allow several ways to respond with learnr by djourd1 on StackOverflow.
Reprex tutorial
Other things
A few other incidental changes:
call_standardise_formals()
(mostly style changes) (129fe76)is_*()
functions (2524b27)list2env()
where the parent of the created env should be the empty env, not the parent frame (very in the weeds)env_rls()
, an rlang-backed replacement forpryr::rls()
(811df61)wrong_value()
whenthis
is missing, i.e. when the value is missing in the user's call (81284ce)