From 6c5068879a31e23a7e5a0f0c936fd1a7c6dab5a7 Mon Sep 17 00:00:00 2001 From: Alex Mickelson Date: Tue, 27 Aug 2024 22:09:31 -0600 Subject: [PATCH] expanding modules, items displaying --- .../[courseName]/modules/ExpandableModule.tsx | 87 ++++++++++++------- nextjs/src/app/course/[courseName]/page.tsx | 2 +- .../local/assignmnet/localAssignment.ts | 3 +- nextjs/src/models/local/quiz/localQuiz.ts | 3 +- nextjs/tailwind.config.ts | 2 + 5 files changed, 63 insertions(+), 34 deletions(-) diff --git a/nextjs/src/app/course/[courseName]/modules/ExpandableModule.tsx b/nextjs/src/app/course/[courseName]/modules/ExpandableModule.tsx index b7d5f13..2d748a8 100644 --- a/nextjs/src/app/course/[courseName]/modules/ExpandableModule.tsx +++ b/nextjs/src/app/course/[courseName]/modules/ExpandableModule.tsx @@ -1,37 +1,62 @@ +import { IModuleItem } from "@/models/local/IModuleItem"; import { LocalModule } from "@/models/local/localModules"; -import React from "react"; +import { getDateFromStringOrThrow } from "@/models/local/timeUtils"; +import React, { useState } from "react"; export default function ExpandableModule({ module }: { module: LocalModule }) { + const [expanded, setExpanded] = useState(false); + + const moduleItems: { + type: "assignment" | "quiz" | "page"; + item: IModuleItem; + }[] = module.assignments + .map( + ( + a + ): { + type: "assignment" | "quiz" | "page"; + item: IModuleItem; + } => ({ + type: "assignment", + item: a, + }) + ) + .concat(module.quizzes.map((q) => ({ type: "quiz", item: q }))) + .concat(module.pages.map((p) => ({ type: "page", item: p }))) + .sort( + (a, b) => + getDateFromStringOrThrow( + a.item.dueAt, + "item due date in expandable module" + ).getTime() - + getDateFromStringOrThrow( + b.item.dueAt, + "item due date in expandable module" + ).getTime() + ); + return ( - <> -
- -
- +
+
setExpanded((e) => !e)} + > + {module.name} +
+
+
+ {moduleItems.map(({ type, item }) => ( +
{item.name}
+ ))} +
+
); } diff --git a/nextjs/src/app/course/[courseName]/page.tsx b/nextjs/src/app/course/[courseName]/page.tsx index b15df8b..1e023a9 100644 --- a/nextjs/src/app/course/[courseName]/page.tsx +++ b/nextjs/src/app/course/[courseName]/page.tsx @@ -20,7 +20,7 @@ export default async function CoursePage({
-
+
diff --git a/nextjs/src/models/local/assignmnet/localAssignment.ts b/nextjs/src/models/local/assignmnet/localAssignment.ts index a1c02c5..9beeea1 100644 --- a/nextjs/src/models/local/assignmnet/localAssignment.ts +++ b/nextjs/src/models/local/assignmnet/localAssignment.ts @@ -1,9 +1,10 @@ +import { IModuleItem } from "../IModuleItem"; import { AssignmentSubmissionType } from "./assignmentSubmissionType"; import { RubricItem } from "./rubricItem"; import { assignmentMarkdownParser } from "./utils/assignmentMarkdownParser"; import { assignmentMarkdownSerializer } from "./utils/assignmentMarkdownSerializer"; -export interface LocalAssignment { +export interface LocalAssignment extends IModuleItem { name: string; description: string; lockAt?: string; // 08/21/2023 23:59:00 diff --git a/nextjs/src/models/local/quiz/localQuiz.ts b/nextjs/src/models/local/quiz/localQuiz.ts index 192c462..70fd667 100644 --- a/nextjs/src/models/local/quiz/localQuiz.ts +++ b/nextjs/src/models/local/quiz/localQuiz.ts @@ -1,7 +1,8 @@ +import { IModuleItem } from "../IModuleItem"; import { LocalQuizQuestion } from "./localQuizQuestion"; import { quizMarkdownUtils } from "./utils/quizMarkdownUtils"; -export interface LocalQuiz { +export interface LocalQuiz extends IModuleItem { name: string; description: string; password?: string; diff --git a/nextjs/tailwind.config.ts b/nextjs/tailwind.config.ts index 68eeab8..eae1ca7 100644 --- a/nextjs/tailwind.config.ts +++ b/nextjs/tailwind.config.ts @@ -12,6 +12,8 @@ const config: Config = { ...borderRadius, xl: "24px", }, + extend: { + } }, plugins: [], };