mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-10 03:38:40 +00:00
feat(web/group/assignment): only show submissions before end_time
This commit is contained in:
parent
639d09b8c3
commit
0f0556b9ef
@ -52,6 +52,7 @@
|
|||||||
$usernames = [];
|
$usernames = [];
|
||||||
$n_users = count($users);
|
$n_users = count($users);
|
||||||
$n_problems = count($problems);
|
$n_problems = count($problems);
|
||||||
|
$submission_end_time = min(new DateTime(), DateTime::createFromFormat('Y-m-d H:i:s', $assignment['end_time']))->format('Y-m-d H:i:s');
|
||||||
|
|
||||||
foreach ($problems as $problem) {
|
foreach ($problems as $problem) {
|
||||||
$problem_ids[] = $problem['problem_id'];
|
$problem_ids[] = $problem['problem_id'];
|
||||||
@ -76,7 +77,7 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
foreach ($problem_ids as $problem_id) {
|
foreach ($problem_ids as $problem_id) {
|
||||||
$cond = "submitter = '{$user['username']}' AND problem_id = $problem_id";
|
$cond = "submitter = '{$user['username']}' AND problem_id = $problem_id AND submit_time <= '$submission_end_time'";
|
||||||
$submission = DB::selectFirst("SELECT id, score FROM submissions INNER JOIN (SELECT MAX(score) AS score FROM submissions WHERE $cond) AS max USING (score) WHERE $cond ORDER BY submit_time DESC");
|
$submission = DB::selectFirst("SELECT id, score FROM submissions INNER JOIN (SELECT MAX(score) AS score FROM submissions WHERE $cond) AS max USING (score) WHERE $cond ORDER BY submit_time DESC");
|
||||||
|
|
||||||
if ($submission) {
|
if ($submission) {
|
||||||
@ -156,14 +157,23 @@ $('#standings').long_table(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
div_classes: ['card', 'my-3', 'table-responsive', 'text-center'],
|
div_classes: ['card', 'my-3', 'table-responsive', 'text-center'],
|
||||||
table_classes: ['table', 'uoj-table', 'mb-0'],
|
table_classes: ['table', 'uoj-table', 'table-bordered', 'mb-0'],
|
||||||
page_len: 20,
|
page_len: 20,
|
||||||
|
print_before_table: function() {
|
||||||
|
var html = '';
|
||||||
|
|
||||||
|
html += '<div class="card-header bg-transparent text-muted text-start small">' +
|
||||||
|
'成绩统计截止时间:<?= $submission_end_time ?>' +
|
||||||
|
'</div>';
|
||||||
|
|
||||||
|
return html;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- end left col -->
|
|
||||||
</div>
|
</div>
|
||||||
|
<!-- end left col -->
|
||||||
|
|
||||||
<aside class="col-lg-3 mt-3 mt-lg-0">
|
<aside class="col-lg-3 mt-3 mt-lg-0">
|
||||||
<!-- right col -->
|
<!-- right col -->
|
||||||
|
@ -332,6 +332,8 @@ EOD);
|
|||||||
<div class="tab-pane active" id="assignments">
|
<div class="tab-pane active" id="assignments">
|
||||||
<?php
|
<?php
|
||||||
$now = new DateTime();
|
$now = new DateTime();
|
||||||
|
$hidden_time = new DateTime();
|
||||||
|
$hidden_time->sub(new DateInterval('P7D'));
|
||||||
echoLongTable(
|
echoLongTable(
|
||||||
['*'],
|
['*'],
|
||||||
'groups_assignments',
|
'groups_assignments',
|
||||||
@ -346,21 +348,23 @@ EOD);
|
|||||||
<th style="width:8em">操作</th>
|
<th style="width:8em">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
EOD,
|
EOD,
|
||||||
function($row) use ($group, $now) {
|
function($row) use ($group, $now, $hidden_time) {
|
||||||
$list = queryProblemList($row['list_id']);
|
$list = queryProblemList($row['list_id']);
|
||||||
$end_time = DateTime::createFromFormat('Y-m-d H:i:s', $row['end_time']);
|
$end_time = DateTime::createFromFormat('Y-m-d H:i:s', $row['end_time']);
|
||||||
|
|
||||||
echo '<tr>';
|
echo '<tr>';
|
||||||
echo '<td class="text-center">', $list['id'], '</td>';
|
echo '<td class="text-center">', $list['id'], '</td>';
|
||||||
echo '<td>', '<a class="text-decoration-none" href="/group/', $group['id'], '/assignment/', $list['id'],'">', HTML::escape($list['title']), '</a>', '</td>';
|
echo '<td>', '<a class="text-decoration-none" href="/group/', $group['id'], '/assignment/', $list['id'],'">', HTML::escape($list['title']), '</a>', '</td>';
|
||||||
if ($end_time < $now) {
|
if ($end_time < $hidden_time) {
|
||||||
|
echo '<td class="text-secondary">已隐藏</td>';
|
||||||
|
} elseif ($end_time < $now) {
|
||||||
echo '<td class="text-danger">已结束</td>';
|
echo '<td class="text-danger">已结束</td>';
|
||||||
} else {
|
} else {
|
||||||
echo '<td class="text-success">进行中</td>';
|
echo '<td class="text-success">进行中</td>';
|
||||||
}
|
}
|
||||||
echo '<td>', $end_time->format('Y-m-d H:i:s'), '</td>';
|
echo '<td>', $end_time->format('Y-m-d H:i:s'), '</td>';
|
||||||
echo '<td>';
|
echo '<td>';
|
||||||
echo '<a class="text-decoration-none d-inline-block align-middle" href="/problem_list/', $list['id'], '/edit">编辑</a> ';
|
echo '<a class="text-decoration-none d-inline-block align-middle" href="/problem_list/', $list['id'], '/manage">编辑</a> ';
|
||||||
echo ' <form class="d-inline-block" method="POST" onsubmit=\'return confirm("你真的要移除这份作业吗?移除作业不会删除题单。")\'>'
|
echo ' <form class="d-inline-block" method="POST" onsubmit=\'return confirm("你真的要移除这份作业吗?移除作业不会删除题单。")\'>'
|
||||||
. '<input type="hidden" name="_token" value="' . crsf_token() . '">'
|
. '<input type="hidden" name="_token" value="' . crsf_token() . '">'
|
||||||
. '<input type="hidden" name="list_id" value="' . $list['id'] . '">'
|
. '<input type="hidden" name="list_id" value="' . $list['id'] . '">'
|
||||||
@ -390,6 +394,7 @@ EOD,
|
|||||||
<li>请为学生预留合理的完成作业的时间。</li>
|
<li>请为学生预留合理的完成作业的时间。</li>
|
||||||
<li>排行榜将在结束后停止更新。</li>
|
<li>排行榜将在结束后停止更新。</li>
|
||||||
<li>如需延长结束时间请删除后再次添加,排行数据不会丢失。</li>
|
<li>如需延长结束时间请删除后再次添加,排行数据不会丢失。</li>
|
||||||
|
<li>作业结束七天后将会自动在小组主页中隐藏,但仍可直接通过 URL 访问。</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -149,7 +149,7 @@ function queryGroupAssignments($group_id) {
|
|||||||
return DB::selectAll("select a.id as id, a.list_id as list_id, a.end_time as end_time, b.title from groups_assignments a left join lists b on a.list_id = b.id where a.group_id = $group_id order by a.end_time asc", MYSQLI_ASSOC);
|
return DB::selectAll("select a.id as id, a.list_id as list_id, a.end_time as end_time, b.title from groups_assignments a left join lists b on a.list_id = b.id where a.group_id = $group_id order by a.end_time asc", MYSQLI_ASSOC);
|
||||||
}
|
}
|
||||||
function queryGroupActiveAssignments($group_id) {
|
function queryGroupActiveAssignments($group_id) {
|
||||||
return DB::selectAll("select a.id as id, a.group_id as group_id, a.list_id as list_id, a.end_time as end_time, b.title from groups_assignments a left join lists b on a.list_id = b.id where a.group_id = $group_id and a.end_time > addtime(now(), '-168:00:00') order by a.end_time asc", MYSQLI_ASSOC);
|
return DB::selectAll("select a.id as id, a.group_id as group_id, a.list_id as list_id, a.end_time as end_time, b.title from groups_assignments a left join lists b on a.list_id = b.id where a.group_id = $group_id and a.end_time >= addtime(now(), '-168:00:00') order by a.end_time asc", MYSQLI_ASSOC);
|
||||||
}
|
}
|
||||||
function queryAssignmentByGroupListID($group_id, $list_id) {
|
function queryAssignmentByGroupListID($group_id, $list_id) {
|
||||||
return DB::selectFirst("select * from groups_assignments where list_id='$list_id' and group_id='$group_id'", MYSQLI_ASSOC);
|
return DB::selectFirst("select * from groups_assignments where list_id='$list_id' and group_id='$group_id'", MYSQLI_ASSOC);
|
||||||
|
@ -21,8 +21,16 @@
|
|||||||
</div>
|
</div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php if ($standings_data): ?>
|
<?php if ($standings_data): ?>
|
||||||
<div class="tab-pane card-body" id="tab-standings">
|
<div class="tab-pane" id="tab-standings">
|
||||||
<?php uojIncludeView('contest-standings', array_merge($standings_data, ['no_bs5_card' => ''])) ?>
|
<?php
|
||||||
|
uojIncludeView('contest-standings', array_merge(
|
||||||
|
$standings_data,
|
||||||
|
[
|
||||||
|
'standings_config' => [
|
||||||
|
'div_classes' => ['table-responsive', 'mb-3']
|
||||||
|
]
|
||||||
|
]
|
||||||
|
)); ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
<div id="standings" class="
|
<div id="standings"></div>
|
||||||
<?php if (!isset($no_bs5_card)): ?>
|
|
||||||
card card-default
|
|
||||||
<?php endif ?>"></div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
standings_version=<?=$contest['extra_config']['standings_version']?>;
|
var standings_version=<?=$contest['extra_config']['standings_version']?>;
|
||||||
show_self_reviews=<?=isset($show_self_reviews) && $show_self_reviews ? 'true' : 'false' ?>;
|
var show_self_reviews=<?=isset($show_self_reviews) && $show_self_reviews ? 'true' : 'false' ?>;
|
||||||
contest_id=<?=$contest['id']?>;
|
var contest_id=<?=$contest['id']?>;
|
||||||
standings=<?=json_encode($standings)?>;
|
var standings=<?=json_encode($standings)?>;
|
||||||
score=<?=json_encode($score)?>;
|
var score=<?=json_encode($score)?>;
|
||||||
problems=<?=json_encode($contest_data['problems'])?>;
|
var problems=<?=json_encode($contest_data['problems'])?>;
|
||||||
$(document).ready(showStandings());
|
var standings_config = <?=json_encode(isset($standings_config) ? $standings_config : ['_config' => true])?>;
|
||||||
|
|
||||||
|
$(document).ready(showStandings(standings_config));
|
||||||
</script>
|
</script>
|
||||||
|
@ -541,18 +541,16 @@ $.fn.long_table = function(data, cur_page, header_row, get_row_str, config) {
|
|||||||
|
|
||||||
$(table_div).append(
|
$(table_div).append(
|
||||||
$('<div class="' + div_classes.join(' ') + '" />').append(
|
$('<div class="' + div_classes.join(' ') + '" />').append(
|
||||||
|
(typeof config.print_before_table === 'function' ? config.print_before_table() : ''),
|
||||||
$('<table class="' + table_classes.join(' ') + '" />').append(
|
$('<table class="' + table_classes.join(' ') + '" />').append(
|
||||||
$('<thead>' + header_row + '</thead>')
|
$('<thead>' + header_row + '</thead>')
|
||||||
).append(
|
).append(
|
||||||
tbody
|
tbody
|
||||||
)
|
),
|
||||||
|
(typeof config.print_after_table === 'function' ? config.print_after_table() : '')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (config.print_after_table != undefined) {
|
|
||||||
$(table_div).append(config.print_after_table());
|
|
||||||
}
|
|
||||||
|
|
||||||
var get_page_li = function(p, h) {
|
var get_page_li = function(p, h) {
|
||||||
if (p == -1) {
|
if (p == -1) {
|
||||||
return $('<li class="page-item"></li>').addClass('disabled').append($('<a class="page-link"></a>').append(h));
|
return $('<li class="page-item"></li>').addClass('disabled').append($('<a class="page-link"></a>').append(h));
|
||||||
@ -1129,7 +1127,7 @@ function showCommentReplies(id, replies) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// standings
|
// standings
|
||||||
function showStandings() {
|
function showStandings(config) {
|
||||||
$("#standings").long_table(
|
$("#standings").long_table(
|
||||||
standings,
|
standings,
|
||||||
1,
|
1,
|
||||||
@ -1178,9 +1176,9 @@ function showStandings() {
|
|||||||
col_tr += '</tr>';
|
col_tr += '</tr>';
|
||||||
return col_tr;
|
return col_tr;
|
||||||
}, {
|
}, {
|
||||||
div_classes: ['table-responsive'],
|
div_classes: config.div_classes ? config.div_classes : ['table-responsive', 'card', 'my-3'],
|
||||||
table_classes: ['table', 'table-bordered', 'text-center', 'align-middle', 'uoj-table', 'uoj-standings-table', 'mb-0'],
|
table_classes: config.table_classes ? config.table_classes : ['table', 'table-bordered', 'text-center', 'align-middle', 'uoj-table', 'uoj-standings-table', 'mb-0'],
|
||||||
page_len: 100,
|
page_len: config.page_len ? config.page_len : 50,
|
||||||
print_after_table: function() {
|
print_after_table: function() {
|
||||||
return '<div class="card-footer bg-transparent text-end text-muted">' + uojLocale("contests::n participants", standings.length) + '</div><script>if (window.MathJax) window.MathJax.typeset();</scr' + 'ipt>';
|
return '<div class="card-footer bg-transparent text-end text-muted">' + uojLocale("contests::n participants", standings.length) + '</div><script>if (window.MathJax) window.MathJax.typeset();</scr' + 'ipt>';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user