Browse Source

Add rejudge support

pull/6/head
t123yh 7 years ago
parent
commit
f6700e80e1
  1. 5
      modules/contest.js
  2. 7
      modules/submission.js
  3. 11
      views/submission.ejs
  4. 2
      views/submissions.ejs
  5. 8
      views/submissions_item.ejs

5
modules/contest.js

@ -271,7 +271,8 @@ function getDisplayConfig(contest) {
showOthers: contest.allowedSeeingOthers(),
showDetailResult: contest.allowedSeeingTestcase(),
showTestdata: false,
inContest: true
inContest: true,
showRejudge: false
};
}
@ -408,7 +409,7 @@ app.get('/contest/submission/:id', async (req, res) => {
type: 'detail'
}, syzoj.config.judge_token) : null,
displayConfig: displayConfig,
contest: contest
contest: contest,
});
} catch (e) {
syzoj.log(e);

7
modules/submission.js

@ -35,6 +35,7 @@ const displayConfig = {
showTestdata: true,
showDetailResult: true,
inContest: false,
showRejudge: false
};
// s is JudgeState
@ -153,9 +154,7 @@ app.get('/submission/:id', async (req, res) => {
judge.code = await syzoj.utils.highlight(judge.code, syzoj.config.languages[judge.language].highlight);
}
judge.allowedRejudge = await judge.problem.isAllowedEditBy(res.locals.user);
judge.allowedManage = await judge.problem.isAllowedManageBy(res.locals.user);
displayConfig.showRejudge = await judge.problem.isAllowedEditBy(res.locals.user);
res.render('submission', {
info: getSubmissionInfo(judge, displayConfig),
roughResult: getRoughResult(judge, displayConfig),
@ -166,7 +165,7 @@ app.get('/submission/:id', async (req, res) => {
type: 'detail',
displayConfig: displayConfig
}, syzoj.config.judge_token) : null,
displayConfig: displayConfig
displayConfig: displayConfig,
});
} catch (e) {
syzoj.log(e);

11
views/submission.ejs

@ -16,10 +16,11 @@
<th v-if="displayConfig.showCode">代码 / 答案文件</th>
<th>提交者</th>
<th>提交时间</th>
<th v-if="showRejudge">重新评测</th>
</tr>
</thead>
<tbody>
<tr is="submission-item" v-bind:data="roughData" :config="displayConfig"></tr>
<tr is="submission-item" v-bind:data="roughData" :config="displayConfig" :showRejudge="showRejudge"></tr>
</tbody>
</table>
@ -39,7 +40,7 @@
<status-label :status="getSubtaskResult(subtask)"></status-label>
</div>
<div class="three wide column">得分
<span style="font-weight: normal; ">{{ subtask.score }}</span>
<span style="font-weight: normal; ">{{ Math.trunc(subtask.score) }}</span>
</div>
</div>
</div>
@ -157,11 +158,14 @@ const vueApp = new Vue({
},
code: <%- JSON.stringify(code) %>,
detailResult: <%- JSON.stringify(detailResult) %>,
displayConfig: displayConfig
displayConfig: displayConfig,
},
computed: {
singleSubtask() {
return this.detailResult.judge.subtasks.length === 1;
},
showRejudge() {
return this.displayConfig.showRejudge && (!this.roughData.running);
}
},
methods: {
@ -223,6 +227,7 @@ if (token != null) {
console.log("Delta: " + JSON.stringify(p));
if (p.from === currentVersion) {
currentVersion = p.to;
console.log("Before patching: " + JSON.stringify(vueApp));
jsondiffpatch.patch(vueApp.detailResult, p.delta);
} else { // Some packets are dropped. Let's reset.
socket.close();

2
views/submissions.ejs

@ -95,7 +95,7 @@
</tr>
</thead>
<tbody>
<tr v-for="item in items" :config="displayConfig" :data="item" is='submission-item'>
<tr v-for="item in items" :config="displayConfig" :showRejudge="false" :data="item" is='submission-item'>
</tr>
</tbody>
</table>

8
views/submissions_item.ejs

@ -14,7 +14,7 @@ const userUrl = <%- JSON.stringify(syzoj.utils.makeUrl(['user', 'VanDarkholme'])
Vue.component('submission-item', {
template: '#submissionItemTemplate',
props: ['data', 'config'],
props: ['data', 'config', 'showRejudge'],
computed: {
statusString() {
const data = this.data;
@ -65,5 +65,11 @@ Vue.component('submission-item', {
<td v-if="config.showCode">{{ data.info.language != null ? data.info.language + ' / ' : '' }}{{ data.info.codeSize }}</td>
<td><a :href="userLink">{{ data.info.user }}</a></td>
<td>{{ data.info.submitTime }}</td>
<td v-if="showRejudge">
<form class="have-csrf" :action="submissionLink + '/rejudge'" method="POST">
<input type="hideen" name="_csrf" value="<%= req.csrfToken() %>" />
<input type="submit" value="rejudge"><i class="repeat icon"></i></input>
</form>
</td>
</tr>
</script>
Loading…
Cancel
Save