mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-26 08:28:42 +00:00
feat(web): display assignments in sidebar
This commit is contained in:
parent
be876d2a1d
commit
17c400d15c
@ -157,7 +157,7 @@
|
|||||||
|
|
||||||
<?php if (Auth::check()): ?>
|
<?php if (Auth::check()): ?>
|
||||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||||
<?php uojIncludeView('sidebar') ?>
|
<?php uojIncludeView('sidebar', ['assignments_hidden' => '', 'groups_hidden' => '']) ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ return [
|
|||||||
'problems lists' => 'Problems Lists',
|
'problems lists' => 'Problems Lists',
|
||||||
'groups' => 'Groups',
|
'groups' => 'Groups',
|
||||||
'add new group' => 'Add new group',
|
'add new group' => 'Add new group',
|
||||||
|
'group announcements' => 'Group Announcements',
|
||||||
'users count' => 'Users',
|
'users count' => 'Users',
|
||||||
'submissions' => 'Submissions',
|
'submissions' => 'Submissions',
|
||||||
'hacks' => 'Hack!',
|
'hacks' => 'Hack!',
|
||||||
@ -30,6 +31,7 @@ return [
|
|||||||
'search' => 'Search',
|
'search' => 'Search',
|
||||||
'news' => 'News',
|
'news' => 'News',
|
||||||
'assignments' => 'Assignments',
|
'assignments' => 'Assignments',
|
||||||
|
'assignments to do' => 'Assignments to do',
|
||||||
'username' => 'Username',
|
'username' => 'Username',
|
||||||
'password' => 'Password',
|
'password' => 'Password',
|
||||||
'new password' => 'New password',
|
'new password' => 'New password',
|
||||||
|
@ -14,6 +14,7 @@ return [
|
|||||||
'problems lists' => '题单',
|
'problems lists' => '题单',
|
||||||
'groups' => '小组',
|
'groups' => '小组',
|
||||||
'add new group' => '添加新小组',
|
'add new group' => '添加新小组',
|
||||||
|
'group announcements' => '小组公告',
|
||||||
'users count' => '用户数量',
|
'users count' => '用户数量',
|
||||||
'submissions' => '提交记录',
|
'submissions' => '提交记录',
|
||||||
'hacks' => 'Hack!',
|
'hacks' => 'Hack!',
|
||||||
@ -30,6 +31,7 @@ return [
|
|||||||
'search' => '搜索',
|
'search' => '搜索',
|
||||||
'news' => '最新动态',
|
'news' => '最新动态',
|
||||||
'assignments' => '作业',
|
'assignments' => '作业',
|
||||||
|
'assignments to do' => '待完成作业',
|
||||||
'username' => '用户名',
|
'username' => '用户名',
|
||||||
'password' => '密码',
|
'password' => '密码',
|
||||||
'new password' => '新密码',
|
'new password' => '新密码',
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<?php if (Auth::check()): ?>
|
<?php if (Auth::check()): ?>
|
||||||
<?php if (!isset($group_announcements_hidden)): ?>
|
<?php if (!isset($groups_hidden)): ?>
|
||||||
<?php $groups = queryGroupsOfUser(Auth::id()); ?>
|
<?php $groups = queryGroupsOfUser(Auth::id()); ?>
|
||||||
<?php if (count($groups)): ?>
|
<?php if (count($groups)): ?>
|
||||||
<div class="card card-default mb-2" id="group-user-announcements">
|
<div class="card card-default mb-2" id="group-user-announcements">
|
||||||
<div class="card-header fw-bold bg-transparent">
|
<div class="card-header fw-bold bg-transparent">
|
||||||
小组公告
|
<?= UOJLocale::get('group announcements') ?>
|
||||||
</div>
|
</div>
|
||||||
<ul class="list-group list-group-flush">
|
<ul class="list-group list-group-flush">
|
||||||
<?php foreach ($groups as $group): ?>
|
<?php foreach ($groups as $group): ?>
|
||||||
@ -21,14 +21,63 @@
|
|||||||
<?= HTML::purifier_inline()->purify($group_announcement) ?>
|
<?= HTML::purifier_inline()->purify($group_announcement) ?>
|
||||||
</div>
|
</div>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<div>(暂无公告)</div>
|
<div class="text-muted">
|
||||||
|
<?= UOJLocale::get('none') ?>
|
||||||
|
</div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</li>
|
</li>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php if (!isset($assignments_hidden)): ?>
|
||||||
|
<?php
|
||||||
|
$assignments = [];
|
||||||
|
foreach ($groups as $group) {
|
||||||
|
$assignments = array_merge($assignments, queryGroupActiveAssignments($group['id']));
|
||||||
|
}
|
||||||
|
|
||||||
|
usort($assignments, function($a, $b) {
|
||||||
|
$deadline_a = DateTime::createFromFormat('Y-m-d H:i:s', $a['deadline']);
|
||||||
|
$deadline_b = DateTime::createFromFormat('Y-m-d H:i:s', $b['deadline']);
|
||||||
|
|
||||||
|
return $deadline_a->getTimestamp() - $deadline_b->getTimestamp();
|
||||||
|
});
|
||||||
|
?>
|
||||||
|
<?php if (count($assignments)): ?>
|
||||||
|
<div class="card card-default mb-2" id="group-assignments">
|
||||||
|
<div class="card-header fw-bold bg-transparent">
|
||||||
|
<?= UOJLocale::get('assignments') ?>
|
||||||
|
</div>
|
||||||
|
<ul class="list-group list-group-flush">
|
||||||
|
<?php foreach ($assignments as $assignment): ?>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<?php
|
||||||
|
$deadline = DateTime::createFromFormat('Y-m-d H:i:s', $assignment['deadline']);
|
||||||
|
$create_time = DateTime::createFromFormat('Y-m-d H:i:s', $assignment['create_time']);
|
||||||
|
$now = new DateTime();
|
||||||
|
?>
|
||||||
|
<a href="<?= HTML::url('/assignment/'.$assignment['id']) ?>" class="fw-bold text-decoration-none">
|
||||||
|
<?= $assignment['title'] ?>
|
||||||
|
<?php if ($deadline < $now): ?>
|
||||||
|
<sup class="fw-normal text-danger">overdue</sup>
|
||||||
|
<?php elseif ($deadline->getTimestamp() - $now->getTimestamp() < 86400): ?>
|
||||||
|
<sup class="fw-normal text-danger">soon</sup>
|
||||||
|
<?php elseif ($now->getTimestamp() - $create_time->getTimestamp() < 86400): ?>
|
||||||
|
<sup class="fw-normal text-danger">new</sup>
|
||||||
|
<?php endif ?>
|
||||||
|
</a>
|
||||||
|
<div class="text-end small text-muted">
|
||||||
|
截止时间: <?= $deadline->format('Y-m-d H:i') ?>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<?php endif // count($assignments) ?>
|
||||||
|
<?php endif // !isset($assignments_hidden) ?>
|
||||||
<?php endif // count($groups) ?>
|
<?php endif // count($groups) ?>
|
||||||
<?php endif // !isset($group_announcements_hidden) ?>
|
<?php endif // !isset($group_hidden) ?>
|
||||||
<?php endif // Auth::check() ?>
|
<?php endif // Auth::check() ?>
|
||||||
|
|
||||||
<?php if (!UOJConfig::$data['switch']['force-login'] || Auth::check()): ?>
|
<?php if (!UOJConfig::$data['switch']['force-login'] || Auth::check()): ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user