mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fix #781
This commit is contained in:
3 files changed
+16
-14
No files matched your search
@@ -261,21 +261,23 @@ export class ContestProblemListHandler extends ContestDetailBaseHandler {
|
|||||||
}
|
}
|
||||||
this.response.body.psdict = this.tsdoc.detail || {};
|
this.response.body.psdict = this.tsdoc.detail || {};
|
||||||
const psdocs: any[] = Object.values(this.response.body.psdict);
|
const psdocs: any[] = Object.values(this.response.body.psdict);
|
||||||
if (contest.canShowSelfRecord.call(this, this.tdoc)) {
|
const canViewRecord = contest.canShowSelfRecord.call(this, this.tdoc);
|
||||||
[this.response.body.rdict, this.response.body.rdocs] = await Promise.all([
|
this.response.body.canViewRecord = canViewRecord;
|
||||||
|
[this.response.body.rdict, this.response.body.rdocs] = canViewRecord
|
||||||
|
? await Promise.all([
|
||||||
record.getList(domainId, psdocs.map((i: any) => i.rid)),
|
record.getList(domainId, psdocs.map((i: any) => i.rid)),
|
||||||
await record.getMulti(domainId, { contest: tid, uid: this.user._id })
|
record.getMulti(domainId, { contest: tid, uid: this.user._id })
|
||||||
.sort({ _id: -1 }).toArray(),
|
.sort({ _id: -1 }).toArray(),
|
||||||
]);
|
])
|
||||||
if (!this.user.own(this.tdoc) && !this.user.hasPerm(PERM.PERM_EDIT_CONTEST)) {
|
: [Object.fromEntries(psdocs.map((i) => [i.rid, { _id: i.rid }])), []];
|
||||||
this.response.body.rdocs = this.response.body.rdocs.map((rdoc) => contest.applyProjection(this.tdoc, rdoc, this.user));
|
if (!this.user.own(this.tdoc) && !this.user.hasPerm(PERM.PERM_EDIT_CONTEST)) {
|
||||||
for (const psdoc of psdocs) {
|
this.response.body.rdocs = this.response.body.rdocs.map((rdoc) => contest.applyProjection(this.tdoc, rdoc, this.user));
|
||||||
this.response.body.rdict[psdoc.rid] = contest.applyProjection(this.tdoc, this.response.body.rdict[psdoc.rid], this.user);
|
for (const psdoc of psdocs) {
|
||||||
}
|
this.response.body.rdict[psdoc.rid] = contest.applyProjection(this.tdoc, this.response.body.rdict[psdoc.rid], this.user);
|
||||||
|
}
|
||||||
|
for (const key in this.response.body.psdict) {
|
||||||
|
this.response.body.psdict[key] = contest.applyProjection(this.tdoc, this.response.body.psdict[key], this.user);
|
||||||
}
|
}
|
||||||
this.response.body.canViewRecord = true;
|
|
||||||
} else {
|
|
||||||
for (const i of psdocs) this.response.body.rdict[i.rid] = { _id: i.rid };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -549,7 +549,7 @@ export class ProblemSubmitHandler extends ProblemDetailHandler {
|
|||||||
}
|
}
|
||||||
if (tid && !pretest && !contest.canShowSelfRecord.call(this, this.tdoc)) {
|
if (tid && !pretest && !contest.canShowSelfRecord.call(this, this.tdoc)) {
|
||||||
this.response.body = { tid };
|
this.response.body = { tid };
|
||||||
this.response.redirect = this.url(this.tdoc.rule === 'homework' ? 'homework_detail' : 'contest_detail', { tid });
|
this.response.redirect = this.url(this.tdoc.rule === 'homework' ? 'homework_detail' : 'contest_problemlist', { tid });
|
||||||
} else {
|
} else {
|
||||||
this.response.body = { rid };
|
this.response.body = { rid };
|
||||||
this.response.redirect = this.url('record_detail', { rid });
|
this.response.redirect = this.url('record_detail', { rid });
|
||||||
|
|||||||
@@ -41,8 +41,8 @@
|
|||||||
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
|
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
|
||||||
{% if psdict[pid] and psdict[pid].rid %}
|
{% if psdict[pid] and psdict[pid].rid %}
|
||||||
{% set rdoc = rdict[psdict[pid].rid] %}
|
{% 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) %}
|
{% if model.contest.canShowSelfRecord.call(handler, tdoc) %}
|
||||||
|
{% set displayScore = ((tdoc.score[pid]|default(100)) * (psdict[pid].score|default(0)) / 100) if showScore else (psdict[pid].penaltyScore|default(psdict[pid].score)) %}
|
||||||
{{ record.render_status_td(rdoc, displayScore=displayScore) }}
|
{{ record.render_status_td(rdoc, displayScore=displayScore) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
<td class="col--status record-status--border"><a href="{{ url('record_detail', rid=rdoc._id) }}">{{ _('Submitted') }}</a></td>
|
<td class="col--status record-status--border"><a href="{{ url('record_detail', rid=rdoc._id) }}">{{ _('Submitted') }}</a></td>
|
||||||
|
|||||||
Reference in new issue
Block a user