[Bugfix:Submission] Fix leaderboard ranking tie#12591
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12591 +/- ##
=========================================
Coverage 21.64% 21.64%
Complexity 9654 9654
=========================================
Files 268 268
Lines 36245 36245
Branches 487 487
=========================================
Hits 7846 7846
Misses 27916 27916
Partials 483 483
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Eli-J-Schwartz
left a comment
There was a problem hiding this comment.
Hi @Ash092016,
I tested this change locally. Here is what it looks like before your change is applied:
Here is what it looks like after your change is applied:
It seems like although your change is working correctly (as seen in the tie for 1st place), the way you are detecting differences in memory and time usage is more precise than what is displayed to the user, effectively preventing most ties. Would it be possible to compare the rounded values that the user sees?
|
Hi @Eli-J-Schwartz, the original logic was comparing the raw, highly precise backend measurements which prevented users with seemingly identical scores from tying. Let me know if there's anything else I should work upon! |
|
Hi @Eli-J-Schwartz, pushed fixes for the PR title length, the Cypress ESLint warning, and the leaderboard test timeout. Ready for review! |
Eli-J-Schwartz
left a comment
There was a problem hiding this comment.
All tests are now passing, other that known test failures on the current main branch.
Everything else is the same as my last review.
### Why is this Change Important & Necessary? Fixes Submitty#12582. Previously, the leaderboard assigned sequential ranks even when students had identical scores. This PR implements "Competition Ranking" (e.g., 1-2-2-4), ensuring that tied students share the same rank and that the subsequent rank skips appropriately. It also adds an automated Cypress test to verify this behavior and prevent future regressions. ### What is the New Behavior? - **Tie Handling**: The leaderboard now compares Points, Time, and Memory metrics against the previous student. If all metrics are identical, they are assigned the same rank. - **Improved Ranking Logic**: Implemented competition ranking in [LeaderboardTable.twig](cci:7://file:///c:/Users/BIT/Desktop/Submitty/site/app/templates/submission/homework/leaderboard/LeaderboardTable.twig:0:0-0:0) where the rank number "jumps" after a tie (e.g., if two students are tied for 1st place, the next student is ranked 3rd). - **Automated Verification**: Added a new test case to [leaderboard_gradeable.spec.js](cci:7://file:///c:/Users/BIT/Desktop/Submitty/site/cypress/e2e/Cypress-Gradeable/leaderboard_gradeable.spec.js:0:0-0:0) that performs two identical student submissions and asserts that they share the same rank on the leaderboard. ### What steps should a reviewer take to reproduce or test the bug or new feature? 1. Navigate to a gradeable with a leaderboard enabled (e.g., the "leaderboard" gradeable in the sample course). 2. Perform two submissions for different students that result in identical Autograding metrics (Points, Time, and Memory). 3. Visit the leaderboard page and observe that both students are listed with the same rank number. 4. Verify that the student following the tied pair has a rank that skipped an intermediate value (Competition Ranking). ### Automated Testing & Documentation - This feature is covered by a new end-to-end Cypress test added to [site/cypress/e2e/Cypress-Gradeable/leaderboard_gradeable.spec.js](cci:7://file:///c:/Users/BIT/Desktop/Submitty/site/cypress/e2e/Cypress-Gradeable/leaderboard_gradeable.spec.js:0:0-0:0). - No additional documentation updates are required for this internal UI refinement. ### Other information - This is not a breaking change. - No database migrations are included. - There are no security concerns. --------- Co-authored-by: Justin Manion <[email protected]>
### Why is this Change Important & Necessary? Fixes Submitty#12582. Previously, the leaderboard assigned sequential ranks even when students had identical scores. This PR implements "Competition Ranking" (e.g., 1-2-2-4), ensuring that tied students share the same rank and that the subsequent rank skips appropriately. It also adds an automated Cypress test to verify this behavior and prevent future regressions. ### What is the New Behavior? - **Tie Handling**: The leaderboard now compares Points, Time, and Memory metrics against the previous student. If all metrics are identical, they are assigned the same rank. - **Improved Ranking Logic**: Implemented competition ranking in [LeaderboardTable.twig](cci:7://file:///c:/Users/BIT/Desktop/Submitty/site/app/templates/submission/homework/leaderboard/LeaderboardTable.twig:0:0-0:0) where the rank number "jumps" after a tie (e.g., if two students are tied for 1st place, the next student is ranked 3rd). - **Automated Verification**: Added a new test case to [leaderboard_gradeable.spec.js](cci:7://file:///c:/Users/BIT/Desktop/Submitty/site/cypress/e2e/Cypress-Gradeable/leaderboard_gradeable.spec.js:0:0-0:0) that performs two identical student submissions and asserts that they share the same rank on the leaderboard. ### What steps should a reviewer take to reproduce or test the bug or new feature? 1. Navigate to a gradeable with a leaderboard enabled (e.g., the "leaderboard" gradeable in the sample course). 2. Perform two submissions for different students that result in identical Autograding metrics (Points, Time, and Memory). 3. Visit the leaderboard page and observe that both students are listed with the same rank number. 4. Verify that the student following the tied pair has a rank that skipped an intermediate value (Competition Ranking). ### Automated Testing & Documentation - This feature is covered by a new end-to-end Cypress test added to [site/cypress/e2e/Cypress-Gradeable/leaderboard_gradeable.spec.js](cci:7://file:///c:/Users/BIT/Desktop/Submitty/site/cypress/e2e/Cypress-Gradeable/leaderboard_gradeable.spec.js:0:0-0:0). - No additional documentation updates are required for this internal UI refinement. ### Other information - This is not a breaking change. - No database migrations are included. - There are no security concerns. --------- Co-authored-by: Justin Manion <[email protected]>

Why is this Change Important & Necessary?
Fixes #12582.
Previously, the leaderboard assigned sequential ranks even when students had identical scores. This PR implements "Competition Ranking" (e.g., 1-2-2-4), ensuring that tied students share the same rank and that the subsequent rank skips appropriately. It also adds an automated Cypress test to verify this behavior and prevent future regressions.
What is the New Behavior?
What steps should a reviewer take to reproduce or test the bug or new feature?
Automated Testing & Documentation
Other information