diff --git a/src/app/frq-feedback/[id]/page.tsx b/src/app/frq-feedback/[id]/page.tsx index 1187fb1f..36d7798a 100644 --- a/src/app/frq-feedback/[id]/page.tsx +++ b/src/app/frq-feedback/[id]/page.tsx @@ -1,4 +1,3 @@ - "use client"; import FRQFeedbackRenderer from "@/components/frq/feedbackRenderer"; @@ -18,11 +17,7 @@ const Page = () => { const fetchFeedback = async () => { setStatus("loading"); try { - const docRef = doc( - db, - "frq-feedback", - frqId - ); + const docRef = doc(db, "frq-feedback", frqId); const docSnap = await getDoc(docRef); if (docSnap.exists()) { @@ -30,10 +25,10 @@ const Page = () => { } else { setStatus("not-found"); } - } catch (error: unknown) { - console.error("Error fetching FRQ feedback:", error); - setStatus("not-found"); - } + } catch (error: unknown) { + console.error("Error fetching FRQ feedback:", error); + setStatus("not-found"); + } }; void fetchFeedback(); @@ -44,11 +39,9 @@ const Page = () => { } return ( -
- -
+
+ +
); }; diff --git a/src/components/frq/feedback/dropdownContent.tsx b/src/components/frq/feedback/dropdownContent.tsx new file mode 100644 index 00000000..2e3183e4 --- /dev/null +++ b/src/components/frq/feedback/dropdownContent.tsx @@ -0,0 +1,105 @@ +"use client"; + +import { ChevronDown, ChevronRight } from "lucide-react"; +import { RenderContent } from "@/components/article-creator/custom_questions/RenderAdvancedTextbox"; +import RubricCriteriaRow from "./rubricCriteriaRow"; +import type { FRQPart, FRQPartFeedback, ResponseAnswer } from "./types"; +import { Textarea } from "@/components/ui/textarea"; + +interface FeedbackSectionProps { + part: FRQPart; + label: string; + answer?: ResponseAnswer; + partFeedback?: FRQPartFeedback; + isOpen: boolean; + onToggle: () => void; + onFeedbackChange: (feedback: string) => void; + onPointsChange: (criterionId: string, points: number) => void; +} + +export default function FeedbackSection({ + part, + label, + answer, + partFeedback, + isOpen, + onToggle, + onFeedbackChange, + onPointsChange, +}: FeedbackSectionProps) { + const pointsEarned = + partFeedback?.gradingCriteria.reduce( + (total, criterion) => total + criterion.points, + 0, + ) ?? 0; + + const pointsPossible = part.gradingCriteria.reduce( + (total, criterion) => total + criterion.points, + 0, + ); + + return ( +
+ + + {isOpen && ( +
+ + +
+ +
+ +
+ {part.gradingCriteria.map((criterion) => { + const criterionScore = partFeedback?.gradingCriteria.find( + (score) => score.criterionId === criterion.id, + ); + + return ( + + onPointsChange(criterion.id, points) + } + /> + ); + })} +
+