diff --git a/Frontend/grader-frontend/src/app/globals.css b/Frontend/grader-frontend/src/app/globals.css index bd8c3d51..225c5bfd 100644 --- a/Frontend/grader-frontend/src/app/globals.css +++ b/Frontend/grader-frontend/src/app/globals.css @@ -135,6 +135,10 @@ font-family: var(--font-sans); } +.Chip{ + @apply px-2 py-1 bg-pink-100 ring ring-primary rounded-md text-sm +} + @layer base { :root { --sidebar: oklch(0.985 0 0); @@ -146,4 +150,8 @@ --sidebar-border: oklch(0.922 0 0); --sidebar-ring: oklch(0.708 0 0); } +} + +button { + cursor: pointer; } \ No newline at end of file diff --git a/Frontend/grader-frontend/src/app/instructor/class/[class_id]/assignments/[assignment_id]/submissions/[submissions_id]/page.tsx b/Frontend/grader-frontend/src/app/instructor/class/[class_id]/assignments/[assignment_id]/submissions/[submissions_id]/page.tsx new file mode 100644 index 00000000..b6ade29d --- /dev/null +++ b/Frontend/grader-frontend/src/app/instructor/class/[class_id]/assignments/[assignment_id]/submissions/[submissions_id]/page.tsx @@ -0,0 +1,56 @@ +'use client' +import { NavSub } from "@/components/page/submissions/navigate" +import { HeaderSub } from "@/components/page/submissions/header"; +import { CodeSection } from "@/components/page/submissions/codeSection"; +import { CommentScreenSection } from "@/components/page/submissions/comment/screen"; +import { FormInputComment,FeedbackFormData } from "@/components/page/submissions/comment/formInput"; +import dayjs from "dayjs"; +import { mockComments } from "@/variables/page/submissions/mockComment"; +import { useState } from "react"; + +export default function Page({ params }: { params: Promise<{ submissions_id: string; }>; }) { + const [code, setCode] = useState("# Write your Python code here\nprint('Hello, World!')"); + function DayFormat(date:number){ + return dayjs.unix(date).format('DD MMMM YYYY HH:mm'); + } + const formattedComments = mockComments.map(comment => ({ + ...comment, + date: DayFormat(parseInt(comment.date)) + })); + + const ProfileData = { + image: 'https://i.pinimg.com/736x/f3/ec/94/f3ec94635f2365e3de3782de0aadbe76.jpg', + name: "Alex Chen", + lab:1, + question: "Question 1: Median of Two Sorted Arrays", + date: DayFormat(parseInt("1703721600")), + score:20, + maxScore: 100 + } + // mock นะจะ + const handleFeedbackSubmit = async (data: FeedbackFormData) => { + console.log('Submitting feedback:', data.comment) + await fetch('/api/feedback', { + method: 'POST', + body: JSON.stringify(data) + }) + } + + return( +
+ console.log("awdwad")} /> +
+
+ +
+
+ + + +
+
+
+ ) +} diff --git a/Frontend/grader-frontend/src/components/page/submissions/codeSection.tsx b/Frontend/grader-frontend/src/components/page/submissions/codeSection.tsx new file mode 100644 index 00000000..8c3b4a41 --- /dev/null +++ b/Frontend/grader-frontend/src/components/page/submissions/codeSection.tsx @@ -0,0 +1,33 @@ +'use client' +import { Button } from "@/components/ui/button"; +import Editor from "@monaco-editor/react"; + +export function CodeSection({code, setCode, language}:{code:string, setCode:(data:string) => void, language:string}) { + return ( +
+
+ +
+
+ setCode(value || "")} + theme="light" + options={{ + readOnly: true, + minimap: { enabled: false }, + fontSize: 14, + lineNumbers: "on", + scrollBeyondLastLine: false, + automaticLayout: true, + wordWrap: "on", + }} + /> +
+
+ ); +} \ No newline at end of file diff --git a/Frontend/grader-frontend/src/components/page/submissions/comment/formInput.tsx b/Frontend/grader-frontend/src/components/page/submissions/comment/formInput.tsx new file mode 100644 index 00000000..6701fcb1 --- /dev/null +++ b/Frontend/grader-frontend/src/components/page/submissions/comment/formInput.tsx @@ -0,0 +1,59 @@ +'use client' +import { useForm } from "react-hook-form" +import { Button } from "@/components/ui/button" +import { Textarea } from "@/components/ui/textarea" + +interface FeedbackFormData { + comment: string +} + +interface FormInputCommentProps { + onSubmit: (data: FeedbackFormData) => Promise | void +} + +export function FormInputComment({ onSubmit }: FormInputCommentProps) { + const { + register, + handleSubmit, + formState: { errors, isSubmitting }, + reset + } = useForm() + + const handleFormSubmit = async (data: FeedbackFormData) => { + try { + await onSubmit(data) + reset() + } catch (error) { + console.error('Error submitting feedback:', error) + } + } + + return( +
+ Give feedback to student +
+