make.paper: Create formatted exam paper in Word, PDF, or HTML

View source: R/make_paper.R

make.paperR Documentation

Create formatted exam paper in Word, PDF, or HTML

Description

Requires a tibble of exam items, such as the one returned by question.bank() and can take one or more .Rmd files with code chunks with code required to generate item data/tables/figures etc.

Usage

make.paper(
  items,
  code_file = NULL,
  output_format = "word",
  out_file_name,
  yaml_header,
  title_page,
  ref_file = NULL,
  pre_preocessor = NULL,
  randomise_qs = TRUE,
  randomise_response_opts = TRUE,
  sample = FALSE
)

Arguments

code_file

character. Path to .Rmd file(s) with code chunks.

output_format

character. Output format for paper: one of "word", "pdf", "html".

out_file_name

character. Name of the output file without extension.

yaml_header,

@param title_page character. Vectors including lines for title page and YAML front matter. It is recommended to generate these using a function similar to sussex.boilerplate().

ref_file

character. Path to a reference docx file with formatting and headers. One can be found in the package folder.

pre_preocessor

Pre-processor function to include title_page in the final document. Currently uses teachR:::sus_pre_processor() that gets called by teachR:::exam_paper_document() passed to rmarkdown::render(). Using alternatives not yet implemented.

randomise_qs

logical. Should order of items be randomised (multi-items that share a single stem/paradigm will be appended to the end of the exam in either case). TRUE by default.

randomise_response_opts

logical. Should order of response options be randomised. TRUE by default.

sample

TRUE to generate a sample paper with correct responses at the end of the paper. FALSE by default.

items.

Data frame of items for a given exam paper. It is recommended to first generate a question bank with question.bank() and then select individual paper items.

Details

Function requires a .css and .js files for correct formatting of lab sheets/handouts. These files sit on the stats website in the [root]/sheet_files folder and the path is hard-coded into the function. Look for css and js objects in function body.

Value

Function returns a message if successful and, if sample=FALSE, produces two versions of paper; one with correct answers (..._WITH_KEY in file name) and one without. A scoring key CSV file gets also generated. If sample=TRUE,, only the sample paper gets generated.

Examples

paper_items <- teachR::question.bank("exam_items.Rmd", authors = "MV")
make.paper(paper_items, "exam_code.Rmd", out_file_name = "AnD_MCQ_paper_19_20",
           yaml_header = boilerplate$yaml, title_page = boiler_plate$title_page,
           ref_file = file.path(path.package("teachR"), "mcq_format_ref.docx"), pre_processor = teachR:::sus_pre_processor)

mivalek/teachR documentation built on Aug. 26, 2022, 6 a.m.