mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 15:18:32 -06:00
when creating assignments, verify the classroom url can be swapped
This commit is contained in:
@@ -17,3 +17,5 @@ courses:
|
||||
name: Old Adv Frontend
|
||||
- path: ./1430/2025-spring-jonathan/Modules/
|
||||
name: Jonathan UX
|
||||
- path: ./1400/2025_spring_alex/modules/
|
||||
name: 1400-spring
|
||||
|
||||
@@ -36,6 +36,7 @@ export const canvasAssignmentService = {
|
||||
{
|
||||
source: "insert_github_classroom_url",
|
||||
destination: localAssignment.githubClassroomAssignmentShareLink || "",
|
||||
strict: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -93,6 +94,7 @@ export const canvasAssignmentService = {
|
||||
source: "insert_github_classroom_url",
|
||||
destination:
|
||||
localAssignment.githubClassroomAssignmentShareLink || "",
|
||||
strict: true,
|
||||
},
|
||||
],
|
||||
}),
|
||||
|
||||
@@ -87,11 +87,25 @@ export function markdownToHTMLSafe({
|
||||
markdownString: string;
|
||||
settings: LocalCourseSettings;
|
||||
convertImages?: boolean;
|
||||
replaceText?: { source: string; destination: string }[];
|
||||
replaceText?: { source: string; destination: string; strict?: boolean }[];
|
||||
}) {
|
||||
const html = markdownToHtmlNoImages(markdownString);
|
||||
const replacedHtml = replaceText.reduce(
|
||||
(acc, { source, destination }) => acc.replaceAll(source, destination),
|
||||
(acc, { source, destination, strict = false }) => {
|
||||
if (strict) {
|
||||
if (typeof destination === "undefined" || destination === null) {
|
||||
throw new Error(
|
||||
`Text replacement failed: destination is undefined for source "${source}"`
|
||||
);
|
||||
}
|
||||
if (destination === "") {
|
||||
throw new Error(
|
||||
`Text replacement failed: destination is empty string for source "${source}"`
|
||||
);
|
||||
}
|
||||
}
|
||||
return acc.replaceAll(source, destination);
|
||||
},
|
||||
html
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user