feat: add view_solution_type form

This commit is contained in:
Baoshuo Ren 2022-09-29 09:27:11 +08:00
parent 4daa3ed248
commit 83678f42b9
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

View File

@ -531,7 +531,6 @@ EOD
$view_type_form = new UOJForm('view_type'); $view_type_form = new UOJForm('view_type');
$view_type_form->addVSelect('view_content_type', $view_type_form->addVSelect('view_content_type',
array('NONE' => '禁止', array('NONE' => '禁止',
'SELF' => '仅自己',
'ALL_AFTER_AC' => 'AC后', 'ALL_AFTER_AC' => 'AC后',
'ALL' => '所有人' 'ALL' => '所有人'
), ),
@ -567,6 +566,33 @@ EOD
}; };
$view_type_form->submit_button_config['class_str'] = 'btn btn-warning btn-block top-buffer-sm'; $view_type_form->submit_button_config['class_str'] = 'btn btn-warning btn-block top-buffer-sm';
$solution_view_type_form = new UOJForm('solution_view_type');
$solution_view_type_form->addVSelect('view_solution_type',
array('NONE' => '禁止',
'ALL_AFTER_AC' => 'AC后',
'ALL' => '所有人'
),
'查看题解:',
$problem_extra_config['view_solution_type']
);
$solution_view_type_form->addVSelect('submit_solution_type',
array('NONE' => '禁止',
'ALL_AFTER_AC' => 'AC后',
'ALL' => '所有人'
),
'提交题解:',
$problem_extra_config['submit_solution_type']
);
$solution_view_type_form->handle = function() {
global $problem, $problem_extra_config;
$config = $problem_extra_config;
$config['view_solution_type'] = $_POST['view_solution_type'];
$config['submit_solution_type'] = $_POST['submit_solution_type'];
$esc_config = DB::escape(json_encode($config));
DB::query("update problems set extra_config = '$esc_config' where id = '{$problem['id']}'");
};
$solution_view_type_form->submit_button_config['class_str'] = 'btn btn-warning btn-block top-buffer-sm';
if ($problem['hackable']) { if ($problem['hackable']) {
$test_std_form = new UOJForm('test_std'); $test_std_form = new UOJForm('test_std');
$test_std_form->handle = function() { $test_std_form->handle = function() {
@ -622,6 +648,7 @@ EOD
$hackable_form->runAtServer(); $hackable_form->runAtServer();
$view_type_form->runAtServer(); $view_type_form->runAtServer();
$solution_view_type_form->runAtServer();
$data_form->runAtServer(); $data_form->runAtServer();
$clear_data_form->runAtServer(); $clear_data_form->runAtServer();
$rejudge_form->runAtServer(); $rejudge_form->runAtServer();
@ -696,6 +723,12 @@ EOD
<?php $view_type_form->printHTML(); ?> <?php $view_type_form->printHTML(); ?>
</div> </div>
</div> </div>
<div class="top-buffer-md">
<button id="button-display_view_type" type="button" class="btn btn-primary btn-block" onclick="$('#div-solution_view_type').toggle('fast');">题解可视权限</button>
<div class="top-buffer-sm" id="div-solution_view_type" style="display:none; padding-left:5px; padding-right:5px;">
<?php $solution_view_type_form->printHTML(); ?>
</div>
</div>
<div class="top-buffer-md"> <div class="top-buffer-md">
<?php $data_form->printHTML(); ?> <?php $data_form->printHTML(); ?>
</div> </div>