Add file io
This commit is contained in:
parent
c9091f2e75
commit
a1bcc2cb46
7 changed files with 154 additions and 80 deletions
23
judge/migrations/0124_auto_20220602_1116.py
Normal file
23
judge/migrations/0124_auto_20220602_1116.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 2.2.25 on 2022-06-02 04:16
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('judge', '0123_auto_20220502_2356'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='problemdata',
|
||||
name='fileio_input',
|
||||
field=models.TextField(blank=True, null=True, verbose_name='input file name'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='problemdata',
|
||||
name='fileio_output',
|
||||
field=models.TextField(blank=True, null=True, verbose_name='output file name'),
|
||||
),
|
||||
]
|
|
@ -105,6 +105,12 @@ class ProblemData(models.Model):
|
|||
upload_to=problem_directory_file,
|
||||
validators=[FileExtensionValidator(allowed_extensions=["cpp"])],
|
||||
)
|
||||
fileio_input = models.TextField(
|
||||
verbose_name=_("input file name"), blank=True, null=True
|
||||
)
|
||||
fileio_output = models.TextField(
|
||||
verbose_name=_("output file name"), blank=True, null=True
|
||||
)
|
||||
|
||||
__original_zipfile = None
|
||||
|
||||
|
|
|
@ -239,6 +239,14 @@ class ProblemDataCompiler(object):
|
|||
init["checker"] = make_checker(self.data)
|
||||
else:
|
||||
self.data.checker_args = ""
|
||||
if self.data.fileio_input:
|
||||
if "file_io" not in init:
|
||||
init["file_io"] = {}
|
||||
init["file_io"]["input"] = self.data.fileio_input
|
||||
if self.data.fileio_output:
|
||||
if "file_io" not in init:
|
||||
init["file_io"] = {}
|
||||
init["file_io"]["output"] = self.data.fileio_output
|
||||
|
||||
return init
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ from django.forms import (
|
|||
Select,
|
||||
formset_factory,
|
||||
FileInput,
|
||||
TextInput,
|
||||
)
|
||||
from django.http import Http404, HttpResponse, HttpResponseRedirect, JsonResponse
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
|
@ -88,6 +89,8 @@ class ProblemDataForm(ModelForm):
|
|||
"custom_checker",
|
||||
"custom_validator",
|
||||
"interactive_judge",
|
||||
"fileio_input",
|
||||
"fileio_output",
|
||||
]
|
||||
widgets = {
|
||||
"zipfile": FineUploadFileInput,
|
||||
|
@ -95,6 +98,8 @@ class ProblemDataForm(ModelForm):
|
|||
"generator": HiddenInput,
|
||||
"output_limit": HiddenInput,
|
||||
"output_prefix": HiddenInput,
|
||||
"fileio_input": TextInput,
|
||||
"fileio_output": TextInput,
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue