mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
updates
This commit is contained in:
@@ -45,6 +45,11 @@ export const fileStorageService = {
|
||||
async createCourseFolderForTesting(courseName: string) {
|
||||
const courseDirectory = path.join(basePath, courseName);
|
||||
|
||||
await fs.mkdir(courseDirectory, { recursive: true });
|
||||
},
|
||||
async createModuleFolderForTesting(courseName: string, moduleName: string) {
|
||||
const courseDirectory = path.join(basePath, courseName);
|
||||
|
||||
await fs.mkdir(courseDirectory, { recursive: true });
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
import { marked } from "marked";
|
||||
import markedKatex from "marked-katex-extension";
|
||||
// import markedKatex from "marked-katex-extension";
|
||||
import * as DOMPurify from "isomorphic-dompurify";
|
||||
|
||||
export function markdownToHTMLSafe(markdownString: string) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
} from "@/models/local/localCourse";
|
||||
import { QuestionType } from "@/models/local/quiz/localQuizQuestion";
|
||||
import { fileStorageService } from "../fileStorage/fileStorageService";
|
||||
import { basePath } from "../fileStorage/utils/fileSystemUtils";
|
||||
|
||||
describe("FileStorageTests", () => {
|
||||
beforeEach(() => {
|
||||
@@ -34,7 +35,9 @@ describe("FileStorageTests", () => {
|
||||
|
||||
await fileStorageService.settings.updateCourseSettings(name, settings);
|
||||
|
||||
const loadedSettings = await fileStorageService.settings.getCourseSettings(name);
|
||||
const loadedSettings = await fileStorageService.settings.getCourseSettings(
|
||||
name
|
||||
);
|
||||
|
||||
expect(loadedSettings).toEqual(settings);
|
||||
});
|
||||
@@ -45,208 +48,18 @@ describe("FileStorageTests", () => {
|
||||
|
||||
await fileStorageService.modules.createModule(courseName, moduleName);
|
||||
|
||||
const moduleNames = await fileStorageService.modules.getModuleNames(courseName);
|
||||
const moduleNames = await fileStorageService.modules.getModuleNames(
|
||||
courseName
|
||||
);
|
||||
|
||||
expect(moduleNames).toContain(moduleName);
|
||||
});
|
||||
|
||||
// it("course modules with assignments can be saved and loaded", async () => {
|
||||
// const testCourse: LocalCourse = {
|
||||
// settings: {
|
||||
// name: "Test Course with modules and assignments",
|
||||
// assignmentGroups: [],
|
||||
// daysOfWeek: [],
|
||||
// startDate: "07/09/2024 23:59:00",
|
||||
// endDate: "07/09/2024 23:59:00",
|
||||
// defaultDueTime: { hour: 1, minute: 59 },
|
||||
// },
|
||||
// modules: [
|
||||
// {
|
||||
// name: "test module 1 with assignments",
|
||||
// assignments: [
|
||||
// {
|
||||
// name: "test assignment",
|
||||
// description: "here is the description",
|
||||
// dueAt: "07/09/2024 23:59:00",
|
||||
// lockAt: "07/09/2024 23:59:00",
|
||||
// submissionTypes: [AssignmentSubmissionType.ONLINE_UPLOAD],
|
||||
// localAssignmentGroupName: "Final Project",
|
||||
// rubric: [
|
||||
// { points: 4, label: "do task 1" },
|
||||
// { points: 2, label: "do task 2" },
|
||||
// ],
|
||||
// allowedFileUploadExtensions: [],
|
||||
// },
|
||||
// ],
|
||||
// quizzes: [],
|
||||
// pages: [],
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
|
||||
// await fileStorageService.saveCourseAsync(testCourse);
|
||||
|
||||
// const loadedCourses = await fileStorageService.loadSavedCourses();
|
||||
// const loadedCourse = loadedCourses.find(
|
||||
// (c) => c.settings.name === testCourse.settings.name
|
||||
// );
|
||||
|
||||
// expect(loadedCourse?.modules[0].assignments).toEqual(
|
||||
// testCourse.modules[0].assignments
|
||||
// );
|
||||
// });
|
||||
|
||||
// it("course modules with quizzes can be saved and loaded", async () => {
|
||||
// const testCourse: LocalCourse = {
|
||||
// settings: {
|
||||
// name: "Test Course with modules and quiz",
|
||||
// assignmentGroups: [],
|
||||
// daysOfWeek: [],
|
||||
// startDate: "07/09/2024 23:59:00",
|
||||
// endDate: "07/09/2024 23:59:00",
|
||||
// defaultDueTime: { hour: 1, minute: 59 },
|
||||
// },
|
||||
// modules: [
|
||||
// {
|
||||
// name: "test module 1 with quiz",
|
||||
// assignments: [],
|
||||
// quizzes: [
|
||||
// {
|
||||
// name: "Test Quiz",
|
||||
// description: "quiz description",
|
||||
// lockAt: "07/09/2024 12:05:00",
|
||||
// dueAt: "07/09/2024 12:05:00",
|
||||
// shuffleAnswers: true,
|
||||
// oneQuestionAtATime: true,
|
||||
// localAssignmentGroupName: "Assignments",
|
||||
// questions: [
|
||||
// {
|
||||
// text: "test essay",
|
||||
// questionType: QuestionType.ESSAY,
|
||||
// points: 1,
|
||||
// answers: [],
|
||||
// matchDistractors: [],
|
||||
// },
|
||||
// ],
|
||||
// showCorrectAnswers: false,
|
||||
// allowedAttempts: 0,
|
||||
// },
|
||||
// ],
|
||||
// pages: [],
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
|
||||
// await fileStorageService.saveCourseAsync(testCourse);
|
||||
|
||||
// const loadedCourses = await fileStorageService.loadSavedCourses();
|
||||
// const loadedCourse = loadedCourses.find(
|
||||
// (c) => c.settings.name === testCourse.settings.name
|
||||
// );
|
||||
|
||||
// expect(loadedCourse?.modules[0].quizzes).toEqual(
|
||||
// testCourse.modules[0].quizzes
|
||||
// );
|
||||
// });
|
||||
|
||||
// it("markdown storage fully populated does not lose data", async () => {
|
||||
// const testCourse: LocalCourse = {
|
||||
// settings: {
|
||||
// name: "Test Course with lots of data",
|
||||
// assignmentGroups: [],
|
||||
// daysOfWeek: [DayOfWeek.Monday, DayOfWeek.Wednesday],
|
||||
// startDate: "07/09/2024 23:59:00",
|
||||
// endDate: "07/09/2024 23:59:00",
|
||||
// defaultDueTime: { hour: 1, minute: 59 },
|
||||
// },
|
||||
// modules: [
|
||||
// {
|
||||
// name: "new test module",
|
||||
// assignments: [
|
||||
// {
|
||||
// name: "test assignment",
|
||||
// description: "here is the description",
|
||||
// dueAt: "07/09/2024 23:59:00",
|
||||
// lockAt: "07/09/2024 23:59:00",
|
||||
// submissionTypes: [AssignmentSubmissionType.ONLINE_UPLOAD],
|
||||
// localAssignmentGroupName: "Final Project",
|
||||
// rubric: [
|
||||
// { points: 4, label: "do task 1" },
|
||||
// { points: 2, label: "do task 2" },
|
||||
// ],
|
||||
// allowedFileUploadExtensions: [],
|
||||
// },
|
||||
// ],
|
||||
// quizzes: [
|
||||
// {
|
||||
// name: "Test Quiz",
|
||||
// description: "quiz description",
|
||||
// lockAt: "07/09/2024 23:59:00",
|
||||
// dueAt: "07/09/2024 23:59:00",
|
||||
// shuffleAnswers: true,
|
||||
// oneQuestionAtATime: false,
|
||||
// localAssignmentGroupName: "someId",
|
||||
// allowedAttempts: -1,
|
||||
// questions: [
|
||||
// {
|
||||
// text: "test short answer",
|
||||
// questionType: QuestionType.SHORT_ANSWER,
|
||||
// points: 1,
|
||||
// answers: [],
|
||||
// matchDistractors: [],
|
||||
// },
|
||||
// ],
|
||||
// showCorrectAnswers: false,
|
||||
// },
|
||||
// ],
|
||||
// pages: [],
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
|
||||
// await fileStorageService.saveCourseAsync(testCourse);
|
||||
|
||||
// const loadedCourses = await fileStorageService.loadSavedCourses();
|
||||
// const loadedCourse = loadedCourses.find(
|
||||
// (c) => c.settings.name === testCourse.settings.name
|
||||
// );
|
||||
|
||||
// expect(loadedCourse).toEqual(testCourse);
|
||||
// });
|
||||
|
||||
// it("markdown storage can persist pages", async () => {
|
||||
// const testCourse: LocalCourse = {
|
||||
// settings: {
|
||||
// name: "Test Course with page",
|
||||
// assignmentGroups: [],
|
||||
// daysOfWeek: [DayOfWeek.Monday, DayOfWeek.Wednesday],
|
||||
// startDate: "07/09/2024 23:59:00",
|
||||
// endDate: "07/09/2024 23:59:00",
|
||||
// defaultDueTime: { hour: 1, minute: 59 },
|
||||
// },
|
||||
// modules: [
|
||||
// {
|
||||
// name: "page test module",
|
||||
// assignments: [],
|
||||
// quizzes: [],
|
||||
// pages: [
|
||||
// {
|
||||
// name: "test page persistence",
|
||||
// dueAt: "07/09/2024 23:59:00",
|
||||
// text: "this is some\n## markdown\n",
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
|
||||
// await fileStorageService.saveCourseAsync(testCourse);
|
||||
|
||||
// const loadedCourses = await fileStorageService.loadSavedCourses();
|
||||
// const loadedCourse = loadedCourses.find(
|
||||
// (c) => c.settings.name === testCourse.settings.name
|
||||
// );
|
||||
|
||||
// expect(loadedCourse).toEqual(testCourse);
|
||||
// });
|
||||
it("invalid quizzes do not get loaded", async () => {
|
||||
const courseName = "testCourse";
|
||||
const invalidQuizMarkdown = "not a quiz";
|
||||
await fileStorageService.createCourseFolderForTesting(courseName);
|
||||
await fileStorageService.modules.createModule(courseName, "testModule");
|
||||
// fs.writeFile(`${basePath}/${courseName}/testModule/testQuiz.md`, invalidQuizMarkdown)
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user