diff --git a/src/content/questions/comp2804/2022-winter-final/1/generator.test.ts b/src/content/questions/comp2804/2022-winter-final/1/generator.test.ts new file mode 100644 index 00000000..0bc66f65 --- /dev/null +++ b/src/content/questions/comp2804/2022-winter-final/1/generator.test.ts @@ -0,0 +1,77 @@ +import { describe, expect } from "@jest/globals"; +import Generator from "./generator"; + +describe("comp2804/2019-winter-final/1", () => { + describe("createSetSizes", () => { + it("will make sizeA smaller than sizeB", () => { + const generator = new Generator(); + + const [sizeA, sizeB] = generator.createSetSizes(); + + expect(sizeA).toBeLessThanOrEqual(sizeB); + }); + }); + + describe("createOptions", () => { + it("will return four options", () => { + const generator = new Generator(); + + const options = generator.createOptions(1, 2); + + expect(options).toHaveLength(4); + }); + + it("will have exactly one correct option", () => { + const generator = new Generator(); + + const options = generator.createOptions(1, 2); + const correctOptions = options.filter((option) => option.correct); + + expect(correctOptions).toHaveLength(1); + }); + }); + + describe("createCorrectOption", () => { + it("will return the correct option", () => { + const generator = new Generator(); + + const option = generator.createCorrectOption(7, 13); + + expect(option.label).toBe("$\\frac{13!}{6!}$"); + expect(option.correct).toBe(true); + }); + }); + + describe("createIncorrectOption1", () => { + it("will return an option where the numerator and delimeter are flipped", () => { + const generator = new Generator(); + + const option = generator.createIncorrectOption1(7, 13); + + expect(option.label).toBe("$\\frac{6!}{13!}$"); + expect(option.correct).toBe(false); + }); + }); + + describe("createIncorrectOption2", () => { + it("will return an option where the delimeter is one less than the correct option", () => { + const generator = new Generator(); + + const option = generator.createIncorrectOption2(7, 13); + + expect(option.label).toBe("$\\frac{13!}{5!}$"); + expect(option.correct).toBe(false); + }); + }); + + describe("createIncorrectOption3", () => { + it("will return an option where the numerator is one less than the correct option and the delimeter is one more than the correct option", () => { + const generator = new Generator(); + + const option = generator.createIncorrectOption3(7, 13); + + expect(option.label).toBe("$\\frac{12!}{7!}$"); + expect(option.correct).toBe(false); + }); + }); +}); diff --git a/src/content/questions/comp2804/2022-winter-final/1/generator.ts b/src/content/questions/comp2804/2022-winter-final/1/generator.ts new file mode 100644 index 00000000..2d98dcd3 --- /dev/null +++ b/src/content/questions/comp2804/2022-winter-final/1/generator.ts @@ -0,0 +1,33 @@ +import { MultipleChoiceQuestionGenerator } from "@common/MultipleChoiceQuestionGenerator"; +import type { + MultipleChoiceQuestion, + MultipleChoiceQuestionOption, +} from "@common/MultipleChoiceQuestionGenerator"; + +class Generator extends MultipleChoiceQuestionGenerator { + generateQuestion(): MultipleChoiceQuestion { + return { + body: "example body", + options: [ + { + label: "option1", + correct: true, + }, + { + label: "option2", + correct: false, + }, + { + label: "option3", + correct: false, + }, + { + label: "option4", + correct: false, + }, + ], + }; + } +} + +export default Generator; diff --git a/src/content/questions/comp2804/2022-winter-final/1/index.md b/src/content/questions/comp2804/2022-winter-final/1/index.md index f89af3a4..a1b134e5 100644 --- a/src/content/questions/comp2804/2022-winter-final/1/index.md +++ b/src/content/questions/comp2804/2022-winter-final/1/index.md @@ -5,6 +5,7 @@ type: multiple-choice author: Michiel Smid question: comp2804/2022-winter-final/1/question.ts solution: comp2804/2022-winter-final/1/solution.md +generator: comp2804/2022-winter-final/1/generator.ts tags: - comp2804 - comp2804-final