mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
multipel choice
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { LocalQuiz } from "../../../../../models/local/quiz/localQuiz";
|
||||
import {
|
||||
LocalQuizQuestion,
|
||||
QuestionType,
|
||||
} from "../../../../../models/local/quiz/localQuizQuestion";
|
||||
import { LocalQuizQuestionAnswer } from "../../../../../models/local/quiz/localQuizQuestionAnswer";
|
||||
import { quizMarkdownUtils } from "@/models/local/quiz/utils/quizMarkdownUtils";
|
||||
import { quizQuestionMarkdownUtils } from "@/models/local/quiz/utils/quizQuestionMarkdownUtils";
|
||||
|
||||
describe("MultipleChoiceTests", () => {
|
||||
it("quiz markdown includes multiple choice question", () => {
|
||||
const quiz: LocalQuiz = {
|
||||
name: "Test Quiz",
|
||||
description: "desc",
|
||||
dueAt: "21/08/2023 23:59:00",
|
||||
lockAt: "21/08/2023 23:59:00",
|
||||
shuffleAnswers: true,
|
||||
oneQuestionAtATime: false,
|
||||
showCorrectAnswers: false,
|
||||
localAssignmentGroupName: "someId",
|
||||
allowedAttempts: -1,
|
||||
questions: [
|
||||
{
|
||||
points: 2,
|
||||
text: `
|
||||
\`some type\` of question
|
||||
|
||||
with many
|
||||
|
||||
\`\`\`
|
||||
lines
|
||||
\`\`\`
|
||||
`,
|
||||
questionType: QuestionType.MULTIPLE_CHOICE,
|
||||
answers: [
|
||||
{ correct: true, text: "true" },
|
||||
{ correct: false, text: "false\n\nendline" },
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const markdown = quizMarkdownUtils.toMarkdown(quiz);
|
||||
const expectedQuestionString = `
|
||||
Points: 2
|
||||
|
||||
\`some type\` of question
|
||||
|
||||
with many
|
||||
|
||||
\`\`\`
|
||||
lines
|
||||
\`\`\`
|
||||
|
||||
*a) true
|
||||
b) false
|
||||
|
||||
endline`;
|
||||
expect(markdown).toContain(expectedQuestionString);
|
||||
});
|
||||
|
||||
it("letter optional for multiple choice", () => {
|
||||
const questionMarkdown = `
|
||||
Points: 2
|
||||
\`some type\` of question
|
||||
*) true
|
||||
) false
|
||||
`;
|
||||
|
||||
const question = quizQuestionMarkdownUtils.parseMarkdown(
|
||||
questionMarkdown,
|
||||
0
|
||||
);
|
||||
expect(question.answers.length).toBe(2);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user