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

Is it possible to configure learnr to always forget previous attempts #607

Open
gadenbuie opened this issue Nov 4, 2021 · 1 comment
Open
Labels
FAQ 🙋 Good question/issue for FAQ section in docs

Comments

@gadenbuie
Copy link
Member

Just got around to using learnr + gradethis for a randomization experiment.
If i'm reading this correctly,
It seems this PR will fix the issue I'm having with my local .Rmd document (not as a package) and on shinyapps.io where my previous attempts are being cached, and I either need to manually "Start Over" or run things in a private/incognito window. 👍

Will this let me also put in the yaml header so that it never caches the previous attempts? Something like:

output: 
  learnr::tutorial:
    progressive: true
    allow_skip: false
    clean: true # <--- this option?

Originally posted by @chendaniely in #601 (comment)

@gadenbuie
Copy link
Member Author

gadenbuie commented Nov 4, 2021

@chendaniely the feature in #601 adds a clean argument to the run_tutorial() function, which controls whether the tutorial is pre-rendered with each run. When clean = TRUE in run_tutorial() (when that feature lands), all of the "static" R code in the tutorial Rmd is re-run to build and launch the tutorial app.

But this is different from individual sessions, i.e. individual times you or others access the running tutorial. While you're interacting with the tutorial, learns uses a couple strategies to store your previous answers so that they can restored when you return to a tutorial. learnr calls this Tutorial Storage and the default behavior is to use the storage mechanisms provided by browsers to have the user's browser keep track of the code or questions that were last entered.

The learnr documentation describes this in the Tutorial Storage page. There you can also find the code required to set up a no-op storage system. I've copied and pasted it below (on 2021-11-04). You can put the code below in the setup chunk of your tutorial and every time you re-load the tutorial it should re-start without restoring any previous answers.

options(tutorial.storage = list(

  # save an arbitrary R object "data" to storage
  save_object = function(tutorial_id, tutorial_version, user_id, object_id, data) {
  
  },
  
  # retreive a single R object from storage
  get_object = function(tutorial_id, tutorial_version, user_id, object_id) { 
    NULL 
  },
  
  # retreive a list of all R objects stored
  get_objects = function(tutorial_id, tutorial_version, user_id) { 
    list() 
  },
  
  # remove all stored R objects
  remove_all_objects = function(tutorial_id, tutorial_version, user_id) {
  
  }
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FAQ 🙋 Good question/issue for FAQ section in docs
Projects
None yet
Development

No branches or pull requests

1 participant