mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
moving name out of file, will mirror file system name
This commit is contained in:
@@ -47,7 +47,6 @@ const parseIndividualRubricItemMarkdown = (rawMarkdown: string) => {
|
||||
};
|
||||
|
||||
const parseSettings = (input: string) => {
|
||||
const name = extractLabelValue(input, "Name");
|
||||
const rawLockAt = extractLabelValue(input, "LockAt");
|
||||
const rawDueAt = extractLabelValue(input, "DueAt");
|
||||
const assignmentGroupName = extractLabelValue(input, "AssignmentGroupName");
|
||||
@@ -58,7 +57,6 @@ const parseSettings = (input: string) => {
|
||||
const lockAt = verifyDateStringOrUndefined(rawLockAt);
|
||||
|
||||
return {
|
||||
name,
|
||||
assignmentGroupName,
|
||||
submissionTypes,
|
||||
fileUploadExtensions,
|
||||
@@ -110,10 +108,10 @@ const parseRubricMarkdown = (rawMarkdown: string) => {
|
||||
|
||||
export const assignmentMarkdownParser = {
|
||||
parseRubricMarkdown,
|
||||
parseMarkdown(input: string): LocalAssignment {
|
||||
parseMarkdown(input: string, name: string): LocalAssignment {
|
||||
const settingsString = input.split("---")[0];
|
||||
const {
|
||||
name,
|
||||
// name,
|
||||
assignmentGroupName,
|
||||
submissionTypes,
|
||||
fileUploadExtensions,
|
||||
|
||||
@@ -40,8 +40,7 @@ const parseNumberOrThrow = (value: string, label: string): number => {
|
||||
}
|
||||
return parsed;
|
||||
};
|
||||
const getQuizWithOnlySettings = (settings: string): LocalQuiz => {
|
||||
const name = extractLabelValue(settings, "Name");
|
||||
const getQuizWithOnlySettings = (settings: string, name: string): LocalQuiz => {
|
||||
|
||||
const rawShuffleAnswers = extractLabelValue(settings, "ShuffleAnswers");
|
||||
const shuffleAnswers = parseBooleanOrThrow(
|
||||
@@ -136,10 +135,10 @@ Description: ${quiz.description}
|
||||
${questionMarkdown}`;
|
||||
},
|
||||
|
||||
parseMarkdown(input: string): LocalQuiz {
|
||||
parseMarkdown(input: string, name: string): LocalQuiz {
|
||||
const splitInput = input.split("---\n");
|
||||
const settings = splitInput[0];
|
||||
const quizWithoutQuestions = getQuizWithOnlySettings(settings);
|
||||
const quizWithoutQuestions = getQuizWithOnlySettings(settings, name);
|
||||
|
||||
const rawQuestions = splitInput.slice(1);
|
||||
const questions = rawQuestions
|
||||
|
||||
@@ -6,8 +6,9 @@ import { assignmentMarkdownParser } from "../assignment/utils/assignmentMarkdown
|
||||
|
||||
describe("AssignmentMarkdownTests", () => {
|
||||
it("can parse assignment settings", () => {
|
||||
const name = "test assignment";
|
||||
const assignment: LocalAssignment = {
|
||||
name: "test assignment",
|
||||
name,
|
||||
description: "here is the description",
|
||||
dueAt: "08/21/2023 23:59:00",
|
||||
lockAt: "08/21/2023 23:59:00",
|
||||
@@ -22,15 +23,18 @@ describe("AssignmentMarkdownTests", () => {
|
||||
|
||||
const assignmentMarkdown =
|
||||
assignmentMarkdownSerializer.toMarkdown(assignment);
|
||||
const parsedAssignment =
|
||||
assignmentMarkdownParser.parseMarkdown(assignmentMarkdown);
|
||||
const parsedAssignment = assignmentMarkdownParser.parseMarkdown(
|
||||
assignmentMarkdown,
|
||||
name
|
||||
);
|
||||
|
||||
expect(parsedAssignment).toEqual(assignment);
|
||||
});
|
||||
|
||||
it("assignment with empty rubric can be parsed", () => {
|
||||
const name = "test assignment";
|
||||
const assignment: LocalAssignment = {
|
||||
name: "test assignment",
|
||||
name,
|
||||
description: "here is the description",
|
||||
dueAt: "08/21/2023 23:59:00",
|
||||
lockAt: "08/21/2023 23:59:00",
|
||||
@@ -43,14 +47,15 @@ describe("AssignmentMarkdownTests", () => {
|
||||
const assignmentMarkdown =
|
||||
assignmentMarkdownSerializer.toMarkdown(assignment);
|
||||
const parsedAssignment =
|
||||
assignmentMarkdownParser.parseMarkdown(assignmentMarkdown);
|
||||
assignmentMarkdownParser.parseMarkdown(assignmentMarkdown, name);
|
||||
|
||||
expect(parsedAssignment).toEqual(assignment);
|
||||
});
|
||||
|
||||
it("assignment with empty submission types can be parsed", () => {
|
||||
const name = "test assignment";
|
||||
const assignment: LocalAssignment = {
|
||||
name: "test assignment",
|
||||
name,
|
||||
description: "here is the description",
|
||||
dueAt: "08/21/2023 23:59:00",
|
||||
lockAt: "08/21/2023 23:59:00",
|
||||
@@ -66,14 +71,15 @@ describe("AssignmentMarkdownTests", () => {
|
||||
const assignmentMarkdown =
|
||||
assignmentMarkdownSerializer.toMarkdown(assignment);
|
||||
const parsedAssignment =
|
||||
assignmentMarkdownParser.parseMarkdown(assignmentMarkdown);
|
||||
assignmentMarkdownParser.parseMarkdown(assignmentMarkdown, name);
|
||||
|
||||
expect(parsedAssignment).toEqual(assignment);
|
||||
});
|
||||
|
||||
it("assignment without lockAt date can be parsed", () => {
|
||||
const name = "test assignment";
|
||||
const assignment: LocalAssignment = {
|
||||
name: "test assignment",
|
||||
name,
|
||||
description: "here is the description",
|
||||
dueAt: "08/21/2023 23:59:00",
|
||||
lockAt: undefined,
|
||||
@@ -89,14 +95,15 @@ describe("AssignmentMarkdownTests", () => {
|
||||
const assignmentMarkdown =
|
||||
assignmentMarkdownSerializer.toMarkdown(assignment);
|
||||
const parsedAssignment =
|
||||
assignmentMarkdownParser.parseMarkdown(assignmentMarkdown);
|
||||
assignmentMarkdownParser.parseMarkdown(assignmentMarkdown, name);
|
||||
|
||||
expect(parsedAssignment).toEqual(assignment);
|
||||
});
|
||||
|
||||
it("assignment without description can be parsed", () => {
|
||||
const name = "test assignment";
|
||||
const assignment: LocalAssignment = {
|
||||
name: "test assignment",
|
||||
name,
|
||||
description: "",
|
||||
dueAt: "08/21/2023 23:59:00",
|
||||
lockAt: "08/21/2023 23:59:00",
|
||||
@@ -112,14 +119,15 @@ describe("AssignmentMarkdownTests", () => {
|
||||
const assignmentMarkdown =
|
||||
assignmentMarkdownSerializer.toMarkdown(assignment);
|
||||
const parsedAssignment =
|
||||
assignmentMarkdownParser.parseMarkdown(assignmentMarkdown);
|
||||
assignmentMarkdownParser.parseMarkdown(assignmentMarkdown, name);
|
||||
|
||||
expect(parsedAssignment).toEqual(assignment);
|
||||
});
|
||||
|
||||
it("assignments can have three dashes", () => {
|
||||
const name = "test assignment";
|
||||
const assignment: LocalAssignment = {
|
||||
name: "test assignment",
|
||||
name,
|
||||
description: "test assignment\n---\nsomestuff",
|
||||
dueAt: "08/21/2023 23:59:00",
|
||||
lockAt: "08/21/2023 23:59:00",
|
||||
@@ -132,14 +140,15 @@ describe("AssignmentMarkdownTests", () => {
|
||||
const assignmentMarkdown =
|
||||
assignmentMarkdownSerializer.toMarkdown(assignment);
|
||||
const parsedAssignment =
|
||||
assignmentMarkdownParser.parseMarkdown(assignmentMarkdown);
|
||||
assignmentMarkdownParser.parseMarkdown(assignmentMarkdown, name);
|
||||
|
||||
expect(parsedAssignment).toEqual(assignment);
|
||||
});
|
||||
|
||||
it("assignments can restrict upload types", () => {
|
||||
const name = "test assignment";
|
||||
const assignment: LocalAssignment = {
|
||||
name: "test assignment",
|
||||
name,
|
||||
description: "here is the description",
|
||||
dueAt: "08/21/2023 23:59:00",
|
||||
lockAt: "08/21/2023 23:59:00",
|
||||
@@ -152,7 +161,7 @@ describe("AssignmentMarkdownTests", () => {
|
||||
const assignmentMarkdown =
|
||||
assignmentMarkdownSerializer.toMarkdown(assignment);
|
||||
const parsedAssignment =
|
||||
assignmentMarkdownParser.parseMarkdown(assignmentMarkdown);
|
||||
assignmentMarkdownParser.parseMarkdown(assignmentMarkdown, name);
|
||||
|
||||
expect(parsedAssignment).toEqual(assignment);
|
||||
});
|
||||
|
||||
@@ -3,8 +3,8 @@ import { quizMarkdownUtils } from "@/models/local/quiz/utils/quizMarkdownUtils";
|
||||
|
||||
describe("Matching Answer Error Messages", () => {
|
||||
it("can parse matching question", () => {
|
||||
const name = "Test Quiz";
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 08/21/2023 23:59:00
|
||||
@@ -18,8 +18,8 @@ question without answer
|
||||
|
||||
`;
|
||||
|
||||
expect(() => quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz)).toThrowError(
|
||||
/question type/
|
||||
);
|
||||
expect(() =>
|
||||
quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name)
|
||||
).toThrowError(/question type/);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,8 +5,8 @@ import { quizQuestionMarkdownUtils } from "@/models/local/quiz/utils/quizQuestio
|
||||
|
||||
describe("MatchingTests", () => {
|
||||
it("can parse matching question", () => {
|
||||
const name = "Test Quiz"
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 08/21/2023 23:59:00
|
||||
@@ -22,7 +22,7 @@ Match the following terms & definitions
|
||||
^ keyword - reserved word that has special meaning in a program (e.g. class, void, static, etc.)
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
const firstQuestion = quiz.questions[0];
|
||||
|
||||
expect(firstQuestion.questionType).toBe(QuestionType.MATCHING);
|
||||
@@ -33,8 +33,8 @@ Match the following terms & definitions
|
||||
});
|
||||
|
||||
it("can create markdown for matching question", () => {
|
||||
const name = "Test Quiz"
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 08/21/2023 23:59:00
|
||||
@@ -50,7 +50,7 @@ Match the following terms & definitions
|
||||
^ keyword - reserved word that has special meaning in a program (e.g. class, void, static, etc.)
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
const questionMarkdown = quizQuestionMarkdownUtils.toMarkdown(
|
||||
quiz.questions[0]
|
||||
);
|
||||
@@ -65,8 +65,8 @@ Match the following terms & definitions
|
||||
});
|
||||
|
||||
it("whitespace is optional", () => {
|
||||
const name = "Test Quiz"
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 08/21/2023 23:59:00
|
||||
@@ -80,13 +80,13 @@ Match the following terms & definitions
|
||||
^statement - a single command to be executed
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
expect(quiz.questions[0].answers[0].text).toBe("statement");
|
||||
});
|
||||
|
||||
it("can have distractors", () => {
|
||||
const name = "Test Quiz"
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 08/21/2023 23:59:00
|
||||
@@ -101,15 +101,15 @@ Match the following terms & definitions
|
||||
^ - this is the distractor
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
expect(quiz.questions[0].matchDistractors).toEqual([
|
||||
"this is the distractor",
|
||||
]);
|
||||
});
|
||||
|
||||
it("can have distractors and be persisted", () => {
|
||||
const name = "Test Quiz"
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 08/21/2023 23:59:00
|
||||
@@ -124,7 +124,7 @@ Match the following terms & definitions
|
||||
^ - this is the distractor
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
const quizMarkdown = quizMarkdownUtils.toMarkdown(quiz);
|
||||
|
||||
expect(quizMarkdown).toContain(
|
||||
|
||||
@@ -41,8 +41,8 @@ oneline question
|
||||
});
|
||||
|
||||
it("can parse question with multiple answers", () => {
|
||||
const name = "Test Quiz"
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 08/21/2023 23:59:00
|
||||
@@ -64,7 +64,7 @@ Which events are triggered when the user clicks on an input field?
|
||||
---
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
const firstQuestion = quiz.questions[0];
|
||||
|
||||
expect(firstQuestion.points).toBe(1);
|
||||
@@ -79,8 +79,8 @@ Which events are triggered when the user clicks on an input field?
|
||||
});
|
||||
|
||||
it("can parse question with multiple answers without a space in false answers", () => {
|
||||
const name = "Test Quiz"
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 08/21/2023 23:59:00
|
||||
@@ -96,7 +96,7 @@ Which events are triggered when the user clicks on an input field?
|
||||
[] submit
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
const firstQuestion = quiz.questions[0];
|
||||
|
||||
expect(firstQuestion.answers.length).toBe(2);
|
||||
@@ -105,8 +105,8 @@ Which events are triggered when the user clicks on an input field?
|
||||
});
|
||||
|
||||
it("can parse question with multiple answers without a space in false answers other example", () => {
|
||||
const name = "Test Quiz"
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 08/21/2023 23:59:00
|
||||
@@ -124,7 +124,7 @@ Which tool(s) will let you: create a database migration or reverse-engineer an e
|
||||
[*] dotnet ef command line interface
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
const firstQuestion = quiz.questions[0];
|
||||
|
||||
expect(firstQuestion.answers.length).toBe(3);
|
||||
|
||||
@@ -6,8 +6,9 @@ import { QuestionType } from "@/models/local/quiz/localQuizQuestion";
|
||||
// Test suite for deterministic checks on LocalQuiz
|
||||
describe("QuizDeterministicChecks", () => {
|
||||
it("SerializationIsDeterministic_EmptyQuiz", () => {
|
||||
const name = "Test Quiz";
|
||||
const quiz: LocalQuiz = {
|
||||
name: "Test Quiz",
|
||||
name,
|
||||
description: "quiz description",
|
||||
lockAt: "08/21/2023 23:59:00",
|
||||
dueAt: "08/21/2023 23:59:00",
|
||||
@@ -20,14 +21,15 @@ describe("QuizDeterministicChecks", () => {
|
||||
};
|
||||
|
||||
const quizMarkdown = quizMarkdownUtils.toMarkdown(quiz);
|
||||
const parsedQuiz = quizMarkdownUtils.parseMarkdown(quizMarkdown);
|
||||
const parsedQuiz = quizMarkdownUtils.parseMarkdown(quizMarkdown, name);
|
||||
|
||||
expect(parsedQuiz).toEqual(quiz);
|
||||
});
|
||||
|
||||
it("SerializationIsDeterministic_ShowCorrectAnswers", () => {
|
||||
const name = "Test Quiz";
|
||||
const quiz: LocalQuiz = {
|
||||
name: "Test Quiz",
|
||||
name,
|
||||
description: "quiz description",
|
||||
lockAt: "08/21/2023 23:59:00",
|
||||
dueAt: "08/21/2023 23:59:00",
|
||||
@@ -40,14 +42,15 @@ describe("QuizDeterministicChecks", () => {
|
||||
};
|
||||
|
||||
const quizMarkdown = quizMarkdownUtils.toMarkdown(quiz);
|
||||
const parsedQuiz = quizMarkdownUtils.parseMarkdown(quizMarkdown);
|
||||
const parsedQuiz = quizMarkdownUtils.parseMarkdown(quizMarkdown, name);
|
||||
|
||||
expect(parsedQuiz).toEqual(quiz);
|
||||
});
|
||||
|
||||
it("SerializationIsDeterministic_ShortAnswer", () => {
|
||||
const name = "Test Quiz";
|
||||
const quiz: LocalQuiz = {
|
||||
name: "Test Quiz",
|
||||
name,
|
||||
description: "quiz description",
|
||||
lockAt: "08/21/2023 23:59:00",
|
||||
dueAt: "08/21/2023 23:59:00",
|
||||
@@ -68,14 +71,15 @@ describe("QuizDeterministicChecks", () => {
|
||||
};
|
||||
|
||||
const quizMarkdown = quizMarkdownUtils.toMarkdown(quiz);
|
||||
const parsedQuiz = quizMarkdownUtils.parseMarkdown(quizMarkdown);
|
||||
const parsedQuiz = quizMarkdownUtils.parseMarkdown(quizMarkdown, name);
|
||||
|
||||
expect(parsedQuiz).toEqual(quiz);
|
||||
});
|
||||
|
||||
it("SerializationIsDeterministic_Essay", () => {
|
||||
const name = "Test Quiz";
|
||||
const quiz: LocalQuiz = {
|
||||
name: "Test Quiz",
|
||||
name,
|
||||
description: "quiz description",
|
||||
lockAt: "08/21/2023 23:59:00",
|
||||
dueAt: "08/21/2023 23:59:00",
|
||||
@@ -96,14 +100,15 @@ describe("QuizDeterministicChecks", () => {
|
||||
};
|
||||
|
||||
const quizMarkdown = quizMarkdownUtils.toMarkdown(quiz);
|
||||
const parsedQuiz = quizMarkdownUtils.parseMarkdown(quizMarkdown);
|
||||
const parsedQuiz = quizMarkdownUtils.parseMarkdown(quizMarkdown, name);
|
||||
|
||||
expect(parsedQuiz).toEqual(quiz);
|
||||
});
|
||||
|
||||
it("SerializationIsDeterministic_MultipleAnswer", () => {
|
||||
const name = "Test Quiz";
|
||||
const quiz: LocalQuiz = {
|
||||
name: "Test Quiz",
|
||||
name,
|
||||
description: "quiz description",
|
||||
lockAt: "08/21/2023 23:59:00",
|
||||
dueAt: "08/21/2023 23:59:00",
|
||||
@@ -127,14 +132,15 @@ describe("QuizDeterministicChecks", () => {
|
||||
};
|
||||
|
||||
const quizMarkdown = quizMarkdownUtils.toMarkdown(quiz);
|
||||
const parsedQuiz = quizMarkdownUtils.parseMarkdown(quizMarkdown);
|
||||
const parsedQuiz = quizMarkdownUtils.parseMarkdown(quizMarkdown, name);
|
||||
|
||||
expect(parsedQuiz).toEqual(quiz);
|
||||
});
|
||||
|
||||
it("SerializationIsDeterministic_MultipleChoice", () => {
|
||||
const name = "Test Quiz";
|
||||
const quiz: LocalQuiz = {
|
||||
name: "Test Quiz",
|
||||
name,
|
||||
description: "quiz description",
|
||||
lockAt: "08/21/2023 23:59:00",
|
||||
dueAt: "08/21/2023 23:59:00",
|
||||
@@ -159,14 +165,15 @@ describe("QuizDeterministicChecks", () => {
|
||||
};
|
||||
|
||||
const quizMarkdown = quizMarkdownUtils.toMarkdown(quiz);
|
||||
const parsedQuiz = quizMarkdownUtils.parseMarkdown(quizMarkdown);
|
||||
const parsedQuiz = quizMarkdownUtils.parseMarkdown(quizMarkdown, name);
|
||||
|
||||
expect(parsedQuiz).toEqual(quiz);
|
||||
});
|
||||
|
||||
it("SerializationIsDeterministic_Matching", () => {
|
||||
const name = "Test Quiz";
|
||||
const quiz: LocalQuiz = {
|
||||
name: "Test Quiz",
|
||||
name,
|
||||
description: "quiz description",
|
||||
lockAt: "08/21/2023 23:59:00",
|
||||
dueAt: "08/21/2023 23:59:00",
|
||||
@@ -191,7 +198,7 @@ describe("QuizDeterministicChecks", () => {
|
||||
};
|
||||
|
||||
const quizMarkdown = quizMarkdownUtils.toMarkdown(quiz);
|
||||
const parsedQuiz = quizMarkdownUtils.parseMarkdown(quizMarkdown);
|
||||
const parsedQuiz = quizMarkdownUtils.parseMarkdown(quizMarkdown, name);
|
||||
|
||||
expect(parsedQuiz).toEqual(quiz);
|
||||
});
|
||||
|
||||
@@ -37,8 +37,8 @@ this is my description in markdown
|
||||
});
|
||||
|
||||
it("can parse markdown quiz with no questions", () => {
|
||||
const name = "Test Quiz";
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 08/21/2023 23:59:00
|
||||
@@ -51,7 +51,7 @@ description
|
||||
---
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
|
||||
const expectedDescription = `
|
||||
this is the
|
||||
@@ -67,8 +67,8 @@ description`;
|
||||
|
||||
it("can parse markdown quiz with password", () => {
|
||||
const password = "this-is-the-password";
|
||||
const name = "Test Quiz";
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
Password: ${password}
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
@@ -82,14 +82,14 @@ description
|
||||
---
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
|
||||
expect(quiz.password).toBe(password);
|
||||
});
|
||||
|
||||
it("can parse markdown quiz and configure to show correct answers", () => {
|
||||
const name = "Test Quiz";
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
ShowCorrectAnswers: false
|
||||
@@ -103,14 +103,14 @@ description
|
||||
---
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
|
||||
expect(quiz.showCorrectAnswers).toBe(false);
|
||||
});
|
||||
|
||||
it("can parse quiz with questions", () => {
|
||||
const name = "Test Quiz";
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 08/21/2023 23:59:00
|
||||
@@ -135,7 +135,7 @@ b) false
|
||||
|
||||
endline`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
const firstQuestion = quiz.questions[0];
|
||||
|
||||
expect(firstQuestion.questionType).toBe(QuestionType.MULTIPLE_CHOICE);
|
||||
@@ -149,8 +149,8 @@ b) false
|
||||
});
|
||||
|
||||
it("can parse multiple questions", () => {
|
||||
const name = "Test Quiz";
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 08/21/2023 23:59:00
|
||||
@@ -170,7 +170,7 @@ Points: 2
|
||||
b) false
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
const firstQuestion = quiz.questions[0];
|
||||
expect(firstQuestion.points).toBe(1);
|
||||
expect(firstQuestion.questionType).toBe(QuestionType.MULTIPLE_ANSWERS);
|
||||
@@ -181,8 +181,8 @@ b) false
|
||||
});
|
||||
|
||||
it("short answer to markdown is correct", () => {
|
||||
const name = "Test Quiz";
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 08/21/2023 23:59:00
|
||||
@@ -197,7 +197,7 @@ Which events are triggered when the user clicks on an input field?
|
||||
short answer
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
const firstQuestion = quiz.questions[0];
|
||||
|
||||
const questionMarkdown =
|
||||
@@ -209,8 +209,8 @@ short_answer`;
|
||||
});
|
||||
|
||||
it("negative points is allowed", () => {
|
||||
const name = "Test Quiz";
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 08/21/2023 23:59:00
|
||||
@@ -226,14 +226,14 @@ Which events are triggered when the user clicks on an input field?
|
||||
short answer
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
const firstQuestion = quiz.questions[0];
|
||||
expect(firstQuestion.points).toBe(-4);
|
||||
});
|
||||
|
||||
it("floating point points is allowed", () => {
|
||||
const name = "Test Quiz";
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 08/21/2023 23:59:00
|
||||
@@ -249,7 +249,7 @@ Which events are triggered when the user clicks on an input field?
|
||||
short answer
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
const firstQuestion = quiz.questions[0];
|
||||
expect(firstQuestion.points).toBe(4.56);
|
||||
});
|
||||
|
||||
@@ -5,8 +5,8 @@ import { describe, it, expect } from "vitest";
|
||||
|
||||
describe("TextAnswerTests", () => {
|
||||
it("can parse essay", () => {
|
||||
const name = "Test Quiz"
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 08/21/2023 23:59:00
|
||||
@@ -21,7 +21,7 @@ Which events are triggered when the user clicks on an input field?
|
||||
essay
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
const firstQuestion = quiz.questions[0];
|
||||
|
||||
expect(firstQuestion.points).toBe(1);
|
||||
@@ -30,8 +30,8 @@ essay
|
||||
});
|
||||
|
||||
it("can parse short answer", () => {
|
||||
const name = "Test Quiz"
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 08/21/2023 23:59:00
|
||||
@@ -46,7 +46,7 @@ Which events are triggered when the user clicks on an input field?
|
||||
short answer
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
const firstQuestion = quiz.questions[0];
|
||||
|
||||
expect(firstQuestion.points).toBe(1);
|
||||
@@ -55,8 +55,9 @@ short answer
|
||||
});
|
||||
|
||||
it("short answer to markdown is correct", () => {
|
||||
|
||||
const name = "Test Quiz"
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 08/21/2023 23:59:00
|
||||
@@ -71,7 +72,7 @@ Which events are triggered when the user clicks on an input field?
|
||||
short answer
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
const firstQuestion = quiz.questions[0];
|
||||
|
||||
const questionMarkdown =
|
||||
@@ -83,8 +84,8 @@ short_answer`;
|
||||
});
|
||||
|
||||
it("essay question to markdown is correct", () => {
|
||||
const name = "Test Quiz"
|
||||
const rawMarkdownQuiz = `
|
||||
Name: Test Quiz
|
||||
ShuffleAnswers: true
|
||||
OneQuestionAtATime: false
|
||||
DueAt: 08/21/2023 23:59:00
|
||||
@@ -99,7 +100,7 @@ Which events are triggered when the user clicks on an input field?
|
||||
essay
|
||||
`;
|
||||
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
const firstQuestion = quiz.questions[0];
|
||||
|
||||
const questionMarkdown =
|
||||
@@ -128,7 +129,7 @@ essay`;
|
||||
// short_answer=
|
||||
// `;
|
||||
|
||||
// const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz);
|
||||
// const quiz = quizMarkdownUtils.parseMarkdown(rawMarkdownQuiz, name);
|
||||
// const firstQuestion = quiz.questions[0];
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user