diff --git a/db/app_uoj233.sql b/db/app_uoj233.sql index 4dd2aa8..9fb0e3a 100644 --- a/db/app_uoj233.sql +++ b/db/app_uoj233.sql @@ -626,6 +626,7 @@ CREATE TABLE `problems` ( PRIMARY KEY (`id`), KEY `assigned_to_judger` (`assigned_to_judger`), KEY `uploader` (`uploader`), + KEY `difficulty` (`difficulty`), KEY `is_hidden` (`is_hidden`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci TABLESPACE `innodb_system`; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/web/app/controllers/problem_set.php b/web/app/controllers/problem_set.php index c7886e8..e557a03 100644 --- a/web/app/controllers/problem_set.php +++ b/web/app/controllers/problem_set.php @@ -128,9 +128,7 @@ function getProblemTR($info) { ) ); } - if (isset($_COOKIE['show_difficulty'])) { - $html .= HTML::tag('td', [], UOJProblem::getDifficultyHTML($problem->info['difficulty'])); - } + $html .= HTML::tag('td', [], UOJProblem::getDifficultyHTML($problem->info['difficulty'])); $html .= HTML::tag('td', [], ClickZans::getCntBlock($problem->info['zan'])); $html .= HTML::tag_end('tr'); return $html; @@ -179,6 +177,10 @@ if (Auth::check() && isset($_GET['my'])) { $cond['problems.uploader'] = Auth::id(); } +if (isset($_GET['difficulty']) && $_GET['difficulty']) { + $cond['problems.difficulty'] = $_GET['difficulty']; +} + if (empty($cond)) { $cond = '1'; } @@ -189,9 +191,7 @@ $header .= '' . UOJLocale::get('problems::problem') . ''; if (isset($_COOKIE['show_submit_mode'])) { $header .= '' . UOJLocale::get('problems::ac ratio') . ''; } -if (isset($_COOKIE['show_difficulty'])) { - $header .= '' . UOJLocale::get('problems::difficulty') . ''; -} +$header .= '' . UOJLocale::get('problems::difficulty') . ''; $header .= '' . UOJLocale::get('appraisal') . ''; $header .= ''; @@ -246,7 +246,6 @@ $pag = new Paginator([
-
@@ -283,13 +282,6 @@ $pag = new Paginator([
- -
- /> - -
@@ -322,19 +314,6 @@ $pag = new Paginator([ } location.reload(); }); - $('#input-show_difficulty').click(function() { - if (this.checked) { - $.cookie('show_difficulty', '', { - path: '/problems', - expires: 365, - }); - } else { - $.removeCookie('show_difficulty', { - path: '/problems' - }); - } - location.reload(); - });
@@ -366,26 +345,39 @@ $pag = new Paginator([
- -
- class="form-check-input" id="input-my"> - +
+ +
+ class="form-check-input" id="input-my"> + +
+ + +
+ class="form-check-input" id="input-is_hidden"> + +
+ +
+
+ +
+
- - -
- class="form-check-input" id="input-is_hidden"> - -
- +
diff --git a/web/app/upgrade/20_problem_difficulty/up.sql b/web/app/upgrade/20_problem_difficulty/up.sql index 5cd8680..16f125a 100644 --- a/web/app/upgrade/20_problem_difficulty/up.sql +++ b/web/app/upgrade/20_problem_difficulty/up.sql @@ -1,2 +1,3 @@ ALTER TABLE `problems` ADD `difficulty` int NOT NULL DEFAULT '-1' AFTER `submit_num`; ALTER TABLE `problems` MODIFY `extra_config` json NOT NULL; +ALTER TABLE `problems` ADD KEY `difficulty` (`difficulty`);