-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
src/content/questions/comp2804/2022-winter-final/1/generator.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
}); | ||
}); |
33 changes: 33 additions & 0 deletions
33
src/content/questions/comp2804/2022-winter-final/1/generator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters