core&ui: show homework relate on problem_detail (#396)

This commit is contained in:
panda authored and GitHub committed 2022-08-04 08:59:55 +08:00
1 parent 7101a3096c
commit 008c30c8e0
8 files changed
+26 -5

No files matched your search

+1
View File
@@ -408,6 +408,7 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler {
this.response.body.rdoc = await record.get(this.args.domainId, this.psdoc.rid);
}
this.response.body.ctdocs = await contest.getRelated(this.args.domainId, this.pdoc.docId);
this.response.body.htdocs = await contest.getRelated(this.args.domainId, this.pdoc.docId, 'homework');
}
}
+2 -2
View File
@@ -487,9 +487,9 @@ export async function get(domainId: string, tid: ObjectID): Promise<Tdoc<30>> {
return tdoc;
}
export async function getRelated(domainId: string, pid: number) {
export async function getRelated(domainId: string, pid: number, rule?: string) {
const rules = Object.keys(RULES).filter((i) => !RULES[i].hidden);
return await document.getMulti(domainId, document.TYPE_CONTEST, { pids: pid, rule: { $in: rules } }).toArray();
return await document.getMulti(domainId, document.TYPE_CONTEST, { pids: pid, rule: rule || { $in: rules } }).toArray();
}
export async function getStatus(domainId: string, tid: ObjectID, uid: number) {