mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: calc difficulty after each submission
This commit is contained in:
1 parent
139c1e2f59
commit
44ec26ac89
7 files changed
+24
-23
No files matched your search
@@ -10,6 +10,7 @@ import {
|
||||
} from '../interface';
|
||||
import paginate from '../lib/paginate';
|
||||
import { isTitle, isContent, isPid } from '../lib/validator';
|
||||
import difficultyAlgorithm from '../lib/difficulty';
|
||||
import * as system from '../model/system';
|
||||
import * as problem from '../model/problem';
|
||||
import * as record from '../model/record';
|
||||
@@ -333,10 +334,10 @@ export class ProblemEditHandler extends ProblemManageHandler {
|
||||
title, content, pid: newPid, hidden, tag: tag ?? [],
|
||||
};
|
||||
let pdoc = await problem.get(domainId, pid);
|
||||
$update.difficulty = difficultyAlgorithm(pdoc.nSubmit, pdoc.nAccept);
|
||||
await bus.serial('problem/before-edit', $update);
|
||||
pdoc = await problem.edit(domainId, pdoc.docId, $update);
|
||||
await bus.emit('problem/edit', pdoc);
|
||||
await global.Hydro.script.difficulty.run({ domainId, pid }, console.log);
|
||||
this.response.redirect = this.url('problem_detail', { pid: newPid || pdoc.docId });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user