mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { quizQuestionMarkdownUtils } from "../../quizzes/models/utils/quizQuestionMarkdownUtils";
|
|
import { FeedbackDelimiters } from "../../quizzes/models/utils/quizFeedbackMarkdownUtils";
|
|
import { QuestionType } from "../../quizzes/models/localQuizQuestion";
|
|
|
|
describe("Custom Feedback Delimiters", () => {
|
|
const customDelimiters: FeedbackDelimiters = {
|
|
correct: ":)",
|
|
incorrect: ":(",
|
|
neutral: ":|",
|
|
};
|
|
|
|
it("can parse question with custom feedback delimiters", () => {
|
|
const input = `Points: 1
|
|
Question text
|
|
:) Correct feedback
|
|
:( Incorrect feedback
|
|
:| Neutral feedback
|
|
*a) Answer 1
|
|
b) Answer 2`;
|
|
|
|
const question = quizQuestionMarkdownUtils.parseMarkdown(input, 0, customDelimiters);
|
|
|
|
expect(question.correctComments).toBe("Correct feedback");
|
|
expect(question.incorrectComments).toBe("Incorrect feedback");
|
|
expect(question.neutralComments).toBe("Neutral feedback");
|
|
});
|
|
|
|
it("can serialize question with custom feedback delimiters", () => {
|
|
const question = {
|
|
points: 1,
|
|
text: "Question text",
|
|
questionType: "multiple_choice_question" as QuestionType,
|
|
answers: [
|
|
{ text: "Answer 1", correct: true, weight: 100 },
|
|
{ text: "Answer 2", correct: false, weight: 0 },
|
|
],
|
|
correctComments: "Correct feedback",
|
|
incorrectComments: "Incorrect feedback",
|
|
neutralComments: "Neutral feedback",
|
|
matchDistractors: [],
|
|
};
|
|
|
|
const markdown = quizQuestionMarkdownUtils.toMarkdown(question, customDelimiters);
|
|
|
|
expect(markdown).toContain(":) Correct feedback");
|
|
expect(markdown).toContain(":( Incorrect feedback");
|
|
expect(markdown).toContain(":| Neutral feedback");
|
|
});
|
|
});
|