learnr
learnr copied to clipboard
Slow down successive exercise execution via debounce
This adds a new option tutorial.exercise.debounce to slow down successive exercise evaluations.
I've noticed that you can overwhelm a server that hosts a learnr tutorial by repeatedly clicking "Run Code" very quickly in an exercise chunk. On the Linux server that I'm using, this causes learnr to run a new R instance for each evaluation, amounting to hundreds or thousands of instances, depending on how quick you can click and how fast the server can execute and tear down again the R instances.
My fix introduces the use of debounce() when the option is active.
Use options("tutorial.exercise.debounce" = 1000) in a setup chunk of an Rmarkdown document to enable a debounce of 1 sec. The default value is 0, which keeps the behavior currently implemented in learnr (i.e. no debounce).
This is my first contribution here, I'm not quite sure if I've updated the documentation at the correct spot.
PR task list:
- [x] Update NEWS
- [x] Update documentation with
devtools::document()
As this issue is security-related, it would be great if the pull-request could be reviewed. Thank you very much.
Thank you for the PR!
I'm closing this PR in favor of #818 as I can not apply suggestions (weird!)
I'm closing this PR in favor of #818 as I can not apply suggestions (weird!)
The PR was opened without the "Allow maintainers to edit this PR" option selected.
The PR was opened without the "Allow maintainers to edit this PR" option selected.
Sorry, that was not on purpose, must have missed it.
Thanks for considering this patch!