core: ProblemDetail: remove difficulty setting check

This commit is contained in:
undefined committed 2021-03-01 21:44:49 +08:00
1 parent 27904e0d7a
commit 66243005e1
1 file changed
+1 -11
+1 -11
View File
@@ -346,22 +346,12 @@ export class ProblemSettingsHandler extends ProblemManageHandler {
@param('hidden', Types.Boolean) @param('hidden', Types.Boolean)
@param('category', Types.String, true, null, parseCategory) @param('category', Types.String, true, null, parseCategory)
@param('tag', Types.String, true, null, parseCategory) @param('tag', Types.String, true, null, parseCategory)
@param('difficultySetting', Types.UnsignedInt)
@param('difficultyAdmin', Types.UnsignedInt, true)
async postSetting( async postSetting(
domainId: string, pid: string | number, hidden = false, domainId: string, pid: string | number, hidden = false,
category: string[] = [], tag: string[] = [], category: string[] = [], tag: string[] = [],
difficultySetting: string, difficultyAdmin: number,
) { ) {
const pdoc = await problem.get(domainId, pid); const pdoc = await problem.get(domainId, pid);
if (!problem.SETTING_DIFFICULTY_RANGE[difficultySetting]) { const update: Partial<Pdoc> = { hidden, category, tag };
throw new ValidationError('difficultySetting');
}
if (!difficultyAdmin) difficultyAdmin = null;
else if (difficultyAdmin < 1 || difficultyAdmin > 9) throw new ValidationError('difficultyAdmin');
const update: Partial<Pdoc> = {
hidden, category, tag, difficultySetting, difficultyAdmin,
};
await bus.serial('problem/setting', update, this); await bus.serial('problem/setting', update, this);
await problem.edit(domainId, pdoc.docId, update); await problem.edit(domainId, pdoc.docId, update);
await global.Hydro.script.difficulty.run({ domainId, pid }, console.log); await global.Hydro.script.difficulty.run({ domainId, pid }, console.log);