Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
FherStk committed Aug 16, 2024
1 parent 251d6d4 commit 0f27045
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions judge/migrations/0147_infer_test_cases_from_zip.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by Django 3.2.25 on 2024-08-16 11:00

from django.db import migrations, models

import judge.models.problem


Expand Down
13 changes: 8 additions & 5 deletions judge/models/problem_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,17 @@ def setup_test_cases_content(self):

last = 0
content = []
test_cases = ProblemTestCase.objects.filter(dataset_id=self.problem.pk)
test_cases = ProblemTestCase.objects.filter(dataset_id=self.problem.pk)

for i, tc in enumerate([x for x in test_cases if x.is_pretest]):
self.append_tescase_to_statement(zip, content, tc, i)
last = i

if last > 0:
last += 1

for i, tc in enumerate([x for x in test_cases if not x.is_pretest]):
self.append_tescase_to_statement(zip, content, tc, i+last+1)
self.append_tescase_to_statement(zip, content, tc, i + last)

self.test_cases_content = '\n'.join(content)

Expand All @@ -122,7 +125,7 @@ def append_tescase_to_statement(self, zip, content, tc, i):
content.append('```')
content.append(zip.read(tc.input_file).decode('utf-8'))
content.append('```')

content.append('')
content.append(f'## Sample Output {i+1}')
content.append('')
Expand All @@ -134,7 +137,7 @@ def append_tescase_to_statement(self, zip, content, tc, i):
content.append('```')
content.append(zip.read(tc.output_file).decode('utf-8'))
content.append('```')

content.append('')

def infer_test_cases_from_zip(self):
Expand Down Expand Up @@ -258,7 +261,7 @@ def _load_test_case_from_doc(self, doc, field, is_pretest):
ptc.output_prefix = doc['output_prefix_length']

if test.get('output_limit_length'):
ptc.output_limit = doc['output_limit_length']
ptc.output_limit = doc['output_limit_length']

if test.get('checker'):
chk = test['checker']
Expand Down

0 comments on commit 0f27045

Please sign in to comment.