Skip to content

Commit 4c030ac

Browse files
authored
Merge pull request #92 from UWB-ACM/rmgeorge/judge-feedback-show-client-side
Made it so that the feedback box shows the feedback that judges previ…
2 parents ef5e651 + 0b7bb0a commit 4c030ac

3 files changed

Lines changed: 33 additions & 1 deletion

File tree

src/app/judging/[id]/ProjectScoringPage.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff 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 =

src/app/judging/[id]/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
getProject,
55
getJudgingQuestions,
66
getScoresForProject,
7+
getFeedback,
78
} from "@/src/util/db/judge";
89
import ProjectScoringPage from "./ProjectScoringPage";
910
import { 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
}

src/util/db/judge.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff 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
*/

0 commit comments

Comments
 (0)