mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: submit_answer
This commit is contained in:
1 parent
5c4221778e
commit
0cb5afa169
18 files changed
+191
-82
No files matched your search
@@ -8,6 +8,8 @@ import { PERM, PRIV, STATUS } from '../model/builtin';
|
||||
import * as contest from '../model/contest';
|
||||
import problem from '../model/problem';
|
||||
import record from '../model/record';
|
||||
import { langs } from '../model/setting';
|
||||
import storage from '../model/storage';
|
||||
import * as system from '../model/system';
|
||||
import TaskModel from '../model/task';
|
||||
import user from '../model/user';
|
||||
@@ -101,7 +103,8 @@ class RecordListHandler extends Handler {
|
||||
|
||||
class RecordDetailHandler extends Handler {
|
||||
@param('rid', Types.ObjectID)
|
||||
async get(domainId: string, rid: ObjectID) {
|
||||
@param('download', Types.Boolean)
|
||||
async get(domainId: string, rid: ObjectID, download = false) {
|
||||
this.response.template = 'record_detail.html';
|
||||
const rdoc = await record.get(domainId, rid);
|
||||
if (!rdoc) throw new RecordNotFoundError(rid);
|
||||
@@ -132,6 +135,17 @@ class RecordDetailHandler extends Handler {
|
||||
rdoc.compilerTexts = [];
|
||||
}
|
||||
|
||||
if (download && rdoc.code.startsWith('@@hydro_submission_file@@')) {
|
||||
const [id, filename] = rdoc.code.split('@@hydro_submission_file@@')[1].split('#');
|
||||
this.response.redirect = await storage.signDownloadLink(`submission/${id}`, filename || 'code', true, 'judge');
|
||||
return;
|
||||
}
|
||||
if (download) {
|
||||
const lang = langs[rdoc.lang]?.pretest || rdoc.lang;
|
||||
this.response.body = rdoc.code;
|
||||
this.response.disposition = `attachment; filename="${langs[lang].code_file}` || `foo.${rdoc.lang}"`;
|
||||
return;
|
||||
}
|
||||
if (pdoc && !(rdoc.contest && this.user._id === rdoc.uid)) {
|
||||
if (!problem.canViewBy(pdoc, this.user)) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user