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`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `assigned_to_judger` (`assigned_to_judger`),
|
KEY `assigned_to_judger` (`assigned_to_judger`),
|
||||||
KEY `uploader` (`uploader`),
|
KEY `uploader` (`uploader`),
|
||||||
|
KEY `difficulty` (`difficulty`),
|
||||||
KEY `is_hidden` (`is_hidden`)
|
KEY `is_hidden` (`is_hidden`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci TABLESPACE `innodb_system`;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci TABLESPACE `innodb_system`;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!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', [], UOJProblem::getDifficultyHTML($problem->info['difficulty']));
|
|
||||||
}
|
|
||||||
$html .= HTML::tag('td', [], ClickZans::getCntBlock($problem->info['zan']));
|
$html .= HTML::tag('td', [], ClickZans::getCntBlock($problem->info['zan']));
|
||||||
$html .= HTML::tag_end('tr');
|
$html .= HTML::tag_end('tr');
|
||||||
return $html;
|
return $html;
|
||||||
@ -179,6 +177,10 @@ if (Auth::check() && isset($_GET['my'])) {
|
|||||||
$cond['problems.uploader'] = Auth::id();
|
$cond['problems.uploader'] = Auth::id();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_GET['difficulty']) && $_GET['difficulty']) {
|
||||||
|
$cond['problems.difficulty'] = $_GET['difficulty'];
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($cond)) {
|
if (empty($cond)) {
|
||||||
$cond = '1';
|
$cond = '1';
|
||||||
}
|
}
|
||||||
@ -189,9 +191,7 @@ $header .= '<th>' . UOJLocale::get('problems::problem') . '</th>';
|
|||||||
if (isset($_COOKIE['show_submit_mode'])) {
|
if (isset($_COOKIE['show_submit_mode'])) {
|
||||||
$header .= '<th class="text-center" style="width:125px;">' . UOJLocale::get('problems::ac ratio') . '</th>';
|
$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 .= '<th class="text-center" style="width:50px;">' . UOJLocale::get('appraisal') . '</th>';
|
||||||
$header .= '</tr>';
|
$header .= '</tr>';
|
||||||
|
|
||||||
@ -246,7 +246,6 @@ $pag = new Paginator([
|
|||||||
<?php echoUOJPageHeader(UOJLocale::get('problems')) ?>
|
<?php echoUOJPageHeader(UOJLocale::get('problems')) ?>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<!-- left col -->
|
<!-- left col -->
|
||||||
<div class="col-lg-9">
|
<div class="col-lg-9">
|
||||||
|
|
||||||
@ -283,13 +282,6 @@ $pag = new Paginator([
|
|||||||
<?= UOJLocale::get('problems::show statistics') ?>
|
<?= UOJLocale::get('problems::show statistics') ?>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -322,19 +314,6 @@ $pag = new Paginator([
|
|||||||
}
|
}
|
||||||
location.reload();
|
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>
|
</script>
|
||||||
|
|
||||||
<div class="card my-3">
|
<div class="card my-3">
|
||||||
@ -366,26 +345,39 @@ $pag = new Paginator([
|
|||||||
<i class="bi bi-search"></i>
|
<i class="bi bi-search"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<?php if (Auth::check()) : ?>
|
<div>
|
||||||
<div class="form-check d-inline-block">
|
<?php if (Auth::check()) : ?>
|
||||||
<input type="checkbox" name="my" <?= isset($_GET['my']) ? 'checked="checked"' : '' ?> class="form-check-input" id="input-my">
|
<div class="form-check d-inline-block">
|
||||||
<label class="form-check-label" for="input-my">
|
<input type="checkbox" name="my" <?= isset($_GET['my']) ? 'checked="checked"' : '' ?> class="form-check-input" id="input-my">
|
||||||
我的题目
|
<label class="form-check-label" for="input-my">
|
||||||
</label>
|
我的题目
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
|
<?php if (UOJProblem::userCanManageSomeProblem(Auth::user())) : ?>
|
||||||
|
<div class="form-check d-inline-block ms-2">
|
||||||
|
<input type="checkbox" name="is_hidden" <?= isset($_GET['is_hidden']) ? 'checked="checked"' : '' ?> class="form-check-input" id="input-is_hidden">
|
||||||
|
<label class="form-check-label" for="input-is_hidden">
|
||||||
|
隐藏题目
|
||||||
|
</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>
|
||||||
<?php endif ?>
|
</div>
|
||||||
<?php if (UOJProblem::userCanManageSomeProblem(Auth::user())) : ?>
|
|
||||||
<div class="form-check d-inline-block ms-2">
|
|
||||||
<input type="checkbox" name="is_hidden" <?= isset($_GET['is_hidden']) ? 'checked="checked"' : '' ?> class="form-check-input" id="input-is_hidden">
|
|
||||||
<label class="form-check-label" for="input-is_hidden">
|
|
||||||
隐藏题目
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<?php endif ?>
|
|
||||||
</form>
|
</form>
|
||||||
<script>
|
<script>
|
||||||
$('#search-input').val(new URLSearchParams(location.search).get('search'));
|
$('#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();
|
$('#form-problem_search').submit();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
ALTER TABLE `problems` ADD `difficulty` int NOT NULL DEFAULT '-1' AFTER `submit_num`;
|
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` MODIFY `extra_config` json NOT NULL;
|
||||||
|
ALTER TABLE `problems` ADD KEY `difficulty` (`difficulty`);
|
||||||
|
Loading…
Reference in New Issue
Block a user