mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
quiz names not in markdown anymore
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
|||||||
} from "@/hooks/localCourse/quizHooks";
|
} from "@/hooks/localCourse/quizHooks";
|
||||||
import { useAuthoritativeUpdates } from "../../../../utils/useAuthoritativeUpdates";
|
import { useAuthoritativeUpdates } from "../../../../utils/useAuthoritativeUpdates";
|
||||||
import { extractLabelValue } from "@/models/local/assignment/utils/markdownUtils";
|
import { extractLabelValue } from "@/models/local/assignment/utils/markdownUtils";
|
||||||
|
import EditQuizHeader from "./EditQuizHeader";
|
||||||
|
|
||||||
const helpString = `QUESTION REFERENCE
|
const helpString = `QUESTION REFERENCE
|
||||||
---
|
---
|
||||||
@@ -150,6 +151,7 @@ export default function EditQuiz({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full flex flex-col align-middle px-1">
|
<div className="h-full flex flex-col align-middle px-1">
|
||||||
|
<EditQuizHeader moduleName={moduleName} quizName={quizName} />
|
||||||
<div className={"min-h-96 h-full flex flex-row w-full"}>
|
<div className={"min-h-96 h-full flex flex-row w-full"}>
|
||||||
{showHelp && (
|
{showHelp && (
|
||||||
<pre className=" max-w-96">
|
<pre className=" max-w-96">
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { useCourseContext } from "@/app/course/[courseName]/context/courseContext";
|
||||||
|
import { getCourseUrl } from "@/services/urlUtils";
|
||||||
|
import Link from "next/link";
|
||||||
|
import { UpdateQuizName } from "./UpdateQuizName";
|
||||||
|
|
||||||
|
export default function EditQuizHeader({
|
||||||
|
moduleName,
|
||||||
|
quizName,
|
||||||
|
}: {
|
||||||
|
quizName: string;
|
||||||
|
moduleName: string;
|
||||||
|
}) {
|
||||||
|
const { courseName } = useCourseContext();
|
||||||
|
return (
|
||||||
|
<div className="py-1 flex flex-row justify-start gap-3">
|
||||||
|
<Link
|
||||||
|
className="btn btn-thin"
|
||||||
|
href={getCourseUrl(courseName)}
|
||||||
|
shallow={true}
|
||||||
|
>
|
||||||
|
{courseName}
|
||||||
|
</Link>
|
||||||
|
<UpdateQuizName quizName={quizName} moduleName={moduleName} />
|
||||||
|
<div>{quizName}</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
import { useCourseContext } from "@/app/course/[courseName]/context/courseContext";
|
||||||
|
import TextInput from "@/components/form/TextInput";
|
||||||
|
import Modal, { useModal } from "@/components/Modal";
|
||||||
|
import { Spinner } from "@/components/Spinner";
|
||||||
|
import {
|
||||||
|
useAssignmentQuery,
|
||||||
|
useUpdateAssignmentMutation,
|
||||||
|
} from "@/hooks/localCourse/assignmentHooks";
|
||||||
|
import { useQuizQuery, useUpdateQuizMutation } from "@/hooks/localCourse/quizHooks";
|
||||||
|
import { getModuleItemUrl } from "@/services/urlUtils";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
|
export function UpdateQuizName({
|
||||||
|
moduleName,
|
||||||
|
quizName,
|
||||||
|
}: {
|
||||||
|
quizName: string;
|
||||||
|
moduleName: string;
|
||||||
|
}) {
|
||||||
|
const modal = useModal();
|
||||||
|
const { courseName } = useCourseContext();
|
||||||
|
const router = useRouter();
|
||||||
|
const [quiz] = useQuizQuery(moduleName, quizName);
|
||||||
|
const updateQuiz = useUpdateQuizMutation();
|
||||||
|
const [name, setName] = useState(quiz.name);
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Modal
|
||||||
|
modalControl={modal}
|
||||||
|
buttonText="Rename Quiz"
|
||||||
|
buttonClass="py-0"
|
||||||
|
modalWidth="w-1/5"
|
||||||
|
>
|
||||||
|
{({ closeModal }) => (
|
||||||
|
<form
|
||||||
|
onSubmit={async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
if (name === quizName) closeModal();
|
||||||
|
|
||||||
|
setIsLoading(true); // page refresh resets flag
|
||||||
|
await updateQuiz.mutateAsync({
|
||||||
|
quiz: quiz,
|
||||||
|
moduleName,
|
||||||
|
quizName: name,
|
||||||
|
previousModuleName: moduleName,
|
||||||
|
previousQuizName: quizName,
|
||||||
|
courseName,
|
||||||
|
});
|
||||||
|
|
||||||
|
// update url (will trigger reload...)
|
||||||
|
router.replace(
|
||||||
|
getModuleItemUrl(courseName, moduleName, "quiz", name),
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TextInput
|
||||||
|
value={name}
|
||||||
|
setValue={setName}
|
||||||
|
label={"Rename Quiz"}
|
||||||
|
/>
|
||||||
|
<button className="w-full my-3">Save New Name</button>
|
||||||
|
{isLoading && <Spinner />}
|
||||||
|
</form>
|
||||||
|
)}
|
||||||
|
</Modal>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -121,8 +121,7 @@ export const quizMarkdownUtils = {
|
|||||||
const questionDelimiter = "\n\n---\n\n";
|
const questionDelimiter = "\n\n---\n\n";
|
||||||
const questionMarkdown = questionMarkdownArray.join(questionDelimiter);
|
const questionMarkdown = questionMarkdownArray.join(questionDelimiter);
|
||||||
|
|
||||||
return `Name: ${quiz.name}
|
return `LockAt: ${quiz.lockAt ?? ""}
|
||||||
LockAt: ${quiz.lockAt ?? ""}
|
|
||||||
DueAt: ${quiz.dueAt}
|
DueAt: ${quiz.dueAt}
|
||||||
Password: ${quiz.password ?? ""}
|
Password: ${quiz.password ?? ""}
|
||||||
ShuffleAnswers: ${quiz.shuffleAnswers.toString().toLowerCase()}
|
ShuffleAnswers: ${quiz.shuffleAnswers.toString().toLowerCase()}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ this is my description in markdown
|
|||||||
|
|
||||||
const markdown = quizMarkdownUtils.toMarkdown(quiz);
|
const markdown = quizMarkdownUtils.toMarkdown(quiz);
|
||||||
|
|
||||||
expect(markdown).toContain("Name: Test Quiz");
|
expect(markdown).not.toContain("Name: Test Quiz");
|
||||||
expect(markdown).toContain(quiz.description);
|
expect(markdown).toContain(quiz.description);
|
||||||
expect(markdown).toContain("ShuffleAnswers: true");
|
expect(markdown).toContain("ShuffleAnswers: true");
|
||||||
expect(markdown).toContain("OneQuestionAtATime: false");
|
expect(markdown).toContain("OneQuestionAtATime: false");
|
||||||
|
|||||||
Reference in New Issue
Block a user