mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
better lecture ui
This commit is contained in:
@@ -3,6 +3,7 @@ import path from "path";
|
||||
import { basePath } from "./utils/fileSystemUtils";
|
||||
import fs from "fs/promises";
|
||||
import {
|
||||
getLectureWeekName,
|
||||
lectureFolderName,
|
||||
lectureToString,
|
||||
parseLecture,
|
||||
@@ -51,19 +52,12 @@ export async function updateLecture(
|
||||
lecture: Lecture
|
||||
) {
|
||||
const courseLectureRoot = path.join(basePath, courseName, lectureFolderName);
|
||||
const startDate = getDateFromStringOrThrow(
|
||||
courseSettings.startDate,
|
||||
"semester start date in update lecture"
|
||||
);
|
||||
const lectureDate = getDateFromStringOrThrow(
|
||||
lecture.date,
|
||||
"lecture start date in update lecture"
|
||||
);
|
||||
const weekNumber = getWeekNumber(startDate, lectureDate)
|
||||
.toString()
|
||||
.padStart(2, "0");
|
||||
|
||||
const weekFolderName = `week-${weekNumber}`;
|
||||
const weekFolderName = getLectureWeekName(courseSettings.startDate, lecture.date);
|
||||
const weekPath = path.join(courseLectureRoot, weekFolderName);
|
||||
if (!(await directoryExists(weekPath))) {
|
||||
await fs.mkdir(weekPath, { recursive: true });
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { getWeekNumber } from "@/app/course/[courseName]/calendar/calendarMonthUtils";
|
||||
import { extractLabelValue } from "@/models/local/assignment/utils/markdownUtils";
|
||||
import { Lecture } from "@/models/local/lecture";
|
||||
import { getDateFromStringOrThrow } from "@/models/local/timeUtils";
|
||||
|
||||
export function parseLecture(fileContent: string): Lecture {
|
||||
try {
|
||||
@@ -27,4 +29,21 @@ Date: ${lecture.date}
|
||||
${lecture.content}`;
|
||||
}
|
||||
|
||||
export const lectureFolderName = "00 - lectures"
|
||||
export const lectureFolderName = "00 - lectures";
|
||||
|
||||
export function getLectureWeekName(semesterStart: string, lectureDate: string) {
|
||||
const startDate = getDateFromStringOrThrow(
|
||||
semesterStart,
|
||||
"semester start date in update lecture"
|
||||
);
|
||||
const targetDate = getDateFromStringOrThrow(
|
||||
lectureDate,
|
||||
"lecture start date in update lecture"
|
||||
);
|
||||
const weekNumber = getWeekNumber(startDate, targetDate)
|
||||
.toString()
|
||||
.padStart(2, "0");
|
||||
|
||||
const weekName = `week-${weekNumber}`;
|
||||
return weekName;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ export function getLectureUrl(courseName: string, lectureDate: string) {
|
||||
encodeURIComponent(lectureDate)
|
||||
);
|
||||
}
|
||||
export function getLecturePreviewUrl(courseName: string, lectureDate: string) {
|
||||
return getLectureUrl(courseName, lectureDate) + "/preview";
|
||||
}
|
||||
|
||||
export function getCourseUrl(courseName: string) {
|
||||
return "/course/" + encodeURIComponent(courseName);
|
||||
|
||||
Reference in New Issue
Block a user