mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +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",
|
"name": "hydrooj",
|
||||||
"version": "2.28.18",
|
"version": "2.28.19",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
},
|
},
|
||||||
"preferUnplugged": true,
|
"preferUnplugged": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hydrooj/utils": "^1.0.20",
|
"@hydrooj/utils": "workspace:*",
|
||||||
"adm-zip": "^0.5.5",
|
"adm-zip": "^0.5.5",
|
||||||
"ansi_up": "^5.0.1",
|
"ansi_up": "^5.0.1",
|
||||||
"cac": "^6.7.3",
|
"cac": "^6.7.3",
|
||||||
|
|||||||
@@ -356,11 +356,13 @@ export class ContestDetailProblemSubmitHandler extends ContestProblemHandler {
|
|||||||
tid,
|
tid,
|
||||||
});
|
});
|
||||||
const rdoc = await record.get(domainId, rid);
|
const rdoc = await record.get(domainId, rid);
|
||||||
await Promise.all([
|
if (!pretest) {
|
||||||
problem.inc(domainId, pid, 'nSubmit', 1),
|
await Promise.all([
|
||||||
domain.incUserInDomain(domainId, this.user._id, 'nSubmit'),
|
problem.inc(domainId, pid, 'nSubmit', 1),
|
||||||
contest.updateStatus(domainId, tid, this.user._id, rid, pid),
|
domain.incUserInDomain(domainId, this.user._id, 'nSubmit'),
|
||||||
]);
|
contest.updateStatus(domainId, tid, this.user._id, rid, pid),
|
||||||
|
]);
|
||||||
|
}
|
||||||
bus.boardcast('record/change', rdoc);
|
bus.boardcast('record/change', rdoc);
|
||||||
if (!pretest && !contest.canShowRecord.call(this, this.tdoc)) {
|
if (!pretest && !contest.canShowRecord.call(this, this.tdoc)) {
|
||||||
this.response.body = { tid };
|
this.response.body = { tid };
|
||||||
|
|||||||
@@ -232,12 +232,14 @@ class HomeworkDetailProblemSubmitHandler extends HomeworkDetailProblemHandler {
|
|||||||
const pdomainId = typeof pid === 'string' ? pid.split(':')[0] : domainId;
|
const pdomainId = typeof pid === 'string' ? pid.split(':')[0] : domainId;
|
||||||
const ppid = typeof pid === 'number' ? pid : +pid.split(':')[1];
|
const ppid = typeof pid === 'number' ? pid : +pid.split(':')[1];
|
||||||
const rdoc = await record.get(domainId, rid);
|
const rdoc = await record.get(domainId, rid);
|
||||||
await Promise.all([
|
if (pretest) {
|
||||||
problem.inc(pdomainId, ppid, 'nSubmit', 1),
|
await Promise.all([
|
||||||
domain.incUserInDomain(domainId, this.user._id, 'nSubmit'),
|
problem.inc(pdomainId, ppid, 'nSubmit', 1),
|
||||||
contest.updateStatus(domainId, tid, this.user._id,
|
domain.incUserInDomain(domainId, this.user._id, 'nSubmit'),
|
||||||
rid, pid, false, 0, document.TYPE_HOMEWORK),
|
contest.updateStatus(domainId, tid, this.user._id,
|
||||||
]);
|
rid, pid, false, 0, document.TYPE_HOMEWORK),
|
||||||
|
]);
|
||||||
|
}
|
||||||
bus.boardcast('record/change', rdoc);
|
bus.boardcast('record/change', rdoc);
|
||||||
this.response.body.tid = tid;
|
this.response.body.tid = tid;
|
||||||
this.response.body.rid = rid;
|
this.response.body.rid = rid;
|
||||||
|
|||||||
@@ -264,19 +264,17 @@ const homework: ContestRule = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function penaltyScore(jdoc) {
|
function penaltyScore(jdoc) {
|
||||||
const { score } = jdoc;
|
|
||||||
const exceedSeconds = Math.floor(
|
const exceedSeconds = Math.floor(
|
||||||
jdoc.rid.generationTime - tdoc.penaltySince.getTime() / 1000,
|
jdoc.rid.generationTime - tdoc.penaltySince.getTime() / 1000,
|
||||||
);
|
);
|
||||||
if (exceedSeconds < 0) return score;
|
if (exceedSeconds < 0) return jdoc.score;
|
||||||
let coefficient = 1;
|
let coefficient = 1;
|
||||||
const keys = Object.keys(tdoc.penaltyRules)
|
const keys = Object.keys(tdoc.penaltyRules).map(parseFloat).sort((a, b) => a - b);
|
||||||
.map(parseFloat).sort((a, b) => a - b);
|
|
||||||
for (const i of keys) {
|
for (const i of keys) {
|
||||||
if (i * 3600 <= exceedSeconds) coefficient = tdoc.penaltyRules[i];
|
if (i * 3600 <= exceedSeconds) coefficient = tdoc.penaltyRules[i];
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
return score * coefficient;
|
return jdoc.score * coefficient;
|
||||||
}
|
}
|
||||||
const detail = [];
|
const detail = [];
|
||||||
for (const j in effective) {
|
for (const j in effective) {
|
||||||
@@ -379,7 +377,10 @@ const homework: ContestRule = {
|
|||||||
} else {
|
} else {
|
||||||
row.push({
|
row.push({
|
||||||
type: 'record',
|
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,
|
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();
|
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(
|
export function getStatus(
|
||||||
domainId: string, tid: ObjectID, uid: number,
|
domainId: string, tid: ObjectID, uid: number,
|
||||||
type: 30 | 60 = document.TYPE_CONTEST,
|
type: 30 | 60 = document.TYPE_CONTEST,
|
||||||
@@ -475,6 +462,23 @@ export function getStatus(
|
|||||||
return document.getStatus(domainId, type, tid, uid);
|
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(
|
export async function getListStatus(
|
||||||
domainId: string, uid: number, tids: ObjectID[],
|
domainId: string, uid: number, tids: ObjectID[],
|
||||||
type: 30 | 60 = document.TYPE_CONTEST,
|
type: 30 | 60 = document.TYPE_CONTEST,
|
||||||
|
|||||||
Reference in new issue
Block a user