diff --git a/README.md b/README.md index 4b52ba210..580d60e39 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ SCNUOJ 可对用户在线提交的源代码进行编译和执行,并通过预 ### 华南师大软院在线评测系统 - [oj.socoding.cn](https://oj.socoding.cn/) - 外网入口 -- [oj-internal.socoding.cn](https://oj-internal.socoding.cn/) - 校园网入口 +- [10.191.65.243:5000](http://10.191.65.243:5000/) - 校园网入口 ### 帮助文档 diff --git a/messages/zh-CN/app.php b/messages/zh-CN/app.php index 6a4e74fa6..d7ece61ed 100644 --- a/messages/zh-CN/app.php +++ b/messages/zh-CN/app.php @@ -241,5 +241,6 @@ 'Current time' => '当前时间', 'Register' => '注册', 'Kanban' => '看板', - 'The submission interval is %d seconds, and you can submit again after %d seconds.' => '提交间隔为 %d 秒,%d 秒后可以再次提交。' + 'The submission interval is %d seconds, and you can submit again after %d seconds.' => '提交间隔为 %d 秒,%d 秒后可以再次提交。', + 'Punish time' => '罚时' ]; diff --git a/migrations/m211018_061720_add_contest_penalty_config.php b/migrations/m211018_061720_add_contest_penalty_config.php new file mode 100644 index 000000000..5ecd3c0ae --- /dev/null +++ b/migrations/m211018_061720_add_contest_penalty_config.php @@ -0,0 +1,40 @@ +addColumn('{{%contest}}', 'punish_time', $this->smallInteger()->defaultValue(20)); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $this->dropColumn('{{%contest}}', 'punish_time'); + } + + /* + // Use up()/down() to run migration code without a transaction. + public function up() + { + + } + + public function down() + { + echo "m211018_061720_add_contest_penalty_config cannot be reverted.\n"; + + return false; + } + */ +} diff --git a/models/Contest.php b/models/Contest.php index b1d20458d..2e8eaaa39 100644 --- a/models/Contest.php +++ b/models/Contest.php @@ -25,6 +25,7 @@ * @property int $created_by * @property string $ext_link * @property string $invite_code + * @property int $punish_time */ class Contest extends \yii\db\ActiveRecord { @@ -85,7 +86,7 @@ public function rules() [['title', 'start_time', 'end_time'], 'required'], [['start_time', 'end_time', 'lock_board_time'], 'safe'], [['description', 'editorial', 'invite_code', 'ext_link'], 'string'], - [['id', 'status', 'type', 'scenario', 'created_by', 'group_id', 'enable_print', 'enable_clarify'], 'integer'], + [['id', 'status', 'type', 'scenario', 'created_by', 'group_id', 'enable_print', 'enable_clarify', 'punish_time'], 'integer'], [['title'], 'string', 'max' => 255], ]; } @@ -108,6 +109,7 @@ public function attributeLabels() 'scenario' => Yii::t('app', 'Scenario'), 'ext_link' => '站外比赛', 'invite_code' => '邀请码', + 'punish_time' => '罚时', ]; } @@ -435,6 +437,7 @@ public function getICPCRankData($lock = true, $endtime = null) $start_time = strtotime($this->start_time); $lock_time = 0x7fffffff; $contest_end_time = strtotime($this->end_time); + $punish_time = intval($this->punish_time ?? 20); if ($endtime == null) { $endtime = $contest_end_time; } @@ -528,7 +531,7 @@ public function getICPCRankData($lock = true, $endtime = null) } else { $result[$user]['ac_time'][$pid] = 0; } - $result[$user]['time'] += $sec + $result[$user]['wa_count'][$pid] * 60 * 20; + $result[$user]['time'] += $sec + $result[$user]['wa_count'][$pid] * 60 * $punish_time; } else if ($row['result'] <= 3) { // 还未测评 ++$result[$user]['pending'][$pid]; diff --git a/modules/admin/views/contest/_form.php b/modules/admin/views/contest/_form.php index c2b7a8744..2509844ec 100644 --- a/modules/admin/views/contest/_form.php +++ b/modules/admin/views/contest/_form.php @@ -75,6 +75,12 @@ ])->label(false) ?>

+
设置比赛的罚时(分钟),仅在 ICPC 赛制生效,不填则默认 20 分钟。
+ field($model, 'punish_time', [ + 'template' => "
罚时
{input}
", + 'options' => ['class' => ''] + ])->textInput()->label(false) ?> +

设置比赛可见性。公开:任何用户均可参加比赛,若启用邀请码则正确填写邀请码的用户均可参赛。私有:任何时候比赛均只能由参赛用户访问,且比赛用户需要在后台手动添加。隐藏:前台无法看到比赛。
diff --git a/modules/admin/views/contest/create.php b/modules/admin/views/contest/create.php index 5afd3221b..d4552f3d2 100644 --- a/modules/admin/views/contest/create.php +++ b/modules/admin/views/contest/create.php @@ -15,6 +15,7 @@ $model->scenario = $model::SCENARIO_ONLINE; $model->enable_clarify = 1; $model->enable_print = 0; +$model->punish_time = 20; //罚时初始值 ?>
diff --git a/modules/admin/views/contest/view.php b/modules/admin/views/contest/view.php index 126dac30d..59b6a9a51 100644 --- a/modules/admin/views/contest/view.php +++ b/modules/admin/views/contest/view.php @@ -146,6 +146,7 @@ 'end_time', 'lock_board_time', 'description:html', + 'punish_time', ], ]) ?>