mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
fix test
This commit is contained in:
@@ -15,3 +15,5 @@ courses:
|
|||||||
name: Telem and Ops
|
name: Telem and Ops
|
||||||
- path: ./4850_AdvancedFE/2024-fall-alex/modules/
|
- path: ./4850_AdvancedFE/2024-fall-alex/modules/
|
||||||
name: Old Adv Frontend
|
name: Old Adv Frontend
|
||||||
|
- path: ./1430/2025-spring-jonathan/Modules/
|
||||||
|
name: Jonathan UX
|
||||||
|
|||||||
@@ -105,7 +105,10 @@ export const getStatus = ({
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const htmlIsSame = htmlIsCloseEnough(
|
const htmlIsSame = htmlIsCloseEnough(
|
||||||
markdownToHTMLSafe(assignment.description, settings),
|
markdownToHTMLSafe({
|
||||||
|
markdownString: assignment.description,
|
||||||
|
settings,
|
||||||
|
}),
|
||||||
canvasAssignment.description
|
canvasAssignment.description
|
||||||
);
|
);
|
||||||
if (!htmlIsSame)
|
if (!htmlIsSame)
|
||||||
|
|||||||
@@ -60,12 +60,6 @@ export default function AssignmentPreview({
|
|||||||
<br />
|
<br />
|
||||||
<section>
|
<section>
|
||||||
<MarkdownDisplay markdown={assignment.description} />
|
<MarkdownDisplay markdown={assignment.description} />
|
||||||
{/* <div
|
|
||||||
className="markdownPreview"
|
|
||||||
dangerouslySetInnerHTML={{
|
|
||||||
__html: htmlPreview,
|
|
||||||
}}
|
|
||||||
></div> */}
|
|
||||||
</section>
|
</section>
|
||||||
<hr />
|
<hr />
|
||||||
<section>
|
<section>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ function DangerousInnerMarkdown({
|
|||||||
<div
|
<div
|
||||||
className={"markdownPreview " + className}
|
className={"markdownPreview " + className}
|
||||||
dangerouslySetInnerHTML={{
|
dangerouslySetInnerHTML={{
|
||||||
__html: markdownToHTMLSafe(markdown, settings),
|
__html: markdownToHTMLSafe({ markdownString: markdown, settings }),
|
||||||
}}
|
}}
|
||||||
></div>
|
></div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { CanvasModuleItem } from "@/features/canvas/models/modules/canvasModuleItems";
|
|
||||||
import { useLocalCourseSettingsQuery } from "@/features/local/course/localCoursesHooks";
|
import { useLocalCourseSettingsQuery } from "@/features/local/course/localCoursesHooks";
|
||||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import { canvasModuleService } from "../services/canvasModuleService";
|
import { canvasModuleService } from "../services/canvasModuleService";
|
||||||
|
|||||||
@@ -29,7 +29,10 @@ export const canvasAssignmentService = {
|
|||||||
) {
|
) {
|
||||||
console.log(`Creating assignment: ${localAssignment.name}`);
|
console.log(`Creating assignment: ${localAssignment.name}`);
|
||||||
const url = `${canvasApi}/courses/${canvasCourseId}/assignments`;
|
const url = `${canvasApi}/courses/${canvasCourseId}/assignments`;
|
||||||
const content = markdownToHTMLSafe(localAssignment.description, settings);
|
const content = markdownToHTMLSafe({
|
||||||
|
markdownString: localAssignment.description,
|
||||||
|
settings,
|
||||||
|
});
|
||||||
|
|
||||||
const contentWithClassroomLinks =
|
const contentWithClassroomLinks =
|
||||||
localAssignment.githubClassroomAssignmentShareLink
|
localAssignment.githubClassroomAssignmentShareLink
|
||||||
@@ -84,7 +87,10 @@ export const canvasAssignmentService = {
|
|||||||
allowed_extensions: localAssignment.allowedFileUploadExtensions.map(
|
allowed_extensions: localAssignment.allowedFileUploadExtensions.map(
|
||||||
(e) => e.toString()
|
(e) => e.toString()
|
||||||
),
|
),
|
||||||
description: markdownToHTMLSafe(localAssignment.description, settings),
|
description: markdownToHTMLSafe({
|
||||||
|
markdownString: localAssignment.description,
|
||||||
|
settings,
|
||||||
|
}),
|
||||||
due_at: getDateFromString(localAssignment.dueAt)?.toISOString(),
|
due_at: getDateFromString(localAssignment.dueAt)?.toISOString(),
|
||||||
lock_at:
|
lock_at:
|
||||||
localAssignment.lockAt &&
|
localAssignment.lockAt &&
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export const canvasPageService = {
|
|||||||
const body = {
|
const body = {
|
||||||
wiki_page: {
|
wiki_page: {
|
||||||
title: page.name,
|
title: page.name,
|
||||||
body: markdownToHTMLSafe(page.text, settings),
|
body: markdownToHTMLSafe({ markdownString: page.text, settings }),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ export const canvasPageService = {
|
|||||||
const body = {
|
const body = {
|
||||||
wiki_page: {
|
wiki_page: {
|
||||||
title: page.name,
|
title: page.name,
|
||||||
body: markdownToHTMLSafe(page.text, settings),
|
body: markdownToHTMLSafe({ markdownString: page.text, settings }),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
await axiosClient.put(url, body);
|
await axiosClient.put(url, body);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export const getAnswers = (
|
|||||||
});
|
});
|
||||||
|
|
||||||
return question.answers.map((answer) => ({
|
return question.answers.map((answer) => ({
|
||||||
answer_html: markdownToHTMLSafe(answer.text, settings),
|
answer_html: markdownToHTMLSafe({ markdownString: answer.text, settings }),
|
||||||
answer_weight: answer.correct ? 100 : 0,
|
answer_weight: answer.correct ? 100 : 0,
|
||||||
answer_text: answer.text,
|
answer_text: answer.text,
|
||||||
}));
|
}));
|
||||||
@@ -53,7 +53,10 @@ const createQuestionOnly = async (
|
|||||||
|
|
||||||
const body = {
|
const body = {
|
||||||
question: {
|
question: {
|
||||||
question_text: markdownToHTMLSafe(question.text, settings),
|
question_text: markdownToHTMLSafe({
|
||||||
|
markdownString: question.text,
|
||||||
|
settings,
|
||||||
|
}),
|
||||||
question_type: getQuestionType(question),
|
question_type: getQuestionType(question),
|
||||||
points_possible: question.points,
|
points_possible: question.points,
|
||||||
position,
|
position,
|
||||||
@@ -175,7 +178,10 @@ export const canvasQuizService = {
|
|||||||
const body = {
|
const body = {
|
||||||
quiz: {
|
quiz: {
|
||||||
title: localQuiz.name,
|
title: localQuiz.name,
|
||||||
description: markdownToHTMLSafe(localQuiz.description, settings),
|
description: markdownToHTMLSafe({
|
||||||
|
markdownString: localQuiz.description,
|
||||||
|
settings,
|
||||||
|
}),
|
||||||
shuffle_answers: localQuiz.shuffleAnswers,
|
shuffle_answers: localQuiz.shuffleAnswers,
|
||||||
access_code: localQuiz.password,
|
access_code: localQuiz.password,
|
||||||
show_correct_answers: localQuiz.showCorrectAnswers,
|
show_correct_answers: localQuiz.showCorrectAnswers,
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
createModuleFile,
|
createModuleFile,
|
||||||
getModuleNamesFromFiles,
|
getModuleNamesFromFiles,
|
||||||
} from "@/features/local/modules/moduleRouter";
|
} from "@/features/local/modules/moduleRouter";
|
||||||
|
import { getCoursePathByName } from "../../globalSettings/globalSettingsFileStorageService";
|
||||||
|
|
||||||
describe("FileStorageTests", () => {
|
describe("FileStorageTests", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
@@ -41,6 +42,7 @@ describe("FileStorageTests", () => {
|
|||||||
assets: [],
|
assets: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
await fileStorageService.settings.createCourseSettings(settings, await getCoursePathByName(name));
|
||||||
await fileStorageService.settings.updateCourseSettings(name, settings);
|
await fileStorageService.settings.updateCourseSettings(name, settings);
|
||||||
|
|
||||||
const loadedSettings = await fileStorageService.settings.getCourseSettings({
|
const loadedSettings = await fileStorageService.settings.getCourseSettings({
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const mermaidExtension = {
|
|||||||
},
|
},
|
||||||
renderer(token: { text: string }) {
|
renderer(token: { text: string }) {
|
||||||
const base64 = btoa(token.text);
|
const base64 = btoa(token.text);
|
||||||
const url = `https://mermaid.ink/img/${base64}?type=svg`
|
const url = `https://mermaid.ink/img/${base64}?type=svg`;
|
||||||
console.log(token.text, url);
|
console.log(token.text, url);
|
||||||
return `<img src="${url}" alt="Mermaid diagram" />`;
|
return `<img src="${url}" alt="Mermaid diagram" />`;
|
||||||
},
|
},
|
||||||
@@ -78,14 +78,27 @@ export function convertImagesToCanvasImages(
|
|||||||
return mutableHtml;
|
return mutableHtml;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function markdownToHTMLSafe(
|
export function markdownToHTMLSafe({
|
||||||
markdownString: string,
|
markdownString,
|
||||||
settings: LocalCourseSettings,
|
settings,
|
||||||
convertImages: boolean = true
|
convertImages = true,
|
||||||
) {
|
replaceText = [],
|
||||||
|
}: {
|
||||||
|
markdownString: string;
|
||||||
|
settings: LocalCourseSettings;
|
||||||
|
convertImages?: boolean;
|
||||||
|
replaceText?: { source: string; destination: string }[];
|
||||||
|
}) {
|
||||||
const html = markdownToHtmlNoImages(markdownString);
|
const html = markdownToHtmlNoImages(markdownString);
|
||||||
if (convertImages) return convertImagesToCanvasImages(html, settings);
|
if (convertImages) return convertImagesToCanvasImages(html, settings);
|
||||||
else return html;
|
|
||||||
|
|
||||||
|
const replacedHtml = replaceText.reduce(
|
||||||
|
(acc, { source, destination }) => acc.replaceAll(source, destination),
|
||||||
|
html
|
||||||
|
);
|
||||||
|
return html;
|
||||||
|
return replacedHtml;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function markdownToHtmlNoImages(markdownString: string) {
|
export function markdownToHtmlNoImages(markdownString: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user