前端创建题目界面增加输入描述和输出描述
This commit is contained in:
26
problem/migrations/0004_auto_20150813_1459.py
Normal file
26
problem/migrations/0004_auto_20150813_1459.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('problem', '0003_auto_20150810_2233'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='problem',
|
||||||
|
name='description_input',
|
||||||
|
field=models.CharField(default='hello', max_length=10000),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='problem',
|
||||||
|
name='description_output',
|
||||||
|
field=models.CharField(default='hello', max_length=10000),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -53,10 +53,17 @@ require(["jquery", "avalon", "editor", "uploader", "bs_alert", "csrf", "tagEdito
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
source: {
|
input_description: {
|
||||||
validators: {
|
validators: {
|
||||||
notEmpty: {
|
notEmpty: {
|
||||||
message: "请输入题目来源"
|
message: "请填写输入描述"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
output_description: {
|
||||||
|
validators: {
|
||||||
|
notEmpty: {
|
||||||
|
message: "请填写输出描述"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,10 +79,6 @@ require(["jquery", "avalon", "editor", "uploader", "bs_alert", "csrf", "tagEdito
|
|||||||
bs_alert("题目描述不能为空!");
|
bs_alert("题目描述不能为空!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (vm.hint == '') {
|
|
||||||
bs_alert("提示不能为空!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var ajaxData = {
|
var ajaxData = {
|
||||||
title: vm.title,
|
title: vm.title,
|
||||||
description: vm.description,
|
description: vm.description,
|
||||||
@@ -86,6 +89,8 @@ require(["jquery", "avalon", "editor", "uploader", "bs_alert", "csrf", "tagEdito
|
|||||||
hint: vm.hint,
|
hint: vm.hint,
|
||||||
source: vm.source,
|
source: vm.source,
|
||||||
tags: $("#tags").tagEditor("getTags")[0].tags,
|
tags: $("#tags").tagEditor("getTags")[0].tags,
|
||||||
|
input_description: vm.input_description,
|
||||||
|
output_description: vm.output_description,
|
||||||
difficulty: vm.difficulty
|
difficulty: vm.difficulty
|
||||||
};
|
};
|
||||||
if (vm.samples.length == 0) {
|
if (vm.samples.length == 0) {
|
||||||
@@ -93,6 +98,13 @@ require(["jquery", "avalon", "editor", "uploader", "bs_alert", "csrf", "tagEdito
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(var i = 0; i < vm.samples.length; i++){
|
||||||
|
if (vm.samples[i].input == "" || vm.samples[i].output == ""){
|
||||||
|
bs_alert("样例输入与样例输出不能为空!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tags.length == 0) {
|
if (tags.length == 0) {
|
||||||
bs_alert("请至少添加一个标签,这将有利于用户发现你的题目!");
|
bs_alert("请至少添加一个标签,这将有利于用户发现你的题目!");
|
||||||
return;
|
return;
|
||||||
@@ -147,12 +159,14 @@ require(["jquery", "avalon", "editor", "uploader", "bs_alert", "csrf", "tagEdito
|
|||||||
description: "",
|
description: "",
|
||||||
cpu: 1000,
|
cpu: 1000,
|
||||||
memory: 256,
|
memory: 256,
|
||||||
samples: [],
|
samples: [{input: "", output: "", "visible": true}],
|
||||||
hint: "",
|
hint: "",
|
||||||
visible: true,
|
visible: true,
|
||||||
difficulty: 0,
|
difficulty: 0,
|
||||||
tags: [],
|
tags: [],
|
||||||
tag: "",
|
tag: "",
|
||||||
|
input_description: "",
|
||||||
|
output_description: "",
|
||||||
test_case_id: "",
|
test_case_id: "",
|
||||||
testCaseList: [],
|
testCaseList: [],
|
||||||
uploadSuccess: false,
|
uploadSuccess: false,
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
|
|
||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-12">
|
||||||
<label>题目标题</label>
|
<label>题目标题</label>
|
||||||
<input type="text" name="title" class="form-control" ms-duplex="title">
|
<input type="text" name="title" autofocus class="form-control" ms-duplex="title">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-12">
|
||||||
<label>题目描述</label>
|
<label>题目描述</label>
|
||||||
<textarea id="problemDescription" placeholder="这里输入内容" autofocus ms-duplex="description"></textarea>
|
<textarea id="problemDescription" placeholder="这里输入内容(此内容不能为空)" ms-duplex="description"></textarea>
|
||||||
<small ms-visible="description==''" style="color:red">请填写题目描述</small>
|
<small ms-visible="description==''" style="color:red">请填写题目描述</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -38,6 +38,16 @@
|
|||||||
<label>标签</label><br>
|
<label>标签</label><br>
|
||||||
<input type="text" id="tags">
|
<input type="text" id="tags">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-12 form-group">
|
||||||
|
<label>输入描述</label><br>
|
||||||
|
<textarea class="form-control" rows="5" name="input_description"
|
||||||
|
ms-duplex="input_description"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-12 form-group">
|
||||||
|
<label>输出描述</label><br>
|
||||||
|
<textarea class="form-control" rows="5" name="output_description"
|
||||||
|
ms-duplex="output_description"></textarea>
|
||||||
|
</div>
|
||||||
<div class="col-md-12"><br>
|
<div class="col-md-12"><br>
|
||||||
<label>样例</label>
|
<label>样例</label>
|
||||||
<a href="javascript:void(0)" class="btn btn-primary btn-sm" ms-click="add_sample()">添加</a>
|
<a href="javascript:void(0)" class="btn btn-primary btn-sm" ms-click="add_sample()">添加</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user