-
Notifications
You must be signed in to change notification settings - Fork 399
Add a Score counter to task overview #1476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
bb17b1a
6653f15
3d62b5d
6b52ff7
8428046
4ae18e9
cbe5f8e
8055bf6
fc50113
251c8b5
527bdea
95cc100
e60f328
13c491e
95349b0
28c1ae1
e0840f6
a958b48
7a3b7b7
fa4e7ca
4b0bd83
d12ba11
85d0eb8
3181514
003a7f9
7aac12b
1134711
6411ec3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,6 +10,8 @@ | |||||||||||||||||||||||||||||||||||
| # Copyright © 2014 Fabian Gundlach <320pointsguy@gmail.com> | ||||||||||||||||||||||||||||||||||||
| # Copyright © 2015-2018 William Di Luigi <williamdiluigi@gmail.com> | ||||||||||||||||||||||||||||||||||||
| # Copyright © 2021 Grace Hawkins <amoomajid99@gmail.com> | ||||||||||||||||||||||||||||||||||||
| # Copyright © 2025 Pasit Sangprachathanarak <ouipingpasit@gmail.com> | ||||||||||||||||||||||||||||||||||||
| # Copyright © 2025 kk@cscmu-cnx | ||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||
| # This program is free software: you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||
| # it under the terms of the GNU Affero General Public License as | ||||||||||||||||||||||||||||||||||||
|
|
@@ -46,11 +48,13 @@ | |||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| import tornado.web | ||||||||||||||||||||||||||||||||||||
| from sqlalchemy.orm.exc import NoResultFound | ||||||||||||||||||||||||||||||||||||
| from sqlalchemy.orm import joinedload | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| from cms import config | ||||||||||||||||||||||||||||||||||||
| from cms.db import User, Participation, Team | ||||||||||||||||||||||||||||||||||||
| from cms.db import User, Participation, Team, Submission, Token, Task, Dataset | ||||||||||||||||||||||||||||||||||||
| from cms.grading.languagemanager import get_language | ||||||||||||||||||||||||||||||||||||
| from cms.grading.steps import COMPILATION_MESSAGES, EVALUATION_MESSAGES | ||||||||||||||||||||||||||||||||||||
| from cms.grading.scoring import task_score | ||||||||||||||||||||||||||||||||||||
| from cms.server import multi_contest | ||||||||||||||||||||||||||||||||||||
| from cms.server.contest.authentication import validate_login | ||||||||||||||||||||||||||||||||||||
| from cms.server.contest.communication import get_communications | ||||||||||||||||||||||||||||||||||||
|
|
@@ -74,8 +78,62 @@ class MainHandler(ContestHandler): | |||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||
| @multi_contest | ||||||||||||||||||||||||||||||||||||
| def get(self): | ||||||||||||||||||||||||||||||||||||
| self.r_params = self.render_params() | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| self.r_params = self.render_params() |
Copilot
AI
Jan 1, 2026
There was a problem hiding this comment.
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.
| # 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
AI
Jan 1, 2026
There was a problem hiding this comment.
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
AI
Jan 1, 2026
There was a problem hiding this comment.
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.
| ret["participation"] = participation |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -182,7 +182,7 @@ <h2>{% trans %}General information{% endtrans %}</h2> | |||||
| {% if actual_phase >= 0 or participation.unrestricted %} | ||||||
| <h2>{% trans %}Task overview{% endtrans %}</h2> | ||||||
|
|
||||||
| <table class="table table-bordered table-striped"> | ||||||
| <table class="main_task_list table table-bordered table-striped"> | ||||||
| <!-- <colgroup> | ||||||
| <col class="task"/> | ||||||
| <col class="time_limit"/> | ||||||
|
|
@@ -193,6 +193,9 @@ <h2>{% trans %}Task overview{% endtrans %}</h2> | |||||
| </colgroup> --> | ||||||
| <thead> | ||||||
| <tr> | ||||||
| {% if contest.show_task_scores_in_overview %} | ||||||
|
||||||
| {% if contest.show_task_scores_in_overview %} | |
| {% if contest.show_task_scores_in_overview and task_scores is defined %} |
There was a problem hiding this comment.
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.