File tree Expand file tree Collapse file tree 3 files changed +16
-6
lines changed
Expand file tree Collapse file tree 3 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -180,7 +180,8 @@ def __init__(self, submission: Submission):
180180 print (f"substitude { codepath } with user implemented" )
181181 wfp .write (filecontent )
182182
183- def judge (self ):
183+ def judge (self ) -> bool :
184+ # return True if grade is 100
184185 tester_path = join (self .sub_dirpath , TESTER_NAME )
185186 if not exists (tester_path ):
186187 raise Exception ("running submission: tester {} not exists" .format (tester_path ))
@@ -189,7 +190,7 @@ def judge(self):
189190 if res == TestResult .Timeout :
190191 self .sub .result = JudgeStatus .PROGRAM_TIMEOUT
191192 self .sub .save ()
192- return
193+ return False
193194 elif res == TestResult .Error :
194195 raise Exception ("Running test proc has some problem" )
195196
@@ -238,3 +239,6 @@ def judge(self):
238239 else :
239240 self .sub .result = JudgeStatus .SOME_PASSED
240241 self .sub .save ()
242+ if grade == 100 :
243+ return True
244+ return False
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ class Problem(models.Model):
2626 # code segment filenames to be substituded
2727 description = RichTextField ()
2828 # hint = RichTextField(null=True)
29- languages = JSONField (default = ["python " ])
29+ languages = JSONField (default = ["Python3 " ])
3030 vm_num = models .IntegerField (default = 1 )
3131 port_num = models .JSONField (default = list )
3232 code_num = models .IntegerField ()
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ def check_contest_permission(self, request):
6868 ):
6969 return self .error ("Your IP is not allowed in this contest" )
7070
71- @validate_serializer (CreateSubmissionSerializer )
71+ # @validate_serializer(CreateSubmissionSerializer)
7272 @login_required
7373 def post (self , request ):
7474 # print(request.data)
@@ -124,8 +124,14 @@ def post(self, request):
124124
125125 # execute judge task in dramatiq
126126 # local_judge_task.send(submission.id, problem._id)
127- tester = SubmissionTester (submission )
128- tester .judge ()
127+
128+ problem .submission_number += 1
129+ try :
130+ if SubmissionTester (submission ).judge ():
131+ problem .accepted_number += 1
132+ except Exception as e :
133+ self .error (str (e ))
134+ problem .save ()
129135
130136 if hide_id :
131137 return self .success ()
You can’t perform that action at this time.
0 commit comments