refactor(problem): store limits into extra_config

This commit is contained in:
Baoshuo Ren 2023-02-07 06:51:04 +08:00
parent 15706742c2
commit 6ff83e810b
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
2 changed files with 18 additions and 9 deletions

View File

@ -259,8 +259,6 @@ if ($pre_submit_check_ret === true && !$no_more_submission) {
$answer_form->runAtServer();
}
$conf = UOJProblem::cur()->getProblemConf();
if (UOJContest::cur()) {
$pageTitle = UOJProblem::cur()->getTitle(['with' => 'letter', 'simplify' => true]);
} else {
@ -291,13 +289,8 @@ if (UOJContest::cur()) {
</h1>
<?php
if (UOJProblem::info('type') == 'local') {
$time_limit = $conf instanceof UOJProblemConf ? $conf->getVal('time_limit', 1) : null;
$memory_limit = $conf instanceof UOJProblemConf ? $conf->getVal('memory_limit', 256) : null;
} else if (UOJProblem::info('type') == 'remote') {
$time_limit = UOJProblem::cur()->getExtraConfig('time_limit');
$memory_limit = UOJProblem::cur()->getExtraConfig('memory_limit');
}
$time_limit = UOJProblem::cur()->getExtraConfig('time_limit');
$memory_limit = UOJProblem::cur()->getExtraConfig('memory_limit');
?>
<div class="text-center small">
时间限制: <?= $time_limit ? "$time_limit s" : "N/A" ?>

View File

@ -482,6 +482,22 @@ class SyncProblemDataHandler {
['mv', "{$this->id}.next.zip", "{$this->id}.zip", '-f'],
]);
DB::update([
"update problems",
"set", [
"extra_config" => DB::json_set(
'extra_config',
'$.time_limit',
$this->final_problem_conf['time_limit'] ? (int)$this->final_problem_conf['time_limit'] : null,
'$.memory_limit',
$this->final_problem_conf['memory_limit'] ? (int)$this->final_problem_conf['memory_limit'] : null,
),
],
"where", [
"id" => $this->id,
],
]);
return '';
}