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
)

answer(
  label,
  correct = FALSE,
  always_show = FALSE,
  weight = c(0, 1),
  correct_quoted = FALSE
)

Arguments

title

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().

points

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().

nr_answers

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.

random_answer_order

should the order of answers be randomized? Randomization is unique for every user.

checkbox

make a multiple response question, i.e., allow the user to select more than one answer.

label

answer text to show. Supports markdown formatting and inline code chunks of the form `r value`.

hide_label

hide the label from non-screen readers.

min_points

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.

mandatory

is this question mandatory for submitting the section? If TRUE, a user can only navigate to the next section if the question is answered.

id

question identifier to be used instead of the code chunk label. Must only contain characters a-z, A-Z, 0-9, dash (-), or underscore (_).

title_container

a function to generate an HTML element to contain the question title.

static_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.

correct

an expression which, evaluated in the rendering environment, determines if the answer is correct or not. Can also be a simple logical.

always_show

even if answer options are randomized, always show this answer.

weight

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.

correct_quoted

is the expression given in correct quoted or not?

Details

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.

See also

Other exam question types: text_question()