feat: add teacher type

This commit is contained in:
Baoshuo Ren 2022-10-01 19:29:40 +08:00
parent 091f35397d
commit 60e2c80b8d
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

View File

@ -196,6 +196,8 @@
null
);
$usertype_options = array(
'student' => '学生',
'teacher' => '老师',
'problem_uploader' => '题目上传者',
'problem_manager' => '题目管理员',
'contest_judger' => '比赛评测员',
@ -207,12 +209,28 @@
global $usertype_form;
$username = $_POST['usertype_username'];
$user = queryUser($username);
switch ($_POST['usertype_type']) {
case 'student':
$user = $_POST['usertype_op'] === 'add'
? addUserType($user, 'student')
: removeUserType($user, 'student');
DB::update("update user_info set usertype = '{$user['usertype']}' where username = '{$username}'");
break;
case 'teacher':
if ($_POST['usertype_op'] === 'add') {
$user = addUserType($user, 'teacher');
$user = removeUserType($user, 'student');
} else {
$user = removeUserType($user, 'teacher');
$user = addUserType($user, 'student');
}
DB::update("update user_info set usertype = '{$user['usertype']}' where username = '{$username}'");
break;
case 'problem_uploader':
case 'problem_manager':
case 'contest_judger':
case 'contest_only':
$user = queryUser($username);
$user = $_POST['usertype_op'] === 'add'
? addUserType($user, $_POST['usertype_type'])
: removeUserType($user, $_POST['usertype_type']);