-
Notifications
You must be signed in to change notification settings - Fork 239
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
Setup chunks should be available to solutions #202
Comments
I'm sorry - I'm afraid I don't know the code well enough to see immediately how this would work. At the moment, I have questions like this:
How would the new features work, to allow me to share the setup between the exercise, the solution and the check? Sorry if that is obvious. |
It's not obvious. I'll admit setup is confusing. Yes, in the current setup, I don't see a direct way to access the information.
|
Sorry to reply on the run, but the exercise comes from here: https://github.com/alan-turing-institute/r-from-scratch/blob/LearnR-course-upload/LearnR-course.Rmd The checker is set here: https://github.com/alan-turing-institute/r-from-scratch/blob/LearnR-course-upload/LearnR-course.Rmd#L188 The exercise setup is here: https://github.com/alan-turing-institute/r-from-scratch/blob/LearnR-course-upload/LearnR-course.Rmd#L188 |
Ok! I believe I found the disconnect.
Once res <- run_until_fail(
parse(text = check_code),
envir = learnr::duplicate_env(envir_prep)
) This would be similar to
|
Ah - so does that mean that |
There will be a unique environment (envir_prep) for each exercise where the setup chunks have been executed. This environment is a copy of the environment before the student runs their code. No. Currently the design of learnr is to isolate each exercise. There have been many requests to be able to change this behavior. This will not change in the near future. |
Sorry for my lack of understanding. When you say 'unique environment', you mean a new environment, that is the same for each exercise, that has been recreated from scratch? If not, how do I customise the variables etc available for each exercise. I'm not proposing to allow students' code executed in one exercise to affect the environment in another - only that to be able to share code across exercises, to configure the environment for the solution, and the check. It's just an extension of what you already have with e.g. |
Should we alter how exercise checkers are evaluated? Currently, we pass in a copy of the setup environment ( I don't know if this will lead to scoping issues. I am still inclined to have the exercise.checker manage the execution environment and it call the checking code within the |
I just want to add that I think I am running into this problem as well, and there is an added wrinkle. When I run my assignments on my own laptop everything runs smoothly but once I upload it to shinyapps I get errors that appear to be the result of the solution checker not having access to the dataset I've loaded in the setup. I am also using |
After talking with @jcheng5, we believe it should be the exercise checker's responsibility. This will be possible in the next release. |
@schloerke - could you say more about how we can solve it using the stuff in the next release? |
I'll make a PR to |
We are writing a tutorial where the students are often, but not always using a data frame that should already be in the workspace. To do this, for the students' code, we have an exercise
my-exercise
that hasexercise.setup="get-the-data"
, whereget-the-data
is a setup chunk that loads the data.Of course the solution needs the same data, but it seems that adding
exercise.setup="get-the-data"
does not work as an option tomy-exercise-solution
.I think the setup for the exercise should be available to the solution by default. At least, it should be possible to pass the setup to the solution code. Otherwise we have to replicate the setup in every solution chunk, which is bearable when the setup is minor, but very annoying when it becomes more complex.
See: alan-turing-institute/r-from-scratch#3 for discussion.
The text was updated successfully, but these errors were encountered: