From f75a89e474ca014ac06f5d2c2be1ab537fdcbaf4 Mon Sep 17 00:00:00 2001 From: Divyank Shah Date: Fri, 17 Nov 2023 19:40:03 -0800 Subject: [PATCH] fix judging --- .../admin/services/judging/Toolbar.jsx | 53 +++++++++++++------ 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/src/components/dynamic/admin/services/judging/Toolbar.jsx b/src/components/dynamic/admin/services/judging/Toolbar.jsx index 5df7b73a4..bd7363c1f 100644 --- a/src/components/dynamic/admin/services/judging/Toolbar.jsx +++ b/src/components/dynamic/admin/services/judging/Toolbar.jsx @@ -84,14 +84,24 @@ const Toolbar = ({ data, setData }) => { let round = 0; // Assign Professors - for (let i = 0; i < teams.length; i += 1) { - if (round === parseInt(input.rotations)) continue; - teams[i].rounds[round].push(professors[judge]); - if (judge < professors.length - 1) { - judge += 1; - } else { - judge = 0; - round += 1; + for (let j = 0; j < input.rotations; j += 1) { + for (let i = 0; i < teams.length; i += 1) { + if (round === parseInt(input.rotations)) continue; + if ( + teams[i].rounds.some((judges) => + judges.some( + (individual) => individual.name === professors[judge].name + ) + ) + ) + continue; + teams[i].rounds[round].push(professors[judge]); + if (judge < professors.length - 1) { + judge += 1; + } else { + judge = 0; + round += 1; + } } } @@ -99,14 +109,25 @@ const Toolbar = ({ data, setData }) => { round = 0; // Assign Students + Industry - for (let i = teams.length - 1; i > -1; i -= 1) { - if (round === parseInt(input.rotations)) continue; - teams[i].rounds[round].push(studentsAndIndustry[judge]); - if (judge < studentsAndIndustry.length - 1) { - judge += 1; - } else { - judge = 0; - round += 1; + for (let j = 0; j < input.rotations; j += 1) { + for (let i = teams.length - 1; i > -1; i -= 1) { + if (round === parseInt(input.rotations)) continue; + if ( + teams[i].rounds.some((judges) => + judges.some( + (individual) => + individual.name === studentsAndIndustry[judge].name + ) + ) + ) + continue; + teams[i].rounds[round].push(studentsAndIndustry[judge]); + if (judge < studentsAndIndustry.length - 1) { + judge += 1; + } else { + judge = 0; + round += 1; + } } }