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