Skip to content

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.

Tips

  • 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 or tempfile). 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 using rmarkdown::render(), you'll need to ensure that output_dir and intermediates_dir are both set to temporary folders. For an example, see the source for compileAssignmentHtmlDefault in flexTeaching.

Warnings

  • 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)
Clone this wiki locally