-
Notifications
You must be signed in to change notification settings - Fork 2
Feat/frontend/submissions #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Nowath
wants to merge
5
commits into
Frontend
Choose a base branch
from
feat/frontend/submissions
base: Frontend
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...ructor/class/[class_id]/assignments/[assignment_id]/submissions/[submissions_id]/page.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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( | ||
| <div className={` px-4 md:px-8 py-8`}> | ||
| <NavSub onClickSV={() => console.log("awdwad")} /> | ||
| <div className="divide-y divide-gray-200 divide-solid px-0 md:px-5"> | ||
| <div className=" px-2 md:px-10 py-2"> | ||
| <HeaderSub | ||
| data={ProfileData} | ||
| /> | ||
| </div> | ||
| <div className=" px-2 md:px-14 py-6 gap-10 flex flex-col"> | ||
| <CodeSection code={code} setCode={setCode} language="python"/> | ||
| <CommentScreenSection data={formattedComments}/> | ||
| <FormInputComment onSubmit={handleFeedbackSubmit}/> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } | ||
33 changes: 33 additions & 0 deletions
33
Frontend/grader-frontend/src/components/page/submissions/codeSection.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 ( | ||
| <div className="space-y-2 w-full"> | ||
| <div className="flex justify-end"> | ||
| <Button size={"sm"} variant={"outline"}> | ||
| {language} | ||
| </Button> | ||
| </div> | ||
| <div className="border rounded-lg overflow-hidden w-auto"> | ||
| <Editor | ||
| height="400px" | ||
| defaultLanguage={language} | ||
| value={code} | ||
| onChange={(value) => setCode(value || "")} | ||
| theme="light" | ||
| options={{ | ||
| readOnly: true, | ||
| minimap: { enabled: false }, | ||
| fontSize: 14, | ||
| lineNumbers: "on", | ||
| scrollBeyondLastLine: false, | ||
| automaticLayout: true, | ||
| wordWrap: "on", | ||
| }} | ||
| /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
59 changes: 59 additions & 0 deletions
59
Frontend/grader-frontend/src/components/page/submissions/comment/formInput.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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> | void | ||
| } | ||
|
|
||
| export function FormInputComment({ onSubmit }: FormInputCommentProps) { | ||
| const { | ||
| register, | ||
| handleSubmit, | ||
| formState: { errors, isSubmitting }, | ||
| reset | ||
| } = useForm<FeedbackFormData>() | ||
|
|
||
| const handleFormSubmit = async (data: FeedbackFormData) => { | ||
| try { | ||
| await onSubmit(data) | ||
| reset() | ||
| } catch (error) { | ||
| console.error('Error submitting feedback:', error) | ||
| } | ||
| } | ||
|
|
||
| return( | ||
| <form onSubmit={handleSubmit(handleFormSubmit)} className="flex flex-col gap-4 items-start"> | ||
| <span className="font-bold">Give feedback to student</span> | ||
| <div className="w-full md:w-100"> | ||
| <Textarea | ||
| {...register("comment", { | ||
| required: "Feedback is required", | ||
| minLength: { | ||
| value: 10, | ||
| message: "Feedback must be at least 10 characters" | ||
| } | ||
| })} | ||
| className="w-full min-h-30" | ||
| placeholder="Comment..." | ||
| /> | ||
| {errors.comment && ( | ||
| <p className="text-sm text-red-500 mt-1">{errors.comment.message}</p> | ||
| )} | ||
| </div> | ||
| <div className="flex w-full justify-end md:justify-start"> | ||
| <Button type="submit" disabled={isSubmitting}> | ||
| {isSubmitting ? "Sending..." : "Send feedback"} | ||
| </Button> | ||
| </div> | ||
| </form> | ||
| ) | ||
| } | ||
|
|
||
| export type { FeedbackFormData } |
46 changes: 46 additions & 0 deletions
46
Frontend/grader-frontend/src/components/page/submissions/comment/screen.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| 'use client' | ||
| import { Button } from "@/components/ui/button"; | ||
| import dayjs from "dayjs"; | ||
| import { | ||
| Avatar, | ||
| AvatarFallback, | ||
| AvatarImage, | ||
| } from "@/components/ui/avatar" | ||
|
|
||
| export function CommentScreenSection({data}: {data:CommentType[]}){ | ||
| return( | ||
| <div className="flex gap-4 flex-col"> | ||
| {data.map(( item, index) => ( | ||
| <Comment key={index} data={item} /> | ||
| ))} | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| interface CommentType{ | ||
| teacher: boolean; | ||
| comment: string; | ||
| name: string; | ||
| date: string; | ||
| image: string; | ||
| } | ||
|
|
||
| function Comment({ data }: { data:CommentType }) { | ||
| return( | ||
| <div className={` flex flex-col gap-4 ${!data.teacher && 'items-end'}`}> | ||
| <div className="flex items-center gap-2"> | ||
| <Avatar className={`ring ring-primary p-0.5 w-10 h-10 ${!data.teacher && 'order-2'}`}> | ||
| <AvatarImage className="rounded-full" src={data.image} alt="Avatar" /> | ||
| <AvatarFallback>{data.teacher ? 'TS': "ST"}</AvatarFallback> | ||
| </Avatar> | ||
| <div className={`flex flex-col ${!data.teacher && 'items-end order-1'} `}> | ||
| <span className="text-gray-700 ">{data.name}</span> | ||
| <span className="text-gray-400 text-xs ">{data.date}</span> | ||
| </div> | ||
| </div> | ||
| <div className=" md:max-w-[60%] ring ring-gray-300 p-2 text-sm rounded-md shadow-md"> | ||
| {data.comment} | ||
| </div> | ||
| </div> | ||
| ) | ||
| } |
39 changes: 39 additions & 0 deletions
39
Frontend/grader-frontend/src/components/page/submissions/header.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| 'use client' | ||
| import { | ||
| Avatar, | ||
| AvatarFallback, | ||
| AvatarImage, | ||
| } from "@/components/ui/avatar" | ||
|
|
||
| interface HeaderType{ | ||
| image:string; | ||
| name:string; | ||
| lab:number; | ||
| question:string; | ||
| date:string; | ||
| score:number; | ||
| maxScore: number; | ||
| } | ||
|
|
||
| export function HeaderSub({data}:{data:HeaderType}) { | ||
| return( | ||
| <div className="w-full flex flex-col gap-2 pb-6"> | ||
| <div className="flex items-center gap-2"> | ||
| <Avatar className="ring ring-primary p-0.5 w-10 h-10"> | ||
| <AvatarImage className="rounded-full" src={data.image} alt="Student_Avatar" /> | ||
| <AvatarFallback>ST</AvatarFallback> | ||
| </Avatar> | ||
| <span className="text-gray-700">{data.name}</span> | ||
| </div> | ||
| <div className="flex flex-col"> | ||
| <span>Lab {data.lab} / {data.question}</span> | ||
| <span className="text-xs text-gray-400">Submited {data.date}</span> | ||
| </div> | ||
| <div className="flex items-center gap-2"> | ||
| <div className=" Chip"> | ||
| <span className="text-sm">{data.score}/{data.maxScore}</span> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } |
19 changes: 19 additions & 0 deletions
19
Frontend/grader-frontend/src/components/page/submissions/navigate.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| 'use client' | ||
| import { Button } from "@/components/ui/button" | ||
| import { CircleArrowLeft } from "lucide-react"; | ||
| import { useRouter } from "next/navigation"; | ||
|
|
||
| export function NavSub({ onClickSV } : {onClickSV:() => void}) { | ||
| const router = useRouter() | ||
| return( | ||
| <div className="w-full flex justify-between items-center"> | ||
| <Button variant="ghost" className=" cursor-pointer *:text-primary" onClick={() => router.back()}> | ||
| <CircleArrowLeft /> | ||
| <span className="underline">Back to lab</span> | ||
| </Button> | ||
| <Button variant="outline" className=" cursor-pointer *:text-primary border border-primary" onClick={onClickSV}> | ||
| <span>Student View</span> | ||
| </Button> | ||
| </div> | ||
| ) | ||
| } |
44 changes: 44 additions & 0 deletions
44
Frontend/grader-frontend/src/variables/page/submissions/mockComment.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| export const mockComments = [ | ||
| { | ||
| teacher: true, | ||
| comment: "Great work on your project! Your attention to detail really shows. Keep up the excellent progress.", | ||
| name: "Dr. Sarah Mitchell", | ||
| date: "1703721600", | ||
| image: "https://i.pinimg.com/736x/f3/ec/94/f3ec94635f2365e3de3782de0aadbe76.jpg" | ||
| }, | ||
| { | ||
| teacher: false, | ||
| comment: "Thanks for the feedback! I really appreciate the guidance on the last assignment.", | ||
| name: "Alex Chen", | ||
| date: "1703808000", | ||
| image: "https://i.pinimg.com/736x/f3/ec/94/f3ec94635f2365e3de3782de0aadbe76.jpg" | ||
| }, | ||
| { | ||
| teacher: true, | ||
| comment: "Remember to submit your homework by Friday. Also, please review chapter 5 before our next class.", | ||
| name: "Prof. James Wilson", | ||
| date: "1703894400", | ||
| image: "https://i.pinimg.com/736x/f3/ec/94/f3ec94635f2365e3de3782de0aadbe76.jpg" | ||
| }, | ||
| { | ||
| teacher: false, | ||
| comment: "Can we schedule a meeting to discuss the upcoming exam? I have a few questions about the material.", | ||
| name: "Maria Rodriguez", | ||
| date: "1703980800", | ||
| image: "https://i.pinimg.com/736x/f3/ec/94/f3ec94635f2365e3de3782de0aadbe76.jpg" | ||
| }, | ||
| { | ||
| teacher: true, | ||
| comment: "Your presentation was outstanding! You demonstrated excellent understanding of the concepts.", | ||
| name: "Dr. Emily Thompson", | ||
| date: "1704067200", | ||
| image: "https://i.pinimg.com/736x/f3/ec/94/f3ec94635f2365e3de3782de0aadbe76.jpg" | ||
| }, | ||
| { | ||
| teacher: false, | ||
| comment: "I'm struggling with the lab assignment. Could you provide some additional resources?", | ||
| name: "David Park", | ||
| date: "1704153600", | ||
| image: "https://i.pinimg.com/736x/f3/ec/94/f3ec94635f2365e3de3782de0aadbe76.jpg" | ||
| } | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,11 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "ES2017", | ||
| "lib": ["dom", "dom.iterable", "esnext"], | ||
| "lib": [ | ||
| "dom", | ||
| "dom.iterable", | ||
| "esnext" | ||
| ], | ||
| "allowJs": true, | ||
| "skipLibCheck": true, | ||
| "strict": true, | ||
|
|
@@ -11,17 +15,28 @@ | |
| "moduleResolution": "bundler", | ||
| "resolveJsonModule": true, | ||
| "isolatedModules": true, | ||
| "jsx": "preserve", | ||
| "jsx": "react-jsx", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ผมแก้ไปตอนไหนว่ะ5363643 |
||
| "incremental": true, | ||
| "plugins": [ | ||
| { | ||
| "name": "next" | ||
| } | ||
| ], | ||
| "paths": { | ||
| "@/*": ["./src/*"] | ||
| "@/*": [ | ||
| "./src/*" | ||
| ] | ||
| } | ||
| }, | ||
| "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], | ||
| "exclude": ["node_modules", "src/lib/api/generated/**"] | ||
| "include": [ | ||
| "next-env.d.ts", | ||
| "**/*.ts", | ||
| "**/*.tsx", | ||
| ".next/types/**/*.ts", | ||
| ".next/dev/types/**/*.ts" | ||
| ], | ||
| "exclude": [ | ||
| "node_modules", | ||
| "src/lib/api/generated/**" | ||
| ] | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.