Browse Source

feat:在比赛测评页面里增加返回比赛的入口同时修改路径。

feature/unlimited-reply
zjz1993 5 years ago
parent
commit
d6b5971d13
  1. 3
      modules/contest.js
  2. 2
      modules/problem.js
  3. 163
      views/submission_contest.ejs

3
modules/contest.js

@ -463,7 +463,8 @@ app.get('/contest/submission/:id', async (req, res) => {
judge.code = await syzoj.utils.highlight(judge.code, syzoj.languages[judge.language].highlight); judge.code = await syzoj.utils.highlight(judge.code, syzoj.languages[judge.language].highlight);
} }
res.render('submission', { res.render('submission_contest', {
contest_id: contest.id,
info: getSubmissionInfo(judge, displayConfig), info: getSubmissionInfo(judge, displayConfig),
roughResult: getRoughResult(judge, displayConfig), roughResult: getRoughResult(judge, displayConfig),
code: (displayConfig.showCode && judge.problem.type !== 'submit-answer') ? judge.code.toString("utf8") : '', code: (displayConfig.showCode && judge.problem.type !== 'submit-answer') ? judge.code.toString("utf8") : '',

2
modules/problem.js

@ -769,6 +769,8 @@ app.post('/problem/:id/submit', app.multer.fields([{ name: 'answer', maxCount: 1
if (contest && (!await contest.isSupervisior(curUser))) { if (contest && (!await contest.isSupervisior(curUser))) {
res.redirect(syzoj.utils.makeUrl(['contest', contest_id, 'submissions'])); res.redirect(syzoj.utils.makeUrl(['contest', contest_id, 'submissions']));
} else if(contest) {
res.redirect(syzoj.utils.makeUrl(['contest','submission', judge_state.id]));
} else { } else {
res.redirect(syzoj.utils.makeUrl(['submission', judge_state.id])); res.redirect(syzoj.utils.makeUrl(['submission', judge_state.id]));
} }

163
views/submission_contest.ejs

@ -3,40 +3,39 @@
<% include header %> <% include header %>
<script src="<%- lib('textfit/2.3.1/textFit.min.js') %>"></script> <script src="<%- lib('textfit/2.3.1/textFit.min.js') %>"></script>
<style> <style>
.single-subtask { .single-subtask {
box-shadow: none !important; box-shadow: none !important;
} }
.single-subtask > .title { .single-subtask > .title {
display: none; display: none;
} }
.single-subtask > .content { .single-subtask > .content {
padding: 0 !important; padding: 0 !important;
} }
.accordion > .content > .accordion { .accordion > .content > .accordion {
margin-top: 0; margin-top: 0;
margin-bottom: 0; margin-bottom: 0;
} }
.accordion > .content > .accordion > .content { .accordion > .content > .accordion > .content {
margin-top: 0; margin-top: 0;
margin-bottom: 14px; margin-bottom: 14px;
} }
.accordion > .content > .accordion > .content > :last-child { .accordion > .content > .accordion > .content > :last-child {
margin-bottom: -10px !important; margin-bottom: -10px !important;
} }
.disabled{
display: none;
}
</style> </style>
<span id="submission_content"> <span id="submission_content">
<div class="padding" id="vueAppFuckSafari"> <div class="padding" id="vueAppFuckSafari">
<a href="<%= syzoj.utils.makeUrl(['contest', contest_id]) %>">返回比赛</a>
<table class="ui very basic center aligned table" id="status_table"> <table class="ui very basic center aligned table" id="status_table">
<thead> <thead>
<tr> <tr>
<th>已分享</th>
<th>编号</th> <th>编号</th>
<th>题目</th> <th>题目</th>
<th>状态</th> <th>状态</th>
@ -55,12 +54,9 @@
<tr is="submission-item" v-bind:data="roughData" :config="displayConfig" :show-rejudge="showRejudge" :show-share="showShare" :progress="getProgress()" :compiling="detailResult && !detailResult.compile"></tr> <tr is="submission-item" v-bind:data="roughData" :config="displayConfig" :show-rejudge="showRejudge" :show-share="showShare" :progress="getProgress()" :compiling="detailResult && !detailResult.compile"></tr>
</tbody> </tbody>
</table> </table>
<div id="cid" class="disabled"><%= cid %></div>
<div id="pid" class="disabled"><%= pid %></div>
<div id="sid" class="disabled"><%= sid %></div>
<code-box no-escape v-bind:content="code"> <code-box no-escape v-bind:content="code">
<% if (formattedCode !== null) { %> <% if (formattedCode !== null) { %>
<a onclick="toggleFormattedCode()" class="ui button" style="position: absolute; top: 0px; right: -4px; border-top-left-radius: 0; border-bottom-right-radius: 0; "> <a onclick="toggleFormattedCode()" class="ui button" style="position: absolute; top: 0px; right: -4px; border-top-left-radius: 0; border-bottom-right-radius: 0; ">
<template v-if="currentFormatted"> <template v-if="currentFormatted">
显示原始代码 显示原始代码
</template> </template>
@ -68,7 +64,7 @@
格式化代码 格式化代码
</template> </template>
</a> </a>
<% } %> <% } %>
</code-box> </code-box>
<code-box v-if="detailResult && detailResult.compile" no-escape title="编译信息" v-bind:content="detailResult.compile.message"></code-box> <code-box v-if="detailResult && detailResult.compile" no-escape title="编译信息" v-bind:content="detailResult.compile.message"></code-box>
<code-box v-if="detailResult" title="系统信息" v-bind:content="detailResult.systemMessage"></code-box> <code-box v-if="detailResult" title="系统信息" v-bind:content="detailResult.systemMessage"></code-box>
@ -135,9 +131,9 @@
<script src="<%- lib('socket.io/2.2.0/socket.io.js') %>"></script> <script src="<%- lib('socket.io/2.2.0/socket.io.js') %>"></script>
<script src="<%- lib('jsondiffpatch/0.2.5/jsondiffpatch.min.js') %>"></script> <script src="<%- lib('jsondiffpatch/0.2.5/jsondiffpatch.min.js') %>"></script>
<% include submissions_item %> <% include submissions_item %>
<script type="text/x-template" id="codeBoxTemplate"> <script type="text/x-template" id="codeBoxTemplate">
<div style="margin-top: 0px; margin-bottom: 14px; " v-if="content != null && content !== ''"> <div style="margin-top: 0px; margin-bottom: 14px; " v-if="content != null && content !== ''">
<p v-if="title" class="transition visible"> <p v-if="title" class="transition visible">
<strong v-html="title"></strong> <strong v-html="title"></strong>
@ -153,16 +149,16 @@
<script> <script>
Vue.component("code-box", { Vue.component("code-box", {
template: "#codeBoxTemplate", template: "#codeBoxTemplate",
props: { props: {
title: String, title: String,
content: String, content: String,
noEscape: { noEscape: {
type: Boolean, type: Boolean,
default: false default: false
}, },
download: String download: String
} }
}); });
const socketUrl = "/detail"; const socketUrl = "/detail";
const displayConfig = <%- serializejs(displayConfig) %>; const displayConfig = <%- serializejs(displayConfig) %>;
@ -170,16 +166,16 @@ const token = <%- serializejs(socketToken) %>;
const TestcaseResultType = {}; const TestcaseResultType = {};
(function (TestcaseResultType) { (function (TestcaseResultType) {
TestcaseResultType[TestcaseResultType["Accepted"] = 1] = "Accepted"; TestcaseResultType[TestcaseResultType["Accepted"] = 1] = "Accepted";
TestcaseResultType[TestcaseResultType["WrongAnswer"] = 2] = "WrongAnswer"; TestcaseResultType[TestcaseResultType["WrongAnswer"] = 2] = "WrongAnswer";
TestcaseResultType[TestcaseResultType["PartiallyCorrect"] = 3] = "PartiallyCorrect"; TestcaseResultType[TestcaseResultType["PartiallyCorrect"] = 3] = "PartiallyCorrect";
TestcaseResultType[TestcaseResultType["MemoryLimitExceeded"] = 4] = "MemoryLimitExceeded"; TestcaseResultType[TestcaseResultType["MemoryLimitExceeded"] = 4] = "MemoryLimitExceeded";
TestcaseResultType[TestcaseResultType["TimeLimitExceeded"] = 5] = "TimeLimitExceeded"; TestcaseResultType[TestcaseResultType["TimeLimitExceeded"] = 5] = "TimeLimitExceeded";
TestcaseResultType[TestcaseResultType["OutputLimitExceeded"] = 6] = "OutputLimitExceeded"; TestcaseResultType[TestcaseResultType["OutputLimitExceeded"] = 6] = "OutputLimitExceeded";
TestcaseResultType[TestcaseResultType["FileError"] = 7] = "FileError"; TestcaseResultType[TestcaseResultType["FileError"] = 7] = "FileError";
TestcaseResultType[TestcaseResultType["RuntimeError"] = 8] = "RuntimeError"; TestcaseResultType[TestcaseResultType["RuntimeError"] = 8] = "RuntimeError";
TestcaseResultType[TestcaseResultType["JudgementFailed"] = 9] = "JudgementFailed"; TestcaseResultType[TestcaseResultType["JudgementFailed"] = 9] = "JudgementFailed";
TestcaseResultType[TestcaseResultType["InvalidInteraction"] = 10] = "InvalidInteraction"; TestcaseResultType[TestcaseResultType["InvalidInteraction"] = 10] = "InvalidInteraction";
})(TestcaseResultType); })(TestcaseResultType);
const statusToString = {}; const statusToString = {};
@ -196,11 +192,11 @@ statusToString[TestcaseResultType.InvalidInteraction] = "Invalid Interaction";
const TaskStatus = {}; const TaskStatus = {};
(function (TaskStatus) { (function (TaskStatus) {
TaskStatus[TaskStatus["Waiting"] = 0] = "Waiting"; TaskStatus[TaskStatus["Waiting"] = 0] = "Waiting";
TaskStatus[TaskStatus["Running"] = 1] = "Running"; TaskStatus[TaskStatus["Running"] = 1] = "Running";
TaskStatus[TaskStatus["Done"] = 2] = "Done"; TaskStatus[TaskStatus["Done"] = 2] = "Done";
TaskStatus[TaskStatus["Failed"] = 3] = "Failed"; TaskStatus[TaskStatus["Failed"] = 3] = "Failed";
TaskStatus[TaskStatus["Skipped"] = 4] = "Skipped"; TaskStatus[TaskStatus["Skipped"] = 4] = "Skipped";
})(TaskStatus); })(TaskStatus);
const unformattedCode = <%- serializejs(code) %>; const unformattedCode = <%- serializejs(code) %>;
@ -318,10 +314,6 @@ const vueApp = new Vue({
}); });
if (token != null) { if (token != null) {
const loadSocketIO = function () { const loadSocketIO = function () {
const cid = parseInt(document.getElementById('cid').innerHTML);
const pid = parseInt(document.getElementById('pid').innerHTML);
const sid = parseInt(document.getElementById('sid').innerHTML);
console.log(sid);
let currentVersion = 0; let currentVersion = 0;
const socket = io(socketUrl); const socket = io(socketUrl);
socket.on('connect', function () { socket.on('connect', function () {
@ -346,68 +338,17 @@ if (token != null) {
console.log("Judge finished"); console.log("Judge finished");
vueApp.roughData.running = false; vueApp.roughData.running = false;
vueApp.roughData.result = p.roughResult; vueApp.roughData.result = p.roughResult;
if (p.roughResult.result === 'Accepted') {
$.ajax({
url: `/api/pass/${cid}/${pid}/${sid}`,
type: 'GET',
success: function (data) {
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert('练习功能发生故障');
}
});
} else {
$.ajax({
url: `/api/nopass/${cid}/${pid}/${sid}`,
type: 'GET',
success: function (data) {
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert('练习功能发生故障');
}
});
}
vueApp.detailResult = p.result; vueApp.detailResult = p.result;
socket.close(); socket.close();
}); });
socket.emit('join', token, function (data) { socket.emit('join', token, function (data) {
console.log("join! ", data); console.log("join! ", data);
// data.ok=true;
// data.finished=true;
// data.roughResult = {
// memory: 7128,
// result: "Accepted",
// score: 100,
// time: 272,
// }
// data.running=false;
if (data && data.ok) { if (data && data.ok) {
if (data.finished) { if (data.finished) {
vueApp.roughData.result = data.roughResult; vueApp.roughData.result = data.roughResult;
// if (!data.result) location.reload(true); // if (!data.result) location.reload(true);
vueApp.detailResult = data.result; vueApp.detailResult = data.result;
vueApp.roughData.running = false; vueApp.roughData.running = false;
// if (data.roughResult.result === 'Accepted') {
// $.ajax({
// url: `/api/pass/${cid}/${pid}/${sid}`,
// type: 'GET',
// success: function (data) {
// },
// error: function (XMLHttpRequest, textStatus, errorThrown) {
// alert('练习功能发生故障');
// }
// });
// } else {
// $.ajax({
// url: `/api/nopass/${cid}/${pid}/${sid}`,
// type: 'GET',
// success: function (data) {
// },
// error: function (XMLHttpRequest, textStatus, errorThrown) {
// alert('练习功能发生故障');
// }
// });
// }
socket.close(); socket.close();
} else { } else {
if (data.running) { if (data.running) {

Loading…
Cancel
Save