-
Notifications
You must be signed in to change notification settings - Fork 398
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
Open
pxsit
wants to merge
27
commits into
cms-dev:main
Choose a base branch
from
pxsit:add-counter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
bb17b1a
Add a Score counter to task overview
pxsit 6653f15
Merge branch 'main' into add-counter
pxsit 3d62b5d
Merge branch 'main' into add-counter
pxsit 6b52ff7
Merge branch 'main' into add-counter
pxsit 8428046
Merge branch 'main' into add-counter
pxsit 4ae18e9
Restore Formatting, Make it toggleable
pxsit cbe5f8e
Fix color not displaying
pxsit 8055bf6
Fix
pxsit fc50113
Fix the Fix
pxsit 251c8b5
Fix the Fix that Fix the Fix
pxsit 527bdea
Merge branch 'main' into add-counter
pxsit 95cc100
Update cws_style.css
pxsit e60f328
Merge branch 'main' into add-counter
pxsit 13c491e
Add credit for original owner?
pxsit 95349b0
Merge branch 'main' into add-counter
pxsit 28c1ae1
Merge branch 'main' into add-counter
pxsit e0840f6
Update update_from_1.5.sql
pxsit a958b48
Merge branch 'main' into add-counter
pxsit 7a3b7b7
Merge branch 'main' into add-counter
pxsit fa4e7ca
Merge branch 'main' into add-counter
pxsit 4b0bd83
Merge branch 'main' into add-counter
pxsit d12ba11
Merge branch 'cms-dev:main' into add-counter
pxsit 85d0eb8
Merge branch 'cms-dev:main' into add-counter
pxsit 3181514
Merge branch 'cms-dev:main' into add-counter
pxsit 003a7f9
Merge branch 'cms-dev:main' into add-counter
pxsit 7aac12b
Remove unused PrintJob import from main.py
pxsit 1134711
Merge branch 'main' into add-counter
pxsit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| # Copyright © 2014 Fabian Gundlach <[email protected]> | ||
| # Copyright © 2015-2018 William Di Luigi <[email protected]> | ||
| # Copyright © 2021 Grace Hawkins <[email protected]> | ||
| # Copyright © 2025 Pasit Sangprachathanarak <[email protected]> | ||
| # | ||
| # 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 +47,13 @@ | |
|
|
||
| import tornado.web | ||
| from sqlalchemy.orm.exc import NoResultFound | ||
| from sqlalchemy.orm import joinedload | ||
|
|
||
| from cms import config | ||
| from cms.db import PrintJob, User, Participation, Team | ||
| from cms.db import PrintJob, 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 | ||
|
|
@@ -76,8 +79,62 @@ class MainHandler(ContestHandler): | |
| """ | ||
| @multi_contest | ||
| def get(self): | ||
| self.r_params = self.render_params() | ||
| self.render("overview.html", **self.r_params) | ||
|
|
||
| def render_params(self): | ||
| ret = super().render_params() | ||
|
|
||
| if self.current_user is not None: | ||
| # 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() | ||
| ) | ||
|
|
||
| self.contest = ( | ||
| self.sql_session.query(Contest) | ||
| .filter(Contest.id == participation.contest.id) | ||
| .options(joinedload(Contest.tasks).joinedload(Task.active_dataset)) | ||
| .first() | ||
| ) | ||
|
|
||
| ret["participation"] = participation | ||
|
|
||
| # Compute public scores for all tasks only if they will be shown | ||
| if self.contest.show_task_scores_in_overview: | ||
| task_scores = {} | ||
| for task in self.contest.tasks: | ||
| score_type = task.active_dataset.score_type_object | ||
| max_public_score = round( | ||
| score_type.max_public_score, task.score_precision | ||
| ) | ||
| public_score, _ = task_score( | ||
| participation, task, public=True, rounded=True | ||
| ) | ||
| task_scores[task.id] = ( | ||
| public_score, | ||
| max_public_score, | ||
| score_type.format_score( | ||
| public_score, | ||
| score_type.max_public_score, | ||
| None, | ||
| task.score_precision, | ||
| translation=self.translation, | ||
| ), | ||
| ) | ||
| ret["task_scores"] = task_scores | ||
|
|
||
| return ret | ||
|
|
||
| class RegistrationHandler(ContestHandler): | ||
| """Registration handler. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.