diff --git a/mo/score.py b/mo/score.py index 99f4cb4a97fe0eadd84a222bc2e69fb2752660f0..50ec9beb21045b2d0a225d8de76d2563085ef772 100644 --- a/mo/score.py +++ b/mo/score.py @@ -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] - # 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)) + 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():