mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-27 07:58:31 -06:00
can update quiz
This commit is contained in:
@@ -3,6 +3,7 @@ import { ReactNode, useState } from "react";
|
||||
import { CourseContext, DraggableItem } from "./courseContext";
|
||||
import { LocalQuiz } from "@/models/local/quiz/localQuiz";
|
||||
import { dateToMarkdownString } from "@/models/local/timeUtils";
|
||||
import { useUpdateQuizMutation } from "@/hooks/localCourse/quizHooks";
|
||||
|
||||
export default function CourseContextProvider({
|
||||
localCourseName,
|
||||
@@ -11,6 +12,7 @@ export default function CourseContextProvider({
|
||||
children: ReactNode;
|
||||
localCourseName: string;
|
||||
}) {
|
||||
const updateQuizMutation = useUpdateQuizMutation(localCourseName);
|
||||
const [itemBeingDragged, setItemBeingDragged] = useState<
|
||||
DraggableItem | undefined
|
||||
>();
|
||||
@@ -58,10 +60,17 @@ export default function CourseContextProvider({
|
||||
setItemBeingDragged(undefined);
|
||||
},
|
||||
itemDrop: (day) => {
|
||||
console.log("dropping");
|
||||
if (itemBeingDragged && day) {
|
||||
if (itemBeingDragged.type === "quiz") {
|
||||
updateQuiz(day);
|
||||
const quiz: LocalQuiz = {
|
||||
...(itemBeingDragged.item as LocalQuiz),
|
||||
dueAt: dateToMarkdownString(day),
|
||||
};
|
||||
updateQuizMutation.mutate({
|
||||
quiz: quiz,
|
||||
quizName: quiz.name,
|
||||
moduleName: itemBeingDragged.sourceModuleName,
|
||||
});
|
||||
}
|
||||
}
|
||||
setItemBeingDragged(undefined);
|
||||
|
||||
@@ -4,6 +4,7 @@ import { createContext, useContext } from "react";
|
||||
|
||||
export interface DraggableItem {
|
||||
item: IModuleItem;
|
||||
sourceModuleName: string;
|
||||
type: "quiz" | "assignment" | "page";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user