mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 12:58:40 +00:00
refactor: group page with bs5
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
a56923d52a
commit
9fc1628709
@ -15,30 +15,79 @@
|
||||
if (!validateUInt($group_id) || !($group = queryGroup($group_id))) {
|
||||
become404Page();
|
||||
}
|
||||
|
||||
if (!isset($_COOKIE['bootstrap4'])) {
|
||||
$REQUIRE_LIB['bootstrap5'] = '';
|
||||
}
|
||||
?>
|
||||
|
||||
<?php echoUOJPageHeader(UOJLocale::get('groups')) ?>
|
||||
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-9">
|
||||
<div class="d-flex justify-content-between">
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
<h1 class="h2">
|
||||
<?php if ($group['is_hidden']): ?>
|
||||
<span class="fs-5 text-danger">[隐藏]</span>
|
||||
<?php endif ?>
|
||||
<?= $group['title'] ?>
|
||||
<span class="fs-5">(ID: #<?= $group['id'] ?>)</span>
|
||||
</h1>
|
||||
<?php else: ?>
|
||||
<h2 style="margin-top: 24px"><?= $group['title'] ?></h2>
|
||||
<p>(<b>小组 ID</b>: <?= $group['id'] ?>)</p>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (isSuperUser($myUser)): ?>
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
<div class="text-end">
|
||||
<a class="btn btn-primary" href="/group/<?= $group['id'] ?>/manage" role="button">
|
||||
<?= UOJLocale::get('problems::manage') ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item"><a class="nav-link" href="/group/<?= $group['id'] ?>/manage" role="tab">管理</a></li>
|
||||
</ul>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
|
||||
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
<div class="card card-default mb-3">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title h4">
|
||||
<?php else: ?>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 mt-4">
|
||||
<h5><?= UOJLocale::get('news') ?></h5>
|
||||
<ul>
|
||||
<h5>
|
||||
<?php endif ?>
|
||||
<?= UOJLocale::get('news') ?>
|
||||
</h5>
|
||||
<ul
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
class="mb-0"
|
||||
<?php endif ?>
|
||||
>
|
||||
<?php
|
||||
$current_ac = queryGroupCurrentAC($group['id']);
|
||||
foreach ($current_ac as $ac) {
|
||||
echo '<li>';
|
||||
echo getUserLink($ac['submitter']);
|
||||
echo ' 解决了问题 ';
|
||||
echo '<a href="/problem/', $ac['problem_id'], '">', $ac['problem_title'], '</a> ';
|
||||
echo '<a ';
|
||||
if (isset($REQUIRE_LIB['bootstrap5'])) {
|
||||
echo ' class="text-decoration-none" ';
|
||||
}
|
||||
echo ' href="/problem/', $ac['problem_id'], '">', $ac['problem_title'], '</a> ';
|
||||
echo '<time class="time">(', $ac['submit_time'], ')</time>';
|
||||
echo '</li>';
|
||||
}
|
||||
@ -50,10 +99,22 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
<div class="card card-default mb-3">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title h4">
|
||||
<?php else: ?>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 mt-4">
|
||||
<h5><?= UOJLocale::get('assignments') ?></h5>
|
||||
<ul>
|
||||
<h5>
|
||||
<?php endif ?>
|
||||
<?= UOJLocale::get('assignments') ?>
|
||||
</h5>
|
||||
<ul
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
class="mb-0"
|
||||
<?php endif ?>
|
||||
>
|
||||
<?php
|
||||
$assignments = queryGroupActiveAssignments($group['id']);
|
||||
foreach ($assignments as $ass) {
|
||||
@ -61,12 +122,12 @@
|
||||
$create_time = DateTime::createFromFormat('Y-m-d H:i:s', $ass['create_time']);
|
||||
$now = new DateTime();
|
||||
|
||||
if ($now->getTimestamp() - $ddl->getTimestamp() > 604800) {
|
||||
continue;
|
||||
} // 7d
|
||||
|
||||
echo '<li>';
|
||||
echo "<a href=\"/problem_list/{$ass['list_id']}\">{$ass['title']} (题单 #{$ass['list_id']})</a>";
|
||||
echo '<a ';
|
||||
if (isset($REQUIRE_LIB['bootstrap5'])) {
|
||||
echo ' class="text-decoration-none" ';
|
||||
}
|
||||
echo ' href="/problem_list/', $ass['list_id'], '">', $ass['title'], ' (题单 #', $ass['list_id'], ')</a>';
|
||||
|
||||
if ($ddl < $now) {
|
||||
echo '<sup style="color:red"> overdue</sup>';
|
||||
@ -77,7 +138,11 @@
|
||||
}
|
||||
|
||||
$ddl_str = $ddl->format('Y-m-d H:i');
|
||||
echo " (截止时间: {$ddl_str},<a href=\"/assignment/{$ass['id']}\">查看完成情况</a>)";
|
||||
echo ' (截止时间: ', $ddl_str, ',<a ';
|
||||
if (isset($REQUIRE_LIB['bootstrap5'])) {
|
||||
echo ' class="text-decoration-none" ';
|
||||
}
|
||||
echo ' href="/assignment/', $ass['id'], '">查看完成情况</a>)';
|
||||
echo '</li>';
|
||||
}
|
||||
|
||||
@ -89,11 +154,38 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
<div class="card card-default mb-3">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title h4">
|
||||
<?php else: ?>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 mt-4">
|
||||
<h5><?= UOJLocale::get('top solver') ?></h5>
|
||||
<?php echoRanklist(array('echo_full' => true, 'group_id' => $group_id, 'by_accepted' => true)) ?>
|
||||
<h5>
|
||||
<?php endif ?>
|
||||
<?= UOJLocale::get('top solver') ?>
|
||||
</h5>
|
||||
<?php echoRanklist(array(
|
||||
'echo_full' => true,
|
||||
'group_id' => $group_id,
|
||||
'by_accepted' => true,
|
||||
'table_classes' => isset($REQUIRE_LIB['bootstrap5'])
|
||||
? array('table', 'text-center', 'mb-0')
|
||||
: array('table', 'table-bordered', 'table-hover', 'table-striped', 'table-text-center')
|
||||
)) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
</div>
|
||||
|
||||
<aside class="col mt-3 mt-md-0">
|
||||
|
||||
<?php uojIncludeView('sidebar', array()); ?>
|
||||
</aside>
|
||||
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<?php echoUOJPageFooter() ?>
|
||||
|
@ -127,11 +127,9 @@
|
||||
},
|
||||
null
|
||||
);
|
||||
|
||||
$default_ddl = new DateTime();
|
||||
$default_ddl->setTime(17, 0, 0);
|
||||
$default_ddl->add(new DateInterval("P7D"));
|
||||
|
||||
$add_new_assignment_form->addInput('new_assignment_deadline', 'text', '截止时间', $default_ddl->format('Y-m-d H:i'),
|
||||
function ($x) {
|
||||
$ddl = DateTime::createFromFormat('Y-m-d H:i', $x);
|
||||
@ -143,7 +141,17 @@
|
||||
},
|
||||
null
|
||||
);
|
||||
$add_new_assignment_form->submit_button_config['align'] = 'compressed';
|
||||
$add_new_assignment_form->submit_button_config['text'] = '添加作业';
|
||||
$add_new_assignment_form->handle = function() {
|
||||
global $group_id, $myUser;
|
||||
$list_id = $_POST['new_assignment_list_id'];
|
||||
$ddl = DateTime::createFromFormat('Y-m-d H:i', $_POST['new_assignment_deadline']);
|
||||
$ddl_str = $ddl->format('Y-m-d H:i:s');
|
||||
|
||||
DB::insert("insert into assignments (group_id, list_id, create_time, deadline) values ({$group_id}, '{$list_id}', now(), '{$ddl_str}')");
|
||||
};
|
||||
$add_new_assignment_form->runAtServer();
|
||||
|
||||
$remove_assignment_form = new UOJForm('remove_assignment');
|
||||
$remove_assignment_form->addInput('remove_assignment_list_id', 'text', '题单 ID', '',
|
||||
@ -223,4 +231,47 @@
|
||||
<h5>删除小组的作业</h5>
|
||||
<?php $remove_assignment_form->printHTML(); ?>
|
||||
|
||||
<h5>已被自动隐藏的作业</h5>
|
||||
<ul>
|
||||
<?php
|
||||
$assignments = queryGroupAssignments($group['id']);
|
||||
foreach ($assignments as $ass) {
|
||||
$ddl = DateTime::createFromFormat('Y-m-d H:i:s', $ass['deadline']);
|
||||
$create_time = DateTime::createFromFormat('Y-m-d H:i:s', $ass['create_time']);
|
||||
$now = new DateTime();
|
||||
|
||||
if ($now->getTimestamp() - $ddl->getTimestamp() <= 604800) {
|
||||
continue;
|
||||
} // 7d
|
||||
|
||||
echo '<li>';
|
||||
echo '<a ';
|
||||
if (isset($REQUIRE_LIB['bootstrap5'])) {
|
||||
echo ' class="text-decoration-none" ';
|
||||
}
|
||||
echo ' href="/problem_list/', $ass['list_id'], '">', $ass['title'], ' (题单 #', $ass['list_id'], ')</a>';
|
||||
|
||||
if ($ddl < $now) {
|
||||
echo '<sup style="color:red"> overdue</sup>';
|
||||
} elseif ($ddl->getTimestamp() - $now->getTimestamp() < 86400) { // 1d
|
||||
echo '<sup style="color:red"> soon</sup>';
|
||||
} elseif ($now->getTimestamp() - $create_time->getTimestamp() < 86400) { // 1d
|
||||
echo '<sup style="color:red"> new</sup>';
|
||||
}
|
||||
|
||||
$ddl_str = $ddl->format('Y-m-d H:i');
|
||||
echo ' (截止时间: ', $ddl_str, ',<a ';
|
||||
if (isset($REQUIRE_LIB['bootstrap5'])) {
|
||||
echo ' class="text-decoration-none" ';
|
||||
}
|
||||
echo ' href="/assignment/', $ass['id'], '">查看完成情况</a>)';
|
||||
echo '</li>';
|
||||
}
|
||||
|
||||
if (count($assignments) == 0) {
|
||||
echo '<p>暂无作业</p>';
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<?php echoUOJPageFooter() ?>
|
||||
|
@ -124,8 +124,11 @@ function queryGroupmateCurrentAC($username) {
|
||||
function queryGroupCurrentAC($group_id) {
|
||||
return DB::selectAll("select a.problem_id as problem_id, a.submitter as submitter, a.submission_id as submission_id, b.submit_time as submit_time, d.title as problem_title, b.submit_time as submit_time, e.realname as realname from best_ac_submissions a inner join submissions b on (a.submission_id = b.id) inner join groups_users c on (a.submitter = c.username and c.group_id = $group_id) inner join problems d on (a.problem_id = d.id and d.is_hidden = 0) inner join user_info e on (a.submitter = e.username) where b.submit_time > addtime(now(), '-360:00:00') order by b.submit_time desc limit 10", MYSQLI_ASSOC);
|
||||
}
|
||||
function queryGroupAssignments($group_id) {
|
||||
return DB::selectAll("select a.id as id, a.list_id as list_id, a.create_time as create_time, a.deadline as deadline, b.title from assignments a left join lists b on a.list_id = b.id where a.group_id = $group_id order by a.deadline asc", MYSQLI_ASSOC);
|
||||
}
|
||||
function queryGroupActiveAssignments($group_id) {
|
||||
return DB::selectAll("select a.id as id, a.list_id as list_id, a.create_time as create_time, a.deadline as deadline, b.title from assignments a left join lists b on a.list_id = b.id where a.group_id = $group_id and a.deadline > addtime(now(), '-360:00:00') order by a.deadline asc", MYSQLI_ASSOC);
|
||||
return DB::selectAll("select a.id as id, a.list_id as list_id, a.create_time as create_time, a.deadline as deadline, b.title from assignments a left join lists b on a.list_id = b.id where a.group_id = $group_id and a.deadline > addtime(now(), '-168:00:00') order by a.deadline asc", MYSQLI_ASSOC);
|
||||
}
|
||||
|
||||
function queryAssignment($id) {
|
||||
|
Loading…
Reference in New Issue
Block a user