log when not loading a file

This commit is contained in:
2025-10-23 12:47:34 -06:00
parent b53948db72
commit e35a5ffab6
7 changed files with 125 additions and 29 deletions

View File

@@ -25,26 +25,28 @@ What is 2+3?
expect(question.questionType).toBe(QuestionType.NUMERICAL);
expect(question.answers[0].numericAnswer).toBe(5);
});
// it("can parse question with range answers", () => {
// const name = "Test Quiz";
// const rawMarkdownQuiz = `
// ShuffleAnswers: true
// OneQuestionAtATime: false
// DueAt: 08/21/2023 23:59:00
// LockAt: 08/21/2023 23:59:00
// AssignmentGroup: Assignments
// AllowedAttempts: -1
// Description: quiz description
// ---
// What is 2+3?
// = 5
// `;
it("can parse question with range answers", () => {
const name = "Test Quiz";
const rawMarkdownQuiz = `
ShuffleAnswers: true
OneQuestionAtATime: false
DueAt: 08/21/2023 23:59:00
LockAt: 08/21/2023 23:59:00
AssignmentGroup: Assignments
AllowedAttempts: -1
Description: quiz description
---
What is the cube root of 2?
= [1.2598, 1.2600]
`;
// const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
// const question = quiz.questions[0];
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
const question = quiz.questions[0];
// expect(question.text).toBe("What is 2+3?");
// expect(question.questionType).toBe(QuestionType.NUMERICAL);
// expect(question.answers[0].numericAnswer).toBe(5);
// });
expect(question.text).toBe("What is the cube root of 2?");
expect(question.questionType).toBe(QuestionType.NUMERICAL);
expect(question.answers[0].numericalAnswerType).toBe("range_answer");
expect(question.answers[0].numericAnswerRangeMin).toBe(1.2598);
expect(question.answers[0].numericAnswerRangeMax).toBe(1.26);
});
});

View File

@@ -195,7 +195,6 @@ describe("QuizDeterministicChecks", () => {
],
allowedAttempts: -1,
showCorrectAnswers: true,
};
const quizMarkdown = quizMarkdownUtils.toMarkdown(quiz);
@@ -221,13 +220,54 @@ describe("QuizDeterministicChecks", () => {
points: 1,
matchDistractors: [],
answers: [
{ text: "= 42", correct: true, numericalAnswerType: "exact_answer", numericAnswer: 42 },
{
text: "= 42",
correct: true,
numericalAnswerType: "exact_answer",
numericAnswer: 42,
},
],
},
],
allowedAttempts: -1,
showCorrectAnswers: true,
};
const quizMarkdown = quizMarkdownUtils.toMarkdown(quiz);
const parsedQuiz = quizMarkdownUtils.parseMarkdown(quizMarkdown, name);
expect(parsedQuiz).toEqual(quiz);
});
it("SerializationIsDeterministic Numeric with range answer", () => {
const name = "Test Quiz";
const quiz: LocalQuiz = {
name,
description: "quiz description",
lockAt: "08/21/2023 23:59:00",
dueAt: "08/21/2023 23:59:00",
shuffleAnswers: true,
oneQuestionAtATime: true,
password: undefined,
localAssignmentGroupName: "Assignments",
questions: [
{
text: "test numeric",
questionType: QuestionType.NUMERICAL,
points: 1,
matchDistractors: [],
answers: [
{
text: "= [2, 5]",
correct: true,
numericalAnswerType: "range_answer",
numericAnswerRangeMin: 2,
numericAnswerRangeMax: 5,
},
],
},
],
allowedAttempts: -1,
showCorrectAnswers: true,
};
const quizMarkdown = quizMarkdownUtils.toMarkdown(quiz);