Show a multiple-choice or single-choice question.
mc_question(
title,
...,
points = 1,
nr_answers = 5,
random_answer_order = TRUE,
checkbox = TRUE,
label = "Select the correct answer(s).",
hide_label = FALSE,
min_points = 0,
mandatory = FALSE,
id = NULL,
title_container = h6,
static_title = NULL,
mathjax_dollar
)
answer(
label,
correct = FALSE,
always_show = FALSE,
weight = c(0, 1),
correct_quoted = FALSE
)
question title. Markdown is supported and by default the title will be rendered dynamically if it contains inline R code.
answer options created with answer()
.
total number of points for the question. Set to NULL
to not give any points for the question.
Will be shown next to the question text, formatted using the points_format
given in exam_config()
.
maximum number of answers to display. At least one correct answer will always be shown.
If NULL
, all answer options are shown. If a vector of length two, the first number specifies the number of
correct answers to be shown and the second number specifies the number of incorrect answers to be shown.
should the order of answers be randomized? Randomization is unique for every user.
make a multiple response question, i.e., allow the user to select more than one answer.
answer text to show. Supports markdown formatting and inline code chunks of the form `r value`
.
hide the label from non-screen readers.
if points
multiplied by the the sum of the weights of all selected answer options is negative,
where to cut off negative points. If NULL
, there is no lower bound.
is this question mandatory for submitting the section? If TRUE
, a user can only navigate to the
next section if the question is answered.
question identifier to be used instead of the code chunk label. Must only contain
characters a-z
, A-Z
, 0-9
, dash (-
), or underscore (_
).
a function to generate an HTML element to contain the question title.
if NULL
, the title will be rendered statically if it doesn't contain inline R code, otherwise
it will be rendered dynamically. If TRUE
, always render the title statically. If FALSE
, always render the
title dynamically on the server.
an expression which, evaluated in the rendering environment, determines if the answer is correct or not. Can also be a simple logical.
even if answer options are randomized, always show this answer.
the weight of this answer, if selected. By default, correct answers have a weight of 1, and incorrect answers have a weight of 0. See details for more information. A negative weight will subtract that proportion of available points from the user's points (e.g., to penalize for selecting incorrect answer options). The sum of all displayed positive weights is standardized to sum to 1, but negative weights are not standardized.
is the expression given in correct
quoted or not?
The weight
of an answer option determines how many points are awarded/subtracted for selecting this answer option.
If correct
is an expression and correctness of an answer option can only be determined at run-time, weight
can be a numeric vector with two elements. The first element is the weight applied if the answer is wrong, the
second element is the weight applied if the answer is correct.
The sum of weights of all displayed correct answers is standardized to sum to 1 (i.e., users selecting all displayed correct answers will get all points), but negative weights are used as given. For example, if the weight of an incorrect answer option is set to -0.5 and the total number of points available for a question is 4, selecting this answer option will reduce the number of points awarded by 2.
Other exam question types:
text_question()