userCanManage(Auth::user()) || UOJResponse::page403(); $cur_tab = UOJRequest::get('tab', 'is_string', 'profile'); $tabs_info = [ 'profile' => [ 'name' => '基本信息', 'url' => '/group/' . UOJGroup::info('id') . '/manage/profile', ], 'assignments' => [ 'name' => '作业管理', 'url' => '/group/' . UOJGroup::info('id') . '/manage/assignments', ], 'users' => [ 'name' => '用户管理', 'url' => '/group/' . UOJGroup::info('id') . '/manage/users', ] ]; if (!isset($tabs_info[$cur_tab])) { UOJResponse::page404(); } if ($cur_tab == 'profile') { $update_profile_form = new UOJForm('update_profile'); $update_profile_form->addInput('name', [ 'label' => '名称', 'default_value' => HTML::unescape(UOJGroup::info('title')), 'validator_php' => function ($title, &$vdata) { if ($title == '') { return '名称不能为空'; } if (strlen($title) > 100) { return '名称过长'; } $title = HTML::escape($title); if ($title === '') { return '无效编码'; } $vdata['title'] = $title; return ''; }, ]); $update_profile_form->addCheckboxes('is_hidden', [ 'div_class' => 'mt-3', 'label' => '可见性', 'label_class' => 'me-3', 'options' => [ 0 => '公开', 1 => '隐藏', ], 'select_class' => 'd-inline-block', 'option_div_class' => 'form-check d-inline-block ms-2', 'default_value' => UOJGroup::info('is_hidden'), ]); $update_profile_form->addTextArea('announcement', [ 'div_class' => 'mt-3', 'label' => '公告', 'input_class' => 'form-control font-monospace', 'default_value' => UOJGroup::info('announcement'), 'help' => '公告支持 Markdown 语法。', 'validator_php' => function ($announcement, &$vdata) { if (strlen($announcement) > 3000) { return '公告过长'; } $vdata['announcement'] = $announcement; return ''; }, ]); $update_profile_form->handle = function ($vdata) { DB::update([ "update `groups`", "set", [ "title" => $vdata['title'], "is_hidden" => $_POST['is_hidden'], "announcement" => $vdata['announcement'], ], "where", [ "id" => UOJGroup::info('id'), ], ]); dieWithJsonData(['status' => 'success', 'message' => '修改成功']); }; $update_profile_form->setAjaxSubmit(<<config['submit_button']['class'] = 'btn btn-secondary'; $update_profile_form->config['submit_button']['text'] = '更新'; $update_profile_form->runAtServer(); } elseif ($cur_tab == 'assignments') { if (isset($_POST['submit-remove_assignment']) && $_POST['submit-remove_assignment'] == 'remove_assignment') { $list_id = UOJRequest::post('list_id'); $list = UOJGroupAssignment::query($list_id); if (!$list || !$list->valid()) { dieWithAlert('题单不合法。'); } DB::delete([ "delete from groups_assignments", "where", [ "list_id" => $list->info['id'], "group_id" => UOJGroup::info('id'), ], ]); dieWithAlert('移除成功!'); } $add_new_assignment_form = new UOJForm('add_new_assignment'); $add_new_assignment_form->addInput('new_assignment_list_id', [ 'label' => '题单 ID', 'validator_php' => function ($list_id, &$vdata) { if (!validateUInt($list_id)) { return '题单 ID 不合法'; } $list = UOJList::query($list_id); if (!$list) { return '题单不存在'; } if ($list->info['is_hidden']) { return '题单是隐藏的'; } if (UOJGroup::cur()->hasAssignment($list)) { return '该题单已经在作业中'; } $vdata['list_id'] = $list_id; return ''; }, ]); $add_new_assignment_form->addInput('new_assignment_end_time', [ 'label' => '截止时间', 'default_value' => UOJTime::time2str((new DateTime())->add(new DateInterval("P7D"))->setTime(22, 30, 0)), 'validator_php' => function ($end_time, &$vdata) { try { $vdata['end_time'] = new DateTime($end_time); } catch (Exception $e) { return '无效时间格式'; } return ''; }, ]); $add_new_assignment_form->handle = function (&$vdata) { DB::insert([ "insert into groups_assignments", DB::bracketed_fields(["group_id", "list_id", "end_time"]), "values", DB::tuple([ UOJGroup::info('id'), $vdata['list_id'], $vdata['end_time']->format('Y-m-d H:i:s'), ]), ]); dieWithJsonData([ 'status' => 'success', 'message' => '题单 #' . $vdata['list_id'] . ' 已经被添加到作业列表中,结束时间为 ' . $vdata['end_time']->format('Y-m-d H:i:s') . '。' ]); }; $add_new_assignment_form->config['submit_button']['class'] = 'btn btn-secondary'; $add_new_assignment_form->config['submit_button']['text'] = '添加'; $add_new_assignment_form->setAjaxSubmit(<<runAtServer(); $hidden_time = new DateTime(); $hidden_time->sub(new DateInterval('P3D')); } elseif ($cur_tab == 'users') { $users_form = newAddDelCmdForm( 'users', function ($username) { $user = UOJUser::query($username); if (!$user) { return '用户不存在。'; } return ''; }, function ($type, $username) { if ($type === '+') { DB::insert([ "insert into groups_users", DB::bracketed_fields(["group_id", "username"]), "values", DB::tuple([ UOJGroup::info('id'), $username, ]), ]); } else if ($type === '-') { DB::delete([ "delete from groups_users", "where", [ "group_id" => UOJGroup::info('id'), "username" => $username, ], ]); } }, null, [ 'help' => '命令格式:命令一行一个,+baoshuo 表示把用户名为 baoshuo 的用户加入小组,-baoshuo 表示把用户名为 baoshuo 的用户从小组中移除。', ] ); $users_form->runAtServer(); } ?>

(ID: #) 管理

getLink([ 'class' => 'btn btn-light d-block mt-2 w-100 text-start text-primary uoj-back-btn', 'text' => ' 返回', ]); ?>
printHTML() ?>
注意事项
  • 隐藏的小组无法被普通用户查看,即使该用户属于本小组。
  • 公告支持 Markdown 语法,但不支持添加数学公式。
UOJGroup::info('id')], 'order by end_time desc, list_id desc', << 题单 ID 标题 状态 结束时间 操作 EOD, function ($row) use ($hidden_time) { $assignment = UOJGroupAssignment::query($row['list_id']); echo HTML::tag_begin('tr'); echo HTML::tag('td', ['class' => 'text-center'], $assignment->info['id']); echo HTML::tag_begin('td'); echo $assignment->getLink(); if ($assignment->info['is_hidden']) { echo ' ', UOJLocale::get('hidden'), ' '; } echo HTML::tag_end('td'); if ($assignment->info['end_time'] < $hidden_time) { echo HTML::tag('td', ['class' => 'text-secondary'], '已隐藏'); } elseif ($assignment->info['end_time'] < UOJTime::$time_now) { echo HTML::tag('td', ['class' => 'text-danger'], '已结束'); } else { echo HTML::tag('td', ['class' => 'text-success'], '进行中'); } echo HTML::tag('td', [], $assignment->info['end_time_str']); echo ''; echo ' 编辑 '; echo '
info['id'], ')吗?移除作业不会删除题单。")\'>' . HTML::hiddenToken() . '' . '' . '
'; echo ''; echo ''; }, [ 'page_len' => 10, 'div_classes' => ['table-responsive'], 'table_classes' => ['table', 'align-middle'], ] ); ?>
printHTML() ?>
注意事项
  • 要被添加为作业的题单必须是公开的。
  • 请为学生预留合理的完成作业的时间。
  • 排行榜将在结束后停止更新。
  • 如需延长结束时间请删除后再次添加,排行数据不会丢失。
  • 作业结束七天后将会自动在小组主页中隐藏,但仍可直接通过 URL 访问。
UOJGroup::info('id')], 'order by username asc', << 用户名 EOD, function ($row) { echo HTML::tag_begin('tr'); echo HTML::tag('td', [], UOJUser::getLink($row['username'])); echo HTML::tag_end('tr'); }, [ 'page_len' => 10, 'div_classes' => ['table-responsive'], 'table_classes' => ['table', 'align-middle'], ] ); ?> printHTML() ?>