core&ui: allow admin view contest when its not started

pull/393/head
undefined 2 years ago
parent b7f0e59e5d
commit ba0beee9a8

@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "3.14.20",
"version": "3.14.21",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",

@ -121,12 +121,16 @@ export class ContestDetailHandler extends ContestDetailBaseHandler {
this.response.body = {
tdoc: this.tdoc, tsdoc: this.tsdoc, udict,
};
if (contest.isNotStarted(this.tdoc)) return;
if (!this.request.json) {
this.response.body.tdoc.content = this.response.body.tdoc.content
.replace(/\(file:\/\//g, `(./${this.tdoc.docId}/file/`)
.replace(/="file:\/\//g, `="./${this.tdoc.docId}/file/`);
}
if (
(contest.isNotStarted(this.tdoc) || !this.tsdoc?.attend)
&& !this.user.own(this.tdoc)
&& !this.user.hasPerm(PERM.PERM_VIEW_CONTEST_HIDDEN_SCOREBOARD)
) return;
const pdict = await problem.getList(domainId, this.tdoc.pids, true, undefined, undefined, problem.PROJECTION_CONTEST_LIST);
const psdict = {};
let rdict = {};

@ -73,7 +73,11 @@ class HomeworkDetailHandler extends Handler {
this.response.body = {
tdoc, tsdoc, udict, ddocs, page, dpcount, dcount,
};
if (contest.isNotStarted(tdoc)) return;
if (
(contest.isNotStarted(tdoc) || !tsdoc?.attend)
&& !this.user.own(tdoc)
&& !this.user.hasPerm(PERM.PERM_VIEW_HOMEWORK_HIDDEN_SCOREBOARD)
) return;
const pdict = await problem.getList(domainId, tdoc.pids, true, undefined, undefined, problem.PROJECTION_CONTEST_LIST);
const psdict = {};
let rdict = {};
@ -93,9 +97,7 @@ class HomeworkDetailHandler extends Handler {
);
}
}
this.response.body.pdict = pdict;
this.response.body.psdict = psdict;
this.response.body.rdict = rdict;
Object.assign(this.response.body, { pdict, psdict, rdict });
}
@param('tid', Types.ObjectID)

@ -1,6 +1,6 @@
{
"name": "@hydrooj/ui-default",
"version": "4.38.24",
"version": "4.38.25",
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0",
"main": "hydro.js",

@ -37,12 +37,11 @@
{% endif %}
</div>
</div>
{% if model.contest.isOngoing(tdoc, tsdoc) or model.contest.isDone(tdoc, tsdoc) %}
<div class="section">
<div class="section__header">
<h1 class="section__title">{{ _('Problem') }}</h1>
</div>
{% if tsdoc.attend or model.contest.isDone(tdoc) %}
{% if pdict %}
<div class="section__body no-padding">
<table class="data-table">
<colgroup>
@ -79,18 +78,23 @@
{% endif %}
{% endif %}
<td class="col--problem col--problem-name">
{{ problem.render_problem_title(pdict[pid], tdoc=tdoc, show_invisible_flag=false, show_tags=false) }}
{% if model.contest.isNotStarted(tdoc) %}
{{ problem.render_problem_title(pdict[pid], show_invisible_flag=false, show_tags=false) }}
{% else %}
{{ problem.render_problem_title(pdict[pid], tdoc=tdoc, show_invisible_flag=false, show_tags=false) }}
{% endif %}
</td>
</tr>
{%- endfor -%}
</tbody>
</table>
</div>
{% elif tsdoc.attend %}
{{ nothing.render('This contest is not live.') }}
{% else %}
{{ nothing.render('Please attend contest to see the problems.') }}
{% endif %}
</div>
{% endif %}
</div>
<div class="medium-3 columns">
{% set owner_udoc = udict[tdoc.owner] %}

@ -16,9 +16,7 @@
<div class="section__header">
<h1 class="section__title">{{ _('Problem') }}</h1>
</div>
{% if model.contest.isNotStarted(tdoc) %}
{{ nothing.render('This homework is not open and you cannot view problems.') }}
{% elif tsdoc.attend or model.contest.isDone(tdoc) %}
{% if pdict %}
<div class="section__body no-padding">
<table class="data-table">
<colgroup>
@ -55,13 +53,19 @@
{% endif %}
{% endif %}
<td class="col--problem col--problem-name">
{{ problem.render_problem_title(pdict[pid], tdoc=tdoc, show_invisible_flag=false, show_tags=false) }}
{% if model.contest.isNotStarted(tdoc) %}
{{ problem.render_problem_title(pdict[pid], show_invisible_flag=false, show_tags=false) }}
{% else %}
{{ problem.render_problem_title(pdict[pid], tdoc=tdoc, show_invisible_flag=false, show_tags=false) }}
{% endif %}
</td>
</tr>
{%- endfor -%}
</tbody>
</table>
</div>
{% elif tsdoc.attend %}
{{ nothing.render('This homework is not open and you cannot view problems.') }}
{% else %}
{{ nothing.render('Please claim the assignment to see the problems.') }}
{% endif %}

Loading…
Cancel
Save