mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-09-21 08:23:20 +00:00
Accept Merge Request #126 新增后台比赛添加,修改,列表功能; avalon重定义问题修复 : (dev-sxw -> dev)
Merge Request: 新增后台比赛添加,修改,列表功能; avalon重定义问题修复 Created By: @esp Accepted By: @virusdefender URL: https://coding.net/u/virusdefender/p/qduoj/git/merge/126
This commit is contained in:
commit
f064ebcf65
19
contest/migrations/0005_contestproblem_score.py
Normal file
19
contest/migrations/0005_contestproblem_score.py
Normal file
@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('contest', '0004_remove_contestproblem_difficulty'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='contestproblem',
|
||||
name='score',
|
||||
field=models.IntegerField(default=0),
|
||||
),
|
||||
]
|
@ -42,6 +42,7 @@ class ContestProblem(AbstractProblem):
|
||||
contest = models.ForeignKey(Contest)
|
||||
# 比如A B 或者1 2 或者 a b 将按照这个排序
|
||||
sort_index = models.CharField(max_length=30)
|
||||
score = models.IntegerField(default=0)
|
||||
|
||||
class Meta:
|
||||
db_table = "contest_problem"
|
||||
|
@ -70,11 +70,11 @@ class CreateContestProblemSerializer(serializers.Serializer):
|
||||
time_limit = serializers.IntegerField()
|
||||
memory_limit = serializers.IntegerField()
|
||||
hint = serializers.CharField(max_length=3000, allow_blank=True)
|
||||
score = serializers.IntegerField(required=False, default=0)
|
||||
sort_index = serializers.CharField(max_length=30)
|
||||
|
||||
|
||||
class ContestProblemSerializer(serializers.ModelSerializer):
|
||||
|
||||
class ContestSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Contest
|
||||
@ -101,10 +101,9 @@ class EditContestProblemSerializer(serializers.Serializer):
|
||||
hint = serializers.CharField(max_length=3000, allow_blank=True)
|
||||
visible = serializers.BooleanField()
|
||||
sort_index = serializers.CharField(max_length=30)
|
||||
score = serializers.IntegerField(required=False, default=0)
|
||||
|
||||
|
||||
class ContestPasswordVerifySerializer(serializers.Serializer):
|
||||
contest_id = serializers.IntegerField()
|
||||
password = serializers.CharField(max_length=30)
|
||||
|
||||
|
||||
|
@ -28,6 +28,9 @@ class ContestAdminAPITest(APITestCase):
|
||||
self.group = Group.objects.create(name="group1", description="des0",
|
||||
join_group_setting=0, visible=True,
|
||||
admin=user2)
|
||||
self.group2 = Group.objects.create(name="group2", description="des0",
|
||||
join_group_setting=0, visible=True,
|
||||
admin=user1)
|
||||
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1,
|
||||
contest_type=2, show_rank=True, show_user_submission=True,
|
||||
start_time="2015-08-15T10:00:00.000Z",
|
||||
@ -78,7 +81,7 @@ class ContestAdminAPITest(APITestCase):
|
||||
response = self.client.post(self.url, data=data)
|
||||
self.assertEqual(response.data["code"], 0)
|
||||
|
||||
def test_group_contest_successfully(self):
|
||||
def test_group_contest_super_admin_successfully(self):
|
||||
self.client.login(username="test1", password="testaa")
|
||||
data = {"title": "title3", "description": "description3", "mode": 1, "contest_type": 0,
|
||||
"show_rank": True, "show_user_submission": True, "start_time": "2015-08-15T10:00:00.000Z",
|
||||
@ -86,6 +89,14 @@ class ContestAdminAPITest(APITestCase):
|
||||
response = self.client.post(self.url, data=data)
|
||||
self.assertEqual(response.data["code"], 0)
|
||||
|
||||
def test_group_contest_admin_successfully(self):
|
||||
self.client.login(username="test2", password="testbb")
|
||||
data = {"title": "title6", "description": "description6", "mode": 2, "contest_type": 0,
|
||||
"show_rank": True, "show_user_submission": True, "start_time": "2015-08-15T10:00:00.000Z",
|
||||
"end_time": "2015-08-15T12:00:00.000Z", "groups": [self.group.id], "visible": True}
|
||||
response = self.client.post(self.url, data=data)
|
||||
self.assertEqual(response.data["code"], 0)
|
||||
|
||||
def test_time_error(self):
|
||||
self.client.login(username="test1", password="testaa")
|
||||
data = {"title": "title2", "description": "description2", "mode": 1, "contest_type": 2,
|
||||
@ -141,6 +152,15 @@ class ContestAdminAPITest(APITestCase):
|
||||
self.assertEqual(response.data["data"]["end_time"], "2015-08-15T13:00:00Z")
|
||||
self.assertEqual(response.data["data"]["visible"], False)
|
||||
|
||||
def test_edit_group_contest_unsuccessfully(self):
|
||||
self.client.login(username="test2", password="testbb")
|
||||
data = {"id": self.group_contest.id, "title": "titleyyy", "description": "descriptionyyyy", "mode": 1,
|
||||
"contest_type": 0, "show_rank": True, "show_user_submission": True,
|
||||
"start_time": "2015-08-15T10:00:00.000Z", "end_time": "2015-08-15T13:00:00.000Z",
|
||||
"groups": [self.group.id], "visible": False}
|
||||
response = self.client.put(self.url, data=data)
|
||||
self.assertEqual(response.data["code"], 1)
|
||||
|
||||
def test_edit_group_at_least_one(self):
|
||||
self.client.login(username="test1", password="testaa")
|
||||
data = {"id": self.group_contest.id, "title": "titleyyy", "description": "descriptionyyyy", "mode": 1,
|
||||
@ -169,7 +189,8 @@ class ContestAdminAPITest(APITestCase):
|
||||
|
||||
def test_edit_global_contest_password_exists(self):
|
||||
self.client.login(username="test1", password="testaa")
|
||||
data = {"id": self.global_contest.id, "title": "title0", "description": "description0", "mode": 1, "contest_type": 2,
|
||||
data = {"id": self.global_contest.id, "title": "title0", "description": "description0", "mode": 1,
|
||||
"contest_type": 2,
|
||||
"show_rank": True, "show_user_submission": True, "start_time": "2015-08-15T10:00:00.000Z",
|
||||
"end_time": "2015-08-15T12:00:00.000Z", "visible": True}
|
||||
response = self.client.put(self.url, data=data)
|
||||
@ -189,6 +210,10 @@ class ContestAdminAPITest(APITestCase):
|
||||
self.client.login(username="test1", password="testaa")
|
||||
self.assertEqual(self.client.get(self.url).data["code"], 0)
|
||||
|
||||
def test_get_data_successfully_by_normal_admin(self):
|
||||
self.client.login(username="test2", password="testbb")
|
||||
self.assertEqual(self.client.get(self.url).data["code"], 0)
|
||||
|
||||
def test_keyword_contest(self):
|
||||
self.client.login(username="test1", password="testaa")
|
||||
response = self.client.get(self.url + "?visible=true")
|
||||
@ -209,6 +234,12 @@ class ContestProblemAdminAPItEST(APITestCase):
|
||||
self.user = User.objects.create(username="test1", admin_type=SUPER_ADMIN)
|
||||
self.user.set_password("testaa")
|
||||
self.user.save()
|
||||
self.user2 = User.objects.create(username="test2", admin_type=ADMIN)
|
||||
self.user2.set_password("testaa")
|
||||
self.user2.save()
|
||||
self.user3 = User.objects.create(username="test3", admin_type=ADMIN)
|
||||
self.user3.set_password("testaa")
|
||||
self.user3.save()
|
||||
self.client.login(username="test1", password="testaa")
|
||||
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1,
|
||||
contest_type=2, show_rank=True, show_user_submission=True,
|
||||
@ -311,6 +342,10 @@ class ContestProblemAdminAPItEST(APITestCase):
|
||||
self.client.login(username="test1", password="testaa")
|
||||
self.assertEqual(self.client.get(self.url).data["code"], 0)
|
||||
|
||||
def test_get_data_unsuccessfully(self):
|
||||
self.client.login(username="test1", password="testaa")
|
||||
self.assertEqual(self.client.get(self.url+"?contest_id=12").data["code"], 1)
|
||||
|
||||
def test_keyword_contest(self):
|
||||
self.client.login(username="test1", password="testaa")
|
||||
response = self.client.get(self.url + "?visible=true")
|
||||
@ -333,4 +368,33 @@ class ContestProblemAdminAPItEST(APITestCase):
|
||||
response = self.client.get(self.url, data=data)
|
||||
self.assertEqual(response.data["code"], 0)
|
||||
|
||||
def test_query_contest_problem_exists_by_contest_id(self):
|
||||
self.client.login(username="test3", password="testaa")
|
||||
response = self.client.get(self.url + "?contest_id=1")
|
||||
self.assertEqual(response.data["code"], 0)
|
||||
self.assertEqual(len(response.data["data"]), 0)
|
||||
|
||||
def test_query_contest_problem_exists_by_normal_admin(self):
|
||||
self.client.login(username="test2", password="testaa")
|
||||
data = {"contest_problem_id": self.contest_problem.id}
|
||||
response = self.client.get(self.url, data=data)
|
||||
self.assertEqual(response.data["code"], 0)
|
||||
|
||||
def test_edit_problem_unsuccessfully_can_not_access(self):
|
||||
self.client.login(username="test2", password="testaa")
|
||||
data = {"id": self.contest_problem.id,
|
||||
"title": "title2222222",
|
||||
"description": "description22222222",
|
||||
"input_description": "input_description2",
|
||||
"output_description": "output_description2",
|
||||
"test_case_id": "1",
|
||||
"source": "source1",
|
||||
"samples": [{"input": "1 1", "output": "2"}],
|
||||
"time_limit": "100",
|
||||
"memory_limit": "1000",
|
||||
"hint": "hint1",
|
||||
"sort_index": "b",
|
||||
"visible": True}
|
||||
response = self.client.put(self.url, data=data)
|
||||
self.assertEqual(response.data["code"], 1)
|
||||
|
||||
|
@ -107,6 +107,8 @@ class ContestAdminAPIView(APIView):
|
||||
return error_response(u"请至少选择一个小组")
|
||||
if data["start_time"] >= data["end_time"]:
|
||||
return error_response(u"比赛的开始时间不能晚于或等于比赛结束的时间")
|
||||
if request.user.admin_type != SUPER_ADMIN and request.user != contest.created_by:
|
||||
return error_response(u"你无权修改该比赛!")
|
||||
contest.title = data["title"]
|
||||
contest.description = data["description"]
|
||||
contest.mode = data["mode"]
|
||||
@ -131,7 +133,10 @@ class ContestAdminAPIView(APIView):
|
||||
---
|
||||
response_serializer: ContestSerializer
|
||||
"""
|
||||
if request.user.admin_type == SUPER_ADMIN:
|
||||
contest = Contest.objects.all().order_by("-last_updated_time")
|
||||
else:
|
||||
contest = Contest.objects.filter(created_by=request.user).order_by("-last_updated_time")
|
||||
visible = request.GET.get("visible", None)
|
||||
if visible:
|
||||
contest = contest.filter(visible=(visible == "true"))
|
||||
@ -168,7 +173,8 @@ class ContestProblemAdminAPIView(APIView):
|
||||
created_by=request.user,
|
||||
hint=data["hint"],
|
||||
contest=contest,
|
||||
sort_index=data["sort_index"])
|
||||
sort_index=data["sort_index"],
|
||||
score=data["score"])
|
||||
return success_response(ContestProblemSerializer(contest_problem).data)
|
||||
else:
|
||||
return serializer_invalid_response(serializer)
|
||||
@ -183,10 +189,14 @@ class ContestProblemAdminAPIView(APIView):
|
||||
serializer = EditContestProblemSerializer(data=request.data)
|
||||
if serializer.is_valid():
|
||||
data = serializer.data
|
||||
|
||||
try:
|
||||
contest_problem = ContestProblem.objects.get(id=data["id"])
|
||||
except ContestProblem.DoesNotExist:
|
||||
return error_response(u"该比赛题目不存在!")
|
||||
contest = Contest.objects.get(id=contest_problem.contest_id)
|
||||
if request.user.admin_type != SUPER_ADMIN and contest.created_by != request.user:
|
||||
return error_response(u"你无权修改该题目!")
|
||||
contest_problem.title = data["title"]
|
||||
contest_problem.description = data["description"]
|
||||
contest_problem.input_description = data["input_description"]
|
||||
@ -198,6 +208,7 @@ class ContestProblemAdminAPIView(APIView):
|
||||
contest_problem.hint = data["hint"]
|
||||
contest_problem.visible = data["visible"]
|
||||
contest_problem.sort_index = data["sort_index"]
|
||||
contest_problem.score = data["score"]
|
||||
contest_problem.save()
|
||||
return success_response(ContestProblemSerializer(contest_problem).data)
|
||||
else:
|
||||
@ -216,7 +227,10 @@ class ContestProblemAdminAPIView(APIView):
|
||||
return success_response(ContestProblemSerializer(contest_problem).data)
|
||||
except ContestProblem.DoesNotExist:
|
||||
return error_response(u"比赛题目不存在")
|
||||
if request.user.admin_type == SUPER_ADMIN:
|
||||
contest_problem = ContestProblem.objects.all().order_by("sort_index")
|
||||
else:
|
||||
contest_problem = ContestProblem.objects.filter(created_by=request.user).order_by("sort_index")
|
||||
visible = request.GET.get("visible", None)
|
||||
if visible:
|
||||
contest_problem = contest_problem.filter(visible=(visible == "true"))
|
||||
@ -224,6 +238,13 @@ class ContestProblemAdminAPIView(APIView):
|
||||
if keyword:
|
||||
contest_problem = contest_problem.filter(Q(title__contains=keyword) |
|
||||
Q(description__contains=keyword))
|
||||
contest_id = request.GET.get("contest_id", None)
|
||||
if contest_id:
|
||||
try:
|
||||
contest = Contest.objects.get(id=contest_id)
|
||||
except Contest.DoesNotExist:
|
||||
return error_response(u"该比赛不存在!")
|
||||
contest_problem = contest_problem.filter(contest=contest).order_by("sort_index")
|
||||
|
||||
return paginate(request, contest_problem, ContestProblemSerializer)
|
||||
|
||||
@ -339,6 +360,3 @@ def contest_list_page(request, page=1):
|
||||
"keyword": keyword, "announcements": announcements,
|
||||
"join": join})
|
||||
|
||||
|
||||
|
||||
|
||||
|
5
static/src/css/contest/add_contest.css
Normal file
5
static/src/css/contest/add_contest.css
Normal file
@ -0,0 +1,5 @@
|
||||
.group-tag {
|
||||
padding-left: 5px; color: #46799b; background: #e0eaf1; white-space: nowrap;
|
||||
overflow: hidden; cursor: pointer; border-radius: 2px 0 0 2px;
|
||||
float: left; padding: 0 4px;box-sizing: border-box;list-style-type: none; margin: 5px;
|
||||
}
|
@ -75,6 +75,9 @@ define("admin", ["jquery", "avalon"], function ($, avalon) {
|
||||
groupId: -1,
|
||||
problemId: -1,
|
||||
adminNavList: [],
|
||||
$contestMode: -1,
|
||||
$problemId: -1,
|
||||
$contestId: -1,
|
||||
hide_loading: function () {
|
||||
$("#loading-gif").hide();
|
||||
},
|
||||
@ -123,6 +126,18 @@ define("admin", ["jquery", "avalon"], function ($, avalon) {
|
||||
vm.template_url = "template/problem/submission_list.html";
|
||||
});
|
||||
|
||||
vm.$watch("showContestProblemPage", function (problemId, contestId, contestMode) {
|
||||
vm.$problemId = problemId;
|
||||
vm.$contestId = contestId;
|
||||
vm.$contestMode = contestMode
|
||||
vm.template_url = "template/contest/edit_problem.html";
|
||||
});
|
||||
|
||||
vm.$watch("showContestListPage", function (problemId) {
|
||||
vm.problemId = problemId;
|
||||
vm.template_url = "template/contest/contest_list.html";
|
||||
});
|
||||
|
||||
avalon.scan();
|
||||
|
||||
window.onhashchange = function () {
|
||||
|
@ -1,7 +1,8 @@
|
||||
require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "datetimePicker",
|
||||
"validator"],
|
||||
function ($, avalon, editor, uploader, bsAlert, csrfTokenHeader) {
|
||||
avalon.vmodels.add_contest = null;
|
||||
|
||||
//avalon.vmodels.add_contest = null;
|
||||
$("#add-contest-form").validator().on('submit', function (e) {
|
||||
if (!e.isDefaultPrevented()){
|
||||
e.preventDefault();
|
||||
@ -12,16 +13,22 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "date
|
||||
contest_type: 0,
|
||||
show_rank: vm.showRank,
|
||||
show_user_submission: vm.showSubmission,
|
||||
//password: vm.password,
|
||||
start_time: vm.startTime,
|
||||
end_time: vm.endTime,
|
||||
visible: true
|
||||
visible: false
|
||||
};
|
||||
if (vm.choseGroupList[0].id == 0) //everyone | public contest
|
||||
if (vm.password == "")
|
||||
ajaxData.contest_type = 1;
|
||||
else{
|
||||
if (vm.choseGroupList.length == 0) {
|
||||
bsAlert("你没有选择参赛用户!");
|
||||
return false;
|
||||
}
|
||||
if (vm.choseGroupList[0].id == 0) { //everyone | public contest
|
||||
if (vm.password) {
|
||||
ajaxData.password = vm.password;
|
||||
ajaxData.contest_type = 2;
|
||||
}
|
||||
else{
|
||||
ajaxData.contest_type = 1;
|
||||
}
|
||||
}
|
||||
else { // Add groups info
|
||||
ajaxData.groups = [];
|
||||
@ -29,9 +36,8 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "date
|
||||
ajaxData.groups.push(parseInt(vm.choseGroupList[i].id))
|
||||
}
|
||||
|
||||
|
||||
console.log(ajaxData);
|
||||
$.ajax({
|
||||
$.ajax({ // Add contest
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: "/api/admin/contest/",
|
||||
dataType: "json",
|
||||
@ -41,8 +47,20 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "date
|
||||
contentType: "application/json",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
bsAlert("添加成功!");
|
||||
console.log(data);
|
||||
bsAlert("添加成功!将转到比赛列表页以便为比赛添加问题(注意比赛当前状态为:隐藏)");
|
||||
vm.title = "";
|
||||
vm.description = "";
|
||||
vm.startTime = "";
|
||||
vm.endTime = "";
|
||||
vm.password = "";
|
||||
vm.mode = "";
|
||||
vm.showRank = false;
|
||||
vm.showSubmission = false;
|
||||
vm.group = "-1";
|
||||
vm.groupList = [];
|
||||
vm.choseGroupList = [];
|
||||
vm.passwordUsable = false;
|
||||
location.hash = "#contest/contest_list";
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
@ -56,9 +74,9 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "date
|
||||
});
|
||||
|
||||
editor("#editor");
|
||||
editor("#problemDescriptionEditor");
|
||||
editor("#problemHintEditor");
|
||||
|
||||
if (avalon.vmodels.add_contest)
|
||||
var vm = avalon.vmodels.add_contest;
|
||||
else
|
||||
var vm = avalon.define({
|
||||
$id: "add_contest",
|
||||
title: "",
|
||||
@ -69,76 +87,10 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "date
|
||||
mode: "",
|
||||
showRank: false,
|
||||
showSubmission: false,
|
||||
problems: [],
|
||||
editingProblemId: 0,
|
||||
editSamples: [],
|
||||
editTestCaseList: [],
|
||||
group: "-1",
|
||||
groupList: [],
|
||||
choseGroupList: [],
|
||||
showProblemEditArea: function (problemIndex) {
|
||||
if (vm.editingProblemId == problemIndex){
|
||||
vm.problems[vm.editingProblemId-1].samples = vm.editSamples;
|
||||
vm.editingProblemId = 0;
|
||||
}
|
||||
else {
|
||||
if (vm.editingProblemId)
|
||||
{
|
||||
vm.problems[vm.editingProblemId-1].samples = vm.editSamples;
|
||||
vm.problems[vm.editingProblemId-1].testCaseList = vm.editTestCaseList;
|
||||
}
|
||||
vm.editingProblemId = problemIndex;
|
||||
vm.editSamples = [];
|
||||
vm.editSamples = vm.problems[vm.editingProblemId-1].samples;
|
||||
vm.editTestCaseList = [];
|
||||
vm.editTestCaseList = vm.problems[vm.editingProblemId-1].testCaseList;
|
||||
}
|
||||
},
|
||||
passwordUsable: false,
|
||||
add_problem: function () {
|
||||
var problem = {
|
||||
title: "",
|
||||
timeLimit: 1000,
|
||||
memoryLimit: 256,
|
||||
description: "",
|
||||
samples: [],
|
||||
visible: true,
|
||||
test_case_id: "",
|
||||
testCaseList: [],
|
||||
hint: "",
|
||||
score: 0,
|
||||
uploadSuccess: false,
|
||||
};
|
||||
vm.problems.push(problem);
|
||||
vm.showProblemEditArea(vm.problems.length);
|
||||
},
|
||||
del_problem: function (problemIndex) {
|
||||
if (confirm("你确定要删除么?")) {
|
||||
vm.editingProblemId = 0;
|
||||
vm.problems.remove(vm.problems[problemIndex-1]);
|
||||
}
|
||||
},
|
||||
hidden: function () {
|
||||
vm.problems[vm.editingProblemId-1].samples = editSamples;
|
||||
vm.problems[vm.editingProblemId-1].testCaseList = editTestCaseList;
|
||||
vm.editingProblemId = 0;
|
||||
},
|
||||
toggle: function (item) {
|
||||
item.visible = !item.visible;
|
||||
},
|
||||
add_sample: function () {
|
||||
vm.editSamples.push({visible: true, input: "", output: ""});
|
||||
},
|
||||
del_sample: function (sample) {
|
||||
if (confirm("你确定要删除么?")) {
|
||||
editSamples.remove(sample);
|
||||
}
|
||||
},
|
||||
getBtnContent: function (item) {
|
||||
if (item.visible)
|
||||
return "折叠";
|
||||
return "展开";
|
||||
},
|
||||
addGroup: function() {
|
||||
if (vm.group == -1) return;
|
||||
if (vm.groupList[vm.group].id == 0){
|
||||
@ -150,8 +102,9 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "date
|
||||
}
|
||||
vm.groupList[vm.group]. chose = true;
|
||||
vm.choseGroupList.push({name:vm.groupList[vm.group].name, index:vm.group, id:vm.groupList[vm.group].id});
|
||||
vm.group = -1;
|
||||
},
|
||||
unchose: function(groupIndex){
|
||||
removeGroup: function(groupIndex){
|
||||
if (vm.groupList[vm.choseGroupList[groupIndex].index].id == 0){
|
||||
vm.passwordUsable = false;
|
||||
for (key in vm.groupList){
|
||||
@ -163,56 +116,41 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "date
|
||||
}
|
||||
});
|
||||
|
||||
var isSuperAdmin = true;
|
||||
$.ajax({ //用于获取该用户创建的所有小组的ajax请求
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: "/api/admin/group/?my_group=true",
|
||||
dataType: "json",
|
||||
$.ajax({ // Get current user type
|
||||
url: "/api/user/",
|
||||
method: "get",
|
||||
contentType: "application/json",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
if (isSuperAdmin)
|
||||
if (data.data.admin_type == 2) { // Is super user
|
||||
vm.isGlobal = true;
|
||||
vm.groupList.push({id:0,name:"所有人",chose:false});
|
||||
for (var key in data.data) {
|
||||
data.data[key].chose = false;
|
||||
vm.groupList.push(data.data[key]);
|
||||
}
|
||||
$.ajax({ // Get the group list of current user
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: "/api/admin/group/",
|
||||
method: "get",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
if (!data.data.length) {
|
||||
bsAlert("您的用户权限只能创建组内比赛,但是您还没有创建过小组");
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < data.data.length; i++) {
|
||||
var item = data.data[i];
|
||||
item["chose"] = false;
|
||||
vm.groupList.push(item);
|
||||
}
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
console.log(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
uploader("#uploader", "/api/admin/test_case_upload/", function (file, respond) {
|
||||
if (respond.code)
|
||||
bsAlert(respond.data);
|
||||
else {
|
||||
vm.problems[vm.editingProblemId-1].test_case_id = respond.data.test_case_id;
|
||||
vm.problems[vm.editingProblemId-1].uploadSuccess = true;
|
||||
vm.editTestCaseList = [];
|
||||
for (var i = 0; i < respond.data.file_list.input.length; i++) {
|
||||
vm.editTestCaseList.push({
|
||||
input: respond.data.file_list.input[i],
|
||||
output: respond.data.file_list.output[i]
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
vm.problems[vm.editingProblemId-1].testCaseList = vm.editTestCaseList;
|
||||
bsAlert("测试数据添加成功!共添加"+vm.editTestCaseList.length +"组测试数据");
|
||||
}
|
||||
},
|
||||
function(){
|
||||
if (vm.editingProblemId == 0)
|
||||
{
|
||||
bsAlert("你还未指定一道题目!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
avalon.scan();
|
||||
|
||||
|
@ -1,11 +1,96 @@
|
||||
require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker"], function ($, avalon, csrfTokenHeader, bsAlert, editor) {
|
||||
require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker", "validator"], function ($, avalon, csrfTokenHeader, bsAlert, editor) {
|
||||
|
||||
avalon.ready(function () {
|
||||
if (avalon.vmodels.contestList) {
|
||||
vm = avalon.vmodels.contestList;
|
||||
vm.editingContest = 0;
|
||||
|
||||
$("#edit-contest-form").validator().on('submit', function (e) {
|
||||
if (!e.isDefaultPrevented()){
|
||||
e.preventDefault();
|
||||
var ajaxData = {
|
||||
id: vm.contestList[vm.editingContestId-1].id,
|
||||
title: vm.editTitle,
|
||||
description: vm.editDescription,
|
||||
mode: vm.editMode,
|
||||
contest_type: 0,
|
||||
show_rank: vm.editShowRank,
|
||||
show_user_submission: vm.editShowSubmission,
|
||||
start_time: vm.editStartTime,
|
||||
end_time: vm.editEndTime,
|
||||
visible: vm.editVisible
|
||||
};
|
||||
if (vm.choseGroupList.length == 0) {
|
||||
bsAlert("你没有选择参赛用户!");
|
||||
return false;
|
||||
}
|
||||
if (vm.choseGroupList[0].id == 0) { //everyone | public contest
|
||||
if (vm.editPassword) {
|
||||
ajaxData.password = vm.editPassword;
|
||||
ajaxData.contest_type = 2;
|
||||
}
|
||||
else{
|
||||
ajaxData.contest_type = 1;
|
||||
}
|
||||
}
|
||||
else { // Add groups info
|
||||
ajaxData.groups = [];
|
||||
for (var i = 0; vm.choseGroupList[i]; i++)
|
||||
ajaxData.groups.push(parseInt(vm.choseGroupList[i].id))
|
||||
}
|
||||
|
||||
console.log(ajaxData);
|
||||
$.ajax({ // Add contest
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: "/api/admin/contest/",
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(ajaxData),
|
||||
method: "put",
|
||||
contentType: "application/json",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
bsAlert("修改成功!");
|
||||
console.log(data);
|
||||
vm.getPage(1);
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
console.log(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
console.log(JSON.stringify(ajaxData));
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if(avalon.vmodels.contestList){
|
||||
// this page has been loaded before, so set the default value
|
||||
var vm = avalon.vmodels.contestList;
|
||||
vm.contestList= [];
|
||||
vm.previousPage= 0;
|
||||
vm.nextPage= 0;
|
||||
vm.page= 1;
|
||||
vm.totalPage= 1;
|
||||
vm.group= "-1";
|
||||
vm.groupList= [];
|
||||
vm.choseGroupList= [];
|
||||
vm.passwordUsable= false;
|
||||
vm.keyword= "";
|
||||
vm.editingContestId= 0;
|
||||
vm.editTitle= "";
|
||||
vm.editDescription= "";
|
||||
vm.editProblemList= [];
|
||||
vm.editPassword= "";
|
||||
vm.editStartTime= "";
|
||||
vm.editEndTime= "";
|
||||
vm.editMode= "";
|
||||
vm.editShowRank= false;
|
||||
vm.editShowSubmission= false;
|
||||
vm.editProblemList= [];
|
||||
vm.editVisible= false;
|
||||
vm.editChoseGroupList= [];
|
||||
vm.editingProblemContestIndex= 0;
|
||||
}
|
||||
else
|
||||
var vm = avalon.define({
|
||||
$id: "contestList",
|
||||
contestList: [],
|
||||
@ -15,9 +100,12 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker"]
|
||||
totalPage: 1,
|
||||
group: "-1",
|
||||
groupList: [],
|
||||
choseGroupList: [],
|
||||
passwordUsable: false,
|
||||
keyword: "",
|
||||
editingContestId: 0,
|
||||
editTitle: "",
|
||||
editDescription: "",
|
||||
editProblemList: [],
|
||||
editPassword: "",
|
||||
editStartTime: "",
|
||||
@ -26,12 +114,9 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker"]
|
||||
editShowRank: false,
|
||||
editShowSubmission: false,
|
||||
editProblemList: [],
|
||||
editingProblemId: 0,
|
||||
editSamples: [],
|
||||
editTestCaseList: [],
|
||||
editVisible: false,
|
||||
editChoseGroupList: [],
|
||||
modelNameList: ["ACM", "AC总数", "分数"],
|
||||
contestTypeNameList: ["小组赛", "公开赛", "有密码保护的公开赛"],
|
||||
editingProblemContestIndex: 0,
|
||||
getNext: function () {
|
||||
if (!vm.nextPage)
|
||||
return;
|
||||
@ -59,35 +144,125 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker"]
|
||||
else {
|
||||
vm.editingContestId = contestId;
|
||||
vm.editTitle = vm.contestList[contestId-1].title;
|
||||
vm.editEndTime = vm.contestList[contestId - 1].end_time;
|
||||
vm.editPassword = vm.contestList[contestId-1].password;
|
||||
vm.editStartTime = vm.contestList[contestId - 1].start_time;
|
||||
vm.editStartTime = vm.contestList[contestId-1].start_time.substring(0,16).replace("T"," ");
|
||||
vm.editEndTime = vm.contestList[contestId-1].end_time.substring(0,16).replace("T"," ");
|
||||
vm.editMode = vm.contestList[contestId-1].mode;
|
||||
vm.editChoseGroupList = [];
|
||||
//= vm.contestList[contestId-1].group;//
|
||||
/*for (var key in vm.contestList[contestId-1].groups){
|
||||
var id = parseInt(vm.contestList[contestId-1].groups);
|
||||
for ()
|
||||
vm.editChoseGroupList.push({
|
||||
name:vm.groupList[vm.group].name,
|
||||
editVisible = vm.contestList[contestId-1].visible;
|
||||
if (vm.contestList[contestId-1].contest_type == 0) { //contest type == 0, contest in group
|
||||
//Clear the choseGroupList
|
||||
var stack = [], sp;
|
||||
for (sp = 0; sp < vm.choseGroupList.length; sp++){
|
||||
stack. push(vm.choseGroupList[sp].index);
|
||||
}
|
||||
while (sp--){
|
||||
vm.removeGroup(stack[sp]);
|
||||
}
|
||||
|
||||
for (var i = 0; i < vm.contestList[contestId-1].groups.length; i++){
|
||||
var id = parseInt(vm.contestList[contestId-1].groups[i]);
|
||||
var index = 0;
|
||||
for (; vm.groupList[index]; index++) {
|
||||
if (vm.groupList[index].id == id)
|
||||
break;
|
||||
}
|
||||
vm.groupList[index].chose = true;
|
||||
vm.choseGroupList.push({
|
||||
name:vm.groupList[index].name,
|
||||
index:index,
|
||||
id:parseInt(vm.contestList[contestId-1].groups)
|
||||
id:id
|
||||
});
|
||||
}*/
|
||||
}
|
||||
}
|
||||
else{
|
||||
vm.group = "0";
|
||||
vm.addGroup()//vm.editChoseGroupList = [0]; id 0 is for the group of everyone~
|
||||
}
|
||||
vm.editShowRank = vm.contestList[contestId-1].show_rank;
|
||||
vm.editShowSubmission = vm.contestList[contestId-1].show_user_submission;
|
||||
//vm.editProblemList = vm.contestList[contestId-1].problems
|
||||
editor("#editor").setValue(vm.contestList[contestId-1].description);
|
||||
vm.editingProblemList = vm.contestList[contestId - 1].problemList;
|
||||
vm.editingProblemContestIndex = 0;
|
||||
}
|
||||
},
|
||||
showEditProblemArea: function(contestId) {
|
||||
if (vm.editingProblemContestIndex == contestId) {
|
||||
vm.editingProblemContestIndex = 0;
|
||||
return;
|
||||
}
|
||||
if (vm.editingContestId&&!confirm("如果继续将丢失未保存的信息,是否继续?")){
|
||||
return;
|
||||
}
|
||||
$.ajax({ // Get the problem list of current contest
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: "/api/admin/contest_problem/?contest_id=" + vm.contestList[contestId-1].id,
|
||||
method: "get",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
vm.editProblemList = data.data;
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
getPageData(1);
|
||||
vm.editingContestId = 0;
|
||||
vm.editingProblemContestIndex = contestId;
|
||||
vm.editMode = vm.contestList[contestId-1].mode;
|
||||
},
|
||||
addGroup: function() {
|
||||
if (vm.group == -1) return;
|
||||
if (vm.groupList[vm.group].id == 0){
|
||||
vm.passwordUsable = true;
|
||||
vm.choseGroupList = [];
|
||||
for (var key in vm.groupList){
|
||||
vm.groupList[key].chose = true;
|
||||
}
|
||||
}
|
||||
vm.groupList[vm.group]. chose = true;
|
||||
// index of the group is relative. It is related to user
|
||||
vm.choseGroupList.push({name:vm.groupList[vm.group].name, index:vm.group, id:vm.groupList[vm.group].id});
|
||||
vm.group = -1;
|
||||
},
|
||||
removeGroup: function(groupIndex){
|
||||
if (vm.groupList[vm.choseGroupList[groupIndex].index].id == 0){
|
||||
vm.passwordUsable = false;
|
||||
for (key in vm.groupList){
|
||||
vm.groupList[key].chose = false;
|
||||
}
|
||||
}
|
||||
vm.groupList[vm.choseGroupList[groupIndex].index].chose = false;
|
||||
vm.choseGroupList.remove(vm.choseGroupList[groupIndex]);
|
||||
},
|
||||
add_problem: function () {
|
||||
vm.$fire("up!showContestProblemPage", 0, vm.contestList[vm.editingProblemContestIndex-1].id, vm.editMode);
|
||||
},
|
||||
showProblemEditor: function(el) {
|
||||
console.log(el);
|
||||
vm.$fire("up!showContestProblemPage", el.id, vm.contestList[vm.editingProblemContestIndex-1].id, vm.editMode);
|
||||
},
|
||||
getYesOrNo: function(yORn) {
|
||||
if (yORn) return "是";
|
||||
return "否";
|
||||
}
|
||||
});
|
||||
getPageData(1);
|
||||
|
||||
//init time picker
|
||||
$("#contest_start_time").datetimepicker({
|
||||
format: "yyyy-mm-dd hh:ii",
|
||||
minuteStep: 5,
|
||||
weekStart: 1,
|
||||
language: "zh-CN"
|
||||
});
|
||||
$("#contest_end_time").datetimepicker({
|
||||
format: "yyyy-mm-dd hh:ii",
|
||||
minuteStep: 5,
|
||||
weekStart: 1,
|
||||
language: "zh-CN"
|
||||
});
|
||||
|
||||
function getPageData(page) {
|
||||
|
||||
var url = "/api/admin/contest/?paging=true&page=" + page + "&page_size=10";
|
||||
if (vm.keyword != "")
|
||||
url += "&keyword=" + vm.keyword;
|
||||
@ -109,18 +284,26 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker"]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var isSuperAdmin = true;
|
||||
|
||||
$.ajax({ //用于获取该用户创建的所有小组的ajax请求
|
||||
|
||||
// Get group list
|
||||
$.ajax({ // Get current user type
|
||||
url: "/api/user/",
|
||||
method: "get",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
if (data.data.admin_type == 2) { // Is super user
|
||||
vm.isGlobal = true;
|
||||
vm.groupList.push({id:0,name:"所有人",chose:false});
|
||||
}
|
||||
$.ajax({ // Get the group list of current user
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: "/api/admin/group/",
|
||||
method: "get",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
if (!data.data.length) {
|
||||
bsAlert("您的用户权限只能创建组内比赛,但是您还没有创建过小组");
|
||||
//this user have no group can use
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < data.data.length; i++) {
|
||||
@ -134,6 +317,10 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker"]
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
avalon.scan();
|
||||
});
|
||||
|
203
static/src/js/app/admin/contest/edit_problem.js
Normal file
203
static/src/js/app/admin/contest/edit_problem.js
Normal file
@ -0,0 +1,203 @@
|
||||
require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "tagEditor", "validator", "jqueryUI"],
|
||||
function ($, avalon, editor, uploader, bsAlert, csrfTokenHeader) {
|
||||
|
||||
avalon.ready(function () {
|
||||
|
||||
$("#edit-problem-form").validator()
|
||||
.on('submit', function (e) {
|
||||
if (!e.isDefaultPrevented()){
|
||||
e.preventDefault();
|
||||
if (vm.testCaseId == "") {
|
||||
bsAlert("你还没有上传测试数据!");
|
||||
return false;
|
||||
}
|
||||
if (vm.description == "") {
|
||||
bsAlert("题目描述不能为空!");
|
||||
return false;
|
||||
}
|
||||
if (vm.timeLimit < 1000 || vm.timeLimit > 5000) {
|
||||
bsAlert("保证时间限制是一个1000-5000的合法整数");
|
||||
return false;
|
||||
}
|
||||
if (vm.samples.length == 0) {
|
||||
bsAlert("请至少添加一组样例!");
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < vm.samples.length; i++) {
|
||||
if (vm.samples[i].input == "" || vm.samples[i].output == "") {
|
||||
bsAlert("样例输入与样例输出不能为空!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var ajaxData = {
|
||||
title: vm.title,
|
||||
description: vm.description,
|
||||
time_limit: vm.timeLimit,
|
||||
memory_limit: vm.memoryLimit,
|
||||
samples: [],
|
||||
test_case_id: vm.testCaseId,
|
||||
hint: vm.hint,
|
||||
visible: vm.visible,
|
||||
contest_id: avalon.vmodels.admin.$contestId,
|
||||
input_description: vm.inputDescription,
|
||||
output_description: vm.outputDescription,
|
||||
sort_index: vm.sortIndex,
|
||||
};
|
||||
if (vm.contestMode == '2') {
|
||||
if (!vm.score) {
|
||||
bsAlert("请输入有效的分值!")
|
||||
return false;
|
||||
}
|
||||
ajaxData.score = vm.score;
|
||||
}
|
||||
var method = "post";
|
||||
if (avalon.vmodels.admin.$problemId) {
|
||||
method = "put";
|
||||
ajaxData.id = avalon.vmodels.admin.$problemId;
|
||||
}
|
||||
|
||||
for (var i = 0; i < vm.samples.$model.length; i++) {
|
||||
ajaxData.samples.push({input: vm.samples.$model[i].input, output: vm.samples.$model[i].output});
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: "/api/admin/contest_problem/",
|
||||
dataType: "json",
|
||||
data: JSON.stringify(ajaxData),
|
||||
method: method,
|
||||
contentType: "application/json",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
bsAlert("题目编辑成功!");
|
||||
vm.goBack(true);
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (!avalon.vmodels.editProblem)
|
||||
var vm = avalon.define({
|
||||
$id: "editProblem",
|
||||
title: "",
|
||||
description: "",
|
||||
timeLimit: 0,
|
||||
memoryLimit: 0,
|
||||
samples: [],
|
||||
hint: "",
|
||||
sortIndex: "",
|
||||
visible: true,
|
||||
inputDescription: "",
|
||||
outputDescription: "",
|
||||
testCaseIdd: "",
|
||||
contestMode: 0,
|
||||
score: 1,
|
||||
uploadSuccess: false,
|
||||
testCaseList: [],
|
||||
addSample: function () {
|
||||
vm.samples.push({input: "", output: "", "visible": true});
|
||||
},
|
||||
delSample: function (sample) {
|
||||
if (confirm("你确定要删除么?")) {
|
||||
vm.samples.remove(sample);
|
||||
}
|
||||
},
|
||||
toggleSample: function (sample) {
|
||||
sample.visible = !sample.visible;
|
||||
},
|
||||
getBtnContent: function (item) {
|
||||
if (item.visible)
|
||||
return "折叠";
|
||||
return "展开";
|
||||
},
|
||||
goBack: function(check){
|
||||
if (check||confirm("这将丢失所有的改动,确定要继续么?")) {
|
||||
vm.$fire("up!showContestListPage");
|
||||
}
|
||||
}
|
||||
});
|
||||
else
|
||||
vm = avalon.vmodels.editProblem;
|
||||
|
||||
var hintEditor = editor("#hint");
|
||||
var descriptionEditor = editor("#problemDescription");
|
||||
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.uploadSuccess = true;
|
||||
vm.testCaseList = [];
|
||||
for (var i = 0; i < response.data.file_list.input.length; i++) {
|
||||
vm.testCaseList.push({
|
||||
input: response.data.file_list.input[i],
|
||||
output: response.data.file_list.output[i]
|
||||
});
|
||||
}
|
||||
bsAlert("测试数据添加成功!共添加" + vm.testCaseList.length + "组测试数据");
|
||||
}
|
||||
});
|
||||
|
||||
vm.contestMode = avalon.vmodels.admin.$contestMode;
|
||||
if (avalon.vmodels.admin.$problemId){
|
||||
$.ajax({
|
||||
url: "/api/admin/contest_problem/?contest_problem_id=" + avalon.vmodels.admin.$problemId,
|
||||
method: "get",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code) {
|
||||
bsAlert(data.data);
|
||||
}
|
||||
else { // Edit mode load the problem data
|
||||
var problem = data.data;
|
||||
vm.testCaseList = [];
|
||||
vm.sortIndex = problem.sort_index;
|
||||
vm.title = problem.title;
|
||||
vm.description = problem.description;
|
||||
vm.timeLimit = problem.time_limit;
|
||||
vm.memoryLimit = problem.memory_limit;
|
||||
vm.hint = problem.hint;
|
||||
vm.visible = problem.visible;
|
||||
vm.inputDescription = problem.input_description;
|
||||
vm.outputDescription = problem.output_description;
|
||||
vm.score = problem.score;
|
||||
vm.samples = [];
|
||||
vm.testCaseId = problem.test_case_id;
|
||||
for (var i = 0; i < problem.samples.length; i++) {
|
||||
vm.samples.push({
|
||||
input: problem.samples[i].input,
|
||||
output: problem.samples[i].output,
|
||||
visible: false
|
||||
})
|
||||
}
|
||||
hintEditor.setValue(vm.hint);
|
||||
descriptionEditor.setValue(vm.description);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else { //Create new problem Set default values
|
||||
vm.testCaseList = [];
|
||||
vm.title = "";
|
||||
vm.timeLimit = 1000;
|
||||
vm.memoryLimit = 256;
|
||||
vm.samples = [];
|
||||
vm.visible = true;
|
||||
vm.inputDescription = "";
|
||||
vm.outputDescription = "";
|
||||
vm.testCaseId = "";
|
||||
vm.sortIndex = "";
|
||||
vm.score = 0;
|
||||
hintEditor.setValue("");
|
||||
descriptionEditor.setValue("");
|
||||
}
|
||||
});
|
||||
avalon.scan();
|
||||
|
||||
});
|
@ -1,7 +1,7 @@
|
||||
require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "tagEditor", "validator", "jqueryUI"],
|
||||
function ($, avalon, editor, uploader, bsAlert, csrfTokenHeader) {
|
||||
avalon.ready(function () {
|
||||
avalon.vmodels.addProblem = null;
|
||||
|
||||
$("#add-problem-form").validator()
|
||||
.on('submit', function (e) {
|
||||
if (!e.isDefaultPrevented()){
|
||||
@ -63,6 +63,7 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "tagE
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
bsAlert("题目添加成功!");
|
||||
location.hash = "problem/problem_list";
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
@ -92,7 +93,27 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "tagE
|
||||
|
||||
var hintEditor = editor("#hint");
|
||||
var problemDescription = editor("#problemDescription");
|
||||
|
||||
if (avalon.vmodels.addProblem) {
|
||||
var vm = avalon.vmodels.addProblem;
|
||||
vm.title = "";
|
||||
vm.description = "";
|
||||
vm.timeLimit = 1000;
|
||||
vm.memoryLimit = 256;
|
||||
vm.samples = [{input: "", output: "", "visible": true}];
|
||||
vm.hint = "";
|
||||
vm.visible = true;
|
||||
vm.difficulty = 0;
|
||||
vm.tags = [];
|
||||
vm.inputDescription = "";
|
||||
vm.outputDescription = "";
|
||||
vm.testCaseId = "";
|
||||
vm.testCaseList = [];
|
||||
vm.uploadSuccess = false;
|
||||
vm.source = "";
|
||||
hintEditor.setValue("");
|
||||
problemDescription.setValue("");
|
||||
}
|
||||
else
|
||||
var vm = avalon.define({
|
||||
$id: "addProblem",
|
||||
title: "",
|
||||
|
@ -2,7 +2,6 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "tagE
|
||||
function ($, avalon, editor, uploader, bsAlert, csrfTokenHeader) {
|
||||
|
||||
avalon.ready(function () {
|
||||
avalon.vmodels.editProblem = null;
|
||||
|
||||
$("#edit-problem-form").validator()
|
||||
.on('submit', function (e) {
|
||||
@ -65,6 +64,7 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "tagE
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
bsAlert("题目编辑成功!");
|
||||
vm.showProblemListPage();
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
@ -75,7 +75,24 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "tagE
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (avalon.vmodels.editProblem) {
|
||||
var vm = avalon.vmodels.editProblem;
|
||||
title: "",
|
||||
description= "";
|
||||
timeLimit= -1;
|
||||
memoryLimit= -1;
|
||||
samples= [];
|
||||
hint= "";
|
||||
visible= true;
|
||||
difficulty= 0;
|
||||
inputDescription= "";
|
||||
outputDescription= "";
|
||||
testCaseIdd= "";
|
||||
uploadSuccess= false;
|
||||
source= "";
|
||||
testCaseList= [];
|
||||
}
|
||||
else
|
||||
var vm = avalon.define({
|
||||
$id: "editProblem",
|
||||
title: "",
|
||||
|
@ -41,10 +41,8 @@ require(["jquery", "avalon", "csrfToken", "bsAlert"], function ($, avalon, csrfT
|
||||
vm.$fire("up!showProblemSubmissionPage", problemId);
|
||||
}
|
||||
});
|
||||
|
||||
getPageData(1);
|
||||
}
|
||||
|
||||
getPageData(1);
|
||||
function getPageData(page) {
|
||||
var url = "/api/admin/problem/?paging=true&page=" + page + "&page_size=10";
|
||||
if (vm.keyword != "")
|
||||
|
@ -7,7 +7,8 @@
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<input type="text" name="name" class="form-control" ms-duplex="title"
|
||||
data-error="请填写比赛名称(名称不能超过50个字)" required>
|
||||
data-error="请填写比赛名称(名称不能超过50个字)" ms-attr-readonly="contestCreated" required>
|
||||
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
</div>
|
||||
@ -17,51 +18,46 @@
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<textarea id="editor" placeholder="这里输入内容" autofocus ms-duplex="description"></textarea>
|
||||
|
||||
<div class="help-block with-errors"></div>
|
||||
<small ms-visible="description==''" style="color:red">请填写比赛描述</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label>开始时间</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label>结束时间</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" name="start_time" id="contest_start_time"
|
||||
ms-duplex="startTime" data-error="请填写比赛开始时间" required>
|
||||
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label>结束时间</label>
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" name="end_time" id="contest_end_time"
|
||||
ms-duplex="endTime" data-error="请填写比赛结束时间" required>
|
||||
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label>允许参加的用户</label>
|
||||
</div>
|
||||
<div class="col-md-6" >
|
||||
<label>密码保护</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<select class="form-control" name="password" ms-duplex="group" ms-change="addGroup" value="-1">
|
||||
<select class="form-control" ms-duplex="group" ms-change="addGroup" value="-1">
|
||||
<option value="-1">请选择</option>
|
||||
<option ms-repeat="groupList" ms-attr-value="$index" ms-visible="!el.chose">{{el.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-6" ms-visible="passwordUsable">
|
||||
<label>密码保护</label>
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" name="password" placeholder="留空就是公开赛" ms-duplex="password" ms-attr-readonly="!passwordUsable">
|
||||
<input type="text" class="form-control" name="password" placeholder="留空就是公开赛" ms-duplex="password">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div ms-repeat="choseGroupList" class="group-tag" ms-click="unchose($index)">{{el.name}}</div>
|
||||
<div ms-repeat="choseGroupList" class="group-tag" ms-click="removeGroup($index)">{{el.name}}</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label>排名方式</label>
|
||||
@ -94,135 +90,12 @@
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label class="text"><input type="checkbox" ms-duplex-checked="showSbumission">
|
||||
<label class="text"><input type="checkbox" ms-duplex-checked="showSubmission">
|
||||
<small>允许查看提交记录</small>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<label>添加题目</label>
|
||||
<a href="javascript:void(0)" class="btn btn-primary btn-sm" ms-click="add_problem()">添加</a>
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>编号</th>
|
||||
<th>题目</th>
|
||||
<th>测试数据</th>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr ms-repeat="problems">
|
||||
<td>题目{{ $index+1 }}</td>
|
||||
<td>{{ el.title }}</td>
|
||||
<td>{{ el.testCaseList.length }}组</td>
|
||||
<td>
|
||||
<a href="javascript:void(0)"class="btn-sm btn-info" ms-click="showProblemEditArea($index+1)">编辑</a>
|
||||
<a href="javascript:void(0)"class="btn-sm btn-danger" ms-click="del_problem($index+1)">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="problem" ms-visible="editingProblemId">
|
||||
<div class="panel panel-default problem-panel">
|
||||
<div class="panel-heading">
|
||||
<span class="panel-title">题目{{editingProblemId}} </span>
|
||||
<a href="javascript:void(0)" class="btn btn-primary btn-sm" ms-click="hidden()">隐藏</a>
|
||||
<a href="javascript:void(0)" class="btn btn-danger btn-sm" ms-click="del_problem(editingProblemId)">删除</a>
|
||||
</div>
|
||||
<div class="panel-body" >
|
||||
<div class="form-group col-md-12">
|
||||
<label>题目标题</label>
|
||||
<input type="text" name="problemName" class="form-control" ms-duplex="problems[editingProblemId-1].title"data-error="请填写题目标题" required>
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label>题目描述</label>
|
||||
<textarea id="problemDescriptionEditor" placeholder="这里输入内容"
|
||||
ms-duplex="problems[editingProblemId-1].description"></textarea>
|
||||
<small ms-visible="editDescription==''" style="color:red">请填写题目描述</small>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label>提示</label>
|
||||
<textarea id="problemHintEditor" placeholder="这里输入内容"
|
||||
ms-duplex="problems[editingProblemId-1].hint"></textarea>
|
||||
</div>
|
||||
<div class="col-md-3 form-group">
|
||||
<label>cpu</label>
|
||||
<input type="number" class="form-control" ms-duplex="problems[editingProblemId-1].timeLimit" data-error="请填写时间限制" required>
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
<div class="col-md-3 form-group">
|
||||
<label>内存</label>
|
||||
<input type="number" class="form-control" ms-duplex="problems[editingProblemId-1].memoryLimit" data-error="请填写内存限制" required>
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
<div class="col-md-3 form-group" ms-visible="mode==2">
|
||||
<label>分值</label>
|
||||
<input type="number" class="form-control" ms-duplex="problems[editingProblemId-1].score" data-error="请填写题目分值" required>
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<label>样例</label>
|
||||
<a href="javascript:void(0)" class="btn btn-primary btn-sm"
|
||||
ms-click="add_sample()">添加</a>
|
||||
<div>
|
||||
<div class="panel panel-default sample-panel" ms-repeat-sample="editSamples">
|
||||
<div class="panel-heading">
|
||||
<span class="panel-title">样例{{$index + 1}}</span>
|
||||
<a href="javascript:void(0)" class="btn btn-primary btn-sm"
|
||||
ms-click="toggle(sample)">{{ getBtnContent(sample)}}</a>
|
||||
<a href="javascript:void(0)" class="btn btn-danger btn-sm"
|
||||
ms-click="del_sample(sample)">删除</a>
|
||||
</div>
|
||||
<div class="panel-body row" ms-visible="sample.visible">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label>样例输入</label>
|
||||
<textarea class="form-control" rows="5"
|
||||
ms-duplex="sample.input"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label>样例输出</label>
|
||||
<textarea class="form-control" rows="5"
|
||||
ms-duplex="sample.output"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
|
||||
<label>测试数据</label>
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<td>编号</td>
|
||||
<td>输入文件名</td>
|
||||
<td>输出文件名</td>
|
||||
</tr>
|
||||
<tr ms-repeat="editTestCaseList">
|
||||
<td>{{$index}}</td>
|
||||
<td>{{ el.input }}</td>
|
||||
<td>{{ el.output }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<label>上传测试测试数据</label>
|
||||
<div id="uploader">
|
||||
<div>选择文件</div>
|
||||
</div>
|
||||
<small class="text-info">请将所有测试用例打包在一个文件中上传,所有文件要在压缩包的根目录,且输入输出文件名要以从1开始连续数字标识要对应例如:<br>
|
||||
1.in 1.out 2.in 2.out
|
||||
</small><br>
|
||||
|
||||
<input type="submit" class="btn btn-success btn-lg" value="发布比赛">
|
||||
</div>
|
||||
</div>
|
||||
|
@ -15,22 +15,23 @@
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>比赛</th>
|
||||
<th>比赛类型</th>
|
||||
<th>公开排名</th>
|
||||
<th>开始时间</th>
|
||||
<th>结束时间</th>
|
||||
<th>可见</th>
|
||||
<th>创建时间</th>
|
||||
<th>创建者</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<tr ms-repeat="contestList" ms-click="showEditContestArea($index+1)">
|
||||
<tr ms-repeat="contestList">
|
||||
<td>{{ el.id }}</td>
|
||||
<td>{{ el.title }}</td>
|
||||
<td>{{ contestTypeNameList[el.contest_type] }}</td>
|
||||
<td>{{ el.show_rank }}</td>
|
||||
<td>{{ el.start_time|date("yyyy-MM-dd HH:mm:ss")}}</td>
|
||||
<td>{{ el.end_time|date("yyyy-MM-dd HH:mm:ss")}}</td>
|
||||
<td>{{ getYesOrNo(el.show_rank) }}</td>
|
||||
<td>{{ getYesOrNo(el.visible) }}</td>
|
||||
<td>{{ el.create_time|date("yyyy-MM-dd HH:mm:ss")}}</td>
|
||||
<td>{{ el.created_by.username }}</td>
|
||||
<td>
|
||||
<a class="btn btn-info" href="javascript:void(0)" ms-click="showEditContestArea($index+1)">编辑</a>
|
||||
<a class="btn btn-primary" href="javascript:void(0)" ms-click="showEditProblemArea($index+1)">编辑问题</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="text-right">
|
||||
@ -39,6 +40,7 @@
|
||||
<button ms-attr-class="getBtnClass('next')" ms-click="getNext">下一页</button>
|
||||
</div>
|
||||
<div ms-visible="editingContestId">
|
||||
<form id="edit-contest-form">
|
||||
<div class="col-md-12">
|
||||
<label>比赛名称</label>
|
||||
</div>
|
||||
@ -56,63 +58,60 @@
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<textarea id="editor" placeholder="这里输入内容" autofocus ms-duplex="editDescription"></textarea>
|
||||
|
||||
<div class="help-block with-errors"></div>
|
||||
<small ms-visible="description==''" style="color:red">请填写比赛描述</small>
|
||||
<small ms-visible="editDescription==''" style="color:red">请填写比赛描述</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label>开始时间</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label>结束时间</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" name="start_time" id="contest_start_time"
|
||||
ms-duplex="editStartTime" data-error="请填写比赛开始时间" required>
|
||||
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label>结束时间</label>
|
||||
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" name="end_time" id="contest_end_time"
|
||||
ms-duplex="editEndTime" data-error="请填写比赛结束时间" required>
|
||||
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label>允许参加的用户</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label>密码保护</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
|
||||
<div class="form-group">
|
||||
<select class="form-control" name="password" ms-duplex="group" ms-change="addGroup" value="-1">
|
||||
<select class="form-control" ms-duplex="group" ms-change="addGroup" value="-1">
|
||||
<option value="-1">请选择</option>
|
||||
<option ms-repeat="groupList" ms-attr-value="$index" ms-visible="!el.chose">{{el.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" name="password" placeholder="留空就是公开赛" ms-duplex="editPassword"
|
||||
ms-attr-readonly="!passwordUsable">
|
||||
</div>
|
||||
<div class="col-md-6" ms-visible="passwordUsable">
|
||||
<label>密码保护</label>
|
||||
<input type="text" class="form-control" name="password" placeholder="留空就是公开赛" ms-duplex="editPassword">
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div ms-repeat="choseGroupList" class="group-tag" ms-click="unchose($index)">{{el.name}}</div>
|
||||
<div ms-repeat="choseGroupList" class="group-tag" ms-click="removeGroup($index)">{{el.name}}</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label>排名方式</label>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label>结束前是否开放排名</label>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label>是否公开提交记录</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
|
||||
<div class="form-group">
|
||||
<label><input type="radio" name="mode" ms-duplex-string="editMode" value="0">
|
||||
<small>ACM</small>
|
||||
@ -125,7 +124,15 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label>是否可见</label><br>
|
||||
<label><input type="checkbox" ms-duplex-checked="editVisible">
|
||||
<small> 可见</small>
|
||||
</label>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label>结束前是否开放排名</label>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="text"><input type="checkbox" ms-duplex-checked="editShowRank">
|
||||
<small>开放排名</small>
|
||||
@ -133,6 +140,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label>是否公开提交记录</label>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="text"><input type="checkbox" ms-duplex-checked="editShowSubmission">
|
||||
<small>允许查看提交记录</small>
|
||||
@ -140,29 +149,35 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<label>添加题目</label>
|
||||
<a href="javascript:void(0)" class="btn btn-primary btn-sm" ms-click="add_problem()">添加</a>
|
||||
<button class="btn btn-primary" type="submit">保存修改</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-md-12" ms-visible="editingProblemContestIndex">
|
||||
<label>题目列表</label>
|
||||
<a href="javascript:void(0)" class="btn btn-success btn-sm" ms-click="add_problem()">添加</a>
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>编号</th>
|
||||
<th>题目</th>
|
||||
<th>测试数据</th>
|
||||
<th ms-visible="editMode=='2'">分值</th>
|
||||
<th>创建时间</th>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr ms-repeat="editProblemList">
|
||||
<td>题目{{ $index+1 }}</td>
|
||||
<td>{{ el.sort_index }}</td>
|
||||
<td>{{ el.title }}</td>
|
||||
<td>{{ el.testCaseList.length }}组</td>
|
||||
<td ms-visible="editMode=='2'">{{ el.score}}</td>
|
||||
<td>{{ el.create_time|date("yyyy-MM-dd HH:mm:ss") }}</td>
|
||||
<td>
|
||||
<a href="javascript:void(0)" class="btn-sm btn-info"
|
||||
ms-click="showProblemEditArea($index+1)">编辑</a>
|
||||
<a href="javascript:void(0)" class="btn-sm btn-danger" ms-click="del_problem($index+1)">删除</a>
|
||||
ms-click="showProblemEditor(el)">编辑</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<script src="/static/js/app/admin/contest/contest_list.js"></script>
|
||||
|
138
template/admin/contest/edit_problem.html
Normal file
138
template/admin/contest/edit_problem.html
Normal file
@ -0,0 +1,138 @@
|
||||
<div ms-controller="editProblem" class="col-md-9">
|
||||
<form id="edit-problem-form">
|
||||
<nav>
|
||||
<ul class="pager">
|
||||
<li class="previous" ms-click="goBack()"><a href="javascript:void(0)"><span
|
||||
aria-hidden="true">←</span> 返回</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label>题目编号</label>
|
||||
<input type="text" name="title" autofocus class="form-control" ms-duplex="sortIndex"
|
||||
data-error="请填写题目编号" maxlength="30" required>
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
<div class="form-group col-md-9">
|
||||
<label>题目标题</label>
|
||||
<input type="text" name="title" autofocus class="form-control" ms-duplex="title"
|
||||
data-error="请填写题目名称" maxlength="30" required>
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label>题目描述</label>
|
||||
<textarea id="problemDescription" placeholder="这里输入内容(此内容不能为空)" ms-duplex="description"></textarea>
|
||||
<small ms-visible="description==''" style="color:red">请填写题目描述</small>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="form-group"><label>时间限制(ms)</label>
|
||||
<input type="number" name="timeLimit" class="form-control" ms-duplex="timeLimit"
|
||||
data-error="请输入时间限制(保证是一个1000-5000的合法整数)" required>
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group"><label>内存限制(MB)</label>
|
||||
<input type="number" name="memory" class="form-control" ms-duplex="memoryLimit"
|
||||
data-error="请输入内存限制(保证是一个合法整数)" required>
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3" ms-visible="contestMode=='2'">
|
||||
<div class="form-group"><label>分值(仅计分模式)</label>
|
||||
<input type="number" name="score" class="form-control" ms-duplex="score">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3 form-group">
|
||||
<label>是否可见</label><br>
|
||||
<label><input type="checkbox" ms-duplex-checked="visible">
|
||||
<small> 可见</small>
|
||||
</label>
|
||||
</div>
|
||||
<div class="col-md-12 form-group">
|
||||
<label>输入描述</label><br>
|
||||
<textarea class="form-control" rows="5" name="input_description"
|
||||
ms-duplex="inputDescription" data-error="请填写输入描述"
|
||||
maxlength="10000" required>
|
||||
</textarea>
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
<div class="col-md-12 form-group">
|
||||
<label>输出描述</label><br>
|
||||
<textarea class="form-control" rows="5" name="output_escription"
|
||||
ms-duplex="outputDescription" data-error="请填写输出描述"
|
||||
maxlength="10000" required>
|
||||
</textarea>
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
<div class="col-md-12"><br>
|
||||
<label>样例</label>
|
||||
<a href="javascript:void(0)" class="btn btn-primary btn-sm" ms-click="addSample()">添加</a>
|
||||
|
||||
<div class="sample">
|
||||
<div class="panel panel-default sample-panel" ms-repeat-sample="samples">
|
||||
<div class="panel-heading">
|
||||
<span class="panel-title">样例{{$index + 1}}</span>
|
||||
<a href="javascript:void(0)" class="btn btn-primary btn-sm"
|
||||
ms-click="toggleSample(sample)">
|
||||
{{ getBtnContent(sample)}}
|
||||
</a>
|
||||
<a href="javascript:void(0)" class="btn btn-danger btn-sm"
|
||||
ms-click="delSample(sample)">
|
||||
删除
|
||||
</a>
|
||||
</div>
|
||||
<div class="panel-body row" ms-visible="sample.visible">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label>样例输入</label>
|
||||
<textarea class="form-control" rows="5" ms-duplex="sample.input"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label>样例输出</label>
|
||||
<textarea class="form-control" rows="5" ms-duplex="sample.output"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12"><br>
|
||||
<label>测试数据(多次上传将覆盖原有测试用例)</label><br>
|
||||
<small class="text-info">请将所有测试用例打包在一个文件中上传,所有文件要在压缩包的根目录,且输入输出文件名要以从1开始连续数字标识要对应例如:<br>
|
||||
1.in 1.out 2.in 2.out
|
||||
</small>
|
||||
<table class="table table-striped" ms-visible="uploadSuccess">
|
||||
<tr>
|
||||
<td>编号</td>
|
||||
<td>输入文件名</td>
|
||||
<td>输出文件名</td>
|
||||
</tr>
|
||||
<tr ms-repeat="testCaseList">
|
||||
<td>{{ $index + 1 }}</td>
|
||||
<td>{{ el.input }}</td>
|
||||
<td>{{ el.output }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<div id="testCaseFile">选择文件</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label>提示</label>
|
||||
<textarea id="hint" placeholder="这里输入内容" ms-duplex="hint"></textarea>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<input type="submit" class="btn btn-success btn-lg" value="发布题目" id="submitBtn">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script src="/static/js/app/admin/contest/edit_problem.js"></script>
|
Loading…
Reference in New Issue
Block a user