import { GraderSpecificationFor } from "../graders/QuestionGrader"; import { ResponseHandler, SubmissionType } from "./responses"; /** * ## Multiple Choice Response Element Specification * * 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](media://response-sample-mc.png) * * ```typescript * 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. */ export type MCSpecification = { /** * The discriminant `"multiple_choice"` is used to distinguish MC specifications. */ kind: "multiple_choice"; /** * Whether or not the question allows multiple selection. */ multiple: boolean; /** * For multiple-selection questions, an optional limit on selected choices. */ limit?: number; /** * Choices for selection. May include markdown. */ choices: string[]; /** * Optional margin added below each option. Uses css size specifcations e.g. "10px", "1em", etc. */ spacing?: string; /** * A sample solution, which may not be blank or invalid. */ sample_solution?: SubmissionType<"multiple_choice">; /** * A default grader, used to evaluate submissions for this response. */ default_grader?: GraderSpecificationFor<"multiple_choice">; }; /** * 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. * * The subset of [[`MCSubmissions`]] that are valid (see [[`validate_submission`]]) for a * particular MC response are those that only contain in-bounds selected choice values, have * no duplicates, and do not contain more selected choices than the response's limit (if any). */ export type MCSubmission = readonly number[]; export declare const MC_HANDLER: ResponseHandler<"multiple_choice">;