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

7
modules/submission.js

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

11
views/submission.ejs

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

2
views/submissions.ejs

@ -95,7 +95,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <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> </tr>
</tbody> </tbody>
</table> </table>

8
views/submissions_item.ejs

@ -14,7 +14,7 @@ const userUrl = <%- JSON.stringify(syzoj.utils.makeUrl(['user', 'VanDarkholme'])
Vue.component('submission-item', { Vue.component('submission-item', {
template: '#submissionItemTemplate', template: '#submissionItemTemplate',
props: ['data', 'config'], props: ['data', 'config', 'showRejudge'],
computed: { computed: {
statusString() { statusString() {
const data = this.data; 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 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><a :href="userLink">{{ data.info.user }}</a></td>
<td>{{ data.info.submitTime }}</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> </tr>
</script> </script>
Loading…
Cancel
Save