# num_to_schoice: Generate Single-Choice Question List from Numeric Solution In exams: Automatic Generation of Exams in R

## Description

A function for generating a single-choice question list for one correct numeric solution along with four wrong solutions.

## Usage

 1 2 3 num_to_schoice(correct, wrong = NULL, range = c(0.5, 1.5) * correct, delta = 1, digits = 2, method = c("runif", "delta"), sign = FALSE, verbose = getOption("num_to_choice_warnings"))

## Arguments

 correct numeric vector of length 1 with correct solution. wrong numeric vector (optional) with wrong solutions. range numeric vector of length 2 with range of random wrong solutions. delta numeric. Minimal distance between solutions. digits integer. Digits that should be displayed. method character specifying method for generating random results. sign logical. Should the sign be changed randomly? verbose logical. Should warnings be issued if no suitable set of wrong solutions can be found?

## Details

The function num_to_schoice (or equivalently num2schoice) can be used for generating a single-choice question list for a numeric correct solution. The question list always comprises five elements, one of which is the correct solution. The wrong solutions can be provided or are generated randomly. If wrong is provided only up to 2 elements of it are used in order to assure some random solutions.

Two methods can be used to generate the wrong solutions: Either simply runif or otherwise a full equi-distant grid for the range with step size delta is set up from which a discrete uniform sample is drawn. The former is preferred if the range is large enough while the latter performs better if the range is small (as compared to delta.

Exercise templates using num_to_schoice should be thoroughly tested in order to avoid problems with too small ranges or almost identical correct and wrong answers! This can potentially cause problems, infinite loops, etc.

## Value

num_to_schoice/num2schoice returns either NULL (if no suitable question list can be found) or a list with the following components:

 solutions a logical vector of length 5 indicating the correct solution, questions a character vector of length 5 with question list.