mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
pages too
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { LocalAssignment } from "./assignment/localAssignment";
|
import { LocalAssignment } from "./assignment/localAssignment";
|
||||||
|
import { LocalCoursePage } from "./page/localCoursePage";
|
||||||
import { LocalQuiz } from "./quiz/localQuiz";
|
import { LocalQuiz } from "./quiz/localQuiz";
|
||||||
import {
|
import {
|
||||||
dateToMarkdownString,
|
dateToMarkdownString,
|
||||||
@@ -32,7 +33,6 @@ export const prepAssignmentForNewSemester = (
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const prepQuizForNewSemester = (
|
export const prepQuizForNewSemester = (
|
||||||
quiz: LocalQuiz,
|
quiz: LocalQuiz,
|
||||||
oldSemesterStartDate: string,
|
oldSemesterStartDate: string,
|
||||||
@@ -45,11 +45,8 @@ export const prepQuizForNewSemester = (
|
|||||||
...quiz,
|
...quiz,
|
||||||
description: descriptionWithoutGithubClassroom,
|
description: descriptionWithoutGithubClassroom,
|
||||||
dueAt:
|
dueAt:
|
||||||
newDateOffset(
|
newDateOffset(quiz.dueAt, oldSemesterStartDate, newSemesterStartDate) ??
|
||||||
quiz.dueAt,
|
quiz.dueAt,
|
||||||
oldSemesterStartDate,
|
|
||||||
newSemesterStartDate
|
|
||||||
) ?? quiz.dueAt,
|
|
||||||
lockAt: newDateOffset(
|
lockAt: newDateOffset(
|
||||||
quiz.lockAt,
|
quiz.lockAt,
|
||||||
oldSemesterStartDate,
|
oldSemesterStartDate,
|
||||||
@@ -58,7 +55,20 @@ export const prepQuizForNewSemester = (
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const prepPageForNewSemester = (
|
||||||
|
page: LocalCoursePage,
|
||||||
|
oldSemesterStartDate: string,
|
||||||
|
newSemesterStartDate: string
|
||||||
|
): LocalCoursePage => {
|
||||||
|
const updatedText = replaceClassroomUrl(page.text);
|
||||||
|
return {
|
||||||
|
...page,
|
||||||
|
text: updatedText,
|
||||||
|
dueAt:
|
||||||
|
newDateOffset(page.dueAt, oldSemesterStartDate, newSemesterStartDate) ??
|
||||||
|
page.dueAt,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const replaceClassroomUrl = (value: string) => {
|
const replaceClassroomUrl = (value: string) => {
|
||||||
const classroomPattern =
|
const classroomPattern =
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { describe, it, expect } from "vitest";
|
import { describe, it, expect } from "vitest";
|
||||||
import { LocalAssignment } from "../assignment/localAssignment";
|
import { LocalAssignment } from "../assignment/localAssignment";
|
||||||
import { prepAssignmentForNewSemester, prepQuizForNewSemester } from "../semesterTransferUtils";
|
import { prepAssignmentForNewSemester, prepPageForNewSemester, prepQuizForNewSemester } from "../semesterTransferUtils";
|
||||||
import { LocalQuiz } from "../quiz/localQuiz";
|
import { LocalQuiz } from "../quiz/localQuiz";
|
||||||
|
import { LocalCoursePage } from "../page/localCoursePage";
|
||||||
|
|
||||||
describe("can take an assignment and template it for a new semester", () => {
|
describe("can take an assignment and template it for a new semester", () => {
|
||||||
it("can sanitize assignment github classroom repo url", () => {
|
it("can sanitize assignment github classroom repo url", () => {
|
||||||
@@ -142,7 +143,7 @@ describe("can offset date based on new semester start", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("can prep quizzes", () => {
|
describe("can prep quizzes", () => {
|
||||||
it("assignment with new semester start, no lock date", () => {
|
it("quiz gets new lock and due dates", () => {
|
||||||
const quiz: LocalQuiz = {
|
const quiz: LocalQuiz = {
|
||||||
name: "Test Quiz",
|
name: "Test Quiz",
|
||||||
description: `
|
description: `
|
||||||
@@ -171,3 +172,24 @@ describe("can prep quizzes", () => {
|
|||||||
expect(sanitizedQuiz.lockAt).toEqual("01/12/2024 23:59:00");
|
expect(sanitizedQuiz.lockAt).toEqual("01/12/2024 23:59:00");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("can prep pages", () => {
|
||||||
|
it("page gets new due date and github url changes", () => {
|
||||||
|
const page: LocalCoursePage = {
|
||||||
|
name: "test title",
|
||||||
|
text: "test text content",
|
||||||
|
dueAt: "08/30/2023 23:59:00",
|
||||||
|
};
|
||||||
|
|
||||||
|
const oldSemesterStartDate = "08/26/2023 23:59:00";
|
||||||
|
const newSemesterStartDate = "01/08/2024 23:59:00";
|
||||||
|
|
||||||
|
const sanitizedPage = prepPageForNewSemester(
|
||||||
|
page,
|
||||||
|
oldSemesterStartDate,
|
||||||
|
newSemesterStartDate
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(sanitizedPage.dueAt).toEqual("01/12/2024 23:59:00");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user