Search code examples
r-exams

Can a single R/Markdown file contain all exercises for R/exams?


Is it possible to have all exercises of an exam in the same R/Markdown file for R/exams? From what I have read, each question has to be in its own file. Sure, I can split, by using R, a R/Markdown file with several questions into files containing a single question, but wouldn't it be easier to have exam2xyz doing that?


Solution

  • It is a fundamental design principle in R/exams that 1 exercise = 1 file (either .Rmd or .Rnw).

    At first this might seem a bit overcomplicated, especially if you are used to putting together written exams with static exercises in a particular order. Users who do so often apply some manual randomization as they include small variations when they re-use exercises from old exams.

    In contrast, R/exams is designed for a different workflow. The goal is to write exercises that already include some level of randomization so that they can be re-used without modification in different contexts, e.g., in different combinations of exercises in written exams or as one of many similar exercises in an item pool in a learning management system etc.

    Therefore requiring that every exercise is a different file facilitates:

    • Building a large pool of independent exercises.
    • Working on the exercise pool collaboratively, e.g., in a version control system.
    • Thorough stress testing of dynamic exercises to make sure that they work in many random variations.
    • Re-using the same exercise file in different contexts.

    If you feel that this does not suit your workflow well, that's fair enough. In that case I would choose some separator line between different exercises in the same file. Then you can write a small function creates files in a temporary directory with the split up files. Feel free to ask for feedback on this if you're struggling with that. But before you do I would encourage you to try to go along with the separate files.