Skip to contents

Each row in the text data frame is interpreted as an exercise. We only need to define the columns that we are going to use; the rest of the columns are taken by default.

Usage

define_exercises(ex, df)

# S3 method for exam
define_exercises(ex, df)

Arguments

ex

An `exam` object.

df

A data frame containing exercises.

Value

An `exam`.

Details

Both the answer and the options are formed by a vector of strings, from which one is chosen to formulate the exercise and select the answer. To represent a vector of strings in a cell, the function `vector_to_string()` is used, which includes a separator ("<|>") between the vector elements to generate a string.

Examples


rmd <- system.file("extdata/template01.Rmd", package = "rexer")
exercises <- system.file("extdata/exercises.csv", package = "rexer")
q <- read_exercise_csv(exercises)
ex <- exam(
  rmd = rmd,
  examinees = NULL,
  instances_num = 10,
  random = TRUE,
  reorder_exercises = TRUE,
  select_n_exercises = NULL
) |>
  define_exercises(q)