Learn R Programming

exams (version 2.1-0)

matrix_to_schoice: Generate Single- and Multiple-Choice Question Lists for Matrix Solutions

Description

Functions for generating single- and multiple-choice question lists for a matrix solution. (Optimized for integer matrices.)

Usage

matrix_to_schoice(x, y = NULL, lower = FALSE, name = "a", delta = 0.5, digits = 0)
matrix_to_mchoice(x, y = NULL, lower = FALSE, name = "a", comparisons = c("==", "<", "="">", "<=", "="">="))
det_to_schoice(x, y = NULL, range = NULL, delta = 0.5, digits = 0)

Arguments

x
matrix (correct result).
y
numeric vector (optional) with (potentially) wrong solutions/comparisons.
lower
logical. Should only elements from the lower triangle be assessed?
name
character. Base name for matrix elements.
delta
numeric. Minimal distance between solutions.
digits
integer. Digits that should be displayed.
comparisons
character. Vector of logical comparisons that should be employed.
range
numeric vector of length 2 (optional) with range of random wrong solutions.

Value

matrix_to_schoice returns a list with the following components:
index
numeric vector with matrix index of the correct solution chosen.
name
character with LaTeX code for the correct matrix element chosen.
solutions
a logical vector of length 5 indicating the correct solution,
questions
a character vector of length 5 with question list.
matrix_to_mchoice returns 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.
explanations
a character vector of length 5 with explanations why the solutions are correct or wrong.
det_to_schoice returns 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.

Details

The function matrix_to_schoice can be used for generating a single-choice question list for a correct result matrix x. One element is picked randomly from the matrix and chosen to be the correct solution. Other values from the observed absolute range are used as wrong solutions by default (if y does not provide an alternative list of potential solutions).

The function matrix_to_mchoice can be used for generating a multiple-choice question list for a correct result matrix x. Each item from the question list is a logical comparison of one matrix element with a comparion value. By default the comparisons are picked randomly from the observed absolute range (unless y specifies a different list of comparisons).

The function det_to_schoice can be used for generating a single-choice question list for the determinant of a 2x2 matrix. It has been optimized for matrices with single-digit integer elements. It may not yield very balanced random solutions for other scenarios.

See Also

num_to_schoice

Examples

Run this code
A <- matrix(c(-9, 0, 5, -2), ncol = 2)
matrix_to_schoice(A)
matrix_to_mchoice(A)
det_to_schoice(A)

B <- matrix(1:9, ncol = 3)
matrix_to_schoice(B)
matrix_to_mchoice(B)

Run the code above in your browser using DataLab