Options
All
  • Public
  • Public/Protected
  • All
Menu

Module response/mc

Index

Type aliases

MCSpecification: { kind: "multiple_choice"; multiple: boolean; choices: string[]; limit?: number; spacing?: string; sample_solution?: ViableSubmission<MCSubmission>; default_grader?: GraderSpecificationFor<"multiple_choice"> }

An Multiple Choice response provides several options that students select from. It may be configured to allow only one choice (rendered as radio buttons) or multiple choice (rendered as checkboxes).

The MCSpecification type alias represents the information needed to specify an MC response as part of a question.

Here's an example of a question with an MC response.

image

export const Question_Sample_MC : QuestionSpecification = {
question_id: "sample_mc",
points: 2,
mk_description:
`
This is a sample question. Which of the following is NOT a heirloom variety of tomato plant?
`,
response: {
kind: "multiple_choice",
choices: [
"Green Zebra",
"Better Boy",
"Black Krim",
"Mr. Stripey",
"Brandywine"
],
multiple: false,
default_grader: new SimpleMCGrader(1)
}
}

Single or Multiple Response

If the multiple property is set to false, choices are rendered as radio buttons and students may only select a single choice. If the property is set to true, choices are rendered as checkboxes and students may select any number of choices.

A multiple-selection MC question may specify a limit for the number of checkboxes that may be selected via the limit property. (This property is ignored if multiple selections are not allowed.)

MC Submissions

Essentially, a submission for an MC response is an array of numbers corresponding to the indices of selected choices. See MCSubmission for details.

Type declaration

  • kind: "multiple_choice"

    The discriminant "multiple_choice" is used to distinguish FITB specifications.

  • multiple: boolean

    Whether or not the question allows multiple selection.

  • choices: string[]

    Choices for selection. May include markdown.

  • Optional limit?: number

    For multiple-selection questions, an optional limit on selected choices.

  • Optional spacing?: string

    Optional margin added below each option. Uses css size specifcations e.g. "10px", "1em", etc.

  • Optional sample_solution?: ViableSubmission<MCSubmission>

    A sample solution, which may not be blank or invalid.

  • Optional default_grader?: GraderSpecificationFor<"multiple_choice">

    A default grader, used to evaluate submissions for this response.

MCSubmission: readonly number[] | typeof INVALID_SUBMISSION | typeof BLANK_SUBMISSION

Essentially, a submission for an MC response is an array of numbers corresponding to the indices of selected choices. For a single response question, this array will be a single element. For multiple response questions, the array may contain one or more elements.

A submission may also be BLANK_SUBMISSION if nothing was selected.

A submission may also be INVALID_SUBMISSION if the array of selected choices contains more elements than a specified limit. (This should not regularly happen, but is possible if e.g. a student were to nefariously edit their answers .json file before turning it in. Upon loading, their submission would be checked and replaced by INVALID_SUBMISSION).

Variables

MC_HANDLER: ResponseHandler<"multiple_choice"> = ...

Generated using TypeDoc