mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 23:58:31 -06:00
can get exact answers
This commit is contained in:
@@ -25,4 +25,26 @@ 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
|
||||
// `;
|
||||
|
||||
// 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);
|
||||
// });
|
||||
});
|
||||
|
||||
@@ -201,6 +201,38 @@ describe("QuizDeterministicChecks", () => {
|
||||
const quizMarkdown = quizMarkdownUtils.toMarkdown(quiz);
|
||||
const parsedQuiz = quizMarkdownUtils.parseMarkdown(quizMarkdown, name);
|
||||
|
||||
expect(parsedQuiz).toEqual(quiz);
|
||||
});
|
||||
it("SerializationIsDeterministic Numeric with exact 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: "= 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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import {
|
||||
getQuestionTypeForCanvas,
|
||||
getAnswers,
|
||||
getAnswersForCanvas,
|
||||
} from "@/features/canvas/services/canvasQuizService";
|
||||
import {
|
||||
QuestionType,
|
||||
zodQuestionType,
|
||||
} from "@/features/local/quizzes/models/localQuizQuestion";
|
||||
import { quizMarkdownUtils } from "@/features/local/quizzes/models/utils/quizMarkdownUtils";
|
||||
import { quizQuestionMarkdownUtils } from "@/features/local/quizzes/models/utils/quizQuestionMarkdownUtils";
|
||||
@@ -255,7 +254,7 @@ short_answer=
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
const firstQuestion = quiz.questions[0];
|
||||
const answers = getAnswers(firstQuestion, {
|
||||
const answers = getAnswersForCanvas(firstQuestion, {
|
||||
name: "",
|
||||
assignmentGroups: [],
|
||||
daysOfWeek: [],
|
||||
|
||||
Reference in New Issue
Block a user