mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 12:58:40 +00:00
feat(web/problems): difficulty filter
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
248a924df7
commit
dfb47c4b32
@ -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 */;
|
||||
|
@ -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', [], 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 .= '<th>' . UOJLocale::get('problems::problem') . '</th>';
|
||||
if (isset($_COOKIE['show_submit_mode'])) {
|
||||
$header .= '<th class="text-center" style="width:125px;">' . UOJLocale::get('problems::ac ratio') . '</th>';
|
||||
}
|
||||
if (isset($_COOKIE['show_difficulty'])) {
|
||||
$header .= '<th class="text-center" style="width:8em;">' . UOJLocale::get('problems::difficulty') . '</th>';
|
||||
}
|
||||
$header .= '<th class="text-center" style="width:8em;">' . UOJLocale::get('problems::difficulty') . '</th>';
|
||||
$header .= '<th class="text-center" style="width:50px;">' . UOJLocale::get('appraisal') . '</th>';
|
||||
$header .= '</tr>';
|
||||
|
||||
@ -246,7 +246,6 @@ $pag = new Paginator([
|
||||
<?php echoUOJPageHeader(UOJLocale::get('problems')) ?>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<!-- left col -->
|
||||
<div class="col-lg-9">
|
||||
|
||||
@ -283,13 +282,6 @@ $pag = new Paginator([
|
||||
<?= UOJLocale::get('problems::show statistics') ?>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check d-inline-block">
|
||||
<input type="checkbox" id="input-show_difficulty" class="form-check-input" <?= isset($_COOKIE['show_difficulty']) ? 'checked="checked" ' : '' ?> />
|
||||
<label class="form-check-label" for="input-show_difficulty">
|
||||
<?= UOJLocale::get('problems::show difficulty') ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -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();
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="card my-3">
|
||||
@ -366,6 +345,7 @@ $pag = new Paginator([
|
||||
<i class="bi bi-search"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<?php if (Auth::check()) : ?>
|
||||
<div class="form-check d-inline-block">
|
||||
<input type="checkbox" name="my" <?= isset($_GET['my']) ? 'checked="checked"' : '' ?> class="form-check-input" id="input-my">
|
||||
@ -382,10 +362,22 @@ $pag = new Paginator([
|
||||
</label>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<div class="row mt-3">
|
||||
<label class="col-sm-3 col-form-label" for="input-difficulty">难度</label>
|
||||
<div class="col-sm-9">
|
||||
<select id="input-difficulty" name="difficulty" class="form-select">
|
||||
<option value="">全部</option>
|
||||
<?php foreach (UOJProblem::$difficulty as $opt_name => $opt_value) : ?>
|
||||
<?= HTML::option($opt_name, $opt_value, $opt_name == $_GET['difficulty']) ?>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
$('#search-input').val(new URLSearchParams(location.search).get('search'));
|
||||
$('#input-my, #input-is_hidden').click(function() {
|
||||
$('#input-my, #input-is_hidden, #input-difficulty').change(function() {
|
||||
$('#form-problem_search').submit();
|
||||
});
|
||||
</script>
|
||||
|
@ -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`);
|
||||
|
Loading…
Reference in New Issue
Block a user