Render a question which asks the user to input a value. Questions of numeric support auto-grading.
text_question( title, points = 1, type = c("textarea", "text", "numeric"), width = "100%", height = NULL, placeholder = NULL, solution = NULL, solution_quoted = FALSE, comp = comp_digits(3, 1), label = "Type your answer below.", hide_label = FALSE, mandatory = FALSE, id = NULL, title_container = h6, static_title = NULL ) comp_abs(tol) comp_rel(tol) comp_digits(digits, pm = 1)
question title. Markdown is supported and by default the title will be rendered dynamically if it contains inline R code.
total number of points for the question. Set to
can be one of
the width of the input, e.g., '300px' or '100%'; see
the height of the input, e.g., '300px' or '100%'; see
A character string giving the user a hint as to what can be entered into the control. Internet Explorer 8 and 9 do not support this option.
an expression to compute the solution to the answer.
The expression is evaluated in the environment returned by the data provider set up via
function comparing the user's input with the correct answer. Must be a function taking two
a label to help screen readers describe the purpose of the input element.
hide the label from non-screen readers.
is this question mandatory for submitting the section? If
question identifier to be used instead of the code chunk label. Must only contain
a function to generate an HTML element to contain the question title.
absolute tolerance (for
number of digits relevant for comparison (significant digits if the correct answer is less than 1 in absolute value).
amount by how much the last (significant) digit may vary between the user's input and the correct answer.
The solution is computed by evaluating the expression given in
solution in the rendering environment.
The expression must yield either a single character string or, if the question is of type numeric, a numeric value.
The result of the expression is rendered with commonmark.
To auto-grade numeric questions, the
solution expression can yield a numeric value or a character value with
answer. This number is compared against the user's answer using the function provided via
comp_abs: compare the user input and the correct answer in absolute terms
abs(input - answer) < tol).
comp_rel: compare the user input and the correct answer in relative terms
abs(input / answer - 1) < tol).
comp_digits: allow the last digit vary by +/-
pm. For answers greater than 1 (in absolute value),
digits is the number of digits after the decimal point and an absolute tolerance of
tol = pm * 10^-digits is used.
For answers less than 1,
digits is the number of significant digits and an
absolute tolerance of
tol = pm * 10^(-shift) is used (
shift is taken such that
the last sign. digit can vary by +/-
abs(input - answer) < tol).
Other exam question types: