mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: add contest score ratio (#765)
Co-authored-by: panda <panda_dtdyy@outlook.com>
This commit is contained in:
1 parent
9013c4eaa6
commit
e25db178fd
11 files changed
+121
-23
No files matched your search
@@ -821,6 +821,7 @@ Set Privilege: 设置权限
|
||||
Set Role: 设置角色
|
||||
Set Roles for Selected User: 设置所选用户的角色
|
||||
Set Roles for selected users: 为所选用户设置角色
|
||||
Set Score for Contest: 设置赛时分数
|
||||
Set time and memory limits: 设置时空限制
|
||||
setting_customize: 个性化
|
||||
setting_display: 显示偏好
|
||||
|
||||
@@ -120,6 +120,10 @@ $highlight-button-color = #F6DF45
|
||||
&.nojs .col--submit-at
|
||||
width: rem(160px)
|
||||
|
||||
.col--score
|
||||
width: rem(80px)
|
||||
text-align: center;
|
||||
|
||||
.col--problem
|
||||
border-left: 1px solid $table-border-color
|
||||
|
||||
@@ -208,3 +212,7 @@ $highlight-button-color = #F6DF45
|
||||
|
||||
.col--awards
|
||||
width: rem(130px)
|
||||
|
||||
.page--contest_manage
|
||||
.col--score
|
||||
width: rem(80px)
|
||||
@@ -1,5 +1,9 @@
|
||||
import $ from 'jquery';
|
||||
import { ActionDialog } from 'vj/components/dialog';
|
||||
import Notification from 'vj/components/notification';
|
||||
import { NamedPage } from 'vj/misc/Page';
|
||||
import { i18n, request, tpl } from 'vj/utils';
|
||||
|
||||
function handleReplyOrBroadcast(ev) {
|
||||
const title = $(ev.currentTarget).data('title');
|
||||
const did = $(ev.currentTarget).data('did');
|
||||
@@ -19,6 +23,50 @@ function handleReplyOrBroadcast(ev) {
|
||||
const page = new NamedPage('contest_manage', () => {
|
||||
$(document).on('click', '[name="broadcast"]', handleReplyOrBroadcast);
|
||||
$(document).on('click', '[name="reply"]', handleReplyOrBroadcast);
|
||||
$(document).on('click', '[name="set_score"]', async (ev) => {
|
||||
const pid = $(ev.currentTarget).data('pid');
|
||||
const op = await new ActionDialog({
|
||||
$body: tpl`
|
||||
<div class="row"><div class="columns">
|
||||
<h1>${i18n('Set Score for Contest')}</h1>
|
||||
</div></div>
|
||||
<div class="row"><div class="columns">
|
||||
<label>
|
||||
${i18n('score')}
|
||||
<div class="textbox-container">
|
||||
<input class="textbox" type="number" step="1" name="score" data-autofocus value="${$(ev.currentTarget).data('score')}"></input>
|
||||
</div>
|
||||
</label>
|
||||
</div></div>
|
||||
`,
|
||||
onDispatch(action) {
|
||||
if (action === 'ok' && $('[name="score"]').val() === null) {
|
||||
$('[name="score"]').focus();
|
||||
return false;
|
||||
}
|
||||
if (!Number.isFinite(+$('[name="score"]').val()) || +$('[name="score"]').val() <= 0) {
|
||||
Notification.error('Invalid score');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
}).open();
|
||||
if (op !== 'ok') return;
|
||||
try {
|
||||
const res = await request.post('', {
|
||||
operation: 'set_score',
|
||||
pid,
|
||||
score: $('[name="score"]').val(),
|
||||
});
|
||||
if (!res.error) {
|
||||
Notification.success('Score Updated');
|
||||
$(ev.currentTarget).text($('[name="score"]').val() as number);
|
||||
$(ev.currentTarget).data('score', $('[name="score"]').val());
|
||||
}
|
||||
} catch (e) {
|
||||
Notification.error(e.message);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
export default page;
|
||||
@@ -3,7 +3,7 @@
|
||||
width: 60px
|
||||
|
||||
.col--size
|
||||
width: 120px
|
||||
width: 100px
|
||||
|
||||
.col--operation
|
||||
width: 40px
|
||||
@@ -1,4 +1,4 @@
|
||||
{% macro render_status_td(rdoc, rid_key='_id', class='', allDomain=false, short=false) %}
|
||||
{% macro render_status_td(rdoc, rid_key='_id', class='', allDomain=false, short=false, displayScore) %}
|
||||
<td class="col--status record-status--border {{ class }} {{ model.builtin.STATUS_CODES[rdoc.status] }}">
|
||||
<div class="col--status__text">
|
||||
<span class="icon record-status--icon {{ model.builtin.STATUS_CODES[rdoc.status] }}"></span>
|
||||
@@ -7,7 +7,7 @@
|
||||
class="record-status--text {{ model.builtin.STATUS_CODES[rdoc.status] }}"
|
||||
>
|
||||
{% if typeof(rdoc['score']) == 'number' %}
|
||||
<span style="color: {{ utils.status.getScoreColor(rdoc.score|default(0)) }}">{{ rdoc.score|default(0) }}</span>
|
||||
<span style="color: {{ utils.status.getScoreColor(rdoc.score|default(0)) }}">{{ displayScore|default(rdoc.score|default(0)) }}</span>
|
||||
{% endif %}
|
||||
{{ model.builtin.STATUS_SHORT_TEXTS[rdoc.status] if short else model.builtin.STATUS_TEXTS[rdoc.status] }}
|
||||
</a>
|
||||
|
||||
@@ -11,10 +11,12 @@
|
||||
<table class="data-table">
|
||||
<colgroup>
|
||||
<col class="col--problem">
|
||||
<col class="col--score">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col--problem">{{ _('Problem') }}</th>
|
||||
<th class="col--score">{{ _('Score') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -25,6 +27,9 @@
|
||||
{{ problem.render_problem_title(pdict[pid], tdoc=tdoc, invalid=true, alphabetic=true) }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="col--score">
|
||||
<a class="typo-a" data-tooltip="{{ _('Set Score for Contest') }}" name="set_score" data-pid="{{ pid }}" data-score="{{ tdoc.score[pid]|default(100) }}">{{ tdoc.score[pid]|default(100) }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{%- endfor -%}
|
||||
</tbody>
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
|
||||
<col class="col--status">
|
||||
<col class="col--submit-at">
|
||||
{% endif %}
|
||||
{% if showScore %}
|
||||
<col class="col--score">
|
||||
{% endif %}
|
||||
<col class="col--problem">
|
||||
</colgroup>
|
||||
@@ -25,6 +28,9 @@
|
||||
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
|
||||
<th class="col--status record-status--border">{{ _('Status') }}</th>
|
||||
<th class="col--submit-at">{{ _('Last Submit At') }}</th>
|
||||
{% endif %}
|
||||
{% if showScore %}
|
||||
<th class="col--score">{{ _('Score') }}</th>
|
||||
{% endif %}
|
||||
<th class="col--problem">{{ _('Problem') }}</th>
|
||||
</tr>
|
||||
@@ -34,17 +40,21 @@
|
||||
<tr>
|
||||
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
|
||||
{% if psdict[pid] and psdict[pid].rid %}
|
||||
{% set rdoc = rdict[psdict[pid].rid] %}
|
||||
{% if model.contest.canShowSelfRecord.call(handler, tdoc) %}
|
||||
{{ record.render_status_td(rdoc) }}
|
||||
{% else %}
|
||||
<td class="col--status record-status--border"><a href="{{ url('record_detail', rid=rdoc._id) }}">{{ _('Submitted') }}</a></td>
|
||||
{% endif %}
|
||||
{% set rdoc = rdict[psdict[pid].rid] %}
|
||||
{% set displayScore = ((tdoc.score[pid]|default(100)) * (psdict[pid].score|default(0)) / 100) if showScore else (psdict[pid].penaltyScore|default(psdict[pid].score)) %}
|
||||
{% if model.contest.canShowSelfRecord.call(handler, tdoc) %}
|
||||
{{ record.render_status_td(rdoc, displayScore=displayScore) }}
|
||||
{% else %}
|
||||
<td class="col--status record-status--border"><a href="{{ url('record_detail', rid=rdoc._id) }}">{{ _('Submitted') }}</a></td>
|
||||
{% endif %}
|
||||
<td class="col--submit-at">{{ datetimeSpan(rdoc._id)|safe }}</td>
|
||||
{% else %}
|
||||
<td class="col--status record-status--border">{{ _('No Submissions') }}</td>
|
||||
<td class="col--submit-at">-</td>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if showScore %}
|
||||
<td class="col--score">{{ tdoc.score[pid]|default(100) }}</td>
|
||||
{% endif %}
|
||||
<td class="col--problem col--problem-name">
|
||||
{{ problem.render_problem_title(pdict[pid], tdoc, alphabetic=true) }}
|
||||
|
||||
Reference in new issue
Block a user