inserting newline after feedback so as to keep separate from following content

This commit is contained in:
Adam Teichert
2025-12-18 15:07:45 -07:00
parent 712a3e5155
commit eb661a3e59
2 changed files with 27 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import { describe, it, expect } from "vitest";
import { quizQuestionMarkdownUtils } from "@/features/local/quizzes/models/utils/quizQuestionMarkdownUtils";
import { QuestionType } from "@/features/local/quizzes/models/localQuizQuestion";
describe("feedback spacing", () => {
it("adds a blank line after feedback before answers", () => {
const question = {
text: "What is 2+2?",
questionType: QuestionType.MULTIPLE_CHOICE,
points: 1,
answers: [
{ correct: true, text: "4" },
],
matchDistractors: [],
correctComments: "Good",
incorrectComments: "No",
neutralComments: "Note",
} as any;
const md = quizQuestionMarkdownUtils.toMarkdown(question as any);
// look for double newline separating feedback block and answer marker
expect(md).toMatch(/\n\n\*?a\)/);
});
});

View File

@@ -89,6 +89,8 @@ export const quizFeedbackMarkdownUtils = {
if (neutralComments) { if (neutralComments) {
feedbackText += `${delimiters.neutral} ${neutralComments}\n`; feedbackText += `${delimiters.neutral} ${neutralComments}\n`;
} }
// Ensure there's a blank line after feedback block so answers are separated
if (feedbackText) feedbackText += "\n";
return feedbackText; return feedbackText;
}, },
}; };