Skip to content
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

Executing invisible code #23

Open
MartinKies opened this issue Jun 8, 2020 · 4 comments
Open

Executing invisible code #23

MartinKies opened this issue Jun 8, 2020 · 4 comments

Comments

@MartinKies
Copy link
Contributor

I am working on a multi-day course where the data set is iteratively cleaned and transformed with an online RTutor Shinyapp. I would like the participants to pause and continue reasonably often and use the exercises to break up the course into several small pieces.

It would be great if the participants could seamlessly pick up their work and and continue with the data set after the transformations. If I understand the manual correctly the proposed solution to do so is to include a chunk at the beginning of each exercise forcing the participant to go through all steps again.

A possible alternative could be to design save points (e.g. using Rdata files) and have the participant load them at the beginning of each exercise. I would prefer it however, if this would happen without the participant having to do so manually as this might prove bothersome if it has to be done a lot.

Is it possible to invisibly execute code when loading an exercise similar to an automatically loaded "include=FALSE" RMD chunk? I played with preknit chunks and tried to directly use RMD code but this did not work.

@skranz
Copy link
Owner

skranz commented Jun 8, 2020

This may not be exactly the solution to what you described, but perhaps still be helpful. I have uploaded a new RTutor version on Github where show.ps has the new argument prev.chunks.sample.solution. If you set it to TRUE then a user can press edit on any chunk even without having solved the previous chunks. All unchecked previous chunks of the current exercise will then be run with the sample solution, i.e. the user can start in any chunk of an exercise in a problem set. By default prev.chunks.sample.solution is TRUE whenever a sample solution button is shown.

Can you check whether that works and is helpful for your problem?

If users solve their problem set at home, continuing where one stopped last time was already possible by setting auto.save.code = TRUE in the call to show.ps. (But this would not have helped e.g. on shinyapps.io because you could not save and reload a particular user's code.)

Note that you should still make each exercise self contained, however. If you want to continue with prepared data from a previous exercise, just add small chunk with a task or task_notest block at the beginning of that exercise which loads again the prepared data. If you repeatedly load a big data set in several exercises you can use memoization. See the chapter in the RTutor documentation here:
https://skranz.github.io/RTutor/articles/04_Evaluation.html

@MartinKies
Copy link
Contributor Author

Thank you very much for your fast response!

I have tested it over the day and this change is indeed helpful. It does not work every time however and I was not able to pinpoint the problem exactly.

I have two exercises:
Exercise A has as the very first chunk a single read.csv statement in a notest chunk. i.e. visible to the participant. Editing a later chunk shows the expected behavior of all previous chunks (including the first one) being executed with the sample solution.

Exercise B has as the very first chunk a single read.csv statement outside a test chunk:

#< task
# Lesen Sie den Datensatz ein ...

#>
verkauf_datensatz <- read.csv("data/verkauf.csv", sep = ";")

This is not executed correctly when skipping it and trying to edit a later chunk:
Failure in this required chunk: You have not yet made an assignment to verkauf_datensatz.

Manually clicking on edit, then solution and then check marks this chunk as correctly solved. All subsequent chunks are solved automatically (e.g. when skipping chunk 2 and 3 and going directly to 4)

@skranz
Copy link
Owner

skranz commented Jun 9, 2020

Thanks for testing. There was indeed still a bug in my code. I have uploaded a new RTutor version. Can you check whether it now works fine?

@MartinKies
Copy link
Contributor Author

Thank you very much! The behavior is now as expected - both exercises can be started at later chunks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants