mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: add contest score ratio (#765)
Co-authored-by: panda <panda_dtdyy@outlook.com>
This commit is contained in:
1 parent
9013c4eaa6
commit
e25db178fd
11 files changed
+121
-23
No files matched your search
@@ -291,7 +291,9 @@ const oi = buildContestRule({
|
||||
display[j.pid] = j;
|
||||
}
|
||||
}
|
||||
for (const i in display) score += display[i].score || 0;
|
||||
for (const i in display) {
|
||||
score += ((tdoc.score?.[i] || 100) * (display[i].score || 0)) / 100;
|
||||
}
|
||||
return { score, detail, display };
|
||||
},
|
||||
showScoreboard: (tdoc, now) => now > tdoc.endAt,
|
||||
@@ -332,6 +334,10 @@ const oi = buildContestRule({
|
||||
{ type: 'rank', value: rank.toString() },
|
||||
{ type: 'user', value: udoc.uname, raw: tsdoc.uid },
|
||||
];
|
||||
const displayScore = (pid: number, score?: number) => {
|
||||
if (typeof score !== 'number') return '-';
|
||||
return score * ((tdoc.score?.[pid] || 100) / 100);
|
||||
};
|
||||
if (config.isExport) {
|
||||
row.push({ type: 'email', value: udoc.mail });
|
||||
row.push({ type: 'string', value: udoc.school || '' });
|
||||
@@ -357,17 +363,20 @@ const oi = buildContestRule({
|
||||
type: 'records',
|
||||
value: '',
|
||||
raw: [{
|
||||
value: tsddict[pid]?.score ?? '-',
|
||||
value: displayScore(pid, tsddict[pid]?.score),
|
||||
raw: tsddict[pid]?.rid || null,
|
||||
score: tsddict[pid]?.score,
|
||||
}, {
|
||||
value: meta?.psdict?.[index]?.score ?? '-',
|
||||
value: displayScore(pid, meta?.psdict?.[index]?.score),
|
||||
raw: meta?.psdict?.[index]?.rid ?? null,
|
||||
score: meta?.psdict?.[index]?.score,
|
||||
}],
|
||||
} : {
|
||||
type: 'record',
|
||||
value: `${tsddict[pid]?.score ?? '-'}${tsddict[pid]?.npending
|
||||
value: `${displayScore(pid, tsddict[pid]?.score)}${tsddict[pid]?.npending
|
||||
? `<span style="color:orange">+${tsddict[pid]?.npending}</span>` : ''}`,
|
||||
raw: tsddict[pid]?.rid || null,
|
||||
score: tsddict[pid]?.score,
|
||||
};
|
||||
if (tsddict[pid]?.status === STATUS.STATUS_ACCEPTED && tsddict[pid]?.rid.getTimestamp().getTime() === meta?.first?.[pid]) {
|
||||
node.style = 'background-color: rgb(217, 240, 199);';
|
||||
@@ -461,7 +470,7 @@ const strictioi = buildContestRule({
|
||||
j.status = Math.max(...Object.values(subtasks[j.pid]).map((i) => i.status));
|
||||
if (!detail[j.pid] || detail[j.pid].score < j.score) detail[j.pid] = { ...j, subtasks: subtasks[j.pid] };
|
||||
}
|
||||
for (const i in detail) score += detail[i].score;
|
||||
for (const i in detail) score += ((tdoc.score?.[i] || 100) * (detail[i].score || 0)) / 100;
|
||||
return { score, detail };
|
||||
},
|
||||
async scoreboardRow(config, _, tdoc, pdict, udoc, rank, tsdoc, meta) {
|
||||
@@ -485,9 +494,10 @@ const strictioi = buildContestRule({
|
||||
for (const pid of tdoc.pids) {
|
||||
row.push({
|
||||
type: 'record',
|
||||
value: tsddict[pid]?.score || '',
|
||||
value: ((tsddict[pid]?.score || 0) * ((tdoc.score?.[pid] || 100) / 100)).toString() || '',
|
||||
hover: Object.values(tsddict[pid]?.subtasks || {}).map((i: SubtaskResult) => `${STATUS_SHORT_TEXTS[i.status]} ${i.score}`).join(','),
|
||||
raw: tsddict[pid]?.rid,
|
||||
score: tsddict[pid]?.score,
|
||||
style: tsddict[pid]?.status === STATUS.STATUS_ACCEPTED && tsddict[pid]?.rid.getTimestamp().getTime() === meta?.first?.[pid]
|
||||
? 'background-color: rgb(217, 240, 199);'
|
||||
: undefined,
|
||||
@@ -523,8 +533,9 @@ const ledo = buildContestRule({
|
||||
let originalScore = 0;
|
||||
for (const pid of tdoc.pids) {
|
||||
if (!detail[pid]) continue;
|
||||
score += detail[pid].penaltyScore;
|
||||
originalScore += detail[pid].score;
|
||||
const rate = (tdoc.score?.[pid] || 100) / 100;
|
||||
score += detail[pid].penaltyScore * rate;
|
||||
originalScore += detail[pid].score * rate;
|
||||
}
|
||||
return {
|
||||
score, originalScore, detail,
|
||||
@@ -555,9 +566,10 @@ const ledo = buildContestRule({
|
||||
for (const pid of tdoc.pids) {
|
||||
row.push({
|
||||
type: 'record',
|
||||
value: tsddict[pid]?.penaltyScore?.toString() || '',
|
||||
value: ((tsddict[pid]?.penaltyScore || 0) * ((tdoc.score?.[pid] || 100) / 100)).toString(),
|
||||
hover: tsddict[pid]?.ntry ? `-${tsddict[pid].ntry} (${Math.round(Math.max(0.7, 0.95 ** tsddict[pid].ntry) * 100)}%)` : '',
|
||||
raw: tsddict[pid]?.rid,
|
||||
score: tsddict[pid]?.score,
|
||||
style: tsddict[pid]?.status === STATUS.STATUS_ACCEPTED && tsddict[pid]?.rid.getTimestamp().getTime() === meta?.first?.[pid]
|
||||
? 'background-color: rgb(217, 240, 199);'
|
||||
: undefined,
|
||||
@@ -587,17 +599,18 @@ const homework = buildContestRule({
|
||||
}
|
||||
|
||||
function penaltyScore(jdoc) {
|
||||
const rate = (tdoc.score?.[jdoc.pid] || 100) / 100;
|
||||
const exceedSeconds = Math.floor(
|
||||
(jdoc.rid.getTimestamp().getTime() - tdoc.penaltySince.getTime()) / 1000,
|
||||
);
|
||||
if (exceedSeconds < 0) return jdoc.score;
|
||||
if (exceedSeconds < 0) return rate * jdoc.score;
|
||||
let coefficient = 1;
|
||||
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 jdoc.score * coefficient;
|
||||
return rate * jdoc.score * coefficient;
|
||||
}
|
||||
const detail = [];
|
||||
for (const j in effective) {
|
||||
@@ -691,7 +704,7 @@ const homework = buildContestRule({
|
||||
} else {
|
||||
row.push({
|
||||
type: 'record',
|
||||
score: tsddict[pid]?.penaltyScore || 0,
|
||||
score: tsddict[pid]?.score,
|
||||
value: colScore === colOriginalScore
|
||||
? '{0}\n{1}'.format(colScore, colTimeStr)
|
||||
: '{0} / {1}\n{2}'.format(colScore, colOriginalScore, colTimeStr),
|
||||
|
||||
Reference in new issue
Block a user