mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
can update quiz
This commit is contained in:
@@ -30,7 +30,6 @@ export default function CourseCalendar() {
|
||||
bg-slate-950
|
||||
"
|
||||
>
|
||||
Month Goes Here
|
||||
{months.map((month) => (
|
||||
<CalendarMonth key={month.month + "" + month.year} month={month} />
|
||||
))}
|
||||
|
||||
@@ -54,7 +54,13 @@ export default function DayItemsInModule({
|
||||
key={q.name}
|
||||
role="button"
|
||||
draggable="true"
|
||||
onDragStart={() => startItemDrag({ type: "quiz", item: q })}
|
||||
onDragStart={() =>
|
||||
startItemDrag({
|
||||
type: "quiz",
|
||||
item: q,
|
||||
sourceModuleName: moduleName,
|
||||
})
|
||||
}
|
||||
onDragEnd={endItemDrag}
|
||||
>
|
||||
{q.name}
|
||||
@@ -65,7 +71,13 @@ export default function DayItemsInModule({
|
||||
key={p.name}
|
||||
role="button"
|
||||
draggable="true"
|
||||
onDragStart={() => startItemDrag({ type: "page", item: p })}
|
||||
onDragStart={() =>
|
||||
startItemDrag({
|
||||
type: "page",
|
||||
item: p,
|
||||
sourceModuleName: moduleName,
|
||||
})
|
||||
}
|
||||
>
|
||||
{p.name}
|
||||
</li>
|
||||
|
||||
@@ -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