mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
more refactor
This commit is contained in:
@@ -4,7 +4,7 @@ import {
|
||||
getDateKey,
|
||||
getTermName,
|
||||
groupByStartDate,
|
||||
} from "@/models/local/utils/timeUtils";
|
||||
} from "@/features/local/utils/timeUtils";
|
||||
import { getCourseUrl } from "@/services/urlUtils";
|
||||
import Link from "next/link";
|
||||
|
||||
|
||||
@@ -18,7 +18,10 @@ import { AssignmentSubmissionType } from "@/features/local/assignments/models/as
|
||||
import { getCourseUrl } from "@/services/urlUtils";
|
||||
import { useRouter } from "next/navigation";
|
||||
import React, { Dispatch, SetStateAction, useMemo, useState } from "react";
|
||||
import { DayOfWeek, LocalCourseSettings } from "@/features/local/course/localCourseSettings";
|
||||
import {
|
||||
DayOfWeek,
|
||||
LocalCourseSettings,
|
||||
} from "@/features/local/course/localCourseSettings";
|
||||
|
||||
const sampleCompose = `services:
|
||||
canvas_manager:
|
||||
|
||||
@@ -6,8 +6,8 @@ import { SuspenseAndErrorHandling } from "@/components/SuspenseAndErrorHandling"
|
||||
import {
|
||||
useGlobalSettingsQuery,
|
||||
useUpdateGlobalSettingsMutation,
|
||||
} from "@/hooks/localCourse/globalSettingsHooks";
|
||||
import { useDirectoryIsCourseQuery } from "@/hooks/localCourse/storageDirectoryHooks";
|
||||
} from "@/features/local/globalSettings/globalSettingsHooks";
|
||||
import { useDirectoryIsCourseQuery } from "@/features/local/utils/storageDirectoryHooks";
|
||||
import { FC, useEffect, useRef, useState } from "react";
|
||||
|
||||
export const AddExistingCourseToGlobalSettings = () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { assignmentMarkdownSerializer } from "@/features/local/assignments/models/utils/assignmentMarkdownSerializer";
|
||||
import { groupByStartDate } from "@/models/local/utils/timeUtils";
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
import { groupByStartDate } from "@/features/local/utils/timeUtils";
|
||||
import { fileStorageService } from "@/features/local/utils/fileStorageService";
|
||||
import { createMcpHandler } from "mcp-handler";
|
||||
import { z } from "zod";
|
||||
import { githubClassroomUrlPrompt } from "./github-classroom-prompt";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createTrpcContext } from "@/services/serverFunctions/context";
|
||||
import { trpcAppRouter } from "@/services/serverFunctions/router/app";
|
||||
import { trpcAppRouter } from "@/services/serverFunctions/router/appRouter";
|
||||
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
|
||||
|
||||
const handler = async (request: Request) => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { CalendarMonthModel, getWeekNumber } from "./calendarMonthUtils";
|
||||
import { Expandable } from "@/components/Expandable";
|
||||
import { CalendarWeek } from "./CalendarWeek";
|
||||
import { useLocalCourseSettingsQuery } from "@/features/local/course/localCoursesHooks";
|
||||
import { getDateFromStringOrThrow } from "@/models/local/utils/timeUtils";
|
||||
import { getDateFromStringOrThrow } from "@/features/local/utils/timeUtils";
|
||||
import UpChevron from "@/components/icons/UpChevron";
|
||||
import DownChevron from "@/components/icons/DownChevron";
|
||||
import { DayOfWeek } from "@/features/local/course/localCourseSettings";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
import { useLocalCourseSettingsQuery } from "@/features/local/course/localCoursesHooks";
|
||||
import { getDateFromStringOrThrow } from "@/models/local/utils/timeUtils";
|
||||
import { getDateFromStringOrThrow } from "@/features/local/utils/timeUtils";
|
||||
import { getWeekNumber } from "./calendarMonthUtils";
|
||||
import Day from "./day/Day";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"use client";
|
||||
import { getDateFromStringOrThrow } from "@/models/local/utils/timeUtils";
|
||||
import { getDateFromStringOrThrow } from "@/features/local/utils/timeUtils";
|
||||
import { getMonthsBetweenDates } from "./calendarMonthUtils";
|
||||
import { CalendarMonth } from "./CalendarMonth";
|
||||
import { useLocalCourseSettingsQuery } from "@/features/local/course/localCoursesHooks";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
dateToMarkdownString,
|
||||
getDateFromStringOrThrow,
|
||||
} from "@/models/local/utils/timeUtils";
|
||||
} from "@/features/local/utils/timeUtils";
|
||||
|
||||
export interface CalendarMonthModel {
|
||||
year: number;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import {
|
||||
getDateFromStringOrThrow,
|
||||
getDateOnlyMarkdownString,
|
||||
} from "@/models/local/utils/timeUtils";
|
||||
} from "@/features/local/utils/timeUtils";
|
||||
import { useDraggingContext } from "../../context/drag/draggingContext";
|
||||
import { useLocalCourseSettingsQuery } from "@/features/local/course/localCoursesHooks";
|
||||
import { ItemInDay } from "./ItemInDay";
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useCourseContext } from "../../context/courseContext";
|
||||
import NewItemForm from "../../modules/NewItemForm";
|
||||
import { DraggableItem } from "../../context/drag/draggingContext";
|
||||
import { useDragStyleContext } from "../../context/drag/dragStyleContext";
|
||||
import { getLectureForDay } from "@/models/local/utils/lectureUtils";
|
||||
import { getLectureForDay } from "@/features/local/utils/lectureUtils";
|
||||
import { useLecturesSuspenseQuery } from "@/features/local/lectures/lectureHooks";
|
||||
import ClientOnly from "@/components/ClientOnly";
|
||||
import { Tooltip } from "@/components/Tooltip";
|
||||
|
||||
@@ -6,7 +6,7 @@ import { LocalAssignment } from "@/features/local/assignments/models/localAssign
|
||||
import {
|
||||
dateToMarkdownString,
|
||||
getDateFromStringOrThrow,
|
||||
} from "@/models/local/utils/timeUtils";
|
||||
} from "@/features/local/utils/timeUtils";
|
||||
import { markdownToHTMLSafe } from "@/services/htmlMarkdownUtils";
|
||||
import { htmlIsCloseEnough } from "@/services/utils/htmlIsCloseEnough";
|
||||
import { ReactNode } from "react";
|
||||
|
||||
@@ -6,7 +6,7 @@ import { LocalAssignment } from "@/features/local/assignments/models/localAssign
|
||||
import {
|
||||
getDateFromStringOrThrow,
|
||||
getDateOnlyMarkdownString,
|
||||
} from "@/models/local/utils/timeUtils";
|
||||
} from "@/features/local/utils/timeUtils";
|
||||
import { ReactNode } from "react";
|
||||
import { useCalendarItemsContext } from "../../context/calendarItemsContext";
|
||||
import { getStatus } from "./getStatus";
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
"use client";
|
||||
import { getDateFromStringOrThrow, dateToMarkdownString } from "@/models/local/utils/timeUtils";
|
||||
|
||||
import {
|
||||
getDateFromStringOrThrow,
|
||||
dateToMarkdownString,
|
||||
} from "@/features/local/utils/timeUtils";
|
||||
|
||||
export function getNewLockDate(
|
||||
originalDueDate: string,
|
||||
@@ -9,13 +11,16 @@ export function getNewLockDate(
|
||||
): string | undefined {
|
||||
// todo: preserve previous due date / lock date offset
|
||||
const dueDate = getDateFromStringOrThrow(originalDueDate, "dueAt date");
|
||||
const lockDate = originalLockDate === undefined
|
||||
const lockDate =
|
||||
originalLockDate === undefined
|
||||
? undefined
|
||||
: getDateFromStringOrThrow(originalLockDate, "lockAt date");
|
||||
|
||||
const originalOffset = lockDate === undefined ? undefined : lockDate.getTime() - dueDate.getTime();
|
||||
const originalOffset =
|
||||
lockDate === undefined ? undefined : lockDate.getTime() - dueDate.getTime();
|
||||
|
||||
const newLockDate = originalOffset === undefined
|
||||
const newLockDate =
|
||||
originalOffset === undefined
|
||||
? undefined
|
||||
: new Date(dayAsDate.getTime() + originalOffset);
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@ import { useLocalCourseSettingsQuery } from "@/features/local/course/localCourse
|
||||
import { useUpdatePageMutation } from "@/features/local/pages/pageHooks";
|
||||
import { LocalAssignment } from "@/features/local/assignments/models/localAssignment";
|
||||
import { Lecture } from "@/features/local/lectures/lectureModel";
|
||||
import { getLectureForDay } from "@/models/local/utils/lectureUtils";
|
||||
import { getLectureForDay } from "@/features/local/utils/lectureUtils";
|
||||
import {
|
||||
getDateFromStringOrThrow,
|
||||
getDateOnlyMarkdownString,
|
||||
dateToMarkdownString,
|
||||
} from "@/models/local/utils/timeUtils";
|
||||
} from "@/features/local/utils/timeUtils";
|
||||
import { Dispatch, SetStateAction, useCallback, DragEvent } from "react";
|
||||
import { DraggableItem } from "./draggingContext";
|
||||
import { getNewLockDate } from "./getNewLockDate";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useLocalCourseSettingsQuery } from "@/features/local/course/localCoursesHooks";
|
||||
import { getDateFromString } from "@/models/local/utils/timeUtils";
|
||||
import { getDateFromString } from "@/features/local/utils/timeUtils";
|
||||
import { getLectureWeekName } from "@/services/fileStorage/utils/lectureUtils";
|
||||
import { getCourseUrl, getLecturePreviewUrl } from "@/services/urlUtils";
|
||||
import { useCourseContext } from "../../context/courseContext";
|
||||
|
||||
@@ -2,7 +2,7 @@ import EditLecture from "./EditLecture";
|
||||
import {
|
||||
getDateFromStringOrThrow,
|
||||
getDateOnlyMarkdownString,
|
||||
} from "@/models/local/utils/timeUtils";
|
||||
} from "@/features/local/utils/timeUtils";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function page({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
getDateFromStringOrThrow,
|
||||
getDateOnlyMarkdownString,
|
||||
} from "@/models/local/utils/timeUtils";
|
||||
} from "@/features/local/utils/timeUtils";
|
||||
import LecturePreviewPage from "./LecturePreviewPage";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
getDateFromString,
|
||||
getDateFromStringOrThrow,
|
||||
getDateOnlyMarkdownString,
|
||||
} from "@/models/local/utils/timeUtils";
|
||||
} from "@/features/local/utils/timeUtils";
|
||||
import { Fragment } from "react";
|
||||
import Modal, { useModal } from "../../../../components/Modal";
|
||||
import NewItemForm from "./NewItemForm";
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
getDateFromString,
|
||||
dateToMarkdownString,
|
||||
getDateFromStringOrThrow,
|
||||
} from "@/models/local/utils/timeUtils";
|
||||
} from "@/features/local/utils/timeUtils";
|
||||
import { useCreateAssignmentMutation } from "@/features/local/assignments/assignmentHooks";
|
||||
|
||||
export default function NewItemForm({
|
||||
|
||||
@@ -6,12 +6,12 @@ import {
|
||||
useLocalCourseSettingsQuery,
|
||||
useUpdateLocalCourseSettingsMutation,
|
||||
} from "@/features/local/course/localCoursesHooks";
|
||||
import { getDateFromString } from "@/models/local/utils/timeUtils";
|
||||
import { getDateFromString } from "@/features/local/utils/timeUtils";
|
||||
import { useEffect, useState } from "react";
|
||||
import {
|
||||
holidaysToString,
|
||||
parseHolidays,
|
||||
} from "../../../../models/local/utils/settingsUtils";
|
||||
} from "../../../../features/local/utils/settingsUtils";
|
||||
import { settingsBox } from "./sharedSettings";
|
||||
|
||||
const exampleString = `springBreak:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
import { useLocalCourseSettingsQuery } from "@/features/local/course/localCoursesHooks";
|
||||
import { getDateOnlyMarkdownString } from "@/models/local/utils/timeUtils";
|
||||
import { getDateOnlyMarkdownString } from "@/features/local/utils/timeUtils";
|
||||
import React from "react";
|
||||
import { settingsBox } from "./sharedSettings";
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ import { Suspense } from "react";
|
||||
import { dehydrate, HydrationBoundary } from "@tanstack/react-query";
|
||||
import { MyToaster } from "./MyToaster";
|
||||
import { createServerSideHelpers } from "@trpc/react-query/server";
|
||||
import { trpcAppRouter } from "@/services/serverFunctions/router/app";
|
||||
import { trpcAppRouter } from "@/services/serverFunctions/router/appRouter";
|
||||
import { createTrpcContext } from "@/services/serverFunctions/context";
|
||||
import superjson from "superjson";
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
import { fileStorageService } from "@/features/local/utils/fileStorageService";
|
||||
import { ClientCacheInvalidation } from "../components/realtime/ClientCacheInvalidation";
|
||||
import { getTitle } from "@/services/titleUtils";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -4,8 +4,8 @@ import { getLecturePreviewUrl } from "@/services/urlUtils";
|
||||
import Link from "next/link";
|
||||
import { useCourseContext } from "../course/[courseName]/context/courseContext";
|
||||
import { useLecturesSuspenseQuery as useLecturesQuery } from "@/features/local/lectures/lectureHooks";
|
||||
import { getLectureForDay } from "@/models/local/utils/lectureUtils";
|
||||
import { getDateOnlyMarkdownString } from "@/models/local/utils/timeUtils";
|
||||
import { getLectureForDay } from "@/features/local/utils/lectureUtils";
|
||||
import { getDateOnlyMarkdownString } from "@/features/local/utils/timeUtils";
|
||||
|
||||
export default function OneCourseLectures() {
|
||||
const { courseName } = useCourseContext();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useDirectoryContentsQuery } from "@/hooks/localCourse/storageDirectoryHooks";
|
||||
import { useDirectoryContentsQuery } from "@/features/local/utils/storageDirectoryHooks";
|
||||
import { useState, useRef, useEffect } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import publicProcedure from "../../../services/serverFunctions/procedures/public";
|
||||
import publicProcedure from "../../../services/serverFunctions/publicProcedure";
|
||||
import { z } from "zod";
|
||||
import { router } from "../../../services/serverFunctions/trpcSetup";
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
import { fileStorageService } from "@/features/local/utils/fileStorageService";
|
||||
import { zodLocalAssignment } from "@/features/local/assignments/models/localAssignment";
|
||||
|
||||
export const assignmentRouter = router({
|
||||
|
||||
@@ -6,7 +6,7 @@ import { assignmentMarkdownSerializer } from "@/features/local/assignments/model
|
||||
import path from "path";
|
||||
import { promises as fs } from "fs";
|
||||
import { courseItemFileStorageService } from "@/features/local/course/courseItemFileStorageService";
|
||||
import { getCoursePathByName } from "@/services/fileStorage/globalSettingsFileStorageService";
|
||||
import { getCoursePathByName } from "@/features/local/globalSettings/globalSettingsFileStorageService";
|
||||
import { directoryOrFileExists } from "@/services/fileStorage/utils/fileSystemUtils";
|
||||
|
||||
const getAssignmentNames = async (courseName: string, moduleName: string) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
verifyDateOrThrow,
|
||||
verifyDateStringOrUndefined,
|
||||
} from "../../../../../models/local/utils/timeUtils";
|
||||
} from "../../../utils/timeUtils";
|
||||
import { AssignmentSubmissionType } from "../assignmentSubmissionType";
|
||||
import { LocalAssignment } from "../localAssignment";
|
||||
import { RubricItem } from "../rubricItem";
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
CourseItemType,
|
||||
typeToFolder,
|
||||
} from "@/features/local/course/courseItemTypes";
|
||||
import { getCoursePathByName } from "../../../services/fileStorage/globalSettingsFileStorageService";
|
||||
import { getCoursePathByName } from "../globalSettings/globalSettingsFileStorageService";
|
||||
import {
|
||||
localPageMarkdownUtils,
|
||||
LocalCoursePage,
|
||||
|
||||
@@ -8,12 +8,12 @@ import { AssignmentSubmissionType } from "@/features/local/assignments/models/as
|
||||
import {
|
||||
getCoursePathByName,
|
||||
getGlobalSettings,
|
||||
} from "../../../services/fileStorage/globalSettingsFileStorageService";
|
||||
import { GlobalSettingsCourse } from "@/models/local/globalSettings";
|
||||
} from "../globalSettings/globalSettingsFileStorageService";
|
||||
import {
|
||||
LocalCourseSettings,
|
||||
localCourseYamlUtils,
|
||||
} from "@/features/local/course/localCourseSettings";
|
||||
import { GlobalSettingsCourse } from "../globalSettings/globalSettingsModels";
|
||||
|
||||
const getCourseSettings = async (
|
||||
course: GlobalSettingsCourse
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
import publicProcedure from "../procedures/public";
|
||||
import publicProcedure from "../../../services/serverFunctions/publicProcedure";
|
||||
import { z } from "zod";
|
||||
import { router } from "../trpcSetup";
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
import { router } from "../../../services/serverFunctions/trpcSetup";
|
||||
import { fileStorageService } from "@/features/local/utils/fileStorageService";
|
||||
import {
|
||||
prepAssignmentForNewSemester,
|
||||
prepLectureForNewSemester,
|
||||
prepPageForNewSemester,
|
||||
prepQuizForNewSemester,
|
||||
} from "@/models/local/utils/semesterTransferUtils";
|
||||
} from "@/features/local/utils/semesterTransferUtils";
|
||||
import {
|
||||
getGlobalSettings,
|
||||
updateGlobalSettings,
|
||||
} from "@/services/fileStorage/globalSettingsFileStorageService";
|
||||
import { getLectures, updateLecture } from "@/features/local/lectures/lectureFileStorageService";
|
||||
} from "@/features/local/globalSettings/globalSettingsFileStorageService";
|
||||
import {
|
||||
getLectures,
|
||||
updateLecture,
|
||||
} from "@/features/local/lectures/lectureFileStorageService";
|
||||
import { zodLocalCourseSettings } from "@/features/local/course/localCourseSettings";
|
||||
|
||||
export const settingsRouter = router({
|
||||
@@ -1,14 +1,14 @@
|
||||
import { promises as fs } from "fs";
|
||||
import path from "path";
|
||||
import { basePath } from "../../../services/fileStorage/utils/fileSystemUtils";
|
||||
import {
|
||||
GlobalSettings,
|
||||
zodGlobalSettings,
|
||||
} from "@/models/local/globalSettings";
|
||||
} from "@/features/local/globalSettings/globalSettingsModels";
|
||||
import {
|
||||
globalSettingsToYaml,
|
||||
parseGlobalSettingsYaml,
|
||||
} from "@/models/local/globalSettingsUtils";
|
||||
import { promises as fs } from "fs";
|
||||
import path from "path";
|
||||
import { basePath } from "./utils/fileSystemUtils";
|
||||
globalSettingsToYaml,
|
||||
} from "@/features/local/globalSettings/globalSettingsUtils";
|
||||
|
||||
const SETTINGS_FILE_PATH =
|
||||
process.env.SETTINGS_FILE_PATH || "./globalSettings.yml";
|
||||
@@ -1,11 +1,11 @@
|
||||
import { zodGlobalSettings } from "@/models/local/globalSettings";
|
||||
import { router } from "../trpcSetup";
|
||||
import { router } from "../../../services/serverFunctions/trpcSetup";
|
||||
import z from "zod";
|
||||
import publicProcedure from "../procedures/public";
|
||||
import publicProcedure from "../../../services/serverFunctions/publicProcedure";
|
||||
import {
|
||||
getGlobalSettings,
|
||||
updateGlobalSettings,
|
||||
} from "@/services/fileStorage/globalSettingsFileStorageService";
|
||||
} from "@/features/local/globalSettings/globalSettingsFileStorageService";
|
||||
import { zodGlobalSettings } from "./globalSettingsModels";
|
||||
|
||||
export const globalSettingsRouter = router({
|
||||
getGlobalSettings: publicProcedure.query(async () => {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { GlobalSettings, zodGlobalSettings } from "./globalSettings";
|
||||
import { GlobalSettings, zodGlobalSettings } from "./globalSettingsModels";
|
||||
import { parse, stringify } from "yaml";
|
||||
|
||||
export const globalSettingsToYaml = (settings: GlobalSettings) => {
|
||||
@@ -14,4 +14,3 @@ export const parseGlobalSettingsYaml = (yaml: string): GlobalSettings => {
|
||||
throw new Error(`Error parsing global settings, got ${yaml}, ${e}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
import path from "path";
|
||||
import fs from "fs/promises";
|
||||
import { Lecture } from "@/features/local/lectures/lectureModel";
|
||||
import { getDateFromStringOrThrow } from "@/models/local/utils/timeUtils";
|
||||
import { getCoursePathByName } from "@/services/fileStorage/globalSettingsFileStorageService";
|
||||
import { getDateFromStringOrThrow } from "@/features/local/utils/timeUtils";
|
||||
import { getCoursePathByName } from "@/features/local/globalSettings/globalSettingsFileStorageService";
|
||||
import {
|
||||
lectureFolderName,
|
||||
parseLecture,
|
||||
getLectureWeekName,
|
||||
lectureToString,
|
||||
} from "@/services/fileStorage/utils/lectureUtils";
|
||||
import { LocalCourseSettings, getDayOfWeek } from "../course/localCourseSettings";
|
||||
import {
|
||||
LocalCourseSettings,
|
||||
getDayOfWeek,
|
||||
} from "../course/localCourseSettings";
|
||||
|
||||
export async function getLectures(courseName: string) {
|
||||
const courseDirectory = await getCoursePathByName(courseName);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { z } from "zod";
|
||||
import publicProcedure from "../../../services/serverFunctions/procedures/public";
|
||||
import publicProcedure from "../../../services/serverFunctions/publicProcedure";
|
||||
import { router } from "../../../services/serverFunctions/trpcSetup";
|
||||
import { zodLecture } from "@/features/local/lectures/lectureModel";
|
||||
import {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { CalendarItemsInterface } from "@/app/course/[courseName]/context/calend
|
||||
import {
|
||||
getDateOnlyMarkdownString,
|
||||
getDateFromStringOrThrow,
|
||||
} from "@/models/local/utils/timeUtils";
|
||||
} from "@/features/local/utils/timeUtils";
|
||||
import {
|
||||
useSuspenseQuery,
|
||||
useMutation,
|
||||
@@ -92,10 +92,7 @@ export const useCoursePagesByModuleByDateQuery = () => {
|
||||
}
|
||||
);
|
||||
const pagesByModuleByDate = pagesAndModules.reduce(
|
||||
(
|
||||
previous,
|
||||
{ page, moduleName }
|
||||
) => {
|
||||
(previous, { page, moduleName }) => {
|
||||
const dueDay = getDateOnlyMarkdownString(
|
||||
getDateFromStringOrThrow(page.dueAt, "due at for page in items context")
|
||||
);
|
||||
@@ -129,9 +126,7 @@ export const useCourseAssignmentsByModuleByDateQuery = () => {
|
||||
trpc.assignment.getAllAssignments.queryOptions({ courseName, moduleName })
|
||||
),
|
||||
});
|
||||
const assignments = assignmentsResults.map(
|
||||
(result) => result.data
|
||||
);
|
||||
const assignments = assignmentsResults.map((result) => result.data);
|
||||
const assignmentsAndModules = moduleNames.flatMap(
|
||||
(moduleName: string, index: number) => {
|
||||
return assignments[index].map((assignment) => ({
|
||||
@@ -141,10 +136,7 @@ export const useCourseAssignmentsByModuleByDateQuery = () => {
|
||||
}
|
||||
);
|
||||
const assignmentsByModuleByDate = assignmentsAndModules.reduce(
|
||||
(
|
||||
previous,
|
||||
{ assignment, moduleName }
|
||||
) => {
|
||||
(previous, { assignment, moduleName }) => {
|
||||
const dueDay = getDateOnlyMarkdownString(
|
||||
getDateFromStringOrThrow(
|
||||
assignment.dueAt,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { LocalCoursePage } from "@/features/local/pages/localCoursePageModels";
|
||||
import { LocalAssignment } from "../assignments/models/localAssignment";
|
||||
import { IModuleItem } from "./IModuleItem";
|
||||
import { getDateFromString } from "../../../models/local/utils/timeUtils";
|
||||
import { getDateFromString } from "../utils/timeUtils";
|
||||
import { LocalQuiz } from "@/features/local/quizzes/models/localQuiz";
|
||||
|
||||
export interface LocalModule {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { promises as fs } from "fs";
|
||||
import { lectureFolderName } from "../../../services/fileStorage/utils/lectureUtils";
|
||||
import { getCoursePathByName } from "../../../services/fileStorage/globalSettingsFileStorageService";
|
||||
import { getCoursePathByName } from "../globalSettings/globalSettingsFileStorageService";
|
||||
|
||||
export const moduleFileStorageService = {
|
||||
async getModuleNames(courseName: string) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { z } from "zod";
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
import { fileStorageService } from "@/features/local/utils/fileStorageService";
|
||||
import { router } from "@/services/serverFunctions/trpcSetup";
|
||||
import publicProcedure from "@/services/serverFunctions/procedures/public";
|
||||
import publicProcedure from "@/services/serverFunctions/publicProcedure";
|
||||
|
||||
export const moduleRouter = router({
|
||||
getModuleNames: publicProcedure
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { IModuleItem } from "@/features/local/modules/IModuleItem";
|
||||
import { verifyDateOrThrow } from "@/models/local/utils/timeUtils";
|
||||
import { verifyDateOrThrow } from "@/features/local/utils/timeUtils";
|
||||
import { z } from "zod";
|
||||
import { extractLabelValue } from "../assignments/models/utils/markdownUtils";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { promises as fs } from "fs";
|
||||
import path from "path";
|
||||
import { courseItemFileStorageService } from "../course/courseItemFileStorageService";
|
||||
import { getCoursePathByName } from "../../../services/fileStorage/globalSettingsFileStorageService";
|
||||
import { getCoursePathByName } from "../globalSettings/globalSettingsFileStorageService";
|
||||
import {
|
||||
LocalCoursePage,
|
||||
localPageMarkdownUtils,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import publicProcedure from "../../../services/serverFunctions/procedures/public";
|
||||
import publicProcedure from "../../../services/serverFunctions/publicProcedure";
|
||||
import { z } from "zod";
|
||||
import { router } from "../../../services/serverFunctions/trpcSetup";
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
import { fileStorageService } from "@/features/local/utils/fileStorageService";
|
||||
import { zodLocalCoursePage } from "@/features/local/pages/localCoursePageModels";
|
||||
|
||||
export const pageRouter = router({
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { verifyDateOrThrow, verifyDateStringOrUndefined } from "@/models/local/utils/timeUtils";
|
||||
import {
|
||||
verifyDateOrThrow,
|
||||
verifyDateStringOrUndefined,
|
||||
} from "@/features/local/utils/timeUtils";
|
||||
import { LocalQuiz } from "../localQuiz";
|
||||
import { quizQuestionMarkdownUtils } from "./quizQuestionMarkdownUtils";
|
||||
|
||||
@@ -38,7 +41,6 @@ const parseNumberOrThrow = (value: string, label: string): number => {
|
||||
return parsed;
|
||||
};
|
||||
const getQuizWithOnlySettings = (settings: string, name: string): LocalQuiz => {
|
||||
|
||||
const rawShuffleAnswers = extractLabelValue(settings, "ShuffleAnswers");
|
||||
const shuffleAnswers = parseBooleanOrThrow(
|
||||
rawShuffleAnswers,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import path from "path";
|
||||
import { promises as fs } from "fs";
|
||||
import { courseItemFileStorageService } from "../course/courseItemFileStorageService";
|
||||
import { getCoursePathByName } from "../../../services/fileStorage/globalSettingsFileStorageService";
|
||||
import { getCoursePathByName } from "../globalSettings/globalSettingsFileStorageService";
|
||||
import { LocalQuiz } from "@/features/local/quizzes/models/localQuiz";
|
||||
import { quizMarkdownUtils } from "@/features/local/quizzes/models/utils/quizMarkdownUtils";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import publicProcedure from "../../../services/serverFunctions/procedures/public";
|
||||
import publicProcedure from "../../../services/serverFunctions/publicProcedure";
|
||||
import { z } from "zod";
|
||||
import { router } from "../../../services/serverFunctions/trpcSetup";
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
import { fileStorageService } from "@/features/local/utils/fileStorageService";
|
||||
import { zodLocalQuiz } from "@/features/local/quizzes/models/localQuiz";
|
||||
|
||||
export const quizRouter = router({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import z from "zod";
|
||||
import publicProcedure from "../procedures/public";
|
||||
import { router } from "../trpcSetup";
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
import publicProcedure from "../../../services/serverFunctions/publicProcedure";
|
||||
import { router } from "../../../services/serverFunctions/trpcSetup";
|
||||
import { fileStorageService } from "@/features/local/utils/fileStorageService";
|
||||
|
||||
export const directoriesRouter = router({
|
||||
getEmptyDirectories: publicProcedure.query(async () => {
|
||||
@@ -1,11 +1,14 @@
|
||||
import { promises as fs } from "fs";
|
||||
import path from "path";
|
||||
import { basePath, directoryOrFileExists } from "./utils/fileSystemUtils";
|
||||
import { quizFileStorageService } from "../../features/local/quizzes/quizFileStorageService";
|
||||
import { pageFileStorageService } from "../../features/local/pages/pageFileStorageService";
|
||||
import { moduleFileStorageService } from "../../features/local/modules/moduleFileStorageService";
|
||||
import { settingsFileStorageService } from "../../features/local/course/settingsFileStorageService";
|
||||
import { getCoursePathByName } from "./globalSettingsFileStorageService";
|
||||
import {
|
||||
basePath,
|
||||
directoryOrFileExists,
|
||||
} from "../../../services/fileStorage/utils/fileSystemUtils";
|
||||
import { quizFileStorageService } from "../quizzes/quizFileStorageService";
|
||||
import { pageFileStorageService } from "../pages/pageFileStorageService";
|
||||
import { moduleFileStorageService } from "../modules/moduleFileStorageService";
|
||||
import { settingsFileStorageService } from "../course/settingsFileStorageService";
|
||||
import { getCoursePathByName } from "../globalSettings/globalSettingsFileStorageService";
|
||||
import { assignmentsFileStorageService } from "@/features/local/assignments/assignmentsFileStorageService";
|
||||
|
||||
export const fileStorageService = {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Lecture } from "../../../features/local/lectures/lectureModel";
|
||||
import { Lecture } from "../lectures/lectureModel";
|
||||
import { getDateOnlyMarkdownString } from "./timeUtils";
|
||||
|
||||
export function getLectureForDay(
|
||||
@@ -1,8 +1,8 @@
|
||||
import { LocalCoursePage } from "@/features/local/pages/localCoursePageModels";
|
||||
import { LocalAssignment } from "../../../features/local/assignments/models/localAssignment";
|
||||
import { Lecture } from "../../../features/local/lectures/lectureModel";
|
||||
import { dateToMarkdownString, getDateFromStringOrThrow } from "./timeUtils";
|
||||
import { LocalAssignment } from "../assignments/models/localAssignment";
|
||||
import { Lecture } from "../lectures/lectureModel";
|
||||
import { LocalQuiz } from "@/features/local/quizzes/models/localQuiz";
|
||||
import { getDateFromStringOrThrow, dateToMarkdownString } from "./timeUtils";
|
||||
|
||||
export const prepAssignmentForNewSemester = (
|
||||
assignment: LocalAssignment,
|
||||
@@ -1,9 +1,6 @@
|
||||
import { GlobalSettings } from "@/features/local/globalSettings/globalSettingsModels";
|
||||
import { globalSettingsToYaml, parseGlobalSettingsYaml } from "@/features/local/globalSettings/globalSettingsUtils";
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { GlobalSettings } from "../globalSettings";
|
||||
import {
|
||||
globalSettingsToYaml,
|
||||
parseGlobalSettingsYaml,
|
||||
} from "../globalSettingsUtils";
|
||||
|
||||
describe("GlobalSettingsMarkdownTests", () => {
|
||||
it("can parse global settings", () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { parseHolidays } from "../utils/settingsUtils";
|
||||
import { parseHolidays } from "../../../features/local/utils/settingsUtils";
|
||||
|
||||
describe("can parse holiday string", () => {
|
||||
it("can parse empty list", () => {
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
prepLectureForNewSemester,
|
||||
prepPageForNewSemester,
|
||||
prepQuizForNewSemester,
|
||||
} from "../utils/semesterTransferUtils";
|
||||
} from "../../../features/local/utils/semesterTransferUtils";
|
||||
import { Lecture } from "../../../features/local/lectures/lectureModel";
|
||||
import { LocalCoursePage } from "@/features/local/pages/localCoursePageModels";
|
||||
import { LocalQuiz } from "@/features/local/quizzes/models/localQuiz";
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { dateToMarkdownString, getDateFromString } from "../utils/timeUtils";
|
||||
import {
|
||||
dateToMarkdownString,
|
||||
getDateFromString,
|
||||
} from "../../../features/local/utils/timeUtils";
|
||||
|
||||
describe("Can properly handle expected date formats", () => {
|
||||
it("can use AM/PM dates", () => {
|
||||
@@ -48,25 +51,24 @@ describe("Can properly handle expected date formats", () => {
|
||||
const dateString = "08/27/2024 23:59:00";
|
||||
const dateObject = getDateFromString(dateString);
|
||||
|
||||
expect(dateObject).not.toBeUndefined()
|
||||
const updatedString = dateToMarkdownString(dateObject!)
|
||||
expect(updatedString).toBe(dateString)
|
||||
expect(dateObject).not.toBeUndefined();
|
||||
const updatedString = dateToMarkdownString(dateObject!);
|
||||
expect(updatedString).toBe(dateString);
|
||||
});
|
||||
it("can handle canvas time format", () => {
|
||||
const dateString = "8/29/2024, 5:00:00 PM";
|
||||
const dateObject = getDateFromString(dateString);
|
||||
|
||||
expect(dateObject).not.toBeUndefined()
|
||||
const updatedString = dateToMarkdownString(dateObject!)
|
||||
expect(updatedString).toBe("08/29/2024 17:00:00")
|
||||
|
||||
})
|
||||
expect(dateObject).not.toBeUndefined();
|
||||
const updatedString = dateToMarkdownString(dateObject!);
|
||||
expect(updatedString).toBe("08/29/2024 17:00:00");
|
||||
});
|
||||
it("can handle date without time", () => {
|
||||
const dateString = "8/29/2024";
|
||||
const dateObject = getDateFromString(dateString);
|
||||
|
||||
expect(dateObject).not.toBeUndefined()
|
||||
const updatedString = dateToMarkdownString(dateObject!)
|
||||
expect(updatedString).toBe("08/29/2024 00:00:00")
|
||||
})
|
||||
expect(dateObject).not.toBeUndefined();
|
||||
const updatedString = dateToMarkdownString(dateObject!);
|
||||
expect(updatedString).toBe("08/29/2024 00:00:00");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@ import { axiosClient } from "../axiosUtils";
|
||||
import { markdownToHTMLSafe } from "../htmlMarkdownUtils";
|
||||
import { CanvasRubricCreationResponse } from "@/models/canvas/assignments/canvasRubricCreationResponse";
|
||||
import { assignmentPoints } from "@/features/local/assignments/models/utils/assignmentPointsUtils";
|
||||
import { getDateFromString } from "@/models/local/utils/timeUtils";
|
||||
import { getDateFromString } from "@/features/local/utils/timeUtils";
|
||||
import { getRubricCriterion } from "./canvasRubricUtils";
|
||||
import { LocalCourseSettings } from "@/features/local/course/localCourseSettings";
|
||||
|
||||
|
||||
@@ -2,12 +2,15 @@ import { CanvasQuiz } from "@/models/canvas/quizzes/canvasQuizModel";
|
||||
import { axiosClient } from "../axiosUtils";
|
||||
import { canvasApi, paginatedRequest } from "./canvasServiceUtils";
|
||||
import { markdownToHTMLSafe } from "../htmlMarkdownUtils";
|
||||
import { getDateFromStringOrThrow } from "@/models/local/utils/timeUtils";
|
||||
import { getDateFromStringOrThrow } from "@/features/local/utils/timeUtils";
|
||||
import { canvasAssignmentService } from "./canvasAssignmentService";
|
||||
import { CanvasQuizQuestion } from "@/models/canvas/quizzes/canvasQuizQuestionModel";
|
||||
import { escapeMatchingText } from "../utils/questionHtmlUtils";
|
||||
import { LocalQuiz } from "@/features/local/quizzes/models/localQuiz";
|
||||
import { LocalQuizQuestion, QuestionType } from "@/features/local/quizzes/models/localQuizQuestion";
|
||||
import {
|
||||
LocalQuizQuestion,
|
||||
QuestionType,
|
||||
} from "@/features/local/quizzes/models/localQuizQuestion";
|
||||
import { LocalCourseSettings } from "@/features/local/course/localCourseSettings";
|
||||
|
||||
export const getAnswers = (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { promises as fs } from "fs";
|
||||
import { getGlobalSettings } from "../globalSettingsFileStorageService";
|
||||
import { getGlobalSettings } from "../../../features/local/globalSettings/globalSettingsFileStorageService";
|
||||
|
||||
export const directoryOrFileExists = async (
|
||||
directoryPath: string
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { getWeekNumber } from "@/app/course/[courseName]/calendar/calendarMonthUtils";
|
||||
import { extractLabelValue } from "@/features/local/assignments/models/utils/markdownUtils";
|
||||
import { Lecture } from "@/features/local/lectures/lectureModel";
|
||||
import { getDateFromStringOrThrow } from "@/models/local/utils/timeUtils";
|
||||
import { getDateFromStringOrThrow } from "@/features/local/utils/timeUtils";
|
||||
|
||||
export function parseLecture(fileContent: string): Lecture {
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { procedure } from "../trpcSetup";
|
||||
import { procedure } from "./trpcSetup";
|
||||
|
||||
const publicProcedure = procedure;
|
||||
|
||||
@@ -2,12 +2,12 @@ import { createTrpcContext } from "../context";
|
||||
import { createCallerFactory, router } from "../trpcSetup";
|
||||
import { assignmentRouter } from "../../../features/local/assignments/assignmentRouter";
|
||||
import { canvasFileRouter } from "./canvasFileRouter";
|
||||
import { directoriesRouter } from "./directoriesRouter";
|
||||
import { globalSettingsRouter } from "./globalSettingsRouter";
|
||||
import { directoriesRouter } from "../../../features/local/utils/directoriesRouter";
|
||||
import { globalSettingsRouter } from "../../../features/local/globalSettings/globalSettingsRouter";
|
||||
import { lectureRouter } from "../../../features/local/lectures/lectureRouter";
|
||||
import { pageRouter } from "../../../features/local/pages/pageRouter";
|
||||
import { quizRouter } from "../../../features/local/quizzes/quizRouter";
|
||||
import { settingsRouter } from "./settingsRouter";
|
||||
import { settingsRouter } from "../../../features/local/course/settingsRouter";
|
||||
import { moduleRouter } from "@/features/local/modules/moduleRouter";
|
||||
|
||||
export const trpcAppRouter = router({
|
||||
@@ -1,4 +1,4 @@
|
||||
import publicProcedure from "../procedures/public";
|
||||
import publicProcedure from "../publicProcedure";
|
||||
import { z } from "zod";
|
||||
import { router } from "../trpcSetup";
|
||||
import {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { createTRPCReact } from "@trpc/react-query";
|
||||
import { createTRPCContext } from '@trpc/tanstack-react-query';
|
||||
import { AppRouter } from "./router/app";
|
||||
import { createTRPCContext } from "@trpc/tanstack-react-query";
|
||||
import { AppRouter } from "./router/appRouter";
|
||||
|
||||
export const trpc = createTRPCReact<AppRouter>();
|
||||
|
||||
export const { TRPCProvider, useTRPC, useTRPCClient } = createTRPCContext<AppRouter>();
|
||||
export const { TRPCProvider, useTRPC, useTRPCClient } =
|
||||
createTRPCContext<AppRouter>();
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { describe, it, expect, beforeEach } from "vitest";
|
||||
import { promises as fs } from "fs";
|
||||
import { fileStorageService } from "../fileStorage/fileStorageService";
|
||||
import { LocalCourseSettings, DayOfWeek } from "@/features/local/course/localCourseSettings";
|
||||
import { fileStorageService } from "../../features/local/utils/fileStorageService";
|
||||
import {
|
||||
LocalCourseSettings,
|
||||
DayOfWeek,
|
||||
} from "@/features/local/course/localCourseSettings";
|
||||
|
||||
describe("FileStorageTests", () => {
|
||||
beforeEach(async () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, beforeEach } from "vitest";
|
||||
import { promises as fs } from "fs";
|
||||
import { fileStorageService } from "../fileStorage/fileStorageService";
|
||||
import { fileStorageService } from "../../features/local/utils/fileStorageService";
|
||||
import { basePath } from "../fileStorage/utils/fileSystemUtils";
|
||||
|
||||
describe("FileStorageTests", () => {
|
||||
|
||||
Reference in New Issue
Block a user