core&ui: fix contest with more than 26 problems have wrong alphabetic id (#1008)

Co-authored-by: undefined <i@undefined.moe>
This commit is contained in:
Bhscerandundefined authored and GitHub committed 2025-07-07 15:31:46 +01:00
1 parent 627ce77d30
commit dc6345c0b3
11 files changed
+30 -18

No files matched your search

+2 -2
View File
@@ -1,6 +1,6 @@
import path from 'path';
import * as status from '@hydrooj/common/status';
import { findFileSync } from '@hydrooj/utils/lib/utils';
import { findFileSync, getAlphabeticId } from '@hydrooj/utils/lib/utils';
import {
avatar, Context, difficultyAlgorithm, fs, PERM, PRIV, Service, STATUS, yaml,
} from 'hydrooj';
@@ -130,7 +130,7 @@ class Nunjucks extends nunjucks.Environment {
this.addGlobal('instanceof', (a, b) => a instanceof b);
this.addGlobal('paginate', misc.paginate);
this.addGlobal('size', misc.size);
this.addGlobal('utils', { status });
this.addGlobal('utils', { status, getAlphabeticId });
this.addGlobal('avatarUrl', avatar);
this.addGlobal('formatSeconds', misc.formatSeconds);
this.addGlobal('model', global.Hydro.model);
@@ -1,4 +1,5 @@
/* eslint-disable react-refresh/only-export-components */
import { getAlphabeticId } from '@hydrooj/utils/lib/common';
import yaml from 'js-yaml';
import React from 'react';
import { HexColorInput, HexColorPicker } from 'react-colorful';
@@ -31,8 +32,8 @@ function Balloon({ tdoc, val }) {
<tr key={pid}>
<td>
{now === pid
? (<b>{String.fromCharCode(65 + tdoc.pids.indexOf(+pid))}</b>)
: (<span>{String.fromCharCode(65 + tdoc.pids.indexOf(+pid))}</span>)}
? (<b>{getAlphabeticId(tdoc.pids.indexOf(+pid))}</b>)
: (<span>{getAlphabeticId(tdoc.pids.indexOf(+pid))}</span>)}
</td>
<td>
<HexColorInput
@@ -8,5 +8,5 @@
{% endmacro %}
{% macro render_clarification_subject(tdoc, pdict, subject) %}
{% if subject == 0 %}{{ _('General Issue') }}{% elif subject == -1 %}{{ _('Technical Issue') }}{% else %}{{ String.fromCharCode(65 + tdoc.pids.indexOf(subject)) + 1 }}. {{ pdict[subject].title }}{% endif %}
{% if subject == 0 %}{{ _('General Issue') }}{% elif subject == -1 %}{{ _('Technical Issue') }}{% else %}{{ utils.getAlphabeticId(tdoc.pids.indexOf(subject)) }}. {{ pdict[subject].title }}{% endif %}
{% endmacro %}
@@ -5,7 +5,7 @@
<a href="{{ url('problem_detail', _linkArgs) }}"{% if small %} data-tooltip="{{ pdoc.title }}"{% endif %}>
{%- endif -%}
{% if show_pid %}
<b>{%- if tdoc and alphabetic -%}{{ String.fromCharCode(65+tdoc.pids.indexOf(pdoc.docId)) }}
<b>{%- if tdoc and alphabetic -%}{{ utils.getAlphabeticId(tdoc.pids.indexOf(pdoc.docId)) }}
{%- elif pdoc.pid and pdoc.pid.includes('-') -%}{{ pdoc.pid.split('-').join('#') }}
{%- else -%}{{ pdoc.pid|default(pdoc.docId) }}{%- endif -%}</b>
{% endif %}
@@ -127,7 +127,7 @@
<option value="0">{{ _('General Issue') }}</option>
<option value="-1">{{ _('Technical Issue') }}</option>
{% for pid in tdoc.pids %}
<option value="{{ pid }}">{{ String.fromCharCode(65+loop.index0) }}. {{ pdict[pid].title }}</option>
<option value="{{ pid }}">{{ utils.getAlphabeticId(loop.index0) }}. {{ pdict[pid].title }}</option>
{% endfor %}
</select>
</label>
@@ -185,7 +185,7 @@
<option value="0">{{ _('General Issue') }}</option>
<option value="-1">{{ _('Technical Issue') }}</option>
{% for pid in tdoc.pids %}
<option value="{{ pid }}">{{ String.fromCharCode(65+loop.index0) }}. {{ pdict[pid].title }}</option>
<option value="{{ pid }}">{{ utils.getAlphabeticId(loop.index0) }}. {{ pdict[pid].title }}</option>
{% endfor %}
</select>
</label>
@@ -25,7 +25,7 @@
</button>
</form>
{% endif %}
<b>{{ String.fromCharCode(65+tdoc.pids.indexOf(bdoc.pid)) }}</b>&nbsp;&nbsp;({{ tdoc.balloon[bdoc.pid].name }})
<b>{{ utils.getAlphabeticId(tdoc.pids.indexOf(bdoc.pid)) }}</b>&nbsp;&nbsp;({{ tdoc.balloon[bdoc.pid].name }})
</td>
<td class="col--submit-by" data-tooltip="{{ bdoc._id.getTimestamp().format() }}">{{ user.render_inline(udict[bdoc.uid], badge=false) }}</td>
<td class="col--send-by"{% if bdoc.sent %} data-tooltip="{{ bdoc.sentAt.format() }}"{% endif %}>
@@ -64,7 +64,7 @@
</form>
{% endif %}
{%- if tdoc -%}
{{ String.fromCharCode(65+tdoc.pids.indexOf(pdoc.docId)) }}
{{ utils.getAlphabeticId(tdoc.pids.indexOf(pdoc.docId)) }}
{%- elif pdoc.pid and pdoc.pid.includes('-') -%}
{{ pdoc.pid.split('-').join('#') }}
{%- else -%}
@@ -80,7 +80,7 @@
<a href="{{ url('problem_detail', pid=pid, query={tid:tdoc.docId}) }}"
class="{% if pass %}pass{% elif fail %}fail{% endif %}
{% if pid==pdoc.docId %} active{% endif %}">
<span class="id">{{ String.fromCharCode(65+loop.index0) }}</span>
<span class="id">{{ utils.getAlphabeticId(loop.index0) }}</span>
{% if status %}<span class="icon icon-{% if pass %}check{% else %}close{% endif %}"></span>{% endif %}
</a>
{%- endfor %}