前端创建题目界面增加输入描述和输出描述

This commit is contained in:
hohoTT 2015-08-13 18:03:38 +08:00
parent d8d91b7ecd
commit a36dd1d267
3 changed files with 59 additions and 9 deletions

View 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,
),
]

View File

@ -53,10 +53,17 @@ require(["jquery", "avalon", "editor", "uploader", "bs_alert", "csrf", "tagEdito
}
}
},
source: {
input_description: {
validators: {
notEmpty: {
message: "请输入题目来源"
message: "请填写输入描述"
}
}
},
output_description: {
validators: {
notEmpty: {
message: "请填写输出描述"
}
}
}
@ -72,10 +79,6 @@ require(["jquery", "avalon", "editor", "uploader", "bs_alert", "csrf", "tagEdito
bs_alert("题目描述不能为空!");
return;
}
if (vm.hint == '') {
bs_alert("提示不能为空!");
return;
}
var ajaxData = {
title: vm.title,
description: vm.description,
@ -86,6 +89,8 @@ require(["jquery", "avalon", "editor", "uploader", "bs_alert", "csrf", "tagEdito
hint: vm.hint,
source: vm.source,
tags: $("#tags").tagEditor("getTags")[0].tags,
input_description: vm.input_description,
output_description: vm.output_description,
difficulty: vm.difficulty
};
if (vm.samples.length == 0) {
@ -93,6 +98,13 @@ require(["jquery", "avalon", "editor", "uploader", "bs_alert", "csrf", "tagEdito
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) {
bs_alert("请至少添加一个标签,这将有利于用户发现你的题目!");
return;
@ -147,12 +159,14 @@ require(["jquery", "avalon", "editor", "uploader", "bs_alert", "csrf", "tagEdito
description: "",
cpu: 1000,
memory: 256,
samples: [],
samples: [{input: "", output: "", "visible": true}],
hint: "",
visible: true,
difficulty: 0,
tags: [],
tag: "",
input_description: "",
output_description: "",
test_case_id: "",
testCaseList: [],
uploadSuccess: false,

View File

@ -3,12 +3,12 @@
<div class="form-group col-md-12">
<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 class="form-group col-md-12">
<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>
</div>
@ -38,6 +38,16 @@
<label>标签</label><br>
<input type="text" id="tags">
</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>
<label>样例</label>
<a href="javascript:void(0)" class="btn btn-primary btn-sm" ms-click="add_sample()">添加</a>