mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
short_answer= making it with answers to canvas (needed to include answer_text)
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { getQuestionType } from "@/services/canvas/canvasQuizService";
|
||||
import { getAnswers, getQuestionType } from "@/services/canvas/canvasQuizService";
|
||||
import { QuestionType, zodQuestionType } from "../../quiz/localQuizQuestion";
|
||||
import { quizMarkdownUtils } from "../../quiz/utils/quizMarkdownUtils";
|
||||
import { quizQuestionMarkdownUtils } from "../../quiz/utils/quizQuestionMarkdownUtils";
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { LocalCourseSettings } from "../../localCourseSettings";
|
||||
|
||||
describe("TextAnswerTests", () => {
|
||||
it("can parse essay", () => {
|
||||
@@ -226,4 +227,47 @@ short_answer=
|
||||
const firstQuestion = quiz.questions[0];
|
||||
expect(getQuestionType(firstQuestion)).toBe("short_answer_question");
|
||||
});
|
||||
|
||||
it("Includes answer_text in answers sent to canvas", () => {
|
||||
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: this is the
|
||||
multi line
|
||||
description
|
||||
---
|
||||
Which events are triggered when the user clicks on an input field?
|
||||
*a) test
|
||||
*b) other
|
||||
short_answer=
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
const firstQuestion = quiz.questions[0];
|
||||
const answers = getAnswers(firstQuestion, {
|
||||
name: "",
|
||||
assignmentGroups: [],
|
||||
daysOfWeek: [],
|
||||
canvasId: 0,
|
||||
startDate: "",
|
||||
endDate: "",
|
||||
defaultDueTime: {
|
||||
hour: 0,
|
||||
minute: 0
|
||||
},
|
||||
defaultAssignmentSubmissionTypes: [],
|
||||
defaultFileUploadTypes: [],
|
||||
holidays: [],
|
||||
assets: []
|
||||
})
|
||||
expect(answers).toHaveLength(2);
|
||||
const firstAnswer = answers[0];
|
||||
expect(firstAnswer).toHaveProperty("answer_text");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
import { CanvasQuizQuestion } from "@/models/canvas/quizzes/canvasQuizQuestionModel";
|
||||
import { LocalCourseSettings } from "@/models/local/localCourseSettings";
|
||||
|
||||
const getAnswers = (
|
||||
export const getAnswers = (
|
||||
question: LocalQuizQuestion,
|
||||
settings: LocalCourseSettings
|
||||
) => {
|
||||
@@ -25,6 +25,7 @@ const getAnswers = (
|
||||
return question.answers.map((answer) => ({
|
||||
answer_html: markdownToHTMLSafe(answer.text, settings),
|
||||
answer_weight: answer.correct ? 100 : 0,
|
||||
answer_text: answer.text,
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user