Functions for generating single- and multiple-choice question lists for a matrix solution. (Optimized for integer matrices.)
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("==", "<", "="">", "<=", "="">="), restricted = FALSE)=",>",>
det_to_schoice(x, y = NULL, range = NULL, delta = 0.5, digits = 0)
matrix_to_schoice
/matrix2schoice
returns a list with the following components:
numeric vector with matrix index of the correct solution chosen.
character with LaTeX code for the correct matrix element chosen.
a logical vector of length 5 indicating the correct
solution,
a character vector of length 5 with question list.
matrix_to_mchoice
/matrix2mchoice
returns a list with the following components:
a logical vector of length 5 indicating the correct
solution,
a character vector of length 5 with question list.
a character vector of length 5 with explanations why the solutions are correct or wrong.
det_to_schoice
/det2schoice
returns a list with the following components:
a logical vector of length 5 indicating the correct
solution,
a character vector of length 5 with question list.
matrix (correct result).
numeric vector (optional) with (potentially) wrong solutions/comparisons.
logical. Should only elements from the lower triangle be assessed?
character. Base name for matrix elements.
numeric. Minimal distance between solutions.
integer. Digits that should be displayed.
character. Vector of logical comparisons that should be employed.
logical. Should the result be restricted ot at least one correct and one wrong solution/comparison?
numeric vector of length 2 (optional) with range of random wrong solutions.
The function matrix_to_schoice
(or equivalently matrix2schoice
)
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
(or equivalently matrix2mchoice
)
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).
In both matrix_to_schoice
and matrix_to_mchoice
it is also
possible to provide a vector x
rather than a matrix. Then the
corresponding question list is shown with a single index only (say \(a_{1}\))
rather than two indexes (say \(a_{11}\)).
The function det_to_schoice
(or equivalently det2schoice
)
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.
num_to_schoice
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