Skip to content

Conversation

@pxsit
Copy link
Contributor

@pxsit pxsit commented Jul 23, 2025

Add a Score counter to task overview
image

@prandla
Copy link
Member

prandla commented Jul 23, 2025

I have some comments about the code, but i'm wondering if this is the UI we want in the first place... I saw some browser extension that showed the task scores on the sidebar next to the task links, maybe that would be better.

Does anyone else have any thoughts?

@Muaath5
Copy link

Muaath5 commented Jul 28, 2025

I have some comments about the code, but i'm wondering if this is the UI we want in the first place... I saw some browser extension that showed the task scores on the sidebar next to the task links, maybe that would be better.

Does anyone else have any thoughts?

I don't see any issues if both of these ways where implemented, but if it was in the task overview it would be better in case of onsite competitions and you don't want others to look into your score :)

@pxsit
Copy link
Contributor Author

pxsit commented Aug 1, 2025

I have some comments about the code, but i'm wondering if this is the UI we want in the first place... I saw some browser extension that showed the task scores on the sidebar next to the task links, maybe that would be better.
Does anyone else have any thoughts?

I don't see any issues if both of these ways where implemented, but if it was in the task overview it would be better in case of onsite competitions and you don't want others to look into your score :)

Added an option to toggle this in AWS (:

Reformat, Fix Updaters, more
@pxsit
Copy link
Contributor Author

pxsit commented Aug 4, 2025

image Im still getting this bug, let me try fix it

@pxsit
Copy link
Contributor Author

pxsit commented Aug 4, 2025

Should be fixed! (According to my testing)

@prandla
Copy link
Member

prandla commented Aug 4, 2025

Sorry, I just looked at the rest of cws_style.css, and now I think your original approach was the best... I thought the places you changed were the only places that defined these colors, but looks like there are quite a few other places that use slightly different colors, so explicitly defining that these colors are in the task overview table and in the submission list table is fine.

After reverting that it should be good to merge.

@codecov
Copy link

codecov bot commented Nov 17, 2025

Codecov Report

❌ Patch coverage is 23.80952% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.64%. Comparing base (4cdaa00) to head (6411ec3).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
cms/server/contest/handlers/main.py 21.05% 15 Missing ⚠️
cms/server/admin/handlers/contest.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1476      +/-   ##
==========================================
- Coverage   54.67%   54.64%   -0.04%     
==========================================
  Files         335      335              
  Lines       27361    27381      +20     
==========================================
+ Hits        14960    14962       +2     
- Misses      12401    12419      +18     
Flag Coverage Δ
functionaltests 0.00% <0.00%> (ø)
unittests 54.64% <23.80%> (-0.04%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI review requested due to automatic review settings January 1, 2026 06:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds a configurable score counter display to the task overview page in the Contest Web Server (CWS). The feature is controlled by a new boolean field show_task_scores_in_overview that can be configured per contest.

  • Adds database column show_task_scores_in_overview to the contests table with default value of true
  • Implements score calculation and display in the task overview table
  • Extends CSS styling to apply score coloring (red/yellow/green) to the task overview scores

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
cmscontrib/updaters/update_from_1.5.sql Adds database migration to create the show_task_scores_in_overview column in the contests table
cms/server/contest/templates/overview.html Adds conditional score column header and data cells to the task overview table
cms/server/contest/static/cws_style.css Extends existing score styling classes to also apply to the main task list
cms/server/contest/handlers/main.py Implements score calculation logic in MainHandler.render_params() and adds necessary imports
cms/server/admin/templates/contest.html Adds checkbox UI element for the new setting in the contest configuration page
cms/server/admin/handlers/contest.py Adds form processing for the new show_task_scores_in_overview field
cms/db/contest.py Adds the show_task_scores_in_overview boolean column definition to the Contest model

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"""
@multi_contest
def get(self):
self.r_params = self.render_params()
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

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

The assignment to self.r_params in the get method is unnecessary and could cause confusion. The parent class ContestHandler.prepare() method already calls self.render_params() and assigns the result to self.r_params at line 104 of contest.py. This line should be removed and the code should simply call self.render("overview.html", **self.r_params) directly.

Suggested change
self.r_params = self.render_params()

Copilot uses AI. Check for mistakes.
Comment on lines +88 to +101
# This massive joined load gets all the information which we will need
participation = (
self.sql_session.query(Participation)
.filter(Participation.id == self.current_user.id)
.options(
joinedload(Participation.user),
joinedload(Participation.contest),
joinedload(Participation.submissions).joinedload(Submission.token),
joinedload(Participation.submissions).joinedload(
Submission.results
),
)
.first()
)
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

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

This code queries the Participation object again even though it should already be available via self.current_user (which is set by the parent class's get_current_user() method). Additionally, the parent class's render_params() method already queries the participation and sets it in the render params at line 210-211 of contest.py. This duplicate query with extensive joins could negatively impact performance and is unnecessary.

Suggested change
# This massive joined load gets all the information which we will need
participation = (
self.sql_session.query(Participation)
.filter(Participation.id == self.current_user.id)
.options(
joinedload(Participation.user),
joinedload(Participation.contest),
joinedload(Participation.submissions).joinedload(Submission.token),
joinedload(Participation.submissions).joinedload(
Submission.results
),
)
.first()
)
# Reuse the participation already loaded by the parent class instead of
# issuing another heavy query here.
participation = ret.get("participation") or self.current_user

Copilot uses AI. Check for mistakes.
Comment on lines +103 to +108
self.contest = (
self.sql_session.query(Contest)
.filter(Contest.id == participation.contest.id)
.options(joinedload(Contest.tasks).joinedload(Task.active_dataset))
.first()
)
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

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

This code queries the Contest object again and assigns it to self.contest, even though self.contest is already set by the parent class's choose_contest() method (called in prepare() at line 85 of contest.py). This duplicate query is unnecessary and could cause confusion about which contest object is being used. The existing self.contest should be used instead, and if additional related data needs to be loaded, it should be done through appropriate joins or queries without reassigning self.contest.

Copilot uses AI. Check for mistakes.
Comment on lines +110 to +111
ret["participation"] = participation

Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

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

The code overwrites ret["participation"] which is already set by the parent class's render_params() method at line 211 of contest.py. This is redundant and could cause confusion about which participation object is being used in the template.

Suggested change
ret["participation"] = participation

Copilot uses AI. Check for mistakes.
</colgroup> -->
<thead>
<tr>
{% if contest.show_task_scores_in_overview %}
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

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

There's an inconsistency in the conditional logic that could cause table column misalignment. Line 196 adds a Score header column when contest.show_task_scores_in_overview is true, but line 215 only adds the score data cell when both contest.show_task_scores_in_overview and task_scores is defined are true. This means if show_task_scores_in_overview is enabled but task_scores is not defined (e.g., when current_user is None), the table will have a Score header but no corresponding data cells, causing a column mismatch. Both conditions should use the same check: contest.show_task_scores_in_overview and task_scores is defined.

Suggested change
{% if contest.show_task_scores_in_overview %}
{% if contest.show_task_scores_in_overview and task_scores is defined %}

Copilot uses AI. Check for mistakes.

from cms import config
from cms.db import User, Participation, Team
from cms.db import User, Participation, Team, Submission, Token, Task, Dataset
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

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

Import of 'Token' is not used.
Import of 'Dataset' is not used.

Suggested change
from cms.db import User, Participation, Team, Submission, Token, Task, Dataset
from cms.db import User, Participation, Team, Submission, Task

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants