mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
starting to resurect tests
This commit is contained in:
@@ -4,10 +4,7 @@ import {
|
||||
LocalCourseSettings,
|
||||
localCourseYamlUtils,
|
||||
} from "@/models/local/localCourse";
|
||||
import {
|
||||
directoryOrFileExists,
|
||||
hasFileSystemEntries,
|
||||
} from "./utils/fileSystemUtils";
|
||||
import { directoryOrFileExists } from "./utils/fileSystemUtils";
|
||||
import {
|
||||
LocalAssignment,
|
||||
localAssignmentMarkdown,
|
||||
@@ -53,6 +50,15 @@ export const fileStorageService = {
|
||||
return courseNamesFromDirectories;
|
||||
},
|
||||
|
||||
async getAllCoursesSettings() {
|
||||
const courses = await fileStorageService.getCourseNames();
|
||||
|
||||
const settings = await Promise.all(
|
||||
courses.map(async (c) => await fileStorageService.getCourseSettings(c))
|
||||
);
|
||||
return settings;
|
||||
},
|
||||
|
||||
async getCourseSettings(courseName: string): Promise<LocalCourseSettings> {
|
||||
const courseDirectory = path.join(basePath, courseName);
|
||||
const settingsPath = path.join(courseDirectory, "settings.yml");
|
||||
@@ -97,6 +103,11 @@ export const fileStorageService = {
|
||||
const modules = await Promise.all(modulePromises);
|
||||
return modules.sort((a, b) => a.localeCompare(b));
|
||||
},
|
||||
async createModule(courseName: string, moduleName: string) {
|
||||
const courseDirectory = path.join(basePath, courseName);
|
||||
|
||||
await fs.mkdir(courseDirectory + "/" + moduleName, { recursive: true });
|
||||
},
|
||||
|
||||
async getAssignmentNames(courseName: string, moduleName: string) {
|
||||
const filePath = path.join(basePath, courseName, moduleName, "assignments");
|
||||
@@ -263,7 +274,6 @@ export const fileStorageService = {
|
||||
}
|
||||
|
||||
const directories = await fs.readdir(basePath, { withFileTypes: true });
|
||||
console.log(directories);
|
||||
const emptyDirectories = (
|
||||
await Promise.all(
|
||||
directories
|
||||
@@ -282,4 +292,10 @@ export const fileStorageService = {
|
||||
|
||||
return emptyDirectories;
|
||||
},
|
||||
|
||||
async createCourseFolderForTesting(courseName: string) {
|
||||
const courseDirectory = path.join(basePath, courseName);
|
||||
|
||||
await fs.mkdir(courseDirectory, { recursive: true });
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,293 +1,252 @@
|
||||
// import path from "path";
|
||||
// import { describe, it, expect, beforeEach } from "vitest";
|
||||
// import fs from "fs";
|
||||
// import { DayOfWeek, LocalCourse } from "@/models/local/localCourse";
|
||||
// import { AssignmentSubmissionType } from "@/models/local/assignmnet/assignmentSubmissionType";
|
||||
// import { QuestionType } from "@/models/local/quiz/localQuizQuestion";
|
||||
// import { fileStorageService } from "../fileStorage/fileStorageService";
|
||||
import path from "path";
|
||||
import { describe, it, expect, beforeEach } from "vitest";
|
||||
import fs from "fs";
|
||||
import {
|
||||
DayOfWeek,
|
||||
LocalCourse,
|
||||
LocalCourseSettings,
|
||||
} from "@/models/local/localCourse";
|
||||
import { QuestionType } from "@/models/local/quiz/localQuizQuestion";
|
||||
import { fileStorageService } from "../fileStorage/fileStorageService";
|
||||
|
||||
// describe("FileStorageTests", () => {
|
||||
// beforeEach(() => {
|
||||
// const storageDirectory = process.env.STORAGE_DIRECTORY ?? "/tmp/canvasManagerTests";
|
||||
// if (fs.existsSync(storageDirectory)) {
|
||||
// fs.rmdirSync(storageDirectory, { recursive: true });
|
||||
// }
|
||||
// fs.mkdirSync(storageDirectory, { recursive: true });
|
||||
// });
|
||||
describe("FileStorageTests", () => {
|
||||
beforeEach(() => {
|
||||
const storageDirectory =
|
||||
process.env.STORAGE_DIRECTORY ?? "/tmp/canvasManagerTests";
|
||||
if (fs.existsSync(storageDirectory)) {
|
||||
fs.rmdirSync(storageDirectory, { recursive: true });
|
||||
}
|
||||
fs.mkdirSync(storageDirectory, { recursive: true });
|
||||
});
|
||||
|
||||
// it("empty course can be saved and loaded", async () => {
|
||||
// const testCourse: LocalCourse = {
|
||||
// settings: {
|
||||
// name: "test empty course",
|
||||
// assignmentGroups: [],
|
||||
// daysOfWeek: [],
|
||||
// startDate: "07/09/2024 23:59:00",
|
||||
// endDate: "07/09/2024 23:59:00",
|
||||
// defaultDueTime: { hour: 1, minute: 59 },
|
||||
// },
|
||||
// modules: [],
|
||||
// };
|
||||
it("course settings can be saved and loaded", async () => {
|
||||
const name = "test empty course";
|
||||
await fileStorageService.createCourseFolderForTesting(name);
|
||||
const settings: LocalCourseSettings = {
|
||||
name,
|
||||
assignmentGroups: [],
|
||||
daysOfWeek: [DayOfWeek.Monday, DayOfWeek.Wednesday],
|
||||
startDate: "07/09/2024 23:59:00",
|
||||
endDate: "07/09/2024 23:59:00",
|
||||
defaultDueTime: { hour: 1, minute: 59 },
|
||||
canvasId: 0,
|
||||
};
|
||||
|
||||
// await fileStorageService.saveCourseAsync(testCourse);
|
||||
await fileStorageService.updateCourseSettings(name, settings);
|
||||
|
||||
// const loadedCourses = await fileStorageService.loadSavedCourses();
|
||||
// const loadedCourse = loadedCourses.find(
|
||||
// (c) => c.settings.name === testCourse.settings.name
|
||||
// );
|
||||
const loadedSettings = await fileStorageService.getCourseSettings(name);
|
||||
|
||||
// expect(loadedCourse).toEqual(testCourse);
|
||||
// });
|
||||
expect(loadedSettings).toEqual(settings);
|
||||
});
|
||||
|
||||
// it("course settings can be saved and loaded", async () => {
|
||||
// const testCourse: LocalCourse = {
|
||||
// settings: {
|
||||
// assignmentGroups: [],
|
||||
// name: "Test Course with settings",
|
||||
// daysOfWeek: [DayOfWeek.Monday, DayOfWeek.Wednesday],
|
||||
// startDate: "07/09/2024 23:59:00",
|
||||
// endDate: "07/09/2024 23:59:00",
|
||||
// defaultDueTime: { hour: 1, minute: 59 },
|
||||
// },
|
||||
// modules: [],
|
||||
// };
|
||||
it("empty course modules can be created", async () => {
|
||||
const courseName = "test empty course";
|
||||
const moduleName = "test module 1";
|
||||
|
||||
// await fileStorageService.saveCourseAsync(testCourse);
|
||||
await fileStorageService.createModule(courseName, moduleName);
|
||||
|
||||
// const loadedCourses = await fileStorageService.loadSavedCourses();
|
||||
// const loadedCourse = loadedCourses.find(
|
||||
// (c) => c.settings.name === testCourse.settings.name
|
||||
// );
|
||||
const moduleNames = await fileStorageService.getModuleNames(courseName);
|
||||
|
||||
// expect(loadedCourse?.settings).toEqual(testCourse.settings);
|
||||
// });
|
||||
expect(moduleNames).toContain(moduleName);
|
||||
});
|
||||
|
||||
// it("empty course modules can be saved and loaded", async () => {
|
||||
// const testCourse: LocalCourse = {
|
||||
// settings: {
|
||||
// name: "Test Course with modules",
|
||||
// assignmentGroups: [],
|
||||
// daysOfWeek: [],
|
||||
// startDate: "07/09/2024 23:59:00",
|
||||
// endDate: "07/09/2024 23:59:00",
|
||||
// defaultDueTime: { hour: 1, minute: 59 },
|
||||
// },
|
||||
// modules: [
|
||||
// {
|
||||
// name: "test module 1",
|
||||
// assignments: [],
|
||||
// quizzes: [],
|
||||
// pages: [],
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
// it("course modules with assignments can be saved and loaded", async () => {
|
||||
// const testCourse: LocalCourse = {
|
||||
// settings: {
|
||||
// name: "Test Course with modules and assignments",
|
||||
// assignmentGroups: [],
|
||||
// daysOfWeek: [],
|
||||
// startDate: "07/09/2024 23:59:00",
|
||||
// endDate: "07/09/2024 23:59:00",
|
||||
// defaultDueTime: { hour: 1, minute: 59 },
|
||||
// },
|
||||
// modules: [
|
||||
// {
|
||||
// name: "test module 1 with assignments",
|
||||
// assignments: [
|
||||
// {
|
||||
// name: "test assignment",
|
||||
// description: "here is the description",
|
||||
// dueAt: "07/09/2024 23:59:00",
|
||||
// lockAt: "07/09/2024 23:59:00",
|
||||
// submissionTypes: [AssignmentSubmissionType.ONLINE_UPLOAD],
|
||||
// localAssignmentGroupName: "Final Project",
|
||||
// rubric: [
|
||||
// { points: 4, label: "do task 1" },
|
||||
// { points: 2, label: "do task 2" },
|
||||
// ],
|
||||
// allowedFileUploadExtensions: [],
|
||||
// },
|
||||
// ],
|
||||
// quizzes: [],
|
||||
// pages: [],
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
|
||||
// await fileStorageService.saveCourseAsync(testCourse);
|
||||
// await fileStorageService.saveCourseAsync(testCourse);
|
||||
|
||||
// const loadedCourses = await fileStorageService.loadSavedCourses();
|
||||
// const loadedCourse = loadedCourses.find(
|
||||
// (c) => c.settings.name === testCourse.settings.name
|
||||
// );
|
||||
// const loadedCourses = await fileStorageService.loadSavedCourses();
|
||||
// const loadedCourse = loadedCourses.find(
|
||||
// (c) => c.settings.name === testCourse.settings.name
|
||||
// );
|
||||
|
||||
// expect(loadedCourse?.modules).toEqual(testCourse.modules);
|
||||
// });
|
||||
// expect(loadedCourse?.modules[0].assignments).toEqual(
|
||||
// testCourse.modules[0].assignments
|
||||
// );
|
||||
// });
|
||||
|
||||
// it("course modules with assignments can be saved and loaded", async () => {
|
||||
// const testCourse: LocalCourse = {
|
||||
// settings: {
|
||||
// name: "Test Course with modules and assignments",
|
||||
// assignmentGroups: [],
|
||||
// daysOfWeek: [],
|
||||
// startDate: "07/09/2024 23:59:00",
|
||||
// endDate: "07/09/2024 23:59:00",
|
||||
// defaultDueTime: { hour: 1, minute: 59 },
|
||||
// },
|
||||
// modules: [
|
||||
// {
|
||||
// name: "test module 1 with assignments",
|
||||
// assignments: [
|
||||
// {
|
||||
// name: "test assignment",
|
||||
// description: "here is the description",
|
||||
// dueAt: "07/09/2024 23:59:00",
|
||||
// lockAt: "07/09/2024 23:59:00",
|
||||
// submissionTypes: [AssignmentSubmissionType.ONLINE_UPLOAD],
|
||||
// localAssignmentGroupName: "Final Project",
|
||||
// rubric: [
|
||||
// { points: 4, label: "do task 1" },
|
||||
// { points: 2, label: "do task 2" },
|
||||
// ],
|
||||
// allowedFileUploadExtensions: [],
|
||||
// },
|
||||
// ],
|
||||
// quizzes: [],
|
||||
// pages: [],
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
// it("course modules with quizzes can be saved and loaded", async () => {
|
||||
// const testCourse: LocalCourse = {
|
||||
// settings: {
|
||||
// name: "Test Course with modules and quiz",
|
||||
// assignmentGroups: [],
|
||||
// daysOfWeek: [],
|
||||
// startDate: "07/09/2024 23:59:00",
|
||||
// endDate: "07/09/2024 23:59:00",
|
||||
// defaultDueTime: { hour: 1, minute: 59 },
|
||||
// },
|
||||
// modules: [
|
||||
// {
|
||||
// name: "test module 1 with quiz",
|
||||
// assignments: [],
|
||||
// quizzes: [
|
||||
// {
|
||||
// name: "Test Quiz",
|
||||
// description: "quiz description",
|
||||
// lockAt: "07/09/2024 12:05:00",
|
||||
// dueAt: "07/09/2024 12:05:00",
|
||||
// shuffleAnswers: true,
|
||||
// oneQuestionAtATime: true,
|
||||
// localAssignmentGroupName: "Assignments",
|
||||
// questions: [
|
||||
// {
|
||||
// text: "test essay",
|
||||
// questionType: QuestionType.ESSAY,
|
||||
// points: 1,
|
||||
// answers: [],
|
||||
// matchDistractors: [],
|
||||
// },
|
||||
// ],
|
||||
// showCorrectAnswers: false,
|
||||
// allowedAttempts: 0,
|
||||
// },
|
||||
// ],
|
||||
// pages: [],
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
|
||||
// await fileStorageService.saveCourseAsync(testCourse);
|
||||
// await fileStorageService.saveCourseAsync(testCourse);
|
||||
|
||||
// const loadedCourses = await fileStorageService.loadSavedCourses();
|
||||
// const loadedCourse = loadedCourses.find(
|
||||
// (c) => c.settings.name === testCourse.settings.name
|
||||
// );
|
||||
// const loadedCourses = await fileStorageService.loadSavedCourses();
|
||||
// const loadedCourse = loadedCourses.find(
|
||||
// (c) => c.settings.name === testCourse.settings.name
|
||||
// );
|
||||
|
||||
// expect(loadedCourse?.modules[0].assignments).toEqual(
|
||||
// testCourse.modules[0].assignments
|
||||
// );
|
||||
// });
|
||||
// expect(loadedCourse?.modules[0].quizzes).toEqual(
|
||||
// testCourse.modules[0].quizzes
|
||||
// );
|
||||
// });
|
||||
|
||||
// it("course modules with quizzes can be saved and loaded", async () => {
|
||||
// const testCourse: LocalCourse = {
|
||||
// settings: {
|
||||
// name: "Test Course with modules and quiz",
|
||||
// assignmentGroups: [],
|
||||
// daysOfWeek: [],
|
||||
// startDate: "07/09/2024 23:59:00",
|
||||
// endDate: "07/09/2024 23:59:00",
|
||||
// defaultDueTime: { hour: 1, minute: 59 },
|
||||
// },
|
||||
// modules: [
|
||||
// {
|
||||
// name: "test module 1 with quiz",
|
||||
// assignments: [],
|
||||
// quizzes: [
|
||||
// {
|
||||
// name: "Test Quiz",
|
||||
// description: "quiz description",
|
||||
// lockAt: "07/09/2024 12:05:00",
|
||||
// dueAt: "07/09/2024 12:05:00",
|
||||
// shuffleAnswers: true,
|
||||
// oneQuestionAtATime: true,
|
||||
// localAssignmentGroupName: "Assignments",
|
||||
// questions: [
|
||||
// {
|
||||
// text: "test essay",
|
||||
// questionType: QuestionType.ESSAY,
|
||||
// points: 1,
|
||||
// answers: [],
|
||||
// matchDistractors: [],
|
||||
// },
|
||||
// ],
|
||||
// showCorrectAnswers: false,
|
||||
// allowedAttempts: 0,
|
||||
// },
|
||||
// ],
|
||||
// pages: [],
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
// it("markdown storage fully populated does not lose data", async () => {
|
||||
// const testCourse: LocalCourse = {
|
||||
// settings: {
|
||||
// name: "Test Course with lots of data",
|
||||
// assignmentGroups: [],
|
||||
// daysOfWeek: [DayOfWeek.Monday, DayOfWeek.Wednesday],
|
||||
// startDate: "07/09/2024 23:59:00",
|
||||
// endDate: "07/09/2024 23:59:00",
|
||||
// defaultDueTime: { hour: 1, minute: 59 },
|
||||
// },
|
||||
// modules: [
|
||||
// {
|
||||
// name: "new test module",
|
||||
// assignments: [
|
||||
// {
|
||||
// name: "test assignment",
|
||||
// description: "here is the description",
|
||||
// dueAt: "07/09/2024 23:59:00",
|
||||
// lockAt: "07/09/2024 23:59:00",
|
||||
// submissionTypes: [AssignmentSubmissionType.ONLINE_UPLOAD],
|
||||
// localAssignmentGroupName: "Final Project",
|
||||
// rubric: [
|
||||
// { points: 4, label: "do task 1" },
|
||||
// { points: 2, label: "do task 2" },
|
||||
// ],
|
||||
// allowedFileUploadExtensions: [],
|
||||
// },
|
||||
// ],
|
||||
// quizzes: [
|
||||
// {
|
||||
// name: "Test Quiz",
|
||||
// description: "quiz description",
|
||||
// lockAt: "07/09/2024 23:59:00",
|
||||
// dueAt: "07/09/2024 23:59:00",
|
||||
// shuffleAnswers: true,
|
||||
// oneQuestionAtATime: false,
|
||||
// localAssignmentGroupName: "someId",
|
||||
// allowedAttempts: -1,
|
||||
// questions: [
|
||||
// {
|
||||
// text: "test short answer",
|
||||
// questionType: QuestionType.SHORT_ANSWER,
|
||||
// points: 1,
|
||||
// answers: [],
|
||||
// matchDistractors: [],
|
||||
// },
|
||||
// ],
|
||||
// showCorrectAnswers: false,
|
||||
// },
|
||||
// ],
|
||||
// pages: [],
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
|
||||
// await fileStorageService.saveCourseAsync(testCourse);
|
||||
// await fileStorageService.saveCourseAsync(testCourse);
|
||||
|
||||
// const loadedCourses = await fileStorageService.loadSavedCourses();
|
||||
// const loadedCourse = loadedCourses.find(
|
||||
// (c) => c.settings.name === testCourse.settings.name
|
||||
// );
|
||||
// const loadedCourses = await fileStorageService.loadSavedCourses();
|
||||
// const loadedCourse = loadedCourses.find(
|
||||
// (c) => c.settings.name === testCourse.settings.name
|
||||
// );
|
||||
|
||||
// expect(loadedCourse?.modules[0].quizzes).toEqual(
|
||||
// testCourse.modules[0].quizzes
|
||||
// );
|
||||
// });
|
||||
// expect(loadedCourse).toEqual(testCourse);
|
||||
// });
|
||||
|
||||
// it("markdown storage fully populated does not lose data", async () => {
|
||||
// const testCourse: LocalCourse = {
|
||||
// settings: {
|
||||
// name: "Test Course with lots of data",
|
||||
// assignmentGroups: [],
|
||||
// daysOfWeek: [DayOfWeek.Monday, DayOfWeek.Wednesday],
|
||||
// startDate: "07/09/2024 23:59:00",
|
||||
// endDate: "07/09/2024 23:59:00",
|
||||
// defaultDueTime: { hour: 1, minute: 59 },
|
||||
// },
|
||||
// modules: [
|
||||
// {
|
||||
// name: "new test module",
|
||||
// assignments: [
|
||||
// {
|
||||
// name: "test assignment",
|
||||
// description: "here is the description",
|
||||
// dueAt: "07/09/2024 23:59:00",
|
||||
// lockAt: "07/09/2024 23:59:00",
|
||||
// submissionTypes: [AssignmentSubmissionType.ONLINE_UPLOAD],
|
||||
// localAssignmentGroupName: "Final Project",
|
||||
// rubric: [
|
||||
// { points: 4, label: "do task 1" },
|
||||
// { points: 2, label: "do task 2" },
|
||||
// ],
|
||||
// allowedFileUploadExtensions: [],
|
||||
// },
|
||||
// ],
|
||||
// quizzes: [
|
||||
// {
|
||||
// name: "Test Quiz",
|
||||
// description: "quiz description",
|
||||
// lockAt: "07/09/2024 23:59:00",
|
||||
// dueAt: "07/09/2024 23:59:00",
|
||||
// shuffleAnswers: true,
|
||||
// oneQuestionAtATime: false,
|
||||
// localAssignmentGroupName: "someId",
|
||||
// allowedAttempts: -1,
|
||||
// questions: [
|
||||
// {
|
||||
// text: "test short answer",
|
||||
// questionType: QuestionType.SHORT_ANSWER,
|
||||
// points: 1,
|
||||
// answers: [],
|
||||
// matchDistractors: [],
|
||||
// },
|
||||
// ],
|
||||
// showCorrectAnswers: false,
|
||||
// },
|
||||
// ],
|
||||
// pages: [],
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
// it("markdown storage can persist pages", async () => {
|
||||
// const testCourse: LocalCourse = {
|
||||
// settings: {
|
||||
// name: "Test Course with page",
|
||||
// assignmentGroups: [],
|
||||
// daysOfWeek: [DayOfWeek.Monday, DayOfWeek.Wednesday],
|
||||
// startDate: "07/09/2024 23:59:00",
|
||||
// endDate: "07/09/2024 23:59:00",
|
||||
// defaultDueTime: { hour: 1, minute: 59 },
|
||||
// },
|
||||
// modules: [
|
||||
// {
|
||||
// name: "page test module",
|
||||
// assignments: [],
|
||||
// quizzes: [],
|
||||
// pages: [
|
||||
// {
|
||||
// name: "test page persistence",
|
||||
// dueAt: "07/09/2024 23:59:00",
|
||||
// text: "this is some\n## markdown\n",
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
|
||||
// await fileStorageService.saveCourseAsync(testCourse);
|
||||
// await fileStorageService.saveCourseAsync(testCourse);
|
||||
|
||||
// const loadedCourses = await fileStorageService.loadSavedCourses();
|
||||
// const loadedCourse = loadedCourses.find(
|
||||
// (c) => c.settings.name === testCourse.settings.name
|
||||
// );
|
||||
// const loadedCourses = await fileStorageService.loadSavedCourses();
|
||||
// const loadedCourse = loadedCourses.find(
|
||||
// (c) => c.settings.name === testCourse.settings.name
|
||||
// );
|
||||
|
||||
// expect(loadedCourse).toEqual(testCourse);
|
||||
// });
|
||||
|
||||
// it("markdown storage can persist pages", async () => {
|
||||
// const testCourse: LocalCourse = {
|
||||
// settings: {
|
||||
// name: "Test Course with page",
|
||||
// assignmentGroups: [],
|
||||
// daysOfWeek: [DayOfWeek.Monday, DayOfWeek.Wednesday],
|
||||
// startDate: "07/09/2024 23:59:00",
|
||||
// endDate: "07/09/2024 23:59:00",
|
||||
// defaultDueTime: { hour: 1, minute: 59 },
|
||||
// },
|
||||
// modules: [
|
||||
// {
|
||||
// name: "page test module",
|
||||
// assignments: [],
|
||||
// quizzes: [],
|
||||
// pages: [
|
||||
// {
|
||||
// name: "test page persistence",
|
||||
// dueAt: "07/09/2024 23:59:00",
|
||||
// text: "this is some\n## markdown\n",
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
|
||||
// await fileStorageService.saveCourseAsync(testCourse);
|
||||
|
||||
// const loadedCourses = await fileStorageService.loadSavedCourses();
|
||||
// const loadedCourse = loadedCourses.find(
|
||||
// (c) => c.settings.name === testCourse.settings.name
|
||||
// );
|
||||
|
||||
// expect(loadedCourse).toEqual(testCourse);
|
||||
// });
|
||||
// });
|
||||
// expect(loadedCourse).toEqual(testCourse);
|
||||
// });
|
||||
});
|
||||
|
||||
24
nextjs/src/services/urlUtils.ts
Normal file
24
nextjs/src/services/urlUtils.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
export function getModuleItemUrl(
|
||||
courseName: string,
|
||||
moduleName: string,
|
||||
type: "assignment" | "page" | "quiz",
|
||||
itemName: string
|
||||
) {
|
||||
return (
|
||||
"/course/" +
|
||||
encodeURIComponent(courseName) +
|
||||
"/modules/" +
|
||||
encodeURIComponent(moduleName) +
|
||||
`/${type}/` +
|
||||
encodeURIComponent(itemName)
|
||||
);
|
||||
}
|
||||
|
||||
export function getCourseUrl(courseName: string) {
|
||||
return "/course/" + encodeURIComponent(courseName);
|
||||
}
|
||||
|
||||
export function getCourseSettingsUrl(courseName: string) {
|
||||
return "/course/" + encodeURIComponent(courseName) + "/settings";
|
||||
}
|
||||
Reference in New Issue
Block a user