-
Notifications
You must be signed in to change notification settings - Fork 4
Important tips, warnings
Richard Morey edited this page Aug 8, 2021
·
3 revisions
This content is relevant to flexTeaching version 0.2+.
Before writing assignments, read Mastering Shiny, Chapter 22: Security. This will help you avoid pitfalls like writing code that exposes the master secret.
-
Only write to temporary files and folders. If you write your own functions to compile assignment pages, make sure you write all files to temporary folders (eg, with
tempdir
ortempfile
). Some services such as shinyapps.io restrict permissions to write to particular folders, so your app may fail if you try to write to a non-temp folder.
When usingrmarkdown::render()
, you'll need to ensure thatoutput_dir
andintermediates_dir
are both set to temporary folders. For an example, see the source forcompileAssignmentHtmlDefault
inflexTeaching
.
-
Never use set.seed() inside a flexTeaching assignment! flexTeaching manages the random seeds; that's its whole purpose, so setting a random seet inside an an assignment will render it useless. If you'd to run some code with a fixed random seed, use the function
R.utils::withSeed()
, e.g.
# Use seed "123"
R.utils::withSeed(
{
y = rnorm(1)
}, 123)
y
# [1] -0.5604756
# (in R 4.1)