Add interactive option
This commit is contained in:
parent
122cd0fa73
commit
ff8f12c134
6 changed files with 112 additions and 5 deletions
31
judge/migrations/0121_auto_20220415_0135.py
Normal file
31
judge/migrations/0121_auto_20220415_0135.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
# Generated by Django 2.2.25 on 2022-04-14 18:35
|
||||
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
import judge.models.problem_data
|
||||
import judge.utils.problem_data
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('judge', '0120_auto_20220306_1124'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='problemdata',
|
||||
name='interactive_judge',
|
||||
field=models.FileField(blank=True, null=True, storage=judge.utils.problem_data.ProblemDataStorage(), upload_to=judge.models.problem_data.problem_directory_file, validators=[django.core.validators.FileExtensionValidator(allowed_extensions=['cpp'])], verbose_name='interactive judge'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='problemdata',
|
||||
name='checker',
|
||||
field=models.CharField(blank=True, choices=[('standard', 'Standard'), ('floats', 'Floats'), ('floatsabs', 'Floats (absolute)'), ('floatsrel', 'Floats (relative)'), ('rstripped', 'Non-trailing spaces'), ('sorted', 'Unordered'), ('identical', 'Byte identical'), ('linecount', 'Line-by-line'), ('custom', 'Custom checker (PY)'), ('customval', 'Custom validator (CPP)'), ('interact', 'Interactive')], max_length=10, verbose_name='checker'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='problemtestcase',
|
||||
name='checker',
|
||||
field=models.CharField(blank=True, choices=[('standard', 'Standard'), ('floats', 'Floats'), ('floatsabs', 'Floats (absolute)'), ('floatsrel', 'Floats (relative)'), ('rstripped', 'Non-trailing spaces'), ('sorted', 'Unordered'), ('identical', 'Byte identical'), ('linecount', 'Line-by-line'), ('custom', 'Custom checker (PY)'), ('customval', 'Custom validator (CPP)'), ('interact', 'Interactive')], max_length=10, verbose_name='checker'),
|
||||
),
|
||||
]
|
|
@ -33,6 +33,7 @@ CHECKERS = (
|
|||
('linecount', _('Line-by-line')),
|
||||
('custom', _('Custom checker (PY)')),
|
||||
('customval', _('Custom validator (CPP)')),
|
||||
('interact', _('Interactive')),
|
||||
)
|
||||
|
||||
|
||||
|
@ -61,6 +62,13 @@ class ProblemData(models.Model):
|
|||
blank=True,
|
||||
upload_to=problem_directory_file,
|
||||
validators=[FileExtensionValidator(allowed_extensions=['cpp'])])
|
||||
interactive_judge = models.FileField(verbose_name=_('interactive judge'),
|
||||
storage=problem_data_storage,
|
||||
null=True,
|
||||
blank=True,
|
||||
upload_to=problem_directory_file,
|
||||
validators=[FileExtensionValidator(allowed_extensions=['cpp'])])
|
||||
|
||||
__original_zipfile = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
|
|
@ -210,9 +210,16 @@ class ProblemDataCompiler(object):
|
|||
if self.data.output_prefix is not None:
|
||||
init['output_prefix_length'] = self.data.output_prefix
|
||||
if self.data.checker:
|
||||
init['checker'] = make_checker(self.data)
|
||||
if self.data.checker == 'interact':
|
||||
init['interactive'] = {
|
||||
'files': split_path_first(self.data.interactive_judge.name)[1]
|
||||
}
|
||||
init['unbuffered'] = True
|
||||
else:
|
||||
init['checker'] = make_checker(self.data)
|
||||
else:
|
||||
self.data.checker_args = ''
|
||||
|
||||
return init
|
||||
|
||||
def compile(self):
|
||||
|
|
|
@ -61,7 +61,7 @@ class ProblemDataForm(ModelForm):
|
|||
|
||||
class Meta:
|
||||
model = ProblemData
|
||||
fields = ['zipfile', 'checker', 'checker_args', 'custom_checker', 'custom_validator']
|
||||
fields = ['zipfile', 'checker', 'checker_args', 'custom_checker', 'custom_validator', 'interactive_judge']
|
||||
widgets = {
|
||||
'zipfile': FineUploadFileInput,
|
||||
'checker_args': HiddenInput,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue