diff --git a/templates/problem/data.html b/templates/problem/data.html index 83d16ed..b21a8ed 100644 --- a/templates/problem/data.html +++ b/templates/problem/data.html @@ -205,6 +205,47 @@ 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; $table.sortable({ containerSelector: 'table', @@ -324,7 +365,7 @@ height: 8em; } - .generator-args-editor .button { + .generator-args-editor #submit-button { display: block; float: right; } @@ -364,7 +405,23 @@