From 0cbb641426ca249ad21fdd3c615bbd33f5ab4683 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Mon, 2 Dec 2019 11:39:40 +0100 Subject: [PATCH] Fix point checking --- kontr_emails.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/kontr_emails.py b/kontr_emails.py index fc86e7a..13191ff 100644 --- a/kontr_emails.py +++ b/kontr_emails.py @@ -87,13 +87,20 @@ class Parser: def __filter(self, all_submissions: Dict[str, List[Submission]]) -> None: for _, submissions in all_submissions.items(): - length = len(submissions) - i = -1 - while not submissions[i].submitted_before_deadline and i >= -length: - i -= 1 + if not submissions[0].submitted_before_deadline: + continue - if i >= -length: - submissions[i].flag = "REVIEW" + length = len(submissions) + max_i = 0 + + for i in range(1, length): + if not submissions[i].submitted_before_deadline: + break + + if submissions[i].points >= submissions[max_i].points: + max_i = i + + submissions[max_i].flag = "REVIEW" def __correct_errors(self, all_submissions: Dict[str, List[Submission]]) -> None: response = input("Do you wish to fix errors? ").strip()