change e testcase table UI and add CPP validator
This commit is contained in:
parent
0ff312e3ba
commit
f74f8b6e05
15 changed files with 803 additions and 181 deletions
36
judge/migrations/0101_custom_validator.py
Normal file
36
judge/migrations/0101_custom_validator.py
Normal file
File diff suppressed because one or more lines are too long
23
judge/migrations/0102_fix_custom_validator.py
Normal file
23
judge/migrations/0102_fix_custom_validator.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 2.2.9 on 2020-03-17 05:05
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('judge', '0101_custom_validator'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
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'), ('customval', 'Custom Validator')], 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'), ('customval', 'Custom Validator')], max_length=10, verbose_name='checker'),
|
||||
),
|
||||
]
|
18
judge/migrations/0103_fix_custom_validator.py
Normal file
18
judge/migrations/0103_fix_custom_validator.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.2.9 on 2020-03-17 05:17
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('judge', '0102_fix_custom_validator'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='problemdata',
|
||||
old_name='custom_valid',
|
||||
new_name='custom_validator',
|
||||
),
|
||||
]
|
|
@ -30,6 +30,7 @@ CHECKERS = (
|
|||
('identical', _('Byte identical')),
|
||||
('linecount', _('Line-by-line')),
|
||||
('custom', _('Custom checker')),
|
||||
('customval', _('Custom Validator')),
|
||||
)
|
||||
|
||||
|
||||
|
@ -52,6 +53,12 @@ class ProblemData(models.Model):
|
|||
blank=True,
|
||||
upload_to=problem_directory_file,
|
||||
validators=[FileExtensionValidator(allowed_extensions=['py'])])
|
||||
custom_validator = models.FileField(verbose_name=_('custom validator file'),
|
||||
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):
|
||||
|
@ -78,6 +85,10 @@ class ProblemData(models.Model):
|
|||
self.generator.name = _problem_directory_file(new, self.generator.name)
|
||||
if self.custom_checker:
|
||||
self.custom_checker.name = _problem_directory_file(new, self.custom_checker.name)
|
||||
if self.custom_checker:
|
||||
self.custom_checker.name = _problem_directory_file(new, self.custom_checker.name)
|
||||
if self.custom_validator:
|
||||
self.custom_validator.name = _problem_directory_file(new, self.custom_validator.name)
|
||||
self.save()
|
||||
_update_code.alters_data = True
|
||||
|
||||
|
|
|
@ -69,6 +69,11 @@ class ProblemDataCompiler(object):
|
|||
if len(custom_checker_path) != 2:
|
||||
raise ProblemDataError(_('How did you corrupt the custom checker path?'))
|
||||
return(custom_checker_path[1])
|
||||
if (case.checker == 'customval'):
|
||||
validator_path = split_path_first(case.custom_validator.name)
|
||||
if len(validator_path) != 2:
|
||||
raise ProblemDataError(_('How did you corrupt the custom checker path?'))
|
||||
return(validator_path[1])
|
||||
if case.checker_args:
|
||||
return {
|
||||
'name': case.checker,
|
||||
|
|
|
@ -287,11 +287,11 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView
|
|||
context_object_name = 'problems'
|
||||
template_name = 'problem/list.html'
|
||||
paginate_by = 50
|
||||
sql_sort = frozenset(('points', 'ac_rate', 'user_count', 'code'))
|
||||
sql_sort = frozenset(('date', 'points', 'ac_rate', 'user_count', 'code'))
|
||||
manual_sort = frozenset(('name', 'group', 'solved', 'type'))
|
||||
all_sorts = sql_sort | manual_sort
|
||||
default_desc = frozenset(('points', 'ac_rate', 'user_count'))
|
||||
default_sort = 'code'
|
||||
default_desc = frozenset(('date', 'points', 'ac_rate', 'user_count'))
|
||||
default_sort = '-date'
|
||||
|
||||
def get_paginator(self, queryset, per_page, orphans=0,
|
||||
allow_empty_first_page=True, **kwargs):
|
||||
|
|
|
@ -8,7 +8,7 @@ from django.conf import settings
|
|||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.forms import BaseModelFormSet, HiddenInput, ModelForm, NumberInput, Select, formset_factory
|
||||
from django.forms import BaseModelFormSet, HiddenInput, ModelForm, NumberInput, Select, formset_factory, FileInput
|
||||
from django.http import Http404, HttpResponse, HttpResponseRedirect
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from django.urls import reverse
|
||||
|
@ -50,9 +50,12 @@ class ProblemDataForm(ModelForm):
|
|||
|
||||
class Meta:
|
||||
model = ProblemData
|
||||
fields = ['zipfile', 'generator', 'output_limit', 'output_prefix', 'checker', 'checker_args', 'custom_checker']
|
||||
fields = ['zipfile', 'checker', 'checker_args', 'custom_checker', 'custom_validator']
|
||||
widgets = {
|
||||
'checker_args': HiddenInput,
|
||||
'generator': HiddenInput,
|
||||
'output_limit': HiddenInput,
|
||||
'output_prefix': HiddenInput,
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,14 +65,14 @@ class ProblemCaseForm(ModelForm):
|
|||
class Meta:
|
||||
model = ProblemTestCase
|
||||
fields = ('order', 'type', 'input_file', 'output_file', 'points',
|
||||
'is_pretest', 'output_limit', 'output_prefix', 'checker', 'checker_args', 'generator_args')
|
||||
'is_pretest', 'checker', 'checker_args') #, 'output_limit', 'output_prefix', 'generator_args')
|
||||
widgets = {
|
||||
'generator_args': HiddenInput,
|
||||
# 'generator_args': HiddenInput,
|
||||
'type': Select(attrs={'style': 'width: 100%'}),
|
||||
'points': NumberInput(attrs={'style': 'width: 4em'}),
|
||||
'output_prefix': NumberInput(attrs={'style': 'width: 4.5em'}),
|
||||
'output_limit': NumberInput(attrs={'style': 'width: 6em'}),
|
||||
'checker_args': HiddenInput,
|
||||
# 'output_prefix': NumberInput(attrs={'style': 'width: 4.5em'}),
|
||||
# 'output_limit': NumberInput(attrs={'style': 'width: 6em'}),
|
||||
# 'checker_args': HiddenInput,
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue