randomize_quiz: Randomize quiz questions

Description Usage Arguments Details Examples

View source: R/randomizer.R

Description

Randomize quiz questions

Usage

1
randomize_quiz(data, id = NULL, randomize_choices = FALSE, n_questions = NULL)

Arguments

data

A data.frame with questions and possible answers

id

An optional ID column. If NULL will generate a numeric ID based on row order

randomize_choices

Logical, if TRUE will also randomize the order of the choices

n_questions

The total number of questions to sample. If NULL, returns all; set to an integer to return that many or use a proportion of items where the total selected is rounded down.

Details

Assumes that there is one line per question and that the question column is named "Question" and that answers begin with "Answer".

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
example_quiz <- data.frame(
  Question = c("First question?", "Second question?",
               "Third question?", "Fourth question?"),
  Answer_A = c("A", "1", "A1", "1A"),
  Answer_B = c("B", "2", "B2", "2B"),
  Answer_C = c("C", "3", "C3", "3C"),
  Answer_D = c("D", "4", "D4", "4D")
)

randomize_quiz(example_quiz)
randomize_quiz(example_quiz, randomize_choices = TRUE)
randomize_quiz(example_quiz, n_questions = 2)
randomize_quiz(example_quiz, n_questions = 0.80)

jmbarbone/QuizRandomizer documentation built on Jan. 1, 2021, 5:33 a.m.