mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-11-04 14:49:58 +08:00
完善测试用例和样例组件
This commit is contained in:
parent
201611948c
commit
b05d4cbac2
@ -38,19 +38,32 @@
|
|||||||
export default({
|
export default({
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
samples: [{input: "12334", output: "111", visible: true}]
|
samples: [{input: "", output: "", visible: true}]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
setSample(samples) {
|
||||||
|
for(let sample of samples) {
|
||||||
|
sample[visible] = false;
|
||||||
|
}
|
||||||
|
this.samples = samples;
|
||||||
|
},
|
||||||
|
getSample() {
|
||||||
|
var samples = this.samples;
|
||||||
|
for(let sample of samples) {
|
||||||
|
delete sample.visible;
|
||||||
|
}
|
||||||
|
return samples;
|
||||||
|
},
|
||||||
addSample() {
|
addSample() {
|
||||||
this.samples.push({input: "", output: "", visible: true})
|
this.samples.push({input: "", output: "", visible: true});
|
||||||
},
|
},
|
||||||
toggleSample(index) {
|
toggleSample(index) {
|
||||||
this.samples[index].visible = !this.samples[index].visible;
|
this.samples[index].visible = !this.samples[index].visible;
|
||||||
},
|
},
|
||||||
delSample(index) {
|
delSample(index) {
|
||||||
confirm(this.$t("problem.deleteThisSample"), ()=> {
|
confirm(this.$t("problem.deleteThisSample"), ()=> {
|
||||||
this.samples.splice(index, 1)
|
this.samples.splice(index, 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,8 @@
|
|||||||
<a v-show="downloadUrl" v-bind:href="downloadUrl">{{ $t("adminUtils.download") }}</a>
|
<a v-show="downloadUrl" v-bind:href="downloadUrl">{{ $t("adminUtils.download") }}</a>
|
||||||
</label>
|
</label>
|
||||||
<br>
|
<br>
|
||||||
|
<input type="checkbox" v-model="OIMode"> {{ $t("problem.OIMode") }}
|
||||||
|
<br>
|
||||||
<label>{{ $t("problem.uploadProgress") }}</label>
|
<label>{{ $t("problem.uploadProgress") }}</label>
|
||||||
<div class="progress">
|
<div class="progress">
|
||||||
<div class="progress-bar progress-bar-striped" role="progressbar " aria-valuenow="{{ uploadProgress }}"
|
<div class="progress-bar progress-bar-striped" role="progressbar " aria-valuenow="{{ uploadProgress }}"
|
||||||
@ -23,11 +25,13 @@
|
|||||||
<td>ID</td>
|
<td>ID</td>
|
||||||
<td>{{ $t("adminUtils.input") }}</td>
|
<td>{{ $t("adminUtils.input") }}</td>
|
||||||
<td>{{ $t("adminUtils.output") }}</td>
|
<td>{{ $t("adminUtils.output") }}</td>
|
||||||
|
<td v-if="OIMode">{{ $t("problem.score") }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-for="testCase in testCaseList">
|
<tr v-for="testCase in testCaseList">
|
||||||
<td>{{ $index + 1 }}</td>
|
<td>{{ $index + 1 }}</td>
|
||||||
<td>{{ testCase.input }}</td>
|
<td>{{ testCase.input_name }}</td>
|
||||||
<td>{{ testCase.output }}</td>
|
<td>{{ testCase.output_name }}</td>
|
||||||
|
<td v-if="OIMode"><input class="score" v-model="testCase.score" type="number" min="1" required></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -50,7 +54,8 @@
|
|||||||
return {
|
return {
|
||||||
downloadUrl: "",
|
downloadUrl: "",
|
||||||
uploadProgress: 0,
|
uploadProgress: 0,
|
||||||
testCaseList: []
|
testCaseList: [],
|
||||||
|
OIMode: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
@ -58,12 +63,37 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
uploadSuccess(f, response){
|
uploadSuccess(f, response){
|
||||||
alert("success");
|
// todo
|
||||||
},
|
},
|
||||||
uploadError(f, reason){
|
uploadError(f, reason){
|
||||||
this.uploadProgress = 0;
|
this.uploadProgress = 0;
|
||||||
alert("error");
|
alert($t("request.error"));
|
||||||
|
},
|
||||||
|
setTestCase(mode, testCaseList) {
|
||||||
|
this.OIMode = mode == "OI";
|
||||||
|
// attr must be set firstly so vue can track it's changes
|
||||||
|
if (this.OIMode) {
|
||||||
|
for(let item of testCaseList) {
|
||||||
|
item.score = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.testCaseList = testCaseList;
|
||||||
|
},
|
||||||
|
getTestCase() {
|
||||||
|
var testCaseList = this.testCaseList;
|
||||||
|
if (!this.OIMode) {
|
||||||
|
for(let item of testCaseList) {
|
||||||
|
delete item.score;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {testCaseList: testCaseList, mode: this.mode == "OI"};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.score {
|
||||||
|
width: 50px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -60,6 +60,8 @@ export default {
|
|||||||
deleteThisSample: "删除这组样例?",
|
deleteThisSample: "删除这组样例?",
|
||||||
testCase: "测试用例",
|
testCase: "测试用例",
|
||||||
uploadProgress: "上传进度",
|
uploadProgress: "上传进度",
|
||||||
|
OIMode: "OI模式",
|
||||||
|
score: "分数"
|
||||||
|
|
||||||
},
|
},
|
||||||
adminUtils: {
|
adminUtils: {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user