mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: shouldn't sync pretest into tsdoc
This commit is contained in:
1 parent
ddbcf42c9b
commit
5e0eb372f6
4 files changed
+41
-33
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.28.18",
|
||||
"version": "2.28.19",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
@@ -12,7 +12,7 @@
|
||||
},
|
||||
"preferUnplugged": true,
|
||||
"dependencies": {
|
||||
"@hydrooj/utils": "^1.0.20",
|
||||
"@hydrooj/utils": "workspace:*",
|
||||
"adm-zip": "^0.5.5",
|
||||
"ansi_up": "^5.0.1",
|
||||
"cac": "^6.7.3",
|
||||
|
||||
@@ -356,11 +356,13 @@ export class ContestDetailProblemSubmitHandler extends ContestProblemHandler {
|
||||
tid,
|
||||
});
|
||||
const rdoc = await record.get(domainId, rid);
|
||||
await Promise.all([
|
||||
problem.inc(domainId, pid, 'nSubmit', 1),
|
||||
domain.incUserInDomain(domainId, this.user._id, 'nSubmit'),
|
||||
contest.updateStatus(domainId, tid, this.user._id, rid, pid),
|
||||
]);
|
||||
if (!pretest) {
|
||||
await Promise.all([
|
||||
problem.inc(domainId, pid, 'nSubmit', 1),
|
||||
domain.incUserInDomain(domainId, this.user._id, 'nSubmit'),
|
||||
contest.updateStatus(domainId, tid, this.user._id, rid, pid),
|
||||
]);
|
||||
}
|
||||
bus.boardcast('record/change', rdoc);
|
||||
if (!pretest && !contest.canShowRecord.call(this, this.tdoc)) {
|
||||
this.response.body = { tid };
|
||||
|
||||
@@ -232,12 +232,14 @@ class HomeworkDetailProblemSubmitHandler extends HomeworkDetailProblemHandler {
|
||||
const pdomainId = typeof pid === 'string' ? pid.split(':')[0] : domainId;
|
||||
const ppid = typeof pid === 'number' ? pid : +pid.split(':')[1];
|
||||
const rdoc = await record.get(domainId, rid);
|
||||
await Promise.all([
|
||||
problem.inc(pdomainId, ppid, 'nSubmit', 1),
|
||||
domain.incUserInDomain(domainId, this.user._id, 'nSubmit'),
|
||||
contest.updateStatus(domainId, tid, this.user._id,
|
||||
rid, pid, false, 0, document.TYPE_HOMEWORK),
|
||||
]);
|
||||
if (pretest) {
|
||||
await Promise.all([
|
||||
problem.inc(pdomainId, ppid, 'nSubmit', 1),
|
||||
domain.incUserInDomain(domainId, this.user._id, 'nSubmit'),
|
||||
contest.updateStatus(domainId, tid, this.user._id,
|
||||
rid, pid, false, 0, document.TYPE_HOMEWORK),
|
||||
]);
|
||||
}
|
||||
bus.boardcast('record/change', rdoc);
|
||||
this.response.body.tid = tid;
|
||||
this.response.body.rid = rid;
|
||||
|
||||
@@ -264,19 +264,17 @@ const homework: ContestRule = {
|
||||
}
|
||||
|
||||
function penaltyScore(jdoc) {
|
||||
const { score } = jdoc;
|
||||
const exceedSeconds = Math.floor(
|
||||
jdoc.rid.generationTime - tdoc.penaltySince.getTime() / 1000,
|
||||
);
|
||||
if (exceedSeconds < 0) return score;
|
||||
if (exceedSeconds < 0) return jdoc.score;
|
||||
let coefficient = 1;
|
||||
const keys = Object.keys(tdoc.penaltyRules)
|
||||
.map(parseFloat).sort((a, b) => a - b);
|
||||
const keys = Object.keys(tdoc.penaltyRules).map(parseFloat).sort((a, b) => a - b);
|
||||
for (const i of keys) {
|
||||
if (i * 3600 <= exceedSeconds) coefficient = tdoc.penaltyRules[i];
|
||||
else break;
|
||||
}
|
||||
return score * coefficient;
|
||||
return jdoc.score * coefficient;
|
||||
}
|
||||
const detail = [];
|
||||
for (const j in effective) {
|
||||
@@ -379,7 +377,10 @@ const homework: ContestRule = {
|
||||
} else {
|
||||
row.push({
|
||||
type: 'record',
|
||||
value: '{0} / {1}\n{2}'.format(colScore, colOriginalScore, colTimeStr),
|
||||
score: colScore || 0,
|
||||
value: colScore === colOriginalScore
|
||||
? '{0}\n{2}'.format(colScore, colTimeStr)
|
||||
: '{0} / {1}\n{2}'.format(colScore, colOriginalScore, colTimeStr),
|
||||
raw: rid,
|
||||
});
|
||||
}
|
||||
@@ -454,20 +455,6 @@ export async function getRelated(domainId: string, pid: ProblemId, type: Type =
|
||||
return await document.getMulti(domainId, type, { pids: pid }).toArray();
|
||||
}
|
||||
|
||||
export async function updateStatus(
|
||||
domainId: string, tid: ObjectID, uid: number, rid: ObjectID, pid: ProblemId,
|
||||
accept = false, score = 0, type: 30 | 60 = document.TYPE_CONTEST,
|
||||
) {
|
||||
const tdoc = await get(domainId, tid, type);
|
||||
const tsdoc = await document.revPushStatus(domainId, type, tid, uid, 'journal', {
|
||||
rid, pid, accept, score,
|
||||
}, 'rid');
|
||||
if (!tsdoc.attend) throw new ContestNotAttendedError(tid, uid);
|
||||
const journal = _getStatusJournal(tsdoc);
|
||||
const stats = RULES[tdoc.rule].stat(tdoc, journal);
|
||||
return await document.revSetStatus(domainId, type, tid, uid, tsdoc.rev, { journal, ...stats });
|
||||
}
|
||||
|
||||
export function getStatus(
|
||||
domainId: string, tid: ObjectID, uid: number,
|
||||
type: 30 | 60 = document.TYPE_CONTEST,
|
||||
@@ -475,6 +462,23 @@ export function getStatus(
|
||||
return document.getStatus(domainId, type, tid, uid);
|
||||
}
|
||||
|
||||
export async function updateStatus(
|
||||
domainId: string, tid: ObjectID, uid: number, rid: ObjectID, pid: ProblemId,
|
||||
accept = false, score = 0, type: 30 | 60 = document.TYPE_CONTEST,
|
||||
) {
|
||||
const [tdoc, otsdoc] = await Promise.all([
|
||||
get(domainId, tid, type),
|
||||
getStatus(domainId, tid, uid, type),
|
||||
]);
|
||||
if (!otsdoc.attend) throw new ContestNotAttendedError(tid, uid);
|
||||
const tsdoc = await document.revPushStatus(domainId, type, tid, uid, 'journal', {
|
||||
rid, pid, accept, score,
|
||||
}, 'rid');
|
||||
const journal = _getStatusJournal(tsdoc);
|
||||
const stats = RULES[tdoc.rule].stat(tdoc, journal);
|
||||
return await document.revSetStatus(domainId, type, tid, uid, tsdoc.rev, { journal, ...stats });
|
||||
}
|
||||
|
||||
export async function getListStatus(
|
||||
domainId: string, uid: number, tids: ObjectID[],
|
||||
type: 30 | 60 = document.TYPE_CONTEST,
|
||||
|
||||
Reference in new issue
Block a user