add autofill testcases
This commit is contained in:
parent
3885f6f071
commit
5562db7ecd
1 changed files with 60 additions and 3 deletions
|
@ -205,6 +205,47 @@
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('a#fill-testcases').click(function () {
|
||||||
|
var inFiles = [], outFiles = [];
|
||||||
|
for (var i = 0; i < window.valid_files.length; i++) {
|
||||||
|
if (window.valid_files[i].endsWith(".in")) {
|
||||||
|
inFiles.push(window.valid_files[i]);
|
||||||
|
}
|
||||||
|
if (window.valid_files[i].endsWith(".out")) {
|
||||||
|
outFiles.push(window.valid_files[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (inFiles.length == 0) {
|
||||||
|
alert("No input/output files. Make sure your files' suffices are .in/.out");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (inFiles.length != outFiles.length) {
|
||||||
|
alert("The input files do not match the output files!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// add boxes
|
||||||
|
while ($total.val() < inFiles.length) {
|
||||||
|
$('a#add-case-row').click();
|
||||||
|
}
|
||||||
|
// fill cases
|
||||||
|
for (var i = 0; i < inFiles.length; i++) {
|
||||||
|
$("#id_cases-" + i + "-input_file").val(inFiles[i]).change();
|
||||||
|
}
|
||||||
|
// add points
|
||||||
|
if ($('#problem-type').val() == "ICPC") {
|
||||||
|
for (i = 0; i + 1 < inFiles.length; i++) {
|
||||||
|
$("#id_cases-" + i + "-points").val("0").change();
|
||||||
|
}
|
||||||
|
$("#id_cases-" + (inFiles.length - 1) + "-points").val("100").change();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (i = 0; i < inFiles.length; i++) {
|
||||||
|
$("#id_cases-" + i + "-points").val("1").change();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
var oldIndex;
|
var oldIndex;
|
||||||
$table.sortable({
|
$table.sortable({
|
||||||
containerSelector: 'table',
|
containerSelector: 'table',
|
||||||
|
@ -324,7 +365,7 @@
|
||||||
height: 8em;
|
height: 8em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.generator-args-editor .button {
|
.generator-args-editor #submit-button {
|
||||||
display: block;
|
display: block;
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
@ -364,7 +405,23 @@
|
||||||
<form action="" method="POST" enctype="multipart/form-data">
|
<form action="" method="POST" enctype="multipart/form-data">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ cases_formset.management_form }}
|
{{ cases_formset.management_form }}
|
||||||
<table class="table">{{ data_form.as_table() }}</table>
|
<table class="table">
|
||||||
|
{{ data_form.as_table() }}
|
||||||
|
<th>
|
||||||
|
<label>Autofill testcases:</label>
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
Problem type:
|
||||||
|
<select id="problem-type">
|
||||||
|
<option value="ICPC">ICPC</option>
|
||||||
|
<option value="OI">OI</option>
|
||||||
|
</select>
|
||||||
|
<a id="fill-testcases" href="#">
|
||||||
|
<i class="fa fa-circle"></i>
|
||||||
|
Fill testcases
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</table>
|
||||||
<div id="column-visible" data-problem="{{ problem.code }}">
|
<div id="column-visible" data-problem="{{ problem.code }}">
|
||||||
<strong>{{ _('Show columns:') }}</strong>
|
<strong>{{ _('Show columns:') }}</strong>
|
||||||
<label>
|
<label>
|
||||||
|
@ -444,7 +501,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<input type="submit" value="{{ _('Submit!') }}" class="button">
|
<input type="submit" value="{{ _('Submit!') }}" class="button" id="submit-button">
|
||||||
<a id="add-case-row" href="#"><i class="fa fa-plus"></i> {{ _('Add new case') }}</a>
|
<a id="add-case-row" href="#"><i class="fa fa-plus"></i> {{ _('Add new case') }}</a>
|
||||||
</form>
|
</form>
|
||||||
<div style="display: none" class="generator-args-editor"><textarea></textarea><a class="button">Save</a></div>
|
<div style="display: none" class="generator-args-editor"><textarea></textarea><a class="button">Save</a></div>
|
||||||
|
|
Loading…
Reference in a new issue