mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
quiz names not in markdown anymore
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
} from "@/hooks/localCourse/quizHooks";
|
||||
import { useAuthoritativeUpdates } from "../../../../utils/useAuthoritativeUpdates";
|
||||
import { extractLabelValue } from "@/models/local/assignment/utils/markdownUtils";
|
||||
import EditQuizHeader from "./EditQuizHeader";
|
||||
|
||||
const helpString = `QUESTION REFERENCE
|
||||
---
|
||||
@@ -150,6 +151,7 @@ export default function EditQuiz({
|
||||
|
||||
return (
|
||||
<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"}>
|
||||
{showHelp && (
|
||||
<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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user