From a2c90093a10f816689aeb5344131565a075779b3 Mon Sep 17 00:00:00 2001 From: esp Date: Wed, 26 Aug 2015 11:28:26 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=89=8D=E7=AB=AF]=E6=B7=BB=E5=8A=A0=E6=AF=94?= =?UTF-8?q?=E8=B5=9B=E7=AE=A1=E7=90=86=E4=B8=AD=E6=9F=A5=E7=9C=8B=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E7=9A=84=E9=A1=B5=E9=9D=A2,=E6=9C=AA=E4=B8=8E?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=E5=AF=B9=E6=8E=A5[CI=20SKIP]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/src/js/app/admin/admin.js | 10 ++- .../src/js/app/admin/contest/contestList.js | 5 +- .../js/app/admin/contest/submissionList.js | 84 +++++++++++++++++++ template/src/admin/contest/contest_list.html | 5 +- .../src/admin/contest/submission_list.html | 34 ++++++++ 5 files changed, 133 insertions(+), 5 deletions(-) create mode 100644 static/src/js/app/admin/contest/submissionList.js create mode 100644 template/src/admin/contest/submission_list.html diff --git a/static/src/js/app/admin/admin.js b/static/src/js/app/admin/admin.js index bd0d51e2..9246f7f3 100644 --- a/static/src/js/app/admin/admin.js +++ b/static/src/js/app/admin/admin.js @@ -133,11 +133,17 @@ define("admin", ["jquery", "avalon"], function ($, avalon) { vm.template_url = "template/contest/edit_problem.html"; }); - vm.$watch("showContestListPage", function (problemId) { - vm.problemId = problemId; + vm.$watch("showContestListPage", function () { vm.template_url = "template/contest/contest_list.html"; }); + vm.$watch("showContestSubmissionPage", function (problemId, contestId, contestMode) { + vm.$problemId = problemId; + vm.$contestId = contestId; + vm.$contestMode = contestMode + vm.template_url = "template/contest/submission_list.html"; + }); + avalon.scan(); window.onhashchange = function () { diff --git a/static/src/js/app/admin/contest/contestList.js b/static/src/js/app/admin/contest/contestList.js index 9c1ba71b..ae3606c6 100644 --- a/static/src/js/app/admin/contest/contestList.js +++ b/static/src/js/app/admin/contest/contestList.js @@ -234,12 +234,15 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker", vm.groupList[vm.choseGroupList[groupIndex].index].chose = false; vm.choseGroupList.remove(vm.choseGroupList[groupIndex]); }, - add_problem: function () { + addProblem: function () { vm.$fire("up!showContestProblemPage", 0, vm.contestList[vm.editingProblemContestIndex-1].id, vm.editMode); }, showProblemEditor: function(el) { vm.$fire("up!showContestProblemPage", el.id, vm.contestList[vm.editingProblemContestIndex-1].id, vm.editMode); }, + showSubmissionPage: function() { + vm.$fire("up!showContestSubmissionPage", el.id, vm.contestList[vm.editingProblemContestIndex-1].id, vm.editMode); + } getYesOrNo: function(yORn) { if (yORn) return "是"; return "否"; diff --git a/static/src/js/app/admin/contest/submissionList.js b/static/src/js/app/admin/contest/submissionList.js new file mode 100644 index 00000000..ff375b21 --- /dev/null +++ b/static/src/js/app/admin/contest/submissionList.js @@ -0,0 +1,84 @@ +require(["jquery", "avalon", "csrfToken", "bsAlert"], function ($, avalon, csrfTokenHeader, bsAlert) { + + avalon.ready(function () { + + if (avalon.vmodels.contestSubmissionList){ + var vm = avalon.vmodels.contestSubmissionList; + } + else { + + var vm = avalon.define({ + $id: "contestSubmissionList", + submissionList: [], + previousPage: 0, + nextPage: 0, + page: 1, + totalPage: 1, + results : { + 0: "Accepted", + 1: "Runtime Error", + 2: "Time Limit Exceeded", + 3: "Memory Limit Exceeded", + 4: "Compile Error", + 5: "Format Error", + 6: "Wrong Answer", + 7: "System Error", + 8: "Waiting" + }, + getNext: function () { + if (!vm.nextPage) + return; + getPageData(vm.page + 1); + }, + getPrevious: function () { + if (!vm.previousPage) + return; + getPageData(vm.page - 1); + }, + getBtnClass: function (btn) { + if (btn == "next") { + return vm.nextPage ? "btn btn-primary" : "btn btn-primary disabled"; + } + else { + return vm.previousPage ? "btn btn-primary" : "btn btn-primary disabled"; + } + }, + getPage: function (page_index) { + getPageData(page_index); + }, + showSubmissionDetailPage: function (submissionId) { + + }, + showProblemListPage: function(){ + vm.$fire("up!showProblemListPage"); + } + }); + } + + getPageData(1); + + function getPageData(page) { + var url = "/api/admin/submission/?paging=true&page=" + page + "&page_size=10&problem_id=" + avalon.vmodels.admin.problemId; + $.ajax({ + url: url, + dataType: "json", + method: "get", + success: function (data) { + if (!data.code) { + vm.submissionList = data.data.results; + vm.totalPage = data.data.total_page; + vm.previousPage = data.data.previous_page; + vm.nextPage = data.data.next_page; + vm.page = page; + } + else { + bsAlert(data.data); + } + } + }); + } + + + }); + avalon.scan(); +}); \ No newline at end of file diff --git a/template/src/admin/contest/contest_list.html b/template/src/admin/contest/contest_list.html index 5c156299..b5e4d6ab 100644 --- a/template/src/admin/contest/contest_list.html +++ b/template/src/admin/contest/contest_list.html @@ -30,7 +30,7 @@ {{ el.created_by.username }} 编辑 - 编辑问题 + 题目 @@ -158,7 +158,8 @@
- 添加 + 添加 + 查看提交 diff --git a/template/src/admin/contest/submission_list.html b/template/src/admin/contest/submission_list.html new file mode 100644 index 00000000..fc8ee7df --- /dev/null +++ b/template/src/admin/contest/submission_list.html @@ -0,0 +1,34 @@ +
+ +

提交列表

+ +
编号
+ + + + + + + + + + + + + + +
ID创建时间作者结果
{{ el.id }}{{ el.create_time|date("yyyy-MM-dd HH:mm:ss")}}{{ el.user }}{{ results[el.result] }} + 详情 +
+
+ 页数:{{ page }}/{{ totalPage }}   + + +
+
+ \ No newline at end of file