diff --git a/nextjs/src/app/course/[courseName]/CourseDetails.tsx b/nextjs/src/app/course/[courseName]/CourseDetails.tsx deleted file mode 100644 index 0856aea..0000000 --- a/nextjs/src/app/course/[courseName]/CourseDetails.tsx +++ /dev/null @@ -1,42 +0,0 @@ -"use client"; -import { getDateFromStringOrThrow } from "@/models/local/timeUtils"; -import { useCourseContext } from "./context/courseContext"; -import { getMonthsBetweenDates } from "./calendar/calendarMonthUtils"; -import CalendarMonth from "./calendar/CalendarMonth"; - -export default function CourseDetails() { - const context = useCourseContext(); - - const startDate = getDateFromStringOrThrow( - context.localCourse.settings.startDate, - "course start date" - ); - const endDate = getDateFromStringOrThrow( - context.localCourse.settings.endDate, - "course end date" - ); - - const months = getMonthsBetweenDates(startDate, endDate); - return ( -
- {context.localCourse.settings.name} -
-
- {months.map((month) => ( - - ))} -
-
-
- first module -
here are the module items
-
-
-
-
- ); -} diff --git a/nextjs/src/app/course/[courseName]/CourseSettings.tsx b/nextjs/src/app/course/[courseName]/CourseSettings.tsx new file mode 100644 index 0000000..76c74cf --- /dev/null +++ b/nextjs/src/app/course/[courseName]/CourseSettings.tsx @@ -0,0 +1,8 @@ +"use client"; + +import { useCourseContext } from "./context/courseContext"; + +export default function CourseSettings() { + const context = useCourseContext(); + return
{context.localCourse.settings.name}
; +} diff --git a/nextjs/src/app/course/[courseName]/ModuleList.tsx b/nextjs/src/app/course/[courseName]/ModuleList.tsx index 628fc69..17001fa 100644 --- a/nextjs/src/app/course/[courseName]/ModuleList.tsx +++ b/nextjs/src/app/course/[courseName]/ModuleList.tsx @@ -1,4 +1,3 @@ -"use client" export default function ModuleList() { return
} \ No newline at end of file diff --git a/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx b/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx index f5bec1d..b299cb6 100644 --- a/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx +++ b/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx @@ -4,13 +4,13 @@ import { CalendarMonthModel } from "./calendarMonthUtils"; import { DayOfWeek, LocalCourse } from "@/models/local/localCourse"; import Day from "./Day"; -export default function CalendarMonth({ +export const CalendarMonth = ({ month, localCourse, }: { month: CalendarMonthModel; localCourse: LocalCourse; -}) { +}) => { const [isCollapsed, setIsCollapsed] = useState(false); const isInPast = diff --git a/nextjs/src/app/course/[courseName]/calendar/CourseCalendar.tsx b/nextjs/src/app/course/[courseName]/calendar/CourseCalendar.tsx new file mode 100644 index 0000000..0c41053 --- /dev/null +++ b/nextjs/src/app/course/[courseName]/calendar/CourseCalendar.tsx @@ -0,0 +1,32 @@ +"use client"; +import { getDateFromStringOrThrow } from "@/models/local/timeUtils"; +import { useCourseContext } from "../context/courseContext"; +import { getMonthsBetweenDates } from "./calendarMonthUtils"; +import { CalendarMonth } from "./CalendarMonth"; + +export default function CourseCalendar() { + const context = useCourseContext(); + + const startDate = getDateFromStringOrThrow( + context.localCourse.settings.startDate, + "course start date" + ); + const endDate = getDateFromStringOrThrow( + context.localCourse.settings.endDate, + "course end date" + ); + + const months = getMonthsBetweenDates(startDate, endDate); + + return ( + <> + {months.map((month) => ( + + ))} + + ); +} diff --git a/nextjs/src/app/course/[courseName]/calendar/Day.tsx b/nextjs/src/app/course/[courseName]/calendar/Day.tsx index 417fb1b..48d6cc7 100644 --- a/nextjs/src/app/course/[courseName]/calendar/Day.tsx +++ b/nextjs/src/app/course/[courseName]/calendar/Day.tsx @@ -1,13 +1,68 @@ -"use client" +"use client"; + +import { getDateFromStringOrThrow } from "@/models/local/timeUtils"; +import { useCourseContext } from "../context/courseContext"; + export default function Day({ day, month }: { day: Date; month: number }) { - const classes = "border rounded rounded-3 p-2 pb-4 m-1 "; + const context = useCourseContext(); const backgroundClass = day.getMonth() + 1 != month ? "" : "bg-slate-900"; + const todaysAssignments = context.localCourse.modules + .flatMap((m) => m.assignments) + .filter((a) => { + const dueDate = getDateFromStringOrThrow( + a.dueAt, + "due at for assignment in day" + ); + + const isSame = + dueDate.getFullYear() === day.getFullYear() && + dueDate.getMonth() === day.getMonth() && + dueDate.getDate() === day.getDate(); + if (a.name === "Chapter 3") console.log(a.name, dueDate, day, isSame); + return isSame; + }); + const todaysQuizzes = context.localCourse.modules + .flatMap((m) => m.quizzes) + .filter((q) => { + const dueDate = getDateFromStringOrThrow( + q.dueAt, + "due at for quiz in day" + ); + return ( + dueDate.getFullYear() === day.getFullYear() && + dueDate.getMonth() === day.getMonth() && + dueDate.getDate() === day.getDate() + ); + }); + const todaysPages = context.localCourse.modules + .flatMap((m) => m.pages) + .filter((p) => { + const dueDate = getDateFromStringOrThrow( + p.dueAt, + "due at for page in day" + ); + return ( + dueDate.getFullYear() === day.getFullYear() && + dueDate.getMonth() === day.getMonth() && + dueDate.getDate() === day.getDate() + ); + }); return ( -
+
{day.getDate()} - {/*
{day.getMonth()}
*/} +
    + {todaysAssignments.map((a) => ( +
  • {a.name}
  • + ))} + {todaysQuizzes.map((q) => ( +
  • {q.name}
  • + ))} + {todaysPages.map((p) => ( +
  • {p.name}
  • + ))} +
); } diff --git a/nextjs/src/app/course/[courseName]/page.tsx b/nextjs/src/app/course/[courseName]/page.tsx index 1a4bbe0..2ae4538 100644 --- a/nextjs/src/app/course/[courseName]/page.tsx +++ b/nextjs/src/app/course/[courseName]/page.tsx @@ -1,7 +1,9 @@ import { getDehydratedClient } from "@/app/layout"; -import { HydrationBoundary } from "@tanstack/react-query"; import CourseContextProvider from "./context/CourseContextProvider"; -import CourseDetails from "./CourseDetails"; +import CourseCalendar from "./calendar/CourseCalendar"; +import { HydrationBoundary } from "@tanstack/react-query"; +import CourseSettings from "./CourseSettings"; +import ModuleList from "./ModuleList"; export default async function CoursePage({ params: { courseName }, @@ -12,7 +14,17 @@ export default async function CoursePage({ return ( - +
+ +
+
+ +
+
+ +
+
+
); diff --git a/nextjs/src/models/local/assignmnet/localAssignment.ts b/nextjs/src/models/local/assignmnet/localAssignment.ts index 0235d44..a1c02c5 100644 --- a/nextjs/src/models/local/assignmnet/localAssignment.ts +++ b/nextjs/src/models/local/assignmnet/localAssignment.ts @@ -6,8 +6,8 @@ import { assignmentMarkdownSerializer } from "./utils/assignmentMarkdownSerializ export interface LocalAssignment { name: string; description: string; - lockAt?: string; // 21/08/2023 23:59:00 - dueAt: string; // 21/08/2023 23:59:00 + lockAt?: string; // 08/21/2023 23:59:00 + dueAt: string; // 08/21/2023 23:59:00 localAssignmentGroupName?: string; submissionTypes: AssignmentSubmissionType[]; allowedFileUploadExtensions: string[]; diff --git a/nextjs/src/models/local/tests/assignmentMarkdown.test.ts b/nextjs/src/models/local/tests/assignmentMarkdown.test.ts index ea6afd8..adc2afa 100644 --- a/nextjs/src/models/local/tests/assignmentMarkdown.test.ts +++ b/nextjs/src/models/local/tests/assignmentMarkdown.test.ts @@ -9,8 +9,8 @@ describe("AssignmentMarkdownTests", () => { const assignment: LocalAssignment = { name: "test assignment", description: "here is the description", - dueAt: "21/08/2023 23:59:00", - lockAt: "21/08/2023 23:59:00", + dueAt: "08/21/2023 23:59:00", + lockAt: "08/21/2023 23:59:00", submissionTypes: [AssignmentSubmissionType.ONLINE_UPLOAD], localAssignmentGroupName: "Final Project", rubric: [ @@ -32,8 +32,8 @@ describe("AssignmentMarkdownTests", () => { const assignment: LocalAssignment = { name: "test assignment", description: "here is the description", - dueAt: "21/08/2023 23:59:00", - lockAt: "21/08/2023 23:59:00", + dueAt: "08/21/2023 23:59:00", + lockAt: "08/21/2023 23:59:00", submissionTypes: [AssignmentSubmissionType.ONLINE_UPLOAD], localAssignmentGroupName: "Final Project", rubric: [], @@ -52,8 +52,8 @@ describe("AssignmentMarkdownTests", () => { const assignment: LocalAssignment = { name: "test assignment", description: "here is the description", - dueAt: "21/08/2023 23:59:00", - lockAt: "21/08/2023 23:59:00", + dueAt: "08/21/2023 23:59:00", + lockAt: "08/21/2023 23:59:00", submissionTypes: [], localAssignmentGroupName: "Final Project", rubric: [ @@ -75,7 +75,7 @@ describe("AssignmentMarkdownTests", () => { const assignment: LocalAssignment = { name: "test assignment", description: "here is the description", - dueAt: "21/08/2023 23:59:00", + dueAt: "08/21/2023 23:59:00", lockAt: undefined, submissionTypes: [], localAssignmentGroupName: "Final Project", @@ -98,8 +98,8 @@ describe("AssignmentMarkdownTests", () => { const assignment: LocalAssignment = { name: "test assignment", description: "", - dueAt: "21/08/2023 23:59:00", - lockAt: "21/08/2023 23:59:00", + dueAt: "08/21/2023 23:59:00", + lockAt: "08/21/2023 23:59:00", submissionTypes: [], localAssignmentGroupName: "Final Project", rubric: [ @@ -121,8 +121,8 @@ describe("AssignmentMarkdownTests", () => { const assignment: LocalAssignment = { name: "test assignment", description: "test assignment\n---\nsomestuff", - dueAt: "21/08/2023 23:59:00", - lockAt: "21/08/2023 23:59:00", + dueAt: "08/21/2023 23:59:00", + lockAt: "08/21/2023 23:59:00", submissionTypes: [], localAssignmentGroupName: "Final Project", rubric: [], @@ -141,8 +141,8 @@ describe("AssignmentMarkdownTests", () => { const assignment: LocalAssignment = { name: "test assignment", description: "here is the description", - dueAt: "21/08/2023 23:59:00", - lockAt: "21/08/2023 23:59:00", + dueAt: "08/21/2023 23:59:00", + lockAt: "08/21/2023 23:59:00", submissionTypes: [AssignmentSubmissionType.ONLINE_UPLOAD], allowedFileUploadExtensions: ["pdf", "txt"], localAssignmentGroupName: "Final Project", diff --git a/nextjs/src/models/local/tests/pageMarkdown.test.ts b/nextjs/src/models/local/tests/pageMarkdown.test.ts index 9d3144f..20611b7 100644 --- a/nextjs/src/models/local/tests/pageMarkdown.test.ts +++ b/nextjs/src/models/local/tests/pageMarkdown.test.ts @@ -6,7 +6,7 @@ describe("PageMarkdownTests", () => { const page: LocalCoursePage = { name: "test title", text: "test text content", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", }; const pageMarkdownString = localPageMarkdownUtils.toMarkdown(page); diff --git a/nextjs/src/models/local/tests/quizMarkdown/matchingAnswers.test.ts b/nextjs/src/models/local/tests/quizMarkdown/matchingAnswers.test.ts index d8c0351..821c7dc 100644 --- a/nextjs/src/models/local/tests/quizMarkdown/matchingAnswers.test.ts +++ b/nextjs/src/models/local/tests/quizMarkdown/matchingAnswers.test.ts @@ -9,8 +9,8 @@ describe("MatchingTests", () => { Name: Test Quiz ShuffleAnswers: true OneQuestionAtATime: false -DueAt: 21/08/2023 23:59:00 -LockAt: 21/08/2023 23:59:00 +DueAt: 08/21/2023 23:59:00 +LockAt: 08/21/2023 23:59:00 AssignmentGroup: Assignments AllowedAttempts: -1 Description: @@ -37,8 +37,8 @@ Match the following terms & definitions Name: Test Quiz ShuffleAnswers: true OneQuestionAtATime: false -DueAt: 21/08/2023 23:59:00 -LockAt: 21/08/2023 23:59:00 +DueAt: 08/21/2023 23:59:00 +LockAt: 08/21/2023 23:59:00 AssignmentGroup: Assignments AllowedAttempts: -1 Description: @@ -69,8 +69,8 @@ Match the following terms & definitions Name: Test Quiz ShuffleAnswers: true OneQuestionAtATime: false -DueAt: 21/08/2023 23:59:00 -LockAt: 21/08/2023 23:59:00 +DueAt: 08/21/2023 23:59:00 +LockAt: 08/21/2023 23:59:00 AssignmentGroup: Assignments AllowedAttempts: -1 Description: @@ -89,8 +89,8 @@ Match the following terms & definitions Name: Test Quiz ShuffleAnswers: true OneQuestionAtATime: false -DueAt: 21/08/2023 23:59:00 -LockAt: 21/08/2023 23:59:00 +DueAt: 08/21/2023 23:59:00 +LockAt: 08/21/2023 23:59:00 AssignmentGroup: Assignments AllowedAttempts: -1 Description: @@ -112,8 +112,8 @@ Match the following terms & definitions Name: Test Quiz ShuffleAnswers: true OneQuestionAtATime: false -DueAt: 21/08/2023 23:59:00 -LockAt: 21/08/2023 23:59:00 +DueAt: 08/21/2023 23:59:00 +LockAt: 08/21/2023 23:59:00 AssignmentGroup: Assignments AllowedAttempts: -1 Description: diff --git a/nextjs/src/models/local/tests/quizMarkdown/multipleAnswers.test.ts b/nextjs/src/models/local/tests/quizMarkdown/multipleAnswers.test.ts index 23acdc6..2693b4a 100644 --- a/nextjs/src/models/local/tests/quizMarkdown/multipleAnswers.test.ts +++ b/nextjs/src/models/local/tests/quizMarkdown/multipleAnswers.test.ts @@ -9,8 +9,8 @@ describe("MultipleAnswersTests", () => { const quiz: LocalQuiz = { name: "Test Quiz", description: "desc", - dueAt: "21/08/2023 23:59:00", - lockAt: "21/08/2023 23:59:00", + dueAt: "08/21/2023 23:59:00", + lockAt: "08/21/2023 23:59:00", shuffleAnswers: true, oneQuestionAtATime: false, showCorrectAnswers: false, @@ -45,8 +45,8 @@ oneline question Name: Test Quiz ShuffleAnswers: true OneQuestionAtATime: false -DueAt: 21/08/2023 23:59:00 -LockAt: 21/08/2023 23:59:00 +DueAt: 08/21/2023 23:59:00 +LockAt: 08/21/2023 23:59:00 AssignmentGroup: Assignments AllowedAttempts: -1 Description: this is the diff --git a/nextjs/src/models/local/tests/quizMarkdown/multipleChoice.test.ts b/nextjs/src/models/local/tests/quizMarkdown/multipleChoice.test.ts index 8bb6584..2d4936f 100644 --- a/nextjs/src/models/local/tests/quizMarkdown/multipleChoice.test.ts +++ b/nextjs/src/models/local/tests/quizMarkdown/multipleChoice.test.ts @@ -10,8 +10,8 @@ describe("MultipleChoiceTests", () => { const quiz: LocalQuiz = { name: "Test Quiz", description: "desc", - dueAt: "21/08/2023 23:59:00", - lockAt: "21/08/2023 23:59:00", + dueAt: "08/21/2023 23:59:00", + lockAt: "08/21/2023 23:59:00", shuffleAnswers: true, oneQuestionAtATime: false, showCorrectAnswers: false, diff --git a/nextjs/src/models/local/tests/quizMarkdown/quizDeterministicChecks.test.ts b/nextjs/src/models/local/tests/quizMarkdown/quizDeterministicChecks.test.ts index eab3500..01b62f5 100644 --- a/nextjs/src/models/local/tests/quizMarkdown/quizDeterministicChecks.test.ts +++ b/nextjs/src/models/local/tests/quizMarkdown/quizDeterministicChecks.test.ts @@ -9,8 +9,8 @@ describe("QuizDeterministicChecks", () => { const quiz: LocalQuiz = { name: "Test Quiz", description: "quiz description", - lockAt: "21/08/2023 23:59:00", - dueAt: "21/08/2023 23:59:00", + lockAt: "08/21/2023 23:59:00", + dueAt: "08/21/2023 23:59:00", shuffleAnswers: true, oneQuestionAtATime: true, localAssignmentGroupName: "Assignments", @@ -29,8 +29,8 @@ describe("QuizDeterministicChecks", () => { const quiz: LocalQuiz = { name: "Test Quiz", description: "quiz description", - lockAt: "21/08/2023 23:59:00", - dueAt: "21/08/2023 23:59:00", + lockAt: "08/21/2023 23:59:00", + dueAt: "08/21/2023 23:59:00", showCorrectAnswers: false, shuffleAnswers: true, oneQuestionAtATime: true, @@ -49,8 +49,8 @@ describe("QuizDeterministicChecks", () => { const quiz: LocalQuiz = { name: "Test Quiz", description: "quiz description", - lockAt: "21/08/2023 23:59:00", - dueAt: "21/08/2023 23:59:00", + lockAt: "08/21/2023 23:59:00", + dueAt: "08/21/2023 23:59:00", shuffleAnswers: true, oneQuestionAtATime: true, localAssignmentGroupName: "Assignments", @@ -77,8 +77,8 @@ describe("QuizDeterministicChecks", () => { const quiz: LocalQuiz = { name: "Test Quiz", description: "quiz description", - lockAt: "21/08/2023 23:59:00", - dueAt: "21/08/2023 23:59:00", + lockAt: "08/21/2023 23:59:00", + dueAt: "08/21/2023 23:59:00", shuffleAnswers: true, oneQuestionAtATime: true, localAssignmentGroupName: "Assignments", @@ -105,8 +105,8 @@ describe("QuizDeterministicChecks", () => { const quiz: LocalQuiz = { name: "Test Quiz", description: "quiz description", - lockAt: "21/08/2023 23:59:00", - dueAt: "21/08/2023 23:59:00", + lockAt: "08/21/2023 23:59:00", + dueAt: "08/21/2023 23:59:00", shuffleAnswers: true, oneQuestionAtATime: true, localAssignmentGroupName: "Assignments", @@ -136,8 +136,8 @@ describe("QuizDeterministicChecks", () => { const quiz: LocalQuiz = { name: "Test Quiz", description: "quiz description", - lockAt: "21/08/2023 23:59:00", - dueAt: "21/08/2023 23:59:00", + lockAt: "08/21/2023 23:59:00", + dueAt: "08/21/2023 23:59:00", shuffleAnswers: true, oneQuestionAtATime: true, password: undefined, @@ -168,8 +168,8 @@ describe("QuizDeterministicChecks", () => { const quiz: LocalQuiz = { name: "Test Quiz", description: "quiz description", - lockAt: "21/08/2023 23:59:00", - dueAt: "21/08/2023 23:59:00", + lockAt: "08/21/2023 23:59:00", + dueAt: "08/21/2023 23:59:00", shuffleAnswers: true, oneQuestionAtATime: true, password: undefined, diff --git a/nextjs/src/models/local/tests/quizMarkdown/quizMarkdown.test.ts b/nextjs/src/models/local/tests/quizMarkdown/quizMarkdown.test.ts index 44afcb4..79d35f7 100644 --- a/nextjs/src/models/local/tests/quizMarkdown/quizMarkdown.test.ts +++ b/nextjs/src/models/local/tests/quizMarkdown/quizMarkdown.test.ts @@ -41,8 +41,8 @@ this is my description in markdown Name: Test Quiz ShuffleAnswers: true OneQuestionAtATime: false -DueAt: 21/08/2023 23:59:00 -LockAt: 21/08/2023 23:59:00 +DueAt: 08/21/2023 23:59:00 +LockAt: 08/21/2023 23:59:00 AssignmentGroup: Assignments AllowedAttempts: -1 Description: this is the @@ -72,8 +72,8 @@ Name: Test Quiz Password: ${password} ShuffleAnswers: true OneQuestionAtATime: false -DueAt: 21/08/2023 23:59:00 -LockAt: 21/08/2023 23:59:00 +DueAt: 08/21/2023 23:59:00 +LockAt: 08/21/2023 23:59:00 AssignmentGroup: Assignments AllowedAttempts: -1 Description: this is the @@ -93,8 +93,8 @@ Name: Test Quiz ShuffleAnswers: true OneQuestionAtATime: false ShowCorrectAnswers: false -DueAt: 21/08/2023 23:59:00 -LockAt: 21/08/2023 23:59:00 +DueAt: 08/21/2023 23:59:00 +LockAt: 08/21/2023 23:59:00 AssignmentGroup: Assignments AllowedAttempts: -1 Description: this is the @@ -113,8 +113,8 @@ description Name: Test Quiz ShuffleAnswers: true OneQuestionAtATime: false -DueAt: 21/08/2023 23:59:00 -LockAt: 21/08/2023 23:59:00 +DueAt: 08/21/2023 23:59:00 +LockAt: 08/21/2023 23:59:00 AssignmentGroup: Assignments AllowedAttempts: -1 Description: this is the @@ -153,8 +153,8 @@ b) false Name: Test Quiz ShuffleAnswers: true OneQuestionAtATime: false -DueAt: 21/08/2023 23:59:00 -LockAt: 21/08/2023 23:59:00 +DueAt: 08/21/2023 23:59:00 +LockAt: 08/21/2023 23:59:00 AssignmentGroup: Assignments AllowedAttempts: -1 Description: this is the @@ -185,8 +185,8 @@ b) false Name: Test Quiz ShuffleAnswers: true OneQuestionAtATime: false -DueAt: 21/08/2023 23:59:00 -LockAt: 21/08/2023 23:59:00 +DueAt: 08/21/2023 23:59:00 +LockAt: 08/21/2023 23:59:00 AssignmentGroup: Assignments AllowedAttempts: -1 Description: this is the @@ -213,8 +213,8 @@ short_answer`; Name: Test Quiz ShuffleAnswers: true OneQuestionAtATime: false -DueAt: 21/08/2023 23:59:00 -LockAt: 21/08/2023 23:59:00 +DueAt: 08/21/2023 23:59:00 +LockAt: 08/21/2023 23:59:00 AssignmentGroup: Assignments AllowedAttempts: -1 Description: this is the @@ -236,8 +236,8 @@ short answer Name: Test Quiz ShuffleAnswers: true OneQuestionAtATime: false -DueAt: 21/08/2023 23:59:00 -LockAt: 21/08/2023 23:59:00 +DueAt: 08/21/2023 23:59:00 +LockAt: 08/21/2023 23:59:00 AssignmentGroup: Assignments AllowedAttempts: -1 Description: this is the diff --git a/nextjs/src/models/local/tests/quizMarkdown/testAnswer.test.ts b/nextjs/src/models/local/tests/quizMarkdown/testAnswer.test.ts index b9b37de..3f3e270 100644 --- a/nextjs/src/models/local/tests/quizMarkdown/testAnswer.test.ts +++ b/nextjs/src/models/local/tests/quizMarkdown/testAnswer.test.ts @@ -9,8 +9,8 @@ describe("TextAnswerTests", () => { Name: Test Quiz ShuffleAnswers: true OneQuestionAtATime: false -DueAt: 21/08/2023 23:59:00 -LockAt: 21/08/2023 23:59:00 +DueAt: 08/21/2023 23:59:00 +LockAt: 08/21/2023 23:59:00 AssignmentGroup: Assignments AllowedAttempts: -1 Description: this is the @@ -34,8 +34,8 @@ essay Name: Test Quiz ShuffleAnswers: true OneQuestionAtATime: false -DueAt: 21/08/2023 23:59:00 -LockAt: 21/08/2023 23:59:00 +DueAt: 08/21/2023 23:59:00 +LockAt: 08/21/2023 23:59:00 AssignmentGroup: Assignments AllowedAttempts: -1 Description: this is the @@ -59,8 +59,8 @@ short answer Name: Test Quiz ShuffleAnswers: true OneQuestionAtATime: false -DueAt: 21/08/2023 23:59:00 -LockAt: 21/08/2023 23:59:00 +DueAt: 08/21/2023 23:59:00 +LockAt: 08/21/2023 23:59:00 AssignmentGroup: Assignments AllowedAttempts: -1 Description: this is the @@ -87,8 +87,8 @@ short_answer`; Name: Test Quiz ShuffleAnswers: true OneQuestionAtATime: false -DueAt: 21/08/2023 23:59:00 -LockAt: 21/08/2023 23:59:00 +DueAt: 08/21/2023 23:59:00 +LockAt: 08/21/2023 23:59:00 AssignmentGroup: Assignments AllowedAttempts: -1 Description: this is the diff --git a/nextjs/src/models/local/tests/timeUtils.test.ts b/nextjs/src/models/local/tests/timeUtils.test.ts index 45e9cb8..74ed36f 100644 --- a/nextjs/src/models/local/tests/timeUtils.test.ts +++ b/nextjs/src/models/local/tests/timeUtils.test.ts @@ -1,23 +1,31 @@ - - - import { describe, it, expect } from "vitest"; import { getDateFromString } from "../timeUtils"; describe("Can properly handle expected date formats", () => { - it("can use AM/PM dates", () =>{ - const dateString = "8/27/2024 1:00:00 AM" - const dateObject = getDateFromString(dateString) - expect(dateObject).not.toBeUndefined() - }) - it("can use 24 hour dates", () =>{ - const dateString = "8/27/2024 23:95:00" - const dateObject = getDateFromString(dateString) - expect(dateObject).not.toBeUndefined() - }) - it("can use ISO format", () =>{ - const dateString = "2024-08-26T00:00:00.0000000" - const dateObject = getDateFromString(dateString) - expect(dateObject).not.toBeUndefined() - }) -}) \ No newline at end of file + it("can use AM/PM dates", () => { + const dateString = "8/27/2024 1:00:00 AM"; + const dateObject = getDateFromString(dateString); + expect(dateObject).not.toBeUndefined(); + }); + it("can use 24 hour dates", () => { + const dateString = "8/27/2024 23:95:00"; + const dateObject = getDateFromString(dateString); + expect(dateObject).not.toBeUndefined(); + }); + it("can use ISO format", () => { + const dateString = "2024-08-26T00:00:00.0000000"; + const dateObject = getDateFromString(dateString); + expect(dateObject).not.toBeUndefined(); + }); + it("can get correct time from format", () => { + const dateString = "08/28/2024 23:59:00"; + const dateObject = getDateFromString(dateString); + + expect(dateObject?.getDate()).toBe(28); + expect(dateObject?.getMonth()).toBe(8 - 1); // 0 based + expect(dateObject?.getFullYear()).toBe(2024); + expect(dateObject?.getMinutes()).toBe(59); + expect(dateObject?.getHours()).toBe(23); + expect(dateObject?.getSeconds()).toBe(0); + }); +}); diff --git a/nextjs/src/models/local/timeUtils.ts b/nextjs/src/models/local/timeUtils.ts index 06dc7e8..0c4cb27 100644 --- a/nextjs/src/models/local/timeUtils.ts +++ b/nextjs/src/models/local/timeUtils.ts @@ -24,7 +24,7 @@ const _getDateFromMilitary = ( datePart: string, timePart: string ): Date | undefined => { - const [day, month, year] = datePart.split("/").map(Number); + const [month, day, year] = datePart.split("/").map(Number); const [hours, minutes, seconds] = timePart.split(":").map(Number); const date = new Date(year, month - 1, day, hours, minutes, seconds); @@ -86,5 +86,5 @@ export const dateToMarkdownString = (date: Date) => { const stringMinutes = String(date.getMinutes()).padStart(2, "0"); const stringSeconds = String(date.getSeconds()).padStart(2, "0"); - return `${stringDay}/${stringMonth}/${stringYear} ${stringHours}:${stringMinutes}:${stringSeconds}`; + return `${stringMonth}/${stringDay}/${stringYear} ${stringHours}:${stringMinutes}:${stringSeconds}`; }; diff --git a/nextjs/src/services/tests/courseDifferenceChanges.test.ts b/nextjs/src/services/tests/courseDifferenceChanges.test.ts index 67dae87..2d1cf36 100644 --- a/nextjs/src/services/tests/courseDifferenceChanges.test.ts +++ b/nextjs/src/services/tests/courseDifferenceChanges.test.ts @@ -10,8 +10,8 @@ describe("CourseDifferencesChangesTests", () => { name: "Test Course", assignmentGroups: [], daysOfWeek: [], - startDate: "09/07/2024 23:59:00", - endDate: "09/07/2024 23:59:00", + startDate: "07/09/2024 23:59:00", + endDate: "07/09/2024 23:59:00", defaultDueTime: { hour: 23, minute: 59, @@ -40,8 +40,8 @@ describe("CourseDifferencesChangesTests", () => { name: "Test Course", assignmentGroups: [], daysOfWeek: [], - startDate: "09/07/2024 23:59:00", - endDate: "09/07/2024 23:59:00", + startDate: "07/09/2024 23:59:00", + endDate: "07/09/2024 23:59:00", defaultDueTime: { hour: 23, minute: 59, @@ -74,8 +74,8 @@ describe("CourseDifferencesChangesTests", () => { name: "Test Course", assignmentGroups: [], daysOfWeek: [], - startDate: "09/07/2024 23:59:00", - endDate: "09/07/2024 23:59:00", + startDate: "07/09/2024 23:59:00", + endDate: "07/09/2024 23:59:00", defaultDueTime: { hour: 23, minute: 59, @@ -88,7 +88,7 @@ describe("CourseDifferencesChangesTests", () => { { name: "test assignment", description: "", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", submissionTypes: [], allowedFileUploadExtensions: [], rubric: [], @@ -108,7 +108,7 @@ describe("CourseDifferencesChangesTests", () => { { name: "test assignment", description: "new description", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", submissionTypes: [], allowedFileUploadExtensions: [], rubric: [], @@ -130,7 +130,7 @@ describe("CourseDifferencesChangesTests", () => { }); it("can properly ignore unchanged modules", () => { - const commonDate = "09/07/2024 23:59:00"; + const commonDate = "07/09/2024 23:59:00"; const oldCourse: LocalCourse = { settings: { name: "Test Course", @@ -171,7 +171,7 @@ describe("CourseDifferencesChangesTests", () => { }); it("only changed assignment represented", () => { - const commonDate = "09/07/2024 23:59:00"; + const commonDate = "07/09/2024 23:59:00"; const oldCourse: LocalCourse = { settings: { name: "Test Course", @@ -249,7 +249,7 @@ describe("CourseDifferencesChangesTests", () => { }); it("identical quizzes ignored", () => { - const commonDate = "09/07/2024 23:59:00"; + const commonDate = "07/09/2024 23:59:00"; const oldCourse: LocalCourse = { settings: { name: "Test Course", @@ -292,7 +292,7 @@ describe("CourseDifferencesChangesTests", () => { }); it("can detect different quiz", () => { - const commonDate = "09/07/2024 23:59:00"; + const commonDate = "07/09/2024 23:59:00"; const oldCourse: LocalCourse = { settings: { name: "Test Course", @@ -359,7 +359,7 @@ describe("CourseDifferencesChangesTests", () => { }); it("can detect only different quiz when other quizzes stay", () => { - const commonDate = "09/07/2024 23:59:00"; + const commonDate = "07/09/2024 23:59:00"; const oldCourse: LocalCourse = { settings: { name: "Test Course", @@ -433,7 +433,7 @@ describe("CourseDifferencesChangesTests", () => { }); it("same pages not detected", () => { - const commonDate = "09/07/2024 23:59:00"; + const commonDate = "07/09/2024 23:59:00"; const oldCourse: LocalCourse = { settings: { name: "Test Course", @@ -471,7 +471,7 @@ describe("CourseDifferencesChangesTests", () => { }); it("different page detected", () => { - const commonDate = "09/07/2024 23:59:00"; + const commonDate = "07/09/2024 23:59:00"; const oldCourse: LocalCourse = { settings: { name: "Test Course", @@ -527,7 +527,7 @@ describe("CourseDifferencesChangesTests", () => { }); it("different page detected but not same page", () => { - const commonDate = "09/07/2024 23:59:00"; + const commonDate = "07/09/2024 23:59:00"; const oldCourse: LocalCourse = { settings: { name: "Test Course", diff --git a/nextjs/src/services/tests/courseDifferencesDeletions.test.ts b/nextjs/src/services/tests/courseDifferencesDeletions.test.ts index dad4b20..d816fbf 100644 --- a/nextjs/src/services/tests/courseDifferencesDeletions.test.ts +++ b/nextjs/src/services/tests/courseDifferencesDeletions.test.ts @@ -9,8 +9,8 @@ describe("CourseDifferencesDeletionsTests", () => { name: "test course", assignmentGroups: [], daysOfWeek: [], - startDate: "09/07/2024 23:59:00", - endDate: "09/07/2024 23:59:00", + startDate: "07/09/2024 23:59:00", + endDate: "07/09/2024 23:59:00", defaultDueTime: { hour: 23, minute: 59, @@ -51,8 +51,8 @@ describe("CourseDifferencesDeletionsTests", () => { name: "test course", assignmentGroups: [], daysOfWeek: [], - startDate: "09/07/2024 23:59:00", - endDate: "09/07/2024 23:59:00", + startDate: "07/09/2024 23:59:00", + endDate: "07/09/2024 23:59:00", defaultDueTime: { hour: 23, minute: 59, @@ -94,8 +94,8 @@ describe("CourseDifferencesDeletionsTests", () => { name: "test course", assignmentGroups: [], daysOfWeek: [], - startDate: "09/07/2024 23:59:00", - endDate: "09/07/2024 23:59:00", + startDate: "07/09/2024 23:59:00", + endDate: "07/09/2024 23:59:00", defaultDueTime: { hour: 23, minute: 59, @@ -108,7 +108,7 @@ describe("CourseDifferencesDeletionsTests", () => { { name: "test assignment", description: "test description", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", submissionTypes: [], allowedFileUploadExtensions: [], rubric: [], @@ -128,7 +128,7 @@ describe("CourseDifferencesDeletionsTests", () => { { name: "test assignment changed name", description: "test description", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", submissionTypes: [], allowedFileUploadExtensions: [], rubric: [], @@ -159,8 +159,8 @@ describe("CourseDifferencesDeletionsTests", () => { name: "test course", assignmentGroups: [], daysOfWeek: [], - startDate: "09/07/2024 23:59:00", - endDate: "09/07/2024 23:59:00", + startDate: "07/09/2024 23:59:00", + endDate: "07/09/2024 23:59:00", defaultDueTime: { hour: 23, minute: 59, @@ -173,7 +173,7 @@ describe("CourseDifferencesDeletionsTests", () => { { name: "test assignment", description: "test description", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", submissionTypes: [], allowedFileUploadExtensions: [], rubric: [], @@ -193,7 +193,7 @@ describe("CourseDifferencesDeletionsTests", () => { { name: "test assignment", description: "test description", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", submissionTypes: [], allowedFileUploadExtensions: [], rubric: [], @@ -219,8 +219,8 @@ describe("CourseDifferencesDeletionsTests", () => { name: "test course", assignmentGroups: [], daysOfWeek: [], - startDate: "09/07/2024 23:59:00", - endDate: "09/07/2024 23:59:00", + startDate: "07/09/2024 23:59:00", + endDate: "07/09/2024 23:59:00", defaultDueTime: { hour: 23, minute: 59, @@ -233,7 +233,7 @@ describe("CourseDifferencesDeletionsTests", () => { { name: "test assignment", description: "test description", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", submissionTypes: [], allowedFileUploadExtensions: [], rubric: [], @@ -241,7 +241,7 @@ describe("CourseDifferencesDeletionsTests", () => { { name: "test assignment 2", description: "test description", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", submissionTypes: [], allowedFileUploadExtensions: [], rubric: [], @@ -261,7 +261,7 @@ describe("CourseDifferencesDeletionsTests", () => { { name: "test assignment", description: "test description", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", submissionTypes: [], allowedFileUploadExtensions: [], rubric: [], @@ -269,7 +269,7 @@ describe("CourseDifferencesDeletionsTests", () => { { name: "test assignment 2 changed", description: "test description", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", submissionTypes: [], allowedFileUploadExtensions: [], rubric: [], @@ -299,8 +299,8 @@ describe("CourseDifferencesDeletionsTests", () => { name: "test course", assignmentGroups: [], daysOfWeek: [], - startDate: "09/07/2024 23:59:00", - endDate: "09/07/2024 23:59:00", + startDate: "07/09/2024 23:59:00", + endDate: "07/09/2024 23:59:00", defaultDueTime: { hour: 23, minute: 59, @@ -314,7 +314,7 @@ describe("CourseDifferencesDeletionsTests", () => { { name: "Test Quiz", description: "test description", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", shuffleAnswers: false, showCorrectAnswers: false, oneQuestionAtATime: false, @@ -324,7 +324,7 @@ describe("CourseDifferencesDeletionsTests", () => { { name: "Test Quiz 2", description: "test description", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", shuffleAnswers: false, showCorrectAnswers: false, oneQuestionAtATime: false, @@ -346,7 +346,7 @@ describe("CourseDifferencesDeletionsTests", () => { { name: "Test Quiz", description: "test description", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", shuffleAnswers: false, showCorrectAnswers: false, oneQuestionAtATime: false, @@ -356,7 +356,7 @@ describe("CourseDifferencesDeletionsTests", () => { { name: "Test Quiz 3", description: "test description", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", shuffleAnswers: false, showCorrectAnswers: false, oneQuestionAtATime: false, @@ -387,8 +387,8 @@ describe("CourseDifferencesDeletionsTests", () => { name: "test course", assignmentGroups: [], daysOfWeek: [], - startDate: "09/07/2024 23:59:00", - endDate: "09/07/2024 23:59:00", + startDate: "07/09/2024 23:59:00", + endDate: "07/09/2024 23:59:00", defaultDueTime: { hour: 23, minute: 59, @@ -403,12 +403,12 @@ describe("CourseDifferencesDeletionsTests", () => { { name: "Test Page", text: "test contents", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", }, { name: "Test Page 2", text: "test contents", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", }, ], }, @@ -425,12 +425,12 @@ describe("CourseDifferencesDeletionsTests", () => { { name: "Test Page", text: "test contents", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", }, { name: "Test Page 3", text: "test contents", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", }, ], }, diff --git a/nextjs/src/services/tests/fileStorage.test.ts b/nextjs/src/services/tests/fileStorage.test.ts index 2f73c8d..a268b03 100644 --- a/nextjs/src/services/tests/fileStorage.test.ts +++ b/nextjs/src/services/tests/fileStorage.test.ts @@ -21,8 +21,8 @@ describe("FileStorageTests", () => { name: "test empty course", assignmentGroups: [], daysOfWeek: [], - startDate: "09/07/2024 23:59:00", - endDate: "09/07/2024 23:59:00", + startDate: "07/09/2024 23:59:00", + endDate: "07/09/2024 23:59:00", defaultDueTime: { hour: 1, minute: 59 }, }, modules: [], @@ -44,8 +44,8 @@ describe("FileStorageTests", () => { assignmentGroups: [], name: "Test Course with settings", daysOfWeek: [DayOfWeek.Monday, DayOfWeek.Wednesday], - startDate: "09/07/2024 23:59:00", - endDate: "09/07/2024 23:59:00", + startDate: "07/09/2024 23:59:00", + endDate: "07/09/2024 23:59:00", defaultDueTime: { hour: 1, minute: 59 }, }, modules: [], @@ -67,8 +67,8 @@ describe("FileStorageTests", () => { name: "Test Course with modules", assignmentGroups: [], daysOfWeek: [], - startDate: "09/07/2024 23:59:00", - endDate: "09/07/2024 23:59:00", + startDate: "07/09/2024 23:59:00", + endDate: "07/09/2024 23:59:00", defaultDueTime: { hour: 1, minute: 59 }, }, modules: [ @@ -97,8 +97,8 @@ describe("FileStorageTests", () => { name: "Test Course with modules and assignments", assignmentGroups: [], daysOfWeek: [], - startDate: "09/07/2024 23:59:00", - endDate: "09/07/2024 23:59:00", + startDate: "07/09/2024 23:59:00", + endDate: "07/09/2024 23:59:00", defaultDueTime: { hour: 1, minute: 59 }, }, modules: [ @@ -108,8 +108,8 @@ describe("FileStorageTests", () => { { name: "test assignment", description: "here is the description", - dueAt: "09/07/2024 23:59:00", - lockAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", + lockAt: "07/09/2024 23:59:00", submissionTypes: [AssignmentSubmissionType.ONLINE_UPLOAD], localAssignmentGroupName: "Final Project", rubric: [ @@ -143,8 +143,8 @@ describe("FileStorageTests", () => { name: "Test Course with modules and quiz", assignmentGroups: [], daysOfWeek: [], - startDate: "09/07/2024 23:59:00", - endDate: "09/07/2024 23:59:00", + startDate: "07/09/2024 23:59:00", + endDate: "07/09/2024 23:59:00", defaultDueTime: { hour: 1, minute: 59 }, }, modules: [ @@ -155,8 +155,8 @@ describe("FileStorageTests", () => { { name: "Test Quiz", description: "quiz description", - lockAt: "09/07/2024 12:05:00", - dueAt: "09/07/2024 12:05:00", + lockAt: "07/09/2024 12:05:00", + dueAt: "07/09/2024 12:05:00", shuffleAnswers: true, oneQuestionAtATime: true, localAssignmentGroupName: "Assignments", @@ -196,8 +196,8 @@ describe("FileStorageTests", () => { name: "Test Course with lots of data", assignmentGroups: [], daysOfWeek: [DayOfWeek.Monday, DayOfWeek.Wednesday], - startDate: "09/07/2024 23:59:00", - endDate: "09/07/2024 23:59:00", + startDate: "07/09/2024 23:59:00", + endDate: "07/09/2024 23:59:00", defaultDueTime: { hour: 1, minute: 59 }, }, modules: [ @@ -207,8 +207,8 @@ describe("FileStorageTests", () => { { name: "test assignment", description: "here is the description", - dueAt: "09/07/2024 23:59:00", - lockAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", + lockAt: "07/09/2024 23:59:00", submissionTypes: [AssignmentSubmissionType.ONLINE_UPLOAD], localAssignmentGroupName: "Final Project", rubric: [ @@ -222,8 +222,8 @@ describe("FileStorageTests", () => { { name: "Test Quiz", description: "quiz description", - lockAt: "09/07/2024 23:59:00", - dueAt: "09/07/2024 23:59:00", + lockAt: "07/09/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", shuffleAnswers: true, oneQuestionAtATime: false, localAssignmentGroupName: "someId", @@ -261,8 +261,8 @@ describe("FileStorageTests", () => { name: "Test Course with page", assignmentGroups: [], daysOfWeek: [DayOfWeek.Monday, DayOfWeek.Wednesday], - startDate: "09/07/2024 23:59:00", - endDate: "09/07/2024 23:59:00", + startDate: "07/09/2024 23:59:00", + endDate: "07/09/2024 23:59:00", defaultDueTime: { hour: 1, minute: 59 }, }, modules: [ @@ -273,7 +273,7 @@ describe("FileStorageTests", () => { pages: [ { name: "test page persistence", - dueAt: "09/07/2024 23:59:00", + dueAt: "07/09/2024 23:59:00", text: "this is some\n## markdown\n", }, ],