Skip to content

Commit

Permalink
Add problem rule type ASSIGNMENT
Browse files Browse the repository at this point in the history
OI type에서 테스트케이스 점수 설정 가능 및 개별 점수의 총합으로 score 저장하게 구현됨
ASSIGNMENT rule type을 추가해 OI type과 동일하게 사용, 나중에 부가 기능 필요시 따로 구현
  • Loading branch information
cranemont committed Jan 12, 2022
1 parent 8545653 commit 5fc3631
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions backend/judge/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)):
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions backend/problem/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Meta:
class ProblemRuleType(Choices):
ACM = "ACM"
OI = "OI"
ASSIGNMENT = "ASSIGNMENT"


class ProblemDifficulty(object):
Expand Down
2 changes: 1 addition & 1 deletion backend/problem/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion backend/problem/views/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5fc3631

Please sign in to comment.