Skip to content

Commit e2cf72d

Browse files
committed
average score with # of judges scored them
1 parent f1c928b commit e2cf72d

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

app/(api)/_utils/scoring/rankTeams.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export interface RankTeamsResults {
8383
team_id: string;
8484
final_score: number;
8585
comments: string[];
86+
submission_count: number; // Track number of submissions
8687
};
8788
}[];
8889
}
@@ -152,6 +153,7 @@ export default function RankTeams({ submissions }: RankTeamsProps) {
152153
// - we update the score by adding it up
153154
const existing_team = results[track_name][existingTeamIndex];
154155
existing_team.team.final_score += score; // add the score up
156+
existing_team.team.submission_count += 1; // increment submission count
155157

156158
// - add the comments as well
157159
if (submission.comments) {
@@ -166,15 +168,25 @@ export default function RankTeams({ submissions }: RankTeamsProps) {
166168
comments: submission.comments
167169
? [submission.comments]
168170
: ([] as string[]),
171+
submission_count: 1, // initialize submission count
169172
},
170173
});
171174
}
172175
}
173176
}
174177
}
175178

176-
// Sort teams by score for each track (from highest to lowest)
179+
// Calculate average scores and sort teams for each track
177180
for (const track_name in results) {
181+
// Calculate average scores
182+
results[track_name].forEach((item) => {
183+
if (item.team.submission_count > 0) {
184+
item.team.final_score =
185+
item.team.final_score / item.team.submission_count;
186+
}
187+
});
188+
189+
// Sort teams by score (from highest to lowest)
178190
results[track_name].sort((a, b) => b.team.final_score - a.team.final_score);
179191
}
180192

app/(pages)/(hackers)/_components/DOE/Judging/IndexHeroContentJudging.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default function IndexHeroContentJudging() {
6767
<h2>
6868
<strong>Judging Information</strong>
6969
</h2>
70-
<Link href={'/judging'}>
70+
<Link href={'/project-info'}>
7171
<button className={styles.schedule_button}>
7272
Read on the process
7373
<LuArrowUpRight size={23} />

app/(pages)/(hackers)/_components/IndexHero/IndexHeroContentDone.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export default function IndexHeroContentDone() {
100100
<h2>
101101
<strong>Judging Information</strong>
102102
</h2>
103-
<Link href={'/judging'}>
103+
<Link href={'/project-info'}>
104104
<button className={styles.schedule_button}>
105105
Read on the process
106106
<LuArrowUpRight size={23} />

app/(pages)/admin/_components/RankTeams/RankTeamsUI.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,17 @@ export default function RankTeamsUI() {
447447
</p>
448448
)}
449449
</div>
450-
<Badge variant="secondary" className="ml-2">
451-
Score: {result.team.final_score.toFixed(2)}
452-
</Badge>
450+
<div className="flex flex-col items-end gap-1">
451+
<Badge variant="secondary">
452+
Score: {result.team.final_score.toFixed(2)}
453+
</Badge>
454+
<Badge variant="outline" className="text-xs">
455+
{result.team.submission_count}{' '}
456+
{result.team.submission_count === 1
457+
? 'Judge'
458+
: 'Judges'}
459+
</Badge>
460+
</div>
453461
</div>
454462

455463
{questions.length > 0 && (

0 commit comments

Comments
 (0)