core: handle referenced config

This commit is contained in:
undefined committed 2021-10-25 11:41:15 +08:00
1 parent e15b8b4f69
commit 3b6b6e3c17
3 files changed
+12 -4

No files matched your search

+4 -2
View File
@@ -262,9 +262,11 @@ export class ContestProblemHandler extends Handler {
if (!this.pdoc) throw new ProblemNotFoundError(domainId, pid); if (!this.pdoc) throw new ProblemNotFoundError(domainId, pid);
this.pdoc.pid = _pid; this.pdoc.pid = _pid;
this.pdoc.tag.length = 0; this.pdoc.tag.length = 0;
// @ts-ignore
if (this.pdoc.domainId !== domainId) this.pdoc.docId = `${this.pdoc.domainId}:${this.pdoc.docId}`;
this.attended = this.tsdoc && this.tsdoc.attend === 1; this.attended = this.tsdoc && this.tsdoc.attend === 1;
if (this.pdoc.reference) {
const pdoc = await problem.get(this.pdoc.reference.domainId, this.pdoc.reference.pid);
this.pdoc.config = pdoc.config;
}
const showAccept = contest.canShowScoreboard.call(this, this.tdoc, true); const showAccept = contest.canShowScoreboard.call(this, this.tdoc, true);
if (!showAccept) this.pdoc.nAccept = 0; if (!showAccept) this.pdoc.nAccept = 0;
if (contest.isNotStarted(this.tdoc)) throw new ContestNotLiveError(tid); if (contest.isNotStarted(this.tdoc)) throw new ContestNotLiveError(tid);
+4 -2
View File
@@ -132,8 +132,10 @@ class HomeworkDetailProblemHandler extends Handler {
contest.getStatus(domainId, tid, this.user._id), contest.getStatus(domainId, tid, this.user._id),
]); ]);
if (!this.pdoc) throw new ProblemNotFoundError(domainId, this.pid); if (!this.pdoc) throw new ProblemNotFoundError(domainId, this.pid);
// @ts-ignore if (this.pdoc.reference) {
if (this.pdoc.domainId !== domainId) this.pdoc.docId = `${this.pdoc.domainId}:${this.pdoc.docId}`; const pdoc = await problem.get(this.pdoc.reference.domainId, this.pdoc.reference.pid);
this.pdoc.config = pdoc.config;
}
this.pdoc.pid = _pid; this.pdoc.pid = _pid;
this.attended = this.tsdoc?.attend === 1; this.attended = this.tsdoc?.attend === 1;
this.response.body = { this.response.body = {
+4
View File
@@ -224,6 +224,10 @@ export class ProblemDetailHandler extends ProblemHandler {
problem.getStatus(domainId, this.pdoc.docId, this.user._id), problem.getStatus(domainId, this.pdoc.docId, this.user._id),
user.getById(domainId, this.pdoc.owner), user.getById(domainId, this.pdoc.owner),
]); ]);
if (this.pdoc.reference) {
const pdoc = await problem.get(this.pdoc.reference.domainId, this.pdoc.reference.pid);
this.pdoc.config = pdoc.config;
}
const [scnt, dcnt] = await Promise.all([ const [scnt, dcnt] = await Promise.all([
solution.count(domainId, { parentId: this.pdoc.docId }), solution.count(domainId, { parentId: this.pdoc.docId }),
discussion.count(domainId, { parentId: this.pdoc.docId }), discussion.count(domainId, { parentId: this.pdoc.docId }),