题目难度自动计算

This commit is contained in:
undefined committed 2020-08-08 14:28:17 +08:00
1 parent 37d449d42f
commit 16108993cf
10 files changed
+113 -29

No files matched your search

+3
View File
@@ -165,6 +165,7 @@ class SystemSettingHandler extends SystemHandler {
class SystemUserImportHandler extends SystemHandler {
async get() {
this.response.body.users = [];
this.response.body.path.push(['manage_user_import']);
this.response.template = 'manage_user_import.html';
}
@@ -188,7 +189,9 @@ class SystemUserImportHandler extends SystemHandler {
}
} else messages.push(`Line ${i + 1}: Input invalid.`);
}
messages.push(`${udocs.length} users found.`);
await Promise.all(tasks);
this.response.body.path.push(['manage_user_import']);
this.response.body.users = udocs;
this.response.body.messages = messages;
}
+12 -1
View File
@@ -369,12 +369,23 @@ class ProblemSettingsHandler extends ProblemManageHandler {
@param('hidden', Types.Boolean)
@param('category', Types.String, true, null, parseCategory)
@param('tag', Types.String, true, null, parseCategory)
@param('difficultySetting', Types.UnsignedInt)
@param('difficultyAdmin', Types.UnsignedInt, true)
async postSetting(
domainId: string, pid: string | number, hidden = false,
category: string[] = [], tag: string[] = [],
difficultySetting: string, difficultyAdmin: number,
) {
const pdoc = await problem.get(domainId, pid);
await problem.edit(domainId, pdoc.docId, { hidden, category, tag });
if (!problem.SETTING_DIFFICULTY_RANGE[difficultySetting]) {
throw new ValidationError('difficultySetting');
}
if (!difficultyAdmin) difficultyAdmin = null;
else if (difficultyAdmin < 1 || difficultyAdmin > 9) throw new ValidationError('difficultyAdmin');
await problem.edit(domainId, pdoc.docId, {
hidden, category, tag, difficultySetting, difficultyAdmin,
});
await global.Hydro.script.difficulty.run({ domainId, pid }, console.log);
this.back();
}
}