diff --git a/backend/judge/dispatcher.py b/backend/judge/dispatcher.py index 2e204bfa2..63cbb0f56 100644 --- a/backend/judge/dispatcher.py +++ b/backend/judge/dispatcher.py @@ -94,6 +94,7 @@ def __init__(self, submission_id, problem_id): super().__init__() self.submission = Submission.objects.get(id=submission_id) self.contest_id = self.submission.contest_id + self.assignment_id = self.submission.assignment_id self.last_result = self.submission.result if self.submission.info else None if self.contest_id: @@ -107,8 +108,8 @@ def _compute_statistic_info(self, resp_data): self.submission.statistic_info["time_cost"] = max([x["cpu_time"] for x in resp_data]) self.submission.statistic_info["memory_cost"] = max([x["memory"] for x in resp_data]) - # sum up the score in OI mode - if self.problem.rule_type == ProblemRuleType.OI: + # sum up the score in OI or ASSIGNMENT mode + if self.problem.rule_type in (ProblemRuleType.OI, ProblemRuleType.ASSIGNMENT): score = 0 try: for i in range(len(resp_data)): @@ -219,7 +220,7 @@ def judge(self): with transaction.atomic(): self.update_contest_problem_status() self.update_contest_rank() - else: + elif not self.assignment_id: if self.last_result: self.update_problem_status_rejudge() else: diff --git a/backend/problem/models.py b/backend/problem/models.py index 5fa459a68..9f2d2a40a 100644 --- a/backend/problem/models.py +++ b/backend/problem/models.py @@ -19,6 +19,7 @@ class Meta: class ProblemRuleType(Choices): ACM = "ACM" OI = "OI" + ASSIGNMENT = "ASSIGNMENT" class ProblemDifficulty(object): diff --git a/backend/problem/serializers.py b/backend/problem/serializers.py index b2d491b89..b5d0d77bc 100644 --- a/backend/problem/serializers.py +++ b/backend/problem/serializers.py @@ -58,7 +58,7 @@ class CreateOrEditProblemSerializer(serializers.Serializer): memory_limit = serializers.IntegerField(min_value=1, max_value=1024) languages = LanguageNameMultiChoiceField() template = serializers.DictField(child=serializers.CharField(min_length=1)) - rule_type = serializers.ChoiceField(choices=[ProblemRuleType.ACM, ProblemRuleType.OI]) + rule_type = serializers.ChoiceField(choices=[ProblemRuleType.ACM, ProblemRuleType.OI, ProblemRuleType.ASSIGNMENT]) io_mode = ProblemIOModeSerializer() spj = serializers.BooleanField() spj_language = SPJLanguageNameChoiceField(allow_blank=True, allow_null=True) diff --git a/backend/problem/views/admin.py b/backend/problem/views/admin.py index 5274907c6..079db0148 100644 --- a/backend/problem/views/admin.py +++ b/backend/problem/views/admin.py @@ -300,7 +300,7 @@ def common_checks(self, request): else: data["spj_language"] = None data["spj_code"] = None - if data["rule_type"] == ProblemRuleType.OI: + if data["rule_type"] in (ProblemRuleType.OI, ProblemRuleType.ASSIGNMENT): total_score = 0 for item in data["test_case_score"]: if item["score"] <= 0: