Browse Source

feat: 在测评列表里加入是否分享的列和筛选条件。

feature/unlimited-reply
zjz1993 5 years ago
parent
commit
80157dac41
  1. 29
      libs/submissions_process.js
  2. 5
      modules/submission.js
  3. 72
      views/submissions.ejs
  4. 1
      views/submissions_item.ejs

29
libs/submissions_process.js

@ -1,19 +1,22 @@
const {getCachedJudgeState} = require('./judger');
const _ = require('lodash');
const getSubmissionInfo = (s, displayConfig) => ({
submissionId: s.id,
taskId: s.task_id,
user: s.user.username,
userId: s.user_id,
problemName: s.problem.title,
problemId: s.problem_id,
language: displayConfig.showCode ? ((s.language != null && s.language !== '') ? syzoj.languages[s.language].show : null) : null,
codeSize: displayConfig.showCode ? s.code_length : null,
submitTime: syzoj.utils.formatDate(s.submit_time),
isPractice: s.is_practice,
c_id: s.c_id
});
const getSubmissionInfo = (s, displayConfig) => {
return {
submissionId: s.id,
taskId: s.task_id,
user: s.user.username,
userId: s.user_id,
problemName: s.problem.title,
problemId: s.problem_id,
language: displayConfig.showCode ? ((s.language != null && s.language !== '') ? syzoj.languages[s.language].show : null) : null,
codeSize: displayConfig.showCode ? s.code_length : null,
submitTime: syzoj.utils.formatDate(s.submit_time),
isPractice: s.is_practice,
c_id: s.c_id,
is_share: s.is_share || false
}
};
const getRoughResult = (x, displayConfig, roughOnly) => {
let max = 0;

5
modules/submission.js

@ -84,6 +84,11 @@ app.get('/submissions', async (req, res) => {
query.andWhere('status = :status', { status: req.query.status });
isFiltered = true;
}
if (req.query.isshare) {
query.andWhere('is_share = :status', { status: req.query.isshare });
}
if (!inContest && (!curUser || !await curUser.hasPrivilege('manage_problem'))) {
if (req.query.problem_id) {

72
views/submissions.ejs

@ -1,6 +1,15 @@
<% this.title = '提交记录' %>
<% include header %>
<% include util %>
<style>
.label{
font-size: 1.2em;
margin-right: 1px;
}
.padding{
overflow-x: auto;
}
</style>
<script src="<%- lib('textfit/2.3.1/textFit.min.js') %>"></script>
<div class="padding">
<% if (displayConfig.inContest) { %>
@ -17,10 +26,10 @@
<form action="<%= syzoj.utils.makeUrl(displayConfig.inContest ? ['contest', contest.id, 'submissions'] : ['submissions']) %>" class="ui mini form" method="get" role="form" id="form">
<input type="hidden" name="contest" value="<%= form.contest %>" />
<div class="inline fields" style="margin-bottom: 25px; white-space: nowrap; ">
<label style="font-size: 1.2em; margin-right: 1px; ">题目:</label>
<label class="label">题目:</label>
<div class="field"><input name="problem_id" style="width: 50px; " type="text" value="<%= form.problem_id %>"></div>
<% if (displayConfig.showOthers) { %>
<label style="font-size: 1.2em; margin-right: 1px; ">提交者:</label>
<label class="label">提交者:</label>
<div class="field"><input name="submitter" style="width: 100px; " type="text" value="<%= form.submitter %>"></div>
<% } %>
<% if (displayConfig.showScore) { %>
@ -29,7 +38,7 @@
<label style="font-size: 1.2em; margin-right: 7px; ">~</label>
<div class="field"><input name="max_score" style="width: 45px; " type="text" value="<%= form.max_score || 100 %>"></div>
<% } %>
<label style="font-size: 1.2em; margin-right: 1px; ">语言:</label>
<label class="label">语言:</label>
<div class="field">
<div class="ui fluid selection dropdown" id="select_language" style="width: 110px; ">
<input type="hidden" name="language" value="<%= form.language %>">
@ -46,7 +55,7 @@
</div>
</div>
<% if (displayConfig.showResult) { %>
<label style="font-size: 1.2em; margin-right: 1px; ">状态:</label>
<label class="label">状态:</label>
<div class="field">
<div class="ui fluid selection dropdown" id="select_status" style="width: 210px; ">
<input type="hidden" name="status" value="<%= form.status %>">
@ -62,29 +71,45 @@
</div>
</div>
<% } %>
<button class="ui labeled icon mini button" type="submit">
<i class="search icon"></i>
查询
</button>
<% if (user && displayConfig.showOthers) { %>
<a class="ui mini labeled icon blue button" style="margin-left: auto; " id="my_submit">
<i class="user icon"></i>
我的提交
</a>
<script>
$(function () {
$('#my_submit').click(function () {
$('[name=submitter]').val(<%- serializejs(user.username) %>);
$('#form').submit();
});
});
</script>
<% } %>
<label class="label">代码是否分享:</label>
<div class="field">
<div class="ui fluid selection dropdown" id="select_share" style="width: 110px; ">
<input type="hidden" name="isshare" value="<%= form.isshare %>">
<i class="dropdown icon"></i>
<div class="default text"></div>
<div class="menu">
<div class="item" data-value=""><b>不限</b></div>
<div class="item" data-value="1"><b>是</b></div>
<div class="item" data-value="0"><b>否</b></div>
</div>
</div>
</div>
</div>
<div class="inline fields">
<button class="ui labeled icon mini button" type="submit">
<i class="search icon"></i>
查询
</button>
<% if (user && displayConfig.showOthers) { %>
<a class="ui mini labeled icon blue button" id="my_submit">
<i class="user icon"></i>
我的提交
</a>
<script>
$(function () {
$('#my_submit').click(function () {
$('[name=submitter]').val(<%- serializejs(user.username) %>);
$('#form').submit();
});
});
</script>
<% } %>
</div>
</form>
<table id="vueAppFuckSafari" class="ui very basic center aligned table" style="white-space: nowrap; " id="table">
<thead>
<tr>
<th>是否已经分享</th>
<th>编号</th>
<th>题目</th>
<th>状态</th>
@ -133,11 +158,14 @@
$(function () {
$('#select_language').dropdown();
$('#select_status').dropdown();
$('#select_share').dropdown();
});
const itemList = <%- serializejs(items) %>;
const socketUrl = "/rough";
const displayConfig = <%- serializejs(displayConfig) %>;
console.log(itemList);
const vueApp = new Vue({
el: '#vueAppFuckSafari',
data: {

1
views/submissions_item.ejs

@ -66,6 +66,7 @@
<script id="submissionItemTemplate" type="text/x-template">
<tr>
<td><i class="icon" :class="data.info.is_share ? 'smile': 'meh'" style="font-size: 1.5em"></i></td>
<% if (active === 'submissions') { %>
<td><a :href="submissionLink"><b>#{{ data.info.submissionId }}</b></a></td>
<% } else { %>

Loading…
Cancel
Save