core: 修复ACM赛制计分

This commit is contained in:
undefined committed 2021-05-13 00:45:23 +08:00
1 parent a764211eee
commit 7c6e97fdfc
9 files changed
+25 -19

No files matched your search

+6 -3
View File
@@ -307,10 +307,13 @@ export class ContestProblemFileDownloadHandler extends ContestProblemHandler {
}
class ContestDetailProblemSubmitHandler extends ContestProblemHandler {
async prepare() {
if (!contest.isOngoing(this.tdoc)) throw new ContestNotLiveError(this.tdoc.docId);
}
@param('tid', Types.ObjectID)
@param('pid', Types.UnsignedInt)
async prepare(domainId: string, tid: ObjectID, pid: number) {
if (!contest.isOngoing(this.tdoc)) throw new ContestNotLiveError(this.tdoc.docId);
async get(domainId: string, tid: ObjectID, pid: number) {
let rdocs = [];
if (contest.canShowRecord.call(this, this.tdoc)) {
rdocs = await record.getUserInProblemMulti(
@@ -318,7 +321,6 @@ class ContestDetailProblemSubmitHandler extends ContestProblemHandler {
this.pdoc.docId, true,
).sort({ _id: -1 }).limit(10).toArray();
}
this.response.template = 'problem_submit.html';
const path = [
['Hydro', 'homepage'],
['contest_main', 'contest_main'],
@@ -335,6 +337,7 @@ class ContestDetailProblemSubmitHandler extends ContestProblemHandler {
rdocs,
page_name: 'contest_detail_problem_submit',
};
this.response.template = 'problem_submit.html';
}
@param('tid', Types.ObjectID)
+3
View File
@@ -117,6 +117,9 @@ class RecordDetailHandler extends Handler {
rdoc,
pdoc,
};
if (rdoc.contest) {
this.response.body.tdoc = await contest.get(domainId, rdoc.contest.tid, rdoc.contest.type);
}
}
@param('rid', Types.ObjectID)
+9 -8
View File
@@ -39,9 +39,9 @@ const acm: ContestRule = {
for (const key in effective) {
const j = effective[key];
const real = j.rid.generationTime - Math.floor(tdoc.beginAt.getTime() / 1000);
const penalty = 20 * 60 * naccept[j.pid];
const penalty = 20 * 60 * (naccept[j.pid] || 0);
detail.push({
...j, naccept: naccept[j.pid], time: real + penalty, real, penalty,
...j, naccept: naccept[j.pid] || 0, time: real + penalty, real, penalty,
});
}
for (const d of detail) {
@@ -53,7 +53,7 @@ const acm: ContestRule = {
return { accept, time, detail };
},
async scoreboard(isExport, _, tdoc, pdict, cursor, page) {
const [rankedTsdocs, nPages] = await ranked(cursor, (a, b) => a.score === b.score, page);
const [rankedTsdocs, nPages] = await ranked(cursor, (a, b) => a.score === b.score && a.time === b.time, page);
const uids = rankedTsdocs.map(([, tsdoc]) => tsdoc.uid);
const udict = await user.getList(tdoc.domainId, uids);
const columns: ScoreboardRow = [
@@ -109,20 +109,21 @@ const acm: ContestRule = {
);
}
for (const pid of tdoc.pids) {
const doc = tsddict[pid] || {};
let rid;
let colAccepted;
let colTime;
let colTimeStr;
if (tsddict[pid]?.accept) {
rid = tsddict[pid].rid;
if (doc.accept) {
rid = doc.rid;
colAccepted = _('Accepted');
colTime = tsddict[pid].time;
colTimeStr = misc.formatSeconds(colTime);
colTime = doc.time;
colTimeStr = misc.formatSeconds(colTime) + (doc.naccept ? ` (-${doc.naccept})` : '');
} else {
rid = null;
colAccepted = '-';
colTime = '-';
colTimeStr = '-';
colTimeStr = doc.naccept ? `(-${doc.naccept})` : '-';
}
if (isExport) {
row.push({ type: 'string', value: colAccepted });