Skip to content
Snippets Groups Projects
Commit 40c8ebad authored by Martin Mareš's avatar Martin Mareš
Browse files

mo.score: Neúspěšní řešitelé nepotřebují jednoznačné pořadí

U neúspěšných řešitelů třídíme primárně podle bodů, sekundárně podle
jména, a jmenovce pak případně podle ročníku.

Také jsem do class Score přidal flagy, zda jsou definovaní vítězové
a úspěšní řešitelé.
parent f11f5795
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !36. Comments created here will be created in the context of that merge request.
......@@ -83,6 +83,8 @@ class Score:
round: db.Round
contest: Optional[db.Contest]
part_states: List[db.PartState]
want_successful: bool
want_winners: bool
# Řádky výsledkovky
_results: Dict[int, ScoreResult]
......@@ -104,6 +106,8 @@ class Score:
self.round = round
self.contest = contest
self.part_states = part_states
self.want_successful = round.score_successful_limit is not None
self.want_winners = round.score_winner_limit is not None
# Příprava subquery na účastníky (contest_subq obsahuje master_contest_id)
sess = db.get_session()
......@@ -186,14 +190,8 @@ class Score:
def _mark_winners(self):
for result in self._results.values():
total_points = result.get_total_points()
result.winner = (
self.round.score_winner_limit is not None
and total_points >= self.round.score_winner_limit
)
result.successful = (
self.round.score_successful_limit is not None
and total_points >= self.round.score_successful_limit
)
result.winner = self.want_winners and total_points >= self.round.score_winner_limit
result.successful = self.want_successful and total_points >= self.round.score_successful_limit
def _load_prev_round(self, step: int) -> bool:
"""Načtení úloh a řešení předchozího kola, pokud takové existuje."""
......@@ -337,8 +335,12 @@ class Score:
points_from_max = list(sorted(sol_points.values()))
points_from_difficult = [sol_points[task_id] for task_id in tasks_by_difficulty]
if result.successful or not self.want_successful:
# Primárně podle počtu získaných bodů, sekundárně podle bodů od maxima, terciárně podle bodů od nejobtížnější
result._order_key.extend((total_points, points_from_max, points_from_difficult))
else:
# Neúspěšné řešitele třídíme podle počtu získaných bodů, sekundárně podle jména
result._order_key.extend((total_points, result.user.name_sort_key()))
# Otestujeme, jestli teď existují sdílená místa
if not self._exists_same_order_key():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment