File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,19 +17,24 @@ export default function ProjectScoringPage({
1717 project,
1818 questions,
1919 existingScores,
20+ existingFeedback,
2021} : {
2122 project : Project ;
2223 questions : JudgingQuestion [ ] ;
2324 existingScores : JudgingScore [ ] ;
25+ existingFeedback : string | null ;
2426} ) {
2527 const router = useRouter ( ) ;
2628
2729 // Seed state from any scores already in the DB so revisiting the page pre-fills inputs.
2830 const [ scores , setScores ] = useState < Record < number , number > > (
2931 Object . fromEntries ( existingScores . map ( ( s ) => [ s . questionId , s . score ] ) ) ,
3032 ) ;
33+ const [ feedback , setFeedback ] = useState < string > (
34+ existingFeedback === null ? "" : existingFeedback ,
35+ ) ;
36+
3137 const [ completing , setCompleting ] = useState ( false ) ;
32- const [ feedback , setFeedback ] = useState < string > ( "" ) ;
3338
3439 // All questions must have a defined score before the judge can mark complete.
3540 const allScored =
Original file line number Diff line number Diff line change 44 getProject ,
55 getJudgingQuestions ,
66 getScoresForProject ,
7+ getFeedback ,
78} from "@/src/util/db/judge" ;
89import ProjectScoringPage from "./ProjectScoringPage" ;
910import { ensureJudgePermission } from "@/src/util/judge" ;
@@ -28,11 +29,14 @@ export default async function Page({
2829 getScoresForProject ( session . user ! . id , projectId ) ,
2930 ] ) ;
3031
32+ const existingFeedback = await getFeedback ( projectId , session . user ! . id ) ;
33+
3134 return (
3235 < ProjectScoringPage
3336 project = { project }
3437 questions = { questions }
3538 existingScores = { existingScores }
39+ existingFeedback = { existingFeedback }
3640 />
3741 ) ;
3842}
Original file line number Diff line number Diff line change @@ -161,6 +161,29 @@ export async function getTrack(trackId: number): Promise<Track | null> {
161161 } ;
162162}
163163
164+ /**
165+ * This function returns the feedback that a specific judge left on a specific project
166+ *
167+ * @param projectId This is the id of the project
168+ * @param judgeId This is the id of the judge
169+ * @returns String that is the feedback
170+ */
171+ export async function getFeedback (
172+ projectId : number ,
173+ judgeId : number ,
174+ ) : Promise < string | null > {
175+ const data =
176+ await sql `SELECT feedback FROM judge_assignments WHERE project_id = ${ projectId } and judge_id = ${ judgeId } ` ;
177+
178+ if ( data . length === 0 ) {
179+ return null ;
180+ }
181+
182+ const row = data [ 0 ] ;
183+
184+ return row . feedback ;
185+ }
186+
164187/**
165188 * Returns all tracks.
166189 */
You can’t perform that action at this time.
0 commit comments