Skip to content

[Bugfix:Submission] Fix leaderboard ranking tie#12591

Merged
bmcutler merged 10 commits into
Submitty:mainfrom
Ash092016:leaderboard-ranking-test
Mar 27, 2026
Merged

[Bugfix:Submission] Fix leaderboard ranking tie#12591
bmcutler merged 10 commits into
Submitty:mainfrom
Ash092016:leaderboard-ranking-test

Conversation

@Ash092016

Copy link
Copy Markdown
Contributor

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?

  • 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 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 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.
  • 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.

@codecov

codecov Bot commented Mar 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 21.64%. Comparing base (9e1a364) to head (952a701).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            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           
Flag Coverage Δ
autograder 21.32% <ø> (ø)
js 2.04% <ø> (ø)
migrator 100.00% <ø> (ø)
php 20.66% <ø> (ø)
python_submitty_utils 80.08% <ø> (ø)
submitty_daemon_jobs 91.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Eli-J-Schwartz Eli-J-Schwartz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Ash092016,
I tested this change locally. Here is what it looks like before your change is applied:

Image

Here is what it looks like after your change is applied:

Image

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?

@github-project-automation github-project-automation Bot moved this from Seeking Reviewer to Work in Progress in Submitty Development Mar 24, 2026
@Ash092016

Copy link
Copy Markdown
Contributor Author

Hi @Eli-J-Schwartz, the original logic was comparing the raw, highly precise backend measurements which prevented users with seemingly identical scores from tying.
I've just pushed a new commit that updates the LeaderboardTable.twig logic. It now explicitly applies the same math (round(1) for time, and converting memory to MB then rounding) before checking for ties. This ensures the ranking logic perfectly matches the formatted values displayed to the users on the leaderboard UI.

Let me know if there's anything else I should work upon!

@automateprojectmangement automateprojectmangement Bot moved this from Work in Progress to In Review in Submitty Development Mar 25, 2026

@Eli-J-Schwartz Eli-J-Schwartz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this PR again, and the changes are working correctly:

Image

Additionally, I reviewed the code, and the functional changes appear to be free of bugs.

Please fix any remaining test errors, and then I will approve the PR.

@github-project-automation github-project-automation Bot moved this from In Review to Work in Progress in Submitty Development Mar 26, 2026
@Ash092016 Ash092016 changed the title [Bugfix:Submission] Correct leaderboard competition ranking logic [Bugfix:Submission] Fix leaderboard ranking tie Mar 27, 2026
@Ash092016

Copy link
Copy Markdown
Contributor Author

Hi @Eli-J-Schwartz, pushed fixes for the PR title length, the Cypress ESLint warning, and the leaderboard test timeout. Ready for review!

@automateprojectmangement automateprojectmangement Bot moved this from Work in Progress to In Review in Submitty Development Mar 27, 2026

@Eli-J-Schwartz Eli-J-Schwartz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests are now passing, other that known test failures on the current main branch.
Everything else is the same as my last review.

@github-project-automation github-project-automation Bot moved this from In Review to Awaiting Maintainer Review in Submitty Development Mar 27, 2026
@bmcutler
bmcutler merged commit 2aa745d into Submitty:main Mar 27, 2026
24 of 26 checks passed
GarvitKhandelwal31 pushed a commit to GarvitKhandelwal31/Submitty that referenced this pull request Mar 29, 2026
### 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]>
GarvitKhandelwal31 pushed a commit to GarvitKhandelwal31/Submitty that referenced this pull request Apr 14, 2026
### 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Cypress Testing for Leaderboard Gradeable Rankings

4 participants