checker
This commit is contained in:
parent
1995708fdf
commit
0e2e6eea83
@ -53,11 +53,11 @@ class UserInfo(models.Model):
|
|||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def available_tasks(self):
|
def available_tasks(self):
|
||||||
return Task.objects.filter(Q(public=True) | Q(creator=self.user) | Q(editors__in=self.user.username)).order_by('name')
|
return Task.objects.filter(Q(public=True) | Q(creator=self.user) | Q(editors__contains=[self.user.username])).order_by('name')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available_sets(self):
|
def available_sets(self):
|
||||||
return Set.objects.filter(Q(public=True) | Q(creator=self.user) | Q(editors__in=self.user.username)).order_by('name')
|
return Set.objects.filter(Q(public=True) | Q(creator=self.user) | Q(editors__contains=[self.user.username])).order_by('name')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def place(self):
|
def place(self):
|
||||||
|
@ -38,8 +38,13 @@ class BaseTester:
|
|||||||
raise TestException("RE")
|
raise TestException("RE")
|
||||||
result = open(join(self.solution.testing_directory, "output.txt"), "r").read()
|
result = open(join(self.solution.testing_directory, "output.txt"), "r").read()
|
||||||
print("got result", result)
|
print("got result", result)
|
||||||
if result.strip().replace('\r\n', '\n') != self.predicted.strip().replace('\r\n', '\n'):
|
if exists(f"solutions/{self.solution.id}/checker.sh"):
|
||||||
raise TestException("WA")
|
code = self.solution.exec_command(f"./checker.sh --expected {self.predicted} --output {result}")
|
||||||
|
if code != 0:
|
||||||
|
raise TestException("WA")
|
||||||
|
else:
|
||||||
|
if result.strip().replace('\r\n', '\n') != self.predicted.strip().replace('\r\n', '\n'):
|
||||||
|
raise TestException("WA")
|
||||||
|
|
||||||
def after_test(self):
|
def after_test(self):
|
||||||
pass
|
pass
|
||||||
|
@ -168,7 +168,7 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td valign="top">
|
||||||
{% for test in task.tests %}
|
{% for test in task.tests %}
|
||||||
<div id="file_{{ test.id }}">
|
<div id="file_{{ test.id }}">
|
||||||
<i class="fa fa-file"></i> <button class="btn btn-link" {% if not test.readable %}style="color: red;" {% else %}data-toggle="modal" data-target="#filesModalLong{{ test.id }}"{% endif %}>{{ test.filename }}</button><button class="btn btn-link" style="color: black;" onclick="deleteFile({{ test.id }});"><i class="fa fa-times"></i> </button><br>
|
<i class="fa fa-file"></i> <button class="btn btn-link" {% if not test.readable %}style="color: red;" {% else %}data-toggle="modal" data-target="#filesModalLong{{ test.id }}"{% endif %}>{{ test.filename }}</button><button class="btn btn-link" style="color: black;" onclick="deleteFile({{ test.id }});"><i class="fa fa-times"></i> </button><br>
|
||||||
@ -213,10 +213,43 @@
|
|||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
</form>
|
</form>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td valign="top">
|
||||||
{% for file in task.files %}
|
{% for test in task.files %}
|
||||||
<div id="file_{{ file.id }}">
|
<div id="file_{{ test.id }}">
|
||||||
<i class="fa fa-file"></i> <button class="btn btn-link" {% if not file.readable %}style="color: red;"{% endif %}>{{ file.filename }}</button><button class="btn btn-link" style="color: black;" onclick="deleteFile({{ file.id }});"><i class="fa fa-times"></i> </button><br>
|
<i class="fa {% if test.filename == "checker.sh" %}fa-cogs{% else %}fa-file{% endif %}"></i> <button class="btn btn-link" {% if not test.readable %}style="color: red;" {% else %}data-toggle="modal" data-target="#filesModalLong{{ test.id }}"{% endif %}>{{ test.filename }}</button><button class="btn btn-link" style="color: black;" onclick="deleteFile({{ test.id }});"><i class="fa fa-times"></i> </button><br>
|
||||||
|
{% if test.readable %}
|
||||||
|
<form method="POST">{% csrf_token %}
|
||||||
|
<!-- Modal -->
|
||||||
|
<div class="modal fade bd-example-modal-lg" id="filesModalLong{{ test.id }}" tabindex="-1" role="dialog" aria-labelledby="filesModalLongTitle{{ test.id }}" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="filesModalLongTitle{{ test.id }}">{{ test.filename }}</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<textarea cols="82" rows="30" name="text">{{ test.text }}</textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
{% if test.can_be_sample %}Использовать как пример <input type="checkbox" name="is_sample" {% if test.is_sample %}checked{% endif %}>{% endif %}
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal"><i class="fa fa-times"></i> Close</button>
|
||||||
|
<input name="action" value="save_test" type="hidden">
|
||||||
|
<input name="test_id" value="{{ test.id }}" type="hidden">
|
||||||
|
<button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> Save</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<input type="file" style="display: none;" form="form_file_upload" onchange="this.form.submit();" class="btn form-control-file" id="file-upload" value="Выбрать файл" name="file">
|
<input type="file" style="display: none;" form="form_file_upload" onchange="this.form.submit();" class="btn form-control-file" id="file-upload" value="Выбрать файл" name="file">
|
||||||
@ -251,7 +284,7 @@
|
|||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-times"></i> Закрыть</button>
|
<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-times"></i> Закрыть</button>
|
||||||
<button type="submit" class="btn btn-success"><i class="fa fa-file"></i> Создать</button>
|
<button type="submit" class="btn btn-success"><i class="fa fa-file"></i> Создать</button>
|
||||||
<input id="action_create" type="hidden" name="action" value="create_test">
|
<input id="action_create" type="hidden" name="action" value="create_file">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user