mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-11-04 14:49:58 +08:00
修复 vm 中数据清除错误的问题;替换测试用例上传组件
This commit is contained in:
parent
e0bb9eed2b
commit
9e4342f649
@ -8,7 +8,7 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert",
|
||||
.on('submit', function (e) {
|
||||
if (!e.isDefaultPrevented()) {
|
||||
e.preventDefault();
|
||||
if (vm.testCaseId == "") {
|
||||
if (!avalon.vmodels.testCaseUploader.uploaded) {
|
||||
bsAlert("你还没有上传测试数据!");
|
||||
return false;
|
||||
}
|
||||
@ -36,7 +36,7 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert",
|
||||
time_limit: vm.timeLimit,
|
||||
memory_limit: vm.memoryLimit,
|
||||
samples: [],
|
||||
test_case_id: vm.testCaseId,
|
||||
test_case_id: avalon.vmodels.testCaseUploader.testCaseId,
|
||||
hint: avalon.vmodels.contestProblemHintEditor.content,
|
||||
visible: vm.visible,
|
||||
contest_id: avalon.vmodels.admin.contestId,
|
||||
@ -72,6 +72,7 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
bsAlert(alertContent);
|
||||
avalon.vmodels.admin.template_url = "template/contest/problem_list.html";
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
@ -98,7 +99,6 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert",
|
||||
outputDescription: "",
|
||||
testCaseId: "",
|
||||
testCaseList: [],
|
||||
uploadSuccess: false,
|
||||
|
||||
contestProblemDescriptionEditor: {
|
||||
editorId: "contest-problem-description-editor",
|
||||
@ -135,38 +135,20 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert",
|
||||
});
|
||||
else {
|
||||
var vm = avalon.vmodels.editProblem;
|
||||
title = "";
|
||||
description = "";
|
||||
timeLimit = 1000;
|
||||
memoryLimit = 128;
|
||||
samples = [];
|
||||
hint = "";
|
||||
sortIndex = "";
|
||||
visible = true;
|
||||
inputDescription = "";
|
||||
outputDescription = "";
|
||||
testCaseId = "";
|
||||
testCaseList = [];
|
||||
uploadSuccess = false;
|
||||
vm.title = "";
|
||||
vm.description = "";
|
||||
vm.timeLimit = 1000;
|
||||
vm.memoryLimit = 128;
|
||||
vm.samples = [];
|
||||
vm.hint = "";
|
||||
vm.sortIndex = "";
|
||||
vm.visible = true;
|
||||
vm.inputDescription = "";
|
||||
vm.outputDescription = "";
|
||||
vm.testCaseId = "";
|
||||
vm.testCaseList = [];
|
||||
}
|
||||
|
||||
var testCaseUploader = uploader("#testCaseFile", "/api/admin/test_case_upload/", function (file, response) {
|
||||
if (response.code)
|
||||
bsAlert(response.data);
|
||||
else {
|
||||
vm.testCaseId = response.data.test_case_id;
|
||||
vm.testCaseList = [];
|
||||
for (var key in response.data.file_list) {
|
||||
vm.testCaseList.push({
|
||||
input: response.data.file_list[key].input_name,
|
||||
output: response.data.file_list[key].output_name
|
||||
})
|
||||
}
|
||||
vm.uploadSuccess = true;
|
||||
bsAlert("测试数据添加成功!共添加" + vm.testCaseList.length + "组测试数据");
|
||||
}
|
||||
});
|
||||
|
||||
if (avalon.vmodels.admin.contestProblemStatus == "edit") {
|
||||
$.ajax({
|
||||
url: "/api/admin/contest_problem/?contest_problem_id=" + avalon.vmodels.admin.problemId,
|
||||
@ -189,7 +171,7 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert",
|
||||
vm.inputDescription = problem.input_description;
|
||||
vm.outputDescription = problem.output_description;
|
||||
vm.score = problem.score;
|
||||
vm.testCaseId = problem.test_case_id;
|
||||
avalon.vmodels.testCaseUploader.setTestCase(problem.test_case_id);
|
||||
vm.samples = [];
|
||||
for (var i = 0; i < problem.samples.length; i++) {
|
||||
vm.samples.push({
|
||||
@ -199,26 +181,6 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert",
|
||||
})
|
||||
}
|
||||
avalon.vmodels.contestProblemHintEditor.content = problem.hint;
|
||||
$.ajax({
|
||||
url: "/api/admin/test_case_upload/?test_case_id=" + vm.testCaseId,
|
||||
method: "get",
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
if (response.code) {
|
||||
bsAlert(response.data);
|
||||
}
|
||||
else {
|
||||
vm.testCaseList = [];
|
||||
for (var key in response.data.file_list) {
|
||||
vm.testCaseList.push({
|
||||
input: response.data.file_list[key].input_name,
|
||||
output: response.data.file_list[key].output_name
|
||||
})
|
||||
}
|
||||
vm.uploadSuccess = true;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user