mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: update contest path
This commit is contained in:
1 parent
3b6b6e3c17
commit
42b73f36a4
22 files changed
+131
-448
No files matched your search
@@ -23,6 +23,7 @@ Sandbox Host: 沙箱地址
|
|||||||
Standard answer longer than user output.: 标准输出比选手输出长。
|
Standard answer longer than user output.: 标准输出比选手输出长。
|
||||||
Stdout/Stderr size: 标准输出/错误流输出大小限制
|
Stdout/Stderr size: 标准输出/错误流输出大小限制
|
||||||
Strict Memory Mode: 严格内存限制
|
Strict Memory Mode: 严格内存限制
|
||||||
|
Syncing testdata, please wait...: 正在同步测试数据,请稍候...
|
||||||
Temp directory: 临时目录
|
Temp directory: 临时目录
|
||||||
Testdata cache directory: 测试数据缓存目录
|
Testdata cache directory: 测试数据缓存目录
|
||||||
Testdata configuration incorrect.: 题目配置错误。
|
Testdata configuration incorrect.: 题目配置错误。
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/hydrojudge",
|
"name": "@hydrooj/hydrojudge",
|
||||||
"bin": "bin/hydrojudge.js",
|
"bin": "bin/hydrojudge.js",
|
||||||
"version": "2.12.1",
|
"version": "2.12.2",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ class JudgeTask {
|
|||||||
this.clean = [];
|
this.clean = [];
|
||||||
await Lock.aquire(`${this.host}/${this.source}/${this.rid}`);
|
await Lock.aquire(`${this.host}/${this.source}/${this.rid}`);
|
||||||
fs.ensureDirSync(this.tmpdir);
|
fs.ensureDirSync(this.tmpdir);
|
||||||
tmpfs.mount(this.tmpdir, '512m');
|
tmpfs.mount(this.tmpdir, getConfig('tmpfs_size'));
|
||||||
log.info('Submission: %s/%s/%s pid=%s', this.host, this.source, this.rid);
|
log.info('Submission: %s/%s/%s', this.host, this.source, this.rid);
|
||||||
try {
|
try {
|
||||||
if (typeof this.input === 'string') await this.run();
|
if (typeof this.input === 'string') await this.run();
|
||||||
else await this.doSubmission();
|
else await this.doSubmission();
|
||||||
@@ -204,7 +204,7 @@ export default class Hydro {
|
|||||||
}
|
}
|
||||||
if (filenames.length) {
|
if (filenames.length) {
|
||||||
log.info(`Getting problem data: ${this.config.host}/${source}`);
|
log.info(`Getting problem data: ${this.config.host}/${source}`);
|
||||||
if (next) next({ judge_text: '正在同步测试数据,请稍候' });
|
if (next) next({ judge_text: 'Syncing testdata, please wait...' });
|
||||||
await this.ensureLogin();
|
await this.ensureLogin();
|
||||||
const res = await this.axios.post(`/d/${domainId}/judge/files`, {
|
const res = await this.axios.post(`/d/${domainId}/judge/files`, {
|
||||||
pid: +pid,
|
pid: +pid,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "3.0.0",
|
"version": "3.1.0",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -1,28 +1,20 @@
|
|||||||
import AdmZip from 'adm-zip';
|
import AdmZip from 'adm-zip';
|
||||||
import { intersection } from 'lodash';
|
|
||||||
import { lookup } from 'mime-types';
|
|
||||||
import moment from 'moment-timezone';
|
import moment from 'moment-timezone';
|
||||||
import { ObjectID } from 'mongodb';
|
import { ObjectID } from 'mongodb';
|
||||||
import { Time } from '@hydrooj/utils/lib/utils';
|
import { Time } from '@hydrooj/utils/lib/utils';
|
||||||
import {
|
import {
|
||||||
BadRequestError, ContestNotAttendedError, ContestNotFoundError,
|
ContestNotFoundError, ContestNotLiveError, InvalidTokenError,
|
||||||
ContestNotLiveError, InvalidTokenError, PermissionError,
|
PermissionError, ValidationError,
|
||||||
ProblemNotFoundError, RecordNotFoundError, ValidationError,
|
|
||||||
} from '../error';
|
} from '../error';
|
||||||
import {
|
import { Tdoc } from '../interface';
|
||||||
ProblemDoc, Tdoc, User,
|
|
||||||
} from '../interface';
|
|
||||||
import paginate from '../lib/paginate';
|
import paginate from '../lib/paginate';
|
||||||
import { PERM, PRIV } from '../model/builtin';
|
import { PERM, PRIV } from '../model/builtin';
|
||||||
import * as contest from '../model/contest';
|
import * as contest from '../model/contest';
|
||||||
import domain from '../model/domain';
|
|
||||||
import message from '../model/message';
|
import message from '../model/message';
|
||||||
import problem from '../model/problem';
|
import problem from '../model/problem';
|
||||||
import record from '../model/record';
|
import record from '../model/record';
|
||||||
import storage from '../model/storage';
|
|
||||||
import * as system from '../model/system';
|
import * as system from '../model/system';
|
||||||
import user from '../model/user';
|
import user from '../model/user';
|
||||||
import * as bus from '../service/bus';
|
|
||||||
import {
|
import {
|
||||||
Handler, param, Route, Types,
|
Handler, param, Route, Types,
|
||||||
} from '../service/server';
|
} from '../service/server';
|
||||||
@@ -56,9 +48,7 @@ export class ContestDetailHandler extends Handler {
|
|||||||
]);
|
]);
|
||||||
const psdict = {};
|
const psdict = {};
|
||||||
let rdict = {};
|
let rdict = {};
|
||||||
let attended: boolean;
|
|
||||||
if (tsdoc) {
|
if (tsdoc) {
|
||||||
attended = tsdoc.attend === 1;
|
|
||||||
for (const pdetail of tsdoc.journal || []) psdict[pdetail.pid] = pdetail;
|
for (const pdetail of tsdoc.journal || []) psdict[pdetail.pid] = pdetail;
|
||||||
if (contest.canShowSelfRecord.call(this, tdoc)) {
|
if (contest.canShowSelfRecord.call(this, tdoc)) {
|
||||||
const q = [];
|
const q = [];
|
||||||
@@ -67,16 +57,10 @@ export class ContestDetailHandler extends Handler {
|
|||||||
} else {
|
} else {
|
||||||
for (const i in psdict) rdict[psdict[i].rid] = { _id: psdict[i].rid };
|
for (const i in psdict) rdict[psdict[i].rid] = { _id: psdict[i].rid };
|
||||||
}
|
}
|
||||||
} else attended = false;
|
|
||||||
const udict = await user.getList(domainId, [tdoc.owner]);
|
|
||||||
const index = tdoc.pids.map((i) => i.toString());
|
|
||||||
for (const key in pdict) {
|
|
||||||
pdict[key].tag.length = 0;
|
|
||||||
const i = (index.indexOf(key) + 10).toString(36).toUpperCase();
|
|
||||||
if (i !== '9') pdict[key].pid = i;
|
|
||||||
}
|
}
|
||||||
|
const udict = await user.getList(domainId, [tdoc.owner]);
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
tdoc, tsdoc, attended, udict, pdict, psdict, rdict, page,
|
tdoc, tsdoc, udict, pdict, psdict, rdict, page,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +102,7 @@ export class ContestBroadcastHandler extends Handler {
|
|||||||
@param('content', Types.Content)
|
@param('content', Types.Content)
|
||||||
async post(domainId: string, tid: ObjectID, content: string) {
|
async post(domainId: string, tid: ObjectID, content: string) {
|
||||||
const tdoc = await contest.get(domainId, tid);
|
const tdoc = await contest.get(domainId, tid);
|
||||||
if (!this.user.own(tdoc)) throw new PermissionError('Boardcast Message');
|
if (!this.user.own(tdoc)) throw new PermissionError('Broadcast Message');
|
||||||
const tsdocs = await contest.getMultiStatus(domainId, { docId: tid }).toArray();
|
const tsdocs = await contest.getMultiStatus(domainId, { docId: tid }).toArray();
|
||||||
const uids: number[] = Array.from(new Set(tsdocs.map((tsdoc) => tsdoc.uid)));
|
const uids: number[] = Array.from(new Set(tsdocs.map((tsdoc) => tsdoc.uid)));
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
@@ -241,157 +225,6 @@ export class ContestEditHandler extends Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ContestProblemHandler extends Handler {
|
|
||||||
tdoc: Tdoc<30>;
|
|
||||||
pdoc: ProblemDoc;
|
|
||||||
tsdoc: any;
|
|
||||||
udoc: User;
|
|
||||||
attended: boolean;
|
|
||||||
|
|
||||||
@param('tid', Types.ObjectID)
|
|
||||||
@param('pid', Types.Name)
|
|
||||||
async _prepare(domainId: string, tid: ObjectID, _pid: string) {
|
|
||||||
this.tdoc = await contest.get(domainId, tid);
|
|
||||||
const pid = this.tdoc.pids[parseInt(_pid, 36) - 10];
|
|
||||||
if (!pid) throw new ProblemNotFoundError(domainId, tid, _pid);
|
|
||||||
[this.pdoc, this.tsdoc, this.udoc] = await Promise.all([
|
|
||||||
problem.get(domainId, pid),
|
|
||||||
contest.getStatus(domainId, tid, this.user._id),
|
|
||||||
user.getById(domainId, this.tdoc.owner),
|
|
||||||
]);
|
|
||||||
if (!this.pdoc) throw new ProblemNotFoundError(domainId, pid);
|
|
||||||
this.pdoc.pid = _pid;
|
|
||||||
this.pdoc.tag.length = 0;
|
|
||||||
this.attended = this.tsdoc && this.tsdoc.attend === 1;
|
|
||||||
if (this.pdoc.reference) {
|
|
||||||
const pdoc = await problem.get(this.pdoc.reference.domainId, this.pdoc.reference.pid);
|
|
||||||
this.pdoc.config = pdoc.config;
|
|
||||||
}
|
|
||||||
const showAccept = contest.canShowScoreboard.call(this, this.tdoc, true);
|
|
||||||
if (!showAccept) this.pdoc.nAccept = 0;
|
|
||||||
if (contest.isNotStarted(this.tdoc)) throw new ContestNotLiveError(tid);
|
|
||||||
if (!contest.isDone(this.tdoc) && !this.attended) throw new ContestNotAttendedError(tid);
|
|
||||||
this.response.template = 'problem_detail.html';
|
|
||||||
this.response.body = {
|
|
||||||
showAccept,
|
|
||||||
tdoc: this.tdoc,
|
|
||||||
tsdoc: this.tsdoc,
|
|
||||||
pdoc: this.pdoc,
|
|
||||||
udoc: this.udoc,
|
|
||||||
attended: this.attended,
|
|
||||||
page_name: 'contest_detail_problem',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@param('tid', Types.ObjectID)
|
|
||||||
@param('pid', Types.Name)
|
|
||||||
async get(...args: any[]) {
|
|
||||||
this.response.body.path = [
|
|
||||||
['Hydro', 'homepage'],
|
|
||||||
['contest_main', 'contest_main'],
|
|
||||||
[this.tdoc.title, 'contest_detail', { tid: args[1] }, true],
|
|
||||||
[this.pdoc.title, null, null, true],
|
|
||||||
];
|
|
||||||
// Navigate to current additional file download
|
|
||||||
// e.g.  will navigate to 
|
|
||||||
this.response.body.pdoc.content = this.response.body.pdoc.content
|
|
||||||
.replace(/\(file:\/\//g, `(./${args[2]}/file/`)
|
|
||||||
.replace(/="file:\/\//g, `="./${args[2]}/file/`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ContestProblemFileDownloadHandler extends ContestProblemHandler {
|
|
||||||
@param('filename', Types.Name)
|
|
||||||
@param('noDisposition', Types.Boolean)
|
|
||||||
async get(domainId: string, filename: string, noDisposition = false) {
|
|
||||||
if (this.pdoc.reference) {
|
|
||||||
this.pdoc = await problem.get(this.pdoc.reference.domainId, this.pdoc.reference.pid);
|
|
||||||
if (!this.pdoc) throw new ProblemNotFoundError();
|
|
||||||
}
|
|
||||||
const target = `problem/${this.pdoc.domainId}/${this.pdoc.docId}/additional_file/${filename}`;
|
|
||||||
const file = await storage.getMeta(target);
|
|
||||||
if (!file) {
|
|
||||||
this.response.redirect = await storage.signDownloadLink(
|
|
||||||
target, noDisposition ? undefined : filename, false, 'user',
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const type = lookup(filename).toString();
|
|
||||||
const shouldProxy = ['image', 'video', 'audio', 'pdf', 'vnd'].filter((i) => type.includes(i)).length;
|
|
||||||
if (shouldProxy && file.size! < 32 * 1024 * 1024) {
|
|
||||||
this.response.etag = file.etag;
|
|
||||||
this.response.body = await storage.get(target);
|
|
||||||
this.response.type = file['Content-Type'] || type;
|
|
||||||
this.response.disposition = `attachment; filename=${encodeURIComponent(filename)}`;
|
|
||||||
} else {
|
|
||||||
this.response.redirect = await storage.signDownloadLink(
|
|
||||||
target, noDisposition ? undefined : filename, false, 'user',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ContestDetailProblemSubmitHandler extends ContestProblemHandler {
|
|
||||||
@param('pid', Types.Name)
|
|
||||||
async prepare() {
|
|
||||||
if (!this.attended) throw new ContestNotAttendedError(this.tdoc.docId);
|
|
||||||
if (!contest.isOngoing(this.tdoc)) throw new ContestNotLiveError(this.tdoc.docId);
|
|
||||||
if (this.domain.langs) {
|
|
||||||
this.response.body.pdoc.config.langs = intersection(
|
|
||||||
this.response.body.pdoc.config.langs || this.domain.langs.split(','),
|
|
||||||
this.domain.langs.split(','),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@param('tid', Types.ObjectID)
|
|
||||||
@param('pid', Types.Name)
|
|
||||||
async get(domainId: string, tid: ObjectID, pid: string) {
|
|
||||||
this.response.body.path = [
|
|
||||||
['Hydro', 'homepage'],
|
|
||||||
['contest_main', 'contest_main'],
|
|
||||||
[this.tdoc.title, 'contest_detail', { tid }, true],
|
|
||||||
[this.pdoc.title, 'contest_detail_problem', { tid, pid }, true],
|
|
||||||
['contest_detail_problem_submit', null],
|
|
||||||
];
|
|
||||||
this.response.body.page_name = 'contest_detail_problem_submit';
|
|
||||||
this.response.template = 'problem_submit.html';
|
|
||||||
}
|
|
||||||
|
|
||||||
@param('tid', Types.ObjectID)
|
|
||||||
@param('lang', Types.Name)
|
|
||||||
@param('code', Types.Content)
|
|
||||||
@param('pid', Types.Name)
|
|
||||||
@param('pretest', Types.Boolean)
|
|
||||||
@param('input', Types.String, true)
|
|
||||||
async post(domainId: string, tid: ObjectID, lang: string, code: string, _pid: string, pretest = false, input = '') {
|
|
||||||
const pid = this.tdoc.pids[parseInt(_pid, 36) - 10];
|
|
||||||
if (!(this.response.body.pdoc.config.langs || [lang]).includes(lang)) {
|
|
||||||
throw new BadRequestError('Language not allowed.');
|
|
||||||
}
|
|
||||||
await this.limitRate('add_record', 60, system.get('limit.submission'));
|
|
||||||
const rid = await record.add(domainId, pid, this.user._id, lang, code, true, pretest ? input : tid, !pretest);
|
|
||||||
const rdoc = await record.get(domainId, rid);
|
|
||||||
if (!rdoc) throw new RecordNotFoundError(domainId, rid);
|
|
||||||
if (!pretest) {
|
|
||||||
await Promise.all([
|
|
||||||
(this.tsdoc.journal || []).filter((i) => i.pid === pid).length
|
|
||||||
&& problem.inc(this.domainId, this.pdoc.docId, 'nSubmit', 1),
|
|
||||||
domain.incUserInDomain(domainId, this.user._id, 'nSubmit'),
|
|
||||||
contest.updateStatus(domainId, tid, this.user._id, rid, pid),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
bus.broadcast('record/change', rdoc);
|
|
||||||
if (!pretest && !contest.canShowSelfRecord.call(this, this.tdoc)) {
|
|
||||||
this.response.body = { tid };
|
|
||||||
this.response.redirect = this.url('contest_detail', { tid });
|
|
||||||
} else {
|
|
||||||
this.response.body = { rid };
|
|
||||||
this.response.redirect = this.url('record_detail', { rid });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ContestCodeHandler extends Handler {
|
export class ContestCodeHandler extends Handler {
|
||||||
@param('tid', Types.ObjectID)
|
@param('tid', Types.ObjectID)
|
||||||
async get(domainId: string, tid: ObjectID) {
|
async get(domainId: string, tid: ObjectID) {
|
||||||
@@ -428,9 +261,6 @@ export async function apply() {
|
|||||||
Route('contest_edit', '/contest/:tid/edit', ContestEditHandler, PERM.PERM_VIEW_CONTEST);
|
Route('contest_edit', '/contest/:tid/edit', ContestEditHandler, PERM.PERM_VIEW_CONTEST);
|
||||||
Route('contest_scoreboard', '/contest/:tid/scoreboard', ContestScoreboardHandler, PERM.PERM_VIEW_CONTEST);
|
Route('contest_scoreboard', '/contest/:tid/scoreboard', ContestScoreboardHandler, PERM.PERM_VIEW_CONTEST);
|
||||||
Route('contest_scoreboard_download', '/contest/:tid/export/:ext', ContestScoreboardDownloadHandler, PERM.PERM_VIEW_CONTEST);
|
Route('contest_scoreboard_download', '/contest/:tid/export/:ext', ContestScoreboardDownloadHandler, PERM.PERM_VIEW_CONTEST);
|
||||||
Route('contest_detail_problem', '/contest/:tid/p/:pid', ContestProblemHandler, PERM.PERM_VIEW_CONTEST);
|
|
||||||
Route('contest_detail_problem_file_download', '/contest/:tid/p/:pid/file/:filename', ContestProblemFileDownloadHandler, PERM.PERM_VIEW_PROBLEM);
|
|
||||||
Route('contest_detail_problem_submit', '/contest/:tid/p/:pid/submit', ContestDetailProblemSubmitHandler, PERM.PERM_VIEW_CONTEST);
|
|
||||||
Route('contest_code', '/contest/:tid/code', ContestCodeHandler, PERM.PERM_VIEW_CONTEST);
|
Route('contest_code', '/contest/:tid/code', ContestCodeHandler, PERM.PERM_VIEW_CONTEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,20 @@
|
|||||||
import AdmZip from 'adm-zip';
|
import AdmZip from 'adm-zip';
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import { intersection } from 'lodash';
|
|
||||||
import { lookup } from 'mime-types';
|
|
||||||
import moment from 'moment-timezone';
|
import moment from 'moment-timezone';
|
||||||
import { ObjectID } from 'mongodb';
|
import { ObjectID } from 'mongodb';
|
||||||
import { Time } from '@hydrooj/utils/lib/utils';
|
import { Time } from '@hydrooj/utils/lib/utils';
|
||||||
import {
|
import {
|
||||||
BadRequestError, ContestNotFoundError, HomeworkNotAttendedError,
|
ContestNotFoundError, HomeworkNotLiveError, ValidationError,
|
||||||
HomeworkNotLiveError, ProblemNotFoundError, ValidationError,
|
|
||||||
} from '../error';
|
} from '../error';
|
||||||
import {
|
import { PenaltyRules } from '../interface';
|
||||||
PenaltyRules, ProblemDoc, Tdoc, User,
|
|
||||||
} from '../interface';
|
|
||||||
import paginate from '../lib/paginate';
|
import paginate from '../lib/paginate';
|
||||||
import { PERM, PRIV, STATUS } from '../model/builtin';
|
import { PERM, PRIV } from '../model/builtin';
|
||||||
import * as contest from '../model/contest';
|
import * as contest from '../model/contest';
|
||||||
import * as discussion from '../model/discussion';
|
import * as discussion from '../model/discussion';
|
||||||
import domain from '../model/domain';
|
|
||||||
import problem from '../model/problem';
|
import problem from '../model/problem';
|
||||||
import record from '../model/record';
|
import record from '../model/record';
|
||||||
import storage from '../model/storage';
|
|
||||||
import * as system from '../model/system';
|
import * as system from '../model/system';
|
||||||
import user from '../model/user';
|
import user from '../model/user';
|
||||||
import * as bus from '../service/bus';
|
|
||||||
import {
|
import {
|
||||||
Handler, param, Route, Types,
|
Handler, param, Route, Types,
|
||||||
} from '../service/server';
|
} from '../service/server';
|
||||||
@@ -59,9 +51,7 @@ class HomeworkDetailHandler extends Handler {
|
|||||||
]);
|
]);
|
||||||
const psdict = {};
|
const psdict = {};
|
||||||
let rdict = {};
|
let rdict = {};
|
||||||
let attended = false;
|
|
||||||
if (tsdoc) {
|
if (tsdoc) {
|
||||||
attended = tsdoc.attend === 1;
|
|
||||||
for (const pdetail of tsdoc.journal || []) {
|
for (const pdetail of tsdoc.journal || []) {
|
||||||
psdict[pdetail.pid] = pdetail;
|
psdict[pdetail.pid] = pdetail;
|
||||||
rdict[pdetail.rid] = { _id: pdetail.rid };
|
rdict[pdetail.rid] = { _id: pdetail.rid };
|
||||||
@@ -82,14 +72,9 @@ class HomeworkDetailHandler extends Handler {
|
|||||||
const uids = ddocs.map((ddoc) => ddoc.owner);
|
const uids = ddocs.map((ddoc) => ddoc.owner);
|
||||||
uids.push(tdoc.owner);
|
uids.push(tdoc.owner);
|
||||||
const udict = await user.getList(domainId, uids);
|
const udict = await user.getList(domainId, uids);
|
||||||
const index = tdoc.pids.map((i) => i.toString());
|
|
||||||
for (const key in pdict) {
|
|
||||||
const i = (index.indexOf(key) + 10).toString(36).toUpperCase();
|
|
||||||
if (i !== '9') pdict[key].pid = i;
|
|
||||||
}
|
|
||||||
this.response.template = 'homework_detail.html';
|
this.response.template = 'homework_detail.html';
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
tdoc, tsdoc, attended, udict, pdict, psdict, rdict, ddocs, page, dpcount, dcount,
|
tdoc, tsdoc, udict, pdict, psdict, rdict, ddocs, page, dpcount, dcount,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,151 +96,6 @@ class HomeworkDetailHandler extends Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class HomeworkDetailProblemHandler extends Handler {
|
|
||||||
tdoc: Tdoc<30>;
|
|
||||||
pdoc: ProblemDoc;
|
|
||||||
pid: number;
|
|
||||||
tsdoc: any;
|
|
||||||
udoc: User;
|
|
||||||
attended: boolean;
|
|
||||||
|
|
||||||
@param('tid', Types.ObjectID)
|
|
||||||
@param('pid', Types.String)
|
|
||||||
async _prepare(domainId: string, tid: ObjectID, _pid: string) {
|
|
||||||
this.tdoc = await contest.get(domainId, tid);
|
|
||||||
if (this.tdoc.rule !== 'homework') throw new ContestNotFoundError(domainId, tid);
|
|
||||||
this.pid = this.tdoc.pids[parseInt(_pid, 36) - 10];
|
|
||||||
if (!this.pid) throw new ProblemNotFoundError(domainId, tid, _pid);
|
|
||||||
[this.udoc, this.pdoc, this.tsdoc] = await Promise.all([
|
|
||||||
user.getById(domainId, this.tdoc.owner),
|
|
||||||
problem.get(domainId, this.pid),
|
|
||||||
contest.getStatus(domainId, tid, this.user._id),
|
|
||||||
]);
|
|
||||||
if (!this.pdoc) throw new ProblemNotFoundError(domainId, this.pid);
|
|
||||||
if (this.pdoc.reference) {
|
|
||||||
const pdoc = await problem.get(this.pdoc.reference.domainId, this.pdoc.reference.pid);
|
|
||||||
this.pdoc.config = pdoc.config;
|
|
||||||
}
|
|
||||||
this.pdoc.pid = _pid;
|
|
||||||
this.attended = this.tsdoc?.attend === 1;
|
|
||||||
this.response.body = {
|
|
||||||
tdoc: this.tdoc,
|
|
||||||
pdoc: this.pdoc,
|
|
||||||
tsdoc: this.tsdoc,
|
|
||||||
udoc: this.udoc,
|
|
||||||
attended: this.attended,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@param('tid', Types.ObjectID)
|
|
||||||
@param('pid', Types.Name)
|
|
||||||
async get(domainId: string, tid: ObjectID, pid: string) {
|
|
||||||
if (!contest.isDone(this.tdoc)) {
|
|
||||||
if (!this.attended) throw new HomeworkNotAttendedError(tid);
|
|
||||||
if (contest.isNotStarted(this.tdoc)) throw new HomeworkNotLiveError(tid);
|
|
||||||
}
|
|
||||||
this.response.template = 'problem_detail.html';
|
|
||||||
this.response.body.page_name = 'homework_detail_problem';
|
|
||||||
this.response.body.path = [
|
|
||||||
['Hydro', 'homepage'],
|
|
||||||
['homework_main', 'homework_main'],
|
|
||||||
[this.tdoc.title, 'homework_detail', { tid }, true],
|
|
||||||
[this.pdoc.title, null, null, true],
|
|
||||||
];
|
|
||||||
// Navigate to current additional file download
|
|
||||||
// e.g.  will navigate to 
|
|
||||||
this.response.body.pdoc.content = this.response.body.pdoc.content
|
|
||||||
.replace(/\(file:\/\//g, `(./${pid}/file/`)
|
|
||||||
.replace(/="file:\/\//g, `="./${pid}/file/`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class HomeworkProblemFileDownloadHandler extends HomeworkDetailProblemHandler {
|
|
||||||
@param('filename', Types.Name)
|
|
||||||
@param('noDisposition', Types.Boolean)
|
|
||||||
// @ts-ignore
|
|
||||||
async get(domainId: string, filename: string, noDisposition = false) {
|
|
||||||
if (this.pdoc.reference) {
|
|
||||||
this.pdoc = await problem.get(this.pdoc.reference.domainId, this.pdoc.reference.pid);
|
|
||||||
if (!this.pdoc) throw new ProblemNotFoundError();
|
|
||||||
}
|
|
||||||
const target = `problem/${this.pdoc.domainId}/${this.pdoc.docId}/additional_file/${filename}`;
|
|
||||||
const file = await storage.getMeta(target);
|
|
||||||
if (!file) {
|
|
||||||
this.response.redirect = await storage.signDownloadLink(
|
|
||||||
target, noDisposition ? undefined : filename, false, 'user',
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const type = lookup(filename).toString();
|
|
||||||
const shouldProxy = ['image', 'video', 'audio', 'pdf', 'vnd'].filter((i) => type.includes(i)).length;
|
|
||||||
if (shouldProxy && file.size! < 32 * 1024 * 1024) {
|
|
||||||
this.response.etag = file.etag;
|
|
||||||
this.response.body = await storage.get(target);
|
|
||||||
this.response.type = file['Content-Type'] || type;
|
|
||||||
this.response.disposition = `attachment; filename=${encodeURIComponent(filename)}`;
|
|
||||||
} else {
|
|
||||||
this.response.redirect = await storage.signDownloadLink(
|
|
||||||
target, noDisposition ? undefined : filename, false, 'user',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class HomeworkDetailProblemSubmitHandler extends HomeworkDetailProblemHandler {
|
|
||||||
@param('tid', Types.ObjectID)
|
|
||||||
async prepare(domainId: string, tid: ObjectID) {
|
|
||||||
if (!this.attended) throw new HomeworkNotAttendedError(tid);
|
|
||||||
if (!contest.isOngoing(this.tdoc)) throw new HomeworkNotLiveError(tid);
|
|
||||||
if (this.domain.langs) {
|
|
||||||
this.response.body.pdoc.config.langs = intersection(
|
|
||||||
this.response.body.pdoc.config.langs || this.domain.langs.split(','),
|
|
||||||
this.domain.langs.split(','),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@param('tid', Types.ObjectID)
|
|
||||||
@param('pid', Types.String)
|
|
||||||
async get(domainId: string, tid: ObjectID, pid: string) {
|
|
||||||
this.response.body.path = [
|
|
||||||
['Hydro', 'homepage'],
|
|
||||||
['homework_main', 'homework_main'],
|
|
||||||
[this.tdoc.title, 'homework_detail', { tid }, true],
|
|
||||||
[this.pdoc.title, 'homework_detail_problem', { tid, pid }, true],
|
|
||||||
['homework_detail_problem_submit', null],
|
|
||||||
];
|
|
||||||
this.response.template = 'problem_submit.html';
|
|
||||||
}
|
|
||||||
|
|
||||||
@param('tid', Types.ObjectID)
|
|
||||||
@param('code', Types.Content)
|
|
||||||
@param('lang', Types.Name)
|
|
||||||
@param('pretest', Types.Boolean)
|
|
||||||
@param('input', Types.String, true)
|
|
||||||
async post(domainId: string, tid: ObjectID, code: string, lang: string, pretest = false, input = '') {
|
|
||||||
if (this.response.body.pdoc.config?.langs && !this.response.body.pdoc.config.langs.includes(lang)) {
|
|
||||||
throw new BadRequestError('Language not allowed.');
|
|
||||||
}
|
|
||||||
await this.limitRate('add_record', 60, system.get('limit.submission'));
|
|
||||||
const rid = await record.add(domainId, this.pid, this.user._id, lang, code, true, pretest ? input : tid);
|
|
||||||
const rdoc = await record.get(domainId, rid);
|
|
||||||
if (!pretest) {
|
|
||||||
await Promise.all([
|
|
||||||
(this.tsdoc.journal || []).filter((i) => i.pid === this.pid).length
|
|
||||||
&& problem.inc(this.domainId, this.pdoc.docId, 'nSubmit', 1),
|
|
||||||
domain.incUserInDomain(domainId, this.user._id, 'nSubmit'),
|
|
||||||
contest.updateStatus(domainId, tid, this.user._id, rid, this.pid, STATUS.STATUS_WAITING),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
bus.broadcast('record/change', rdoc);
|
|
||||||
this.response.body.tid = tid;
|
|
||||||
this.response.body.rid = rid;
|
|
||||||
if (pretest || contest.canShowSelfRecord.call(this, this.tdoc)) this.response.redirect = this.url('record_detail', { rid });
|
|
||||||
else this.response.redirect = this.url('homework_detail', { tid });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class HomeworkEditHandler extends Handler {
|
class HomeworkEditHandler extends Handler {
|
||||||
@param('tid', Types.ObjectID, true)
|
@param('tid', Types.ObjectID, true)
|
||||||
async get(domainId: string, tid: ObjectID) {
|
async get(domainId: string, tid: ObjectID) {
|
||||||
@@ -406,12 +246,6 @@ export async function apply() {
|
|||||||
'homework_scoreboard_download', '/homework/:tid/scoreboard/download/:ext',
|
'homework_scoreboard_download', '/homework/:tid/scoreboard/download/:ext',
|
||||||
HomeworkScoreboardDownloadHandler, PERM.PERM_VIEW_HOMEWORK_SCOREBOARD,
|
HomeworkScoreboardDownloadHandler, PERM.PERM_VIEW_HOMEWORK_SCOREBOARD,
|
||||||
);
|
);
|
||||||
Route('homework_detail_problem', '/homework/:tid/p/:pid', HomeworkDetailProblemHandler, PERM.PERM_VIEW_HOMEWORK);
|
|
||||||
Route(
|
|
||||||
'homework_detail_problem_file_download', '/homework/:tid/p/:pid/file/:filename',
|
|
||||||
HomeworkProblemFileDownloadHandler, PERM.PERM_VIEW_PROBLEM,
|
|
||||||
);
|
|
||||||
Route('homework_detail_problem_submit', '/homework/:tid/p/:pid/submit', HomeworkDetailProblemSubmitHandler, PERM.PERM_SUBMIT_PROBLEM);
|
|
||||||
Route('homework_code', '/homework/:tid/code', HomeworkCodeHandler, PERM.PERM_VIEW_HOMEWORK);
|
Route('homework_code', '/homework/:tid/code', HomeworkCodeHandler, PERM.PERM_VIEW_HOMEWORK);
|
||||||
Route('homework_edit', '/homework/:tid/edit', HomeworkEditHandler);
|
Route('homework_edit', '/homework/:tid/edit', HomeworkEditHandler);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ import { lookup } from 'mime-types';
|
|||||||
import { FilterQuery, ObjectID } from 'mongodb';
|
import { FilterQuery, ObjectID } from 'mongodb';
|
||||||
import { sortFiles } from '@hydrooj/utils/lib/utils';
|
import { sortFiles } from '@hydrooj/utils/lib/utils';
|
||||||
import {
|
import {
|
||||||
BadRequestError, ForbiddenError, NoProblemError,
|
BadRequestError, ContestNotAttendedError, ContestNotFoundError, ContestNotLiveError, ForbiddenError, NoProblemError,
|
||||||
PermissionError, ProblemNotFoundError, SolutionNotFoundError,
|
PermissionError, ProblemNotFoundError, SolutionNotFoundError,
|
||||||
ValidationError,
|
ValidationError,
|
||||||
} from '../error';
|
} from '../error';
|
||||||
import {
|
import {
|
||||||
ProblemDoc, ProblemStatusDoc, User,
|
ProblemDoc, ProblemStatusDoc, Tdoc, User,
|
||||||
} from '../interface';
|
} from '../interface';
|
||||||
import difficultyAlgorithm from '../lib/difficulty';
|
import difficultyAlgorithm from '../lib/difficulty';
|
||||||
import paginate from '../lib/paginate';
|
import paginate from '../lib/paginate';
|
||||||
@@ -208,26 +208,37 @@ export class ProblemRandomHandler extends ProblemHandler {
|
|||||||
|
|
||||||
export class ProblemDetailHandler extends ProblemHandler {
|
export class ProblemDetailHandler extends ProblemHandler {
|
||||||
pdoc: ProblemDoc;
|
pdoc: ProblemDoc;
|
||||||
|
tdoc?: Tdoc<30>;
|
||||||
|
tsdoc?: any;
|
||||||
udoc: User;
|
udoc: User;
|
||||||
psdoc: ProblemStatusDoc;
|
psdoc: ProblemStatusDoc;
|
||||||
|
|
||||||
@route('pid', Types.Name, true, null, parsePid)
|
@route('pid', Types.Name, true, null, parsePid)
|
||||||
async _prepare(domainId: string, pid: number | string) {
|
@query('tid', Types.ObjectID, true)
|
||||||
this.response.template = 'problem_detail.html';
|
async _prepare(domainId: string, pid: number | string, tid?: ObjectID) {
|
||||||
this.pdoc = await problem.get(domainId, pid);
|
this.pdoc = await problem.get(domainId, pid);
|
||||||
if (!this.pdoc) throw new ProblemNotFoundError(domainId, pid);
|
if (!this.pdoc) throw new ProblemNotFoundError(domainId, pid);
|
||||||
if (this.pdoc.hidden && !this.user.own(this.pdoc)) {
|
if (tid) {
|
||||||
|
this.tdoc = await contest.get(domainId, tid);
|
||||||
|
if (!this.tdoc) throw new ContestNotFoundError(domainId, tid);
|
||||||
|
this.tsdoc = await contest.getStatus(domainId, tid, this.user._id);
|
||||||
|
this.pdoc.tag.length = 0;
|
||||||
|
const showAccept = contest.canShowScoreboard.call(this, this.tdoc, true);
|
||||||
|
if (!showAccept) this.pdoc.nAccept = 0;
|
||||||
|
if (contest.isNotStarted(this.tdoc)) throw new ContestNotLiveError(tid);
|
||||||
|
if (!contest.isDone(this.tdoc) && !this.tsdoc.attend) throw new ContestNotAttendedError(tid);
|
||||||
|
} else if (this.pdoc.hidden && !this.user.own(this.pdoc)) {
|
||||||
this.checkPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN);
|
this.checkPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN);
|
||||||
}
|
}
|
||||||
|
if (this.pdoc.reference) {
|
||||||
|
const pdoc = await problem.get(this.pdoc.reference.domainId, this.pdoc.reference.pid);
|
||||||
|
this.pdoc.config = pdoc.config;
|
||||||
|
}
|
||||||
await bus.serial('problem/get', this.pdoc, this);
|
await bus.serial('problem/get', this.pdoc, this);
|
||||||
[this.psdoc, this.udoc] = await Promise.all([
|
[this.psdoc, this.udoc] = await Promise.all([
|
||||||
problem.getStatus(domainId, this.pdoc.docId, this.user._id),
|
problem.getStatus(domainId, this.pdoc.docId, this.user._id),
|
||||||
user.getById(domainId, this.pdoc.owner),
|
user.getById(domainId, this.pdoc.owner),
|
||||||
]);
|
]);
|
||||||
if (this.pdoc.reference) {
|
|
||||||
const pdoc = await problem.get(this.pdoc.reference.domainId, this.pdoc.reference.pid);
|
|
||||||
this.pdoc.config = pdoc.config;
|
|
||||||
}
|
|
||||||
const [scnt, dcnt] = await Promise.all([
|
const [scnt, dcnt] = await Promise.all([
|
||||||
solution.count(domainId, { parentId: this.pdoc.docId }),
|
solution.count(domainId, { parentId: this.pdoc.docId }),
|
||||||
discussion.count(domainId, { parentId: this.pdoc.docId }),
|
discussion.count(domainId, { parentId: this.pdoc.docId }),
|
||||||
@@ -239,7 +250,15 @@ export class ProblemDetailHandler extends ProblemHandler {
|
|||||||
title: this.pdoc.title,
|
title: this.pdoc.title,
|
||||||
solutionCount: scnt,
|
solutionCount: scnt,
|
||||||
discussionCount: dcnt,
|
discussionCount: dcnt,
|
||||||
|
tdoc: this.tdoc,
|
||||||
|
tsdoc: this.tsdoc,
|
||||||
|
page_name: this.tdoc
|
||||||
|
? this.tdoc.rule === 'homework'
|
||||||
|
? 'homework_detail_problem'
|
||||||
|
: 'contest_detail_problem'
|
||||||
|
: 'problem_detail',
|
||||||
};
|
};
|
||||||
|
this.response.template = 'problem_detail.html';
|
||||||
this.extraTitleContent = this.pdoc.title;
|
this.extraTitleContent = this.pdoc.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,10 +271,12 @@ export class ProblemDetailHandler extends ProblemHandler {
|
|||||||
.replace(/\(file:\/\//g, `(./${this.pdoc.docId}/file/`)
|
.replace(/\(file:\/\//g, `(./${this.pdoc.docId}/file/`)
|
||||||
.replace(/="file:\/\//g, `="./${this.pdoc.docId}/file/`);
|
.replace(/="file:\/\//g, `="./${this.pdoc.docId}/file/`);
|
||||||
}
|
}
|
||||||
if (this.psdoc) {
|
if (!this.response.body.tdoc) {
|
||||||
this.response.body.rdoc = await record.get(this.domainId, this.psdoc.rid);
|
if (this.psdoc?.rid) {
|
||||||
|
this.response.body.rdoc = await record.get(this.domainId, this.psdoc.rid);
|
||||||
|
}
|
||||||
|
this.response.body.ctdocs = await contest.getRelated(this.domainId, this.pdoc.docId);
|
||||||
}
|
}
|
||||||
this.response.body.ctdocs = await contest.getRelated(this.domainId, this.pdoc.docId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@param('pid', Types.UnsignedInt)
|
@param('pid', Types.UnsignedInt)
|
||||||
@@ -288,60 +309,59 @@ export class ProblemDetailHandler extends ProblemHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class ProblemSubmitHandler extends ProblemDetailHandler {
|
export class ProblemSubmitHandler extends ProblemDetailHandler {
|
||||||
async get() {
|
async get(domainId: string, tid?: ObjectID) {
|
||||||
this.response.template = 'problem_submit.html';
|
this.response.template = 'problem_submit.html';
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
pdoc: this.pdoc,
|
pdoc: this.pdoc,
|
||||||
udoc: this.udoc,
|
udoc: this.udoc,
|
||||||
title: this.pdoc.title,
|
title: this.pdoc.title,
|
||||||
|
page_name: this.tdoc
|
||||||
|
? this.tdoc.rule === 'homework'
|
||||||
|
? 'homework_detail_problem_submit'
|
||||||
|
: 'contest_detail_problem_submit'
|
||||||
|
: 'problem_submit',
|
||||||
};
|
};
|
||||||
|
if (tid && !contest.isOngoing(this.tdoc)) throw new ContestNotLiveError(this.tdoc.docId);
|
||||||
if (this.domain.langs) {
|
if (this.domain.langs) {
|
||||||
this.response.body.pdoc.config.langs = intersection(
|
this.response.body.pdoc.config.langs = intersection(
|
||||||
this.response.body.pdoc.config.langs || this.domain.langs.split(','),
|
this.response.body.pdoc.config.langs || this.domain.langs.split(','),
|
||||||
this.domain.langs.split(','),
|
this.domain.langs.split(','),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.response.body.pdoc.config.domainId = this.domainId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@param('lang', Types.Name)
|
@param('lang', Types.Name)
|
||||||
@param('code', Types.Content)
|
@param('code', Types.Content)
|
||||||
@param('pretest', Types.Boolean)
|
@param('pretest', Types.Boolean)
|
||||||
@param('input', Types.String, true)
|
@param('input', Types.String, true)
|
||||||
async post(domainId: string, lang: string, code: string, pretest = false, input = '') {
|
@param('tid', Types.ObjectID, true)
|
||||||
|
async post(domainId: string, lang: string, code: string, pretest = false, input = '', tid?: ObjectID) {
|
||||||
if (this.response.body.pdoc.config?.langs && !this.response.body.pdoc.config.langs.includes(lang)) {
|
if (this.response.body.pdoc.config?.langs && !this.response.body.pdoc.config.langs.includes(lang)) {
|
||||||
throw new BadRequestError('Language not allowed.');
|
throw new BadRequestError('Language not allowed.');
|
||||||
}
|
}
|
||||||
if (pretest && this.response.body.pdoc.config?.type !== 'default') throw new BadRequestError('unable to run pretest');
|
if (pretest && this.response.body.pdoc.config?.type !== 'default') throw new BadRequestError('unable to run pretest');
|
||||||
await this.limitRate('add_record', 60, system.get('limit.submission'));
|
await this.limitRate('add_record', 60, system.get('limit.submission'));
|
||||||
const rid = await record.add(domainId, this.pdoc.docId, this.user._id, lang, code, true, pretest ? input : undefined);
|
const rid = await record.add(domainId, this.pdoc.docId, this.user._id, lang, code, true, pretest ? input : tid, !pretest);
|
||||||
const rdoc = await record.get(domainId, rid);
|
const rdoc = await record.get(domainId, rid);
|
||||||
if (!pretest) {
|
if (!pretest) {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.psdoc?.rid ? Promise.resolve() : problem.inc(domainId, this.pdoc.docId, 'nSubmit', 1),
|
(this.tdoc
|
||||||
|
? (this.tsdoc.journal || []).filter((i) => i.pid === this.pdoc.docId).length
|
||||||
|
: this.psdoc?.rid ? Promise.resolve() : problem.inc(domainId, this.pdoc.docId, 'nSubmit', 1)
|
||||||
|
) && problem.inc(this.domainId, this.pdoc.docId, 'nSubmit', 1),
|
||||||
problem.incStatus(domainId, this.pdoc.docId, this.user._id, 'nSubmit', 1),
|
problem.incStatus(domainId, this.pdoc.docId, this.user._id, 'nSubmit', 1),
|
||||||
domain.incUserInDomain(domainId, this.user._id, 'nSubmit'),
|
domain.incUserInDomain(domainId, this.user._id, 'nSubmit'),
|
||||||
|
tid && contest.updateStatus(domainId, tid, this.user._id, rid, this.pdoc.docId),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
bus.broadcast('record/change', rdoc);
|
bus.broadcast('record/change', rdoc);
|
||||||
this.response.body = { rid };
|
if (tid && !pretest && !contest.canShowSelfRecord.call(this, this.tdoc)) {
|
||||||
this.response.redirect = this.url('record_detail', { rid });
|
this.response.body = { tid };
|
||||||
}
|
this.response.redirect = this.url(this.tdoc.rule === 'homework' ? 'homework_detail' : 'contest_detail', { tid });
|
||||||
}
|
} else {
|
||||||
|
this.response.body = { rid };
|
||||||
export class ProblemPretestHandler extends ProblemDetailHandler {
|
this.response.redirect = this.url('record_detail', { rid });
|
||||||
@param('lang', Types.Name)
|
}
|
||||||
@param('code', Types.Content)
|
|
||||||
@param('input', Types.Content, true)
|
|
||||||
async post(domainId: string, lang: string, code: string, input = '') {
|
|
||||||
await this.limitRate('do_pretest', 60, system.get('limit.pretest'));
|
|
||||||
const rid = await record.add(
|
|
||||||
domainId, this.pdoc.docId, this.user._id,
|
|
||||||
lang, code, true, input,
|
|
||||||
);
|
|
||||||
const rdoc = await record.get(domainId, rid);
|
|
||||||
bus.broadcast('record/change', rdoc);
|
|
||||||
this.response.body = { rid };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -524,7 +544,9 @@ export class ProblemFileDownloadHandler extends ProblemDetailHandler {
|
|||||||
|
|
||||||
export class ProblemSolutionHandler extends ProblemDetailHandler {
|
export class ProblemSolutionHandler extends ProblemDetailHandler {
|
||||||
@param('page', Types.PositiveInt, true)
|
@param('page', Types.PositiveInt, true)
|
||||||
async get(domainId: string, page = 1) {
|
@param('tid', Types.ObjectID, true)
|
||||||
|
async get(domainId: string, page = 1, tid?: ObjectID) {
|
||||||
|
if (tid) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_SOLUTION);
|
||||||
this.response.template = 'problem_solution.html';
|
this.response.template = 'problem_solution.html';
|
||||||
this.checkPerm(PERM.PERM_VIEW_PROBLEM_SOLUTION);
|
this.checkPerm(PERM.PERM_VIEW_PROBLEM_SOLUTION);
|
||||||
const [psdocs, pcount, pscount] = await paginate(
|
const [psdocs, pcount, pscount] = await paginate(
|
||||||
@@ -627,7 +649,9 @@ export class ProblemSolutionHandler extends ProblemDetailHandler {
|
|||||||
export class ProblemSolutionRawHandler extends ProblemDetailHandler {
|
export class ProblemSolutionRawHandler extends ProblemDetailHandler {
|
||||||
@param('psid', Types.ObjectID)
|
@param('psid', Types.ObjectID)
|
||||||
@route('psrid', Types.ObjectID, true)
|
@route('psrid', Types.ObjectID, true)
|
||||||
async get(domainId: string, psid: ObjectID, psrid?: ObjectID) {
|
@param('tid', Types.ObjectID, true)
|
||||||
|
async get(domainId: string, psid: ObjectID, psrid?: ObjectID, tid?: ObjectID) {
|
||||||
|
if (tid) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_SOLUTION);
|
||||||
this.checkPerm(PERM.PERM_VIEW_PROBLEM_SOLUTION);
|
this.checkPerm(PERM.PERM_VIEW_PROBLEM_SOLUTION);
|
||||||
if (psrid) {
|
if (psrid) {
|
||||||
const [psdoc, psrdoc] = await solution.getReply(domainId, psid, psrid);
|
const [psdoc, psrdoc] = await solution.getReply(domainId, psid, psrid);
|
||||||
|
|||||||
@@ -238,6 +238,7 @@ class RecordMainConnectionHandler extends ConnectionHandler {
|
|||||||
if (rdoc.domainId !== this.domainId) return;
|
if (rdoc.domainId !== this.domainId) return;
|
||||||
if (rdoc.contest && ![this.tid, '000000000000000000000000'].includes(rdoc.contest.toString())) return;
|
if (rdoc.contest && ![this.tid, '000000000000000000000000'].includes(rdoc.contest.toString())) return;
|
||||||
}
|
}
|
||||||
|
if (this.tid && rdoc.contest?.toString() !== this.tid) return;
|
||||||
if (this.pid && rdoc.pid !== this.pid) return;
|
if (this.pid && rdoc.pid !== this.pid) return;
|
||||||
if (this.uid && rdoc.uid !== this.uid) return;
|
if (this.uid && rdoc.uid !== this.uid) return;
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ const acm: ContestRule = {
|
|||||||
columns.push({
|
columns.push({
|
||||||
type: 'problem_detail',
|
type: 'problem_detail',
|
||||||
value: '#{0}'.format(i),
|
value: '#{0}'.format(i),
|
||||||
raw: (i + 9).toString(36).toUpperCase(),
|
raw: pid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -203,7 +203,7 @@ const oi: ContestRule = {
|
|||||||
columns.push({
|
columns.push({
|
||||||
type: 'problem_detail',
|
type: 'problem_detail',
|
||||||
value: '#{0}'.format(i),
|
value: '#{0}'.format(i),
|
||||||
raw: (i + 9).toString(36).toUpperCase(),
|
raw: tdoc.pids[i - 1],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -371,7 +371,7 @@ const homework: ContestRule = {
|
|||||||
columns.push({
|
columns.push({
|
||||||
type: 'problem_detail',
|
type: 'problem_detail',
|
||||||
value: '#{0}'.format(i),
|
value: '#{0}'.format(i),
|
||||||
raw: (i + 9).toString(36).toUpperCase(),
|
raw: pid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.26.0",
|
"version": "4.26.1",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
|
|||||||
@@ -2,10 +2,7 @@
|
|||||||
{%- if not invalid %}
|
{%- if not invalid %}
|
||||||
<a
|
<a
|
||||||
{% if tdoc -%}
|
{% if tdoc -%}
|
||||||
href="{{ url(
|
href="{{ url('problem_detail', pid=pdoc.pid|default(pdoc.docId), query={tid:tdoc.docId}) }}"
|
||||||
'contest_detail_problem' if tdoc.docType == model.document.TYPE_CONTEST else 'homework_detail_problem',
|
|
||||||
tid=tdoc.docId, pid=parseContestProblemId(pdoc, tdoc)
|
|
||||||
) }}"
|
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
href="{{ url('problem_detail', pid=pdoc.pid|default(pdoc.docId)) }}"
|
href="{{ url('problem_detail', pid=pdoc.pid|default(pdoc.docId)) }}"
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<span class="bp3-tag bp3-large bp3-minimal problem__tag-item icon icon-schedule">{{ contest.render_duration(tdoc) }} {{ _('hour(s)') }}</span>
|
<span class="bp3-tag bp3-large bp3-minimal problem__tag-item icon icon-schedule">{{ contest.render_duration(tdoc) }} {{ _('hour(s)') }}</span>
|
||||||
<span class="bp3-tag bp3-large bp3-minimal problem__tag-item">{{ _('Host') }}: {{ user.render_inline(udict[tdoc.owner], badge=false) }}</span>
|
<span class="bp3-tag bp3-large bp3-minimal problem__tag-item">{{ _('Host') }}: {{ user.render_inline(udict[tdoc.owner], badge=false) }}</span>
|
||||||
<span class="bp3-tag bp3-large bp3-minimal problem__tag-item icon icon-user--multiple">{{ tdoc['attend']|default(0) }}</span>
|
<span class="bp3-tag bp3-large bp3-minimal problem__tag-item icon icon-user--multiple">{{ tdoc['attend']|default(0) }}</span>
|
||||||
{% if attended %}
|
{% if tsdoc.attend %}
|
||||||
<span class="bp3-tag bp3-large bp3-minimal problem__tag-item icon icon-check">{{ _('Attended') }}</span>
|
<span class="bp3-tag bp3-large bp3-minimal problem__tag-item icon icon-check">{{ _('Attended') }}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
<div class="section__header">
|
<div class="section__header">
|
||||||
<h1 class="section__title">{{ _('Problem') }}</h1>
|
<h1 class="section__title">{{ _('Problem') }}</h1>
|
||||||
</div>
|
</div>
|
||||||
{% if attended or model.contest.isDone(tdoc) %}
|
{% if tsdoc.attend or model.contest.isDone(tdoc) %}
|
||||||
<div class="section__body no-padding">
|
<div class="section__body no-padding">
|
||||||
<table class="data-table">
|
<table class="data-table">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
{%- for column in rows[0] -%}
|
{%- for column in rows[0] -%}
|
||||||
<th class="col--{{ column.type }}">
|
<th class="col--{{ column.type }}">
|
||||||
{% if column.type == 'problem_detail' %}
|
{% if column.type == 'problem_detail' %}
|
||||||
<a href="{{ url(type + '_detail_problem', tid=tdoc.docId, pid=column.raw) }}" data-tooltip="{{ pdict[column.raw].title }}">{{ column.value }}</a>
|
<a href="{{ url('problem_detail', pid=column.raw, query={tid:tdoc.docId}) }}" data-tooltip="{{ pdict[column.raw].title }}">{{ column.value }}</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ column.value }}
|
{{ column.value }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -18,8 +18,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% if model.contest.isNotStarted(tdoc) %}
|
{% if model.contest.isNotStarted(tdoc) %}
|
||||||
{{ nothing.render('This homework is not open and you cannot view problems.') }}
|
{{ nothing.render('This homework is not open and you cannot view problems.') }}
|
||||||
{% else %}
|
{% elif tsdoc.attend or model.contest.isDone(tdoc) %}
|
||||||
{% if attended or model.contest.isDone(tdoc) %}
|
|
||||||
<div class="section__body no-padding">
|
<div class="section__body no-padding">
|
||||||
<table class="data-table">
|
<table class="data-table">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
@@ -65,8 +64,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ nothing.render('Please claim the assignment to see the problems.') }}
|
{{ nothing.render('Please claim the assignment to see the problems.') }}
|
||||||
{% endif %}{# attended or handler.is_done(tdoc) #}
|
{% endif %}
|
||||||
{% endif %}{# handler.is_not_started(tdoc) #}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="medium-3 columns">
|
<div class="medium-3 columns">
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<div class="section__body">
|
<div class="section__body">
|
||||||
<h1>{{ tdoc.title }}</h1>
|
<h1>{{ tdoc.title }}</h1>
|
||||||
<div class="contest-sidebar__status">
|
<div class="contest-sidebar__status">
|
||||||
{% if attended or tdoc.attend %}
|
{% if tsdoc.attend %}
|
||||||
<span class="icon icon-check"></span> {{ _('Attended') }}
|
<span class="icon icon-check"></span> {{ _('Attended') }}
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="icon icon-schedule"></span> {{ _('Not Attended') }}
|
<span class="icon icon-schedule"></span> {{ _('Not Attended') }}
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
<span class="icon icon-award"></span> {{ _('View Contest') }}
|
<span class="icon icon-award"></span> {{ _('View Contest') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not (attended or tdoc.attended) and not model.contest.isDone(tdoc) %}
|
{% if not (tsdoc.attend) and not model.contest.isDone(tdoc) %}
|
||||||
<li class="menu__item">
|
<li class="menu__item">
|
||||||
{% if handler.user.hasPerm(perm.PERM_ATTEND_CONTEST) and handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
|
{% if handler.user.hasPerm(perm.PERM_ATTEND_CONTEST) and handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
|
||||||
<form action="{{ url('contest_detail', tid=tdoc.docId) }}" method="POST">
|
<form action="{{ url('contest_detail', tid=tdoc.docId) }}" method="POST">
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
<dt>{{ _('Status') }}</dt>
|
<dt>{{ _('Status') }}</dt>
|
||||||
<dd>
|
<dd>
|
||||||
{{ _(model.contest.statusText(tdoc)) }}
|
{{ _(model.contest.statusText(tdoc)) }}
|
||||||
{% if attended %}
|
{% if tsdoc.attend %}
|
||||||
({{ _('Attended') }})
|
({{ _('Attended') }})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</dd>
|
</dd>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<div class="section__body">
|
<div class="section__body">
|
||||||
<h1>{{ tdoc['title'] }}</h1>
|
<h1>{{ tdoc['title'] }}</h1>
|
||||||
<div class="contest-sidebar__status">
|
<div class="contest-sidebar__status">
|
||||||
{% if attended %}
|
{% if tsdoc.attend %}
|
||||||
<span class="icon icon-check"></span> {{ _('Claimed') }}
|
<span class="icon icon-check"></span> {{ _('Claimed') }}
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="icon icon-schedule"></span> {{ _('Not Claimed') }}
|
<span class="icon icon-schedule"></span> {{ _('Not Claimed') }}
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
<span class="icon icon-homework"></span> {{ _('View Homework') }}
|
<span class="icon icon-homework"></span> {{ _('View Homework') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not attended and not model.contest.isDone(tdoc) %}
|
{% if not tsdoc.attend and not model.contest.isDone(tdoc) %}
|
||||||
<li class="menu__item">
|
<li class="menu__item">
|
||||||
{% if handler.user.hasPerm(perm.PERM_ATTEND_HOMEWORK) and handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
|
{% if handler.user.hasPerm(perm.PERM_ATTEND_HOMEWORK) and handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
|
||||||
<form action="{{ url('homework_detail', tid=tdoc.docId) }}" method="POST">
|
<form action="{{ url('homework_detail', tid=tdoc.docId) }}" method="POST">
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
<span class="icon icon-download"></span> {{ _('Export All Code') }}
|
<span class="icon icon-download"></span> {{ _('Export All Code') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if attended %}
|
{% if tsdoc.attend %}
|
||||||
<li class="menu__item"><a class="menu__link" href="{{ url('record_main', query={uidOrName:handler.user._id, tid:tdoc.docId}) }}">
|
<li class="menu__item"><a class="menu__link" href="{{ url('record_main', query={uidOrName:handler.user._id, tid:tdoc.docId}) }}">
|
||||||
<span class="icon icon-flag"></span> {{ _('My Recent Submissions') }}
|
<span class="icon icon-flag"></span> {{ _('My Recent Submissions') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
{% if tdoc %}
|
{% if tdoc %}
|
||||||
{% if tdoc.docType == 60 %}
|
{% if not owner_udoc %}
|
||||||
{% include "partials/problem_sidebar_homework.html" %}
|
|
||||||
{% if not owner_udoc %}
|
|
||||||
{% set owner_udoc = udoc %}
|
{% set owner_udoc = udoc %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if tdoc.rule == 'homework' %}
|
||||||
|
{% include "partials/problem_sidebar_homework.html" %}
|
||||||
{% include "partials/homework_sidebar.html" %}
|
{% include "partials/homework_sidebar.html" %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% include "partials/problem_sidebar_contest.html" %}
|
{% include "partials/problem_sidebar_contest.html" %}
|
||||||
{% if not owner_udoc %}
|
|
||||||
{% set owner_udoc = udoc %}
|
|
||||||
{% endif %}
|
|
||||||
{% include "partials/contest_sidebar.html" %}
|
{% include "partials/contest_sidebar.html" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{% import "components/user.html" as user with context %}
|
{% import "components/user.html" as user with context %}
|
||||||
<div class="section side section--problem-sidebar">
|
<div class="section side section--problem-sidebar">
|
||||||
{% if page_name != 'problem_detail' and page_name != 'contest_detail_problem' %}
|
{% if page_name != 'contest_detail_problem' %}
|
||||||
<div class="section__header">
|
<div class="section__header">
|
||||||
<h1 class="section__title">{{ pdoc['title'] }}</h1>
|
<h1 class="section__title">{{ pdoc['title'] }}</h1>
|
||||||
</div>
|
</div>
|
||||||
@@ -16,24 +16,24 @@
|
|||||||
<span class="icon icon-enlarge"></span> {{ _('Quit Scratchpad') }} (Alt+Q)
|
<span class="icon icon-enlarge"></span> {{ _('Quit Scratchpad') }} (Alt+Q)
|
||||||
</a></li>
|
</a></li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="menu__item"><a class="menu__link" href="{{ url('contest_detail_problem', tid=tdoc.docId, pid=pdoc.pid) }}">
|
<li class="menu__item"><a class="menu__link" href="{{ url('problem_detail', pid=pdoc.pid|default(pdoc.docId), query={tid:tdoc.docId}) }}">
|
||||||
<span class="icon icon-flag"></span> {{ _('View Problem') }}
|
<span class="icon icon-flag"></span> {{ _('View Problem') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li class="menu__item scratchpad--hide"><a class="menu__link{% if page_name == 'contest_detail_problem_submit' %} active{% endif %}" href="{{ url('contest_detail_problem_submit', tid=tdoc.docId, pid=pdoc.pid) }}">
|
<li class="menu__item scratchpad--hide"><a class="menu__link{% if page_name == 'contest_detail_problem_submit' %} active{% endif %}" href="{{ url('problem_submit', pid=pdoc.pid|default(pdoc.docId), query={tid:tdoc.docId}) }}">
|
||||||
<span class="icon icon-send"></span> {{ _('Submit') }}
|
<span class="icon icon-send"></span> {{ _('Submit') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% elif model.contest.isDone(tdoc) %}
|
{% elif model.contest.isDone(tdoc) %}
|
||||||
<li class="menu__item scratchpad--hide"><a class="menu__link" href="{{ url('problem_detail', pid=pdoc.docId) }}">
|
<li class="menu__item scratchpad--hide"><a class="menu__link" href="{{ url('problem_detail', pid=pdoc.pid|default(pdoc.docId)) }}">
|
||||||
<span class="icon icon-send"></span> {{ _('Open in Problem Set') }}
|
<span class="icon icon-send"></span> {{ _('Open in Problem Set') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if handler.user.own(pdoc, perm.PERM_EDIT_PROBLEM_SELF) or handler.user.hasPerm(perm.PERM_EDIT_PROBLEM) %}
|
{% if handler.user.own(pdoc, perm.PERM_EDIT_PROBLEM_SELF) or handler.user.hasPerm(perm.PERM_EDIT_PROBLEM) %}
|
||||||
<li class="menu__seperator"></li>
|
<li class="menu__seperator"></li>
|
||||||
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_edit' %} active{% endif %}" href="{{ url('problem_edit', pid=pdoc.docId) }}">
|
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_edit' %} active{% endif %}" href="{{ url('problem_edit', pid=pdoc.pid|default(pdoc.docId)) }}">
|
||||||
<span class="icon icon-edit"></span> {{ _('Edit') }}
|
<span class="icon icon-edit"></span> {{ _('Edit') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_files' %} active{% endif %}" href="{{ url('problem_files', pid=pdoc.docId) }}">
|
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_files' %} active{% endif %}" href="{{ url('problem_files', pid=pdoc.pid|default(pdoc.docId)) }}">
|
||||||
<span class="icon icon-file"></span> {{ _('Files') }}
|
<span class="icon icon-file"></span> {{ _('Files') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{% import "components/user.html" as user with context %}
|
{% import "components/user.html" as user with context %}
|
||||||
<div class="section side section--problem-sidebar">
|
<div class="section side section--problem-sidebar">
|
||||||
{% if page_name != 'problem_detail' and page_name != 'homework_detail_problem' %}
|
{% if page_name != 'homework_detail_problem' %}
|
||||||
<div class="section__header">
|
<div class="section__header">
|
||||||
<h1 class="section__title">{{ pdoc['title'] }}</h1>
|
<h1 class="section__title">{{ pdoc['title'] }}</h1>
|
||||||
</div>
|
</div>
|
||||||
@@ -16,25 +16,25 @@
|
|||||||
<span class="icon icon-enlarge"></span> {{ _('Quit Scratchpad') }} (Alt+Q)
|
<span class="icon icon-enlarge"></span> {{ _('Quit Scratchpad') }} (Alt+Q)
|
||||||
</a></li>
|
</a></li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="menu__item"><a class="menu__link" href="{{ url('homework_detail_problem', tid=tdoc.docId, pid=pdoc.pid) }}">
|
<li class="menu__item"><a class="menu__link" href="{{ url('problem_detail', pid=pdoc.pid|default(pdoc.docId), query={tid:tdoc.docId}) }}">
|
||||||
<span class="icon icon-flag"></span> {{ _('View Problem') }}
|
<span class="icon icon-flag"></span> {{ _('View Problem') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li class="menu__item scratchpad--hide"><a class="menu__link{% if page_name == 'homework_detail_problem_submit' %} active{% endif %}" href="{{ url('homework_detail_problem_submit', tid=tdoc.docId, pid=pdoc.pid) }}">
|
<li class="menu__item scratchpad--hide"><a class="menu__link{% if page_name == 'homework_detail_problem_submit' %} active{% endif %}" href="{{ url('problem_submit', pid=pdoc.pid|default(pdoc.docId), query={tid:tdoc.docId}) }}">
|
||||||
<span class="icon icon-send"></span> {{ _('Submit') }}
|
<span class="icon icon-send"></span> {{ _('Submit') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% elif model.contest.isDone(tdoc) %}
|
{% elif model.contest.isDone(tdoc) %}
|
||||||
<li class="menu__item scratchpad--hide"><a class="menu__link" href="{{ url('problem_detail', pid=pdoc.docId) }}">
|
<li class="menu__item scratchpad--hide"><a class="menu__link" href="{{ url('problem_detail', pid=pdoc.pid|default(pdoc.docId)) }}">
|
||||||
<span class="icon icon-send"></span> {{ _('Open in Problem Set') }}
|
<span class="icon icon-send"></span> {{ _('Open in Problem Set') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if handler.user.own(pdoc, perm.PERM_EDIT_PROBLEM_SELF) or handler.user.hasPerm(perm.PERM_EDIT_PROBLEM) %}
|
{% if handler.user.own(pdoc, perm.PERM_EDIT_PROBLEM_SELF) or handler.user.hasPerm(perm.PERM_EDIT_PROBLEM) %}
|
||||||
<li class="menu__seperator"></li>
|
<li class="menu__seperator"></li>
|
||||||
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_edit' %} active{% endif %}" href="{{ url('problem_edit', pid=pdoc.docId) }}">
|
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_edit' %} active{% endif %}" href="{{ url('problem_edit', pid=pdoc.pid|default(pdoc.docId)) }}">
|
||||||
<span class="icon icon-edit"></span> {{ _('Edit') }}
|
<span class="icon icon-edit"></span> {{ _('Edit') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_files' %} active{% endif %}" href="{{ url('problem_files', pid=pdoc.docId) }}">
|
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_files' %} active{% endif %}" href="{{ url('problem_files', pid=pdoc.pid|default(pdoc.docId)) }}">
|
||||||
<span class="icon icon-wrench"></span> {{ _('Settings') }}
|
<span class="icon icon-file"></span> {{ _('Files') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ol>
|
</ol>
|
||||||
|
|||||||
@@ -84,11 +84,18 @@
|
|||||||
<span class="icon icon-edit"></span> {{ _('Edit') }}
|
<span class="icon icon-edit"></span> {{ _('Edit') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if page_name == 'problem_detail' and (handler.user.own(pdoc) or handler.user.hasPriv(PRIV.PRIV_READ_PROBLEM_DATA) or handler.user.hasPerm(perm.PERM_READ_PROBLEM_DATA)) %}
|
{% if page_name == 'problem_detail' %}
|
||||||
<li class="menu__seperator nojs--hide"></li>
|
<li class="menu__seperator nojs--hide"></li>
|
||||||
<li class="menu__item nojs--hide"><a class="menu__link" href="javascript:;" name="problem-sidebar__download">
|
{% if handler.user.own(pdoc) or handler.user.hasPriv(PRIV.PRIV_READ_PROBLEM_DATA) or handler.user.hasPerm(perm.PERM_READ_PROBLEM_DATA) %}
|
||||||
<span class="icon icon-download"></span> {{ _('Download') }}
|
<li class="menu__item nojs--hide"><a class="menu__link" href="javascript:;" name="problem-sidebar__download">
|
||||||
</a></li>
|
<span class="icon icon-download"></span> {{ _('Download') }}
|
||||||
|
</a></li>
|
||||||
|
{% endif %}
|
||||||
|
{% if handler.user.user.hasPriv(PRIV.PRIV_CREATE_DOMAIN) %}
|
||||||
|
<li class="menu__item nojs--hide"><a class="menu__link" href="javascript:;" name="problem-sidebar__copy">
|
||||||
|
<span class="icon icon-copy"></span> {{ _('Copy') }}
|
||||||
|
</a></li>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
}) }}
|
}) }}
|
||||||
{% if tdoc %}
|
{% if tdoc %}
|
||||||
{{ set(UiContext, 'canViewRecord', model.contest.canShowSelfRecord.call(handler, tdoc)) }}
|
{{ set(UiContext, 'canViewRecord', model.contest.canShowSelfRecord.call(handler, tdoc)) }}
|
||||||
{{ set(UiContext, 'postSubmitUrl', url('contest_detail_problem_submit' if tdoc.docType == model.document.TYPE_CONTEST else 'homework_detail_problem_submit', pid=pdoc.pid, tid=tdoc.docId)) }}
|
{{ set(UiContext, 'postSubmitUrl', url('problem_submit', pid=pdoc.docId, query={tid:tdoc.docId})) }}
|
||||||
{{ set(UiContext, 'getSubmissionsUrl', url('record_main', query={fullStatus:'true', pid:pdoc.pid, tid:tdoc.docId})) }}
|
{{ set(UiContext, 'getSubmissionsUrl', url('record_main', query={fullStatus:'true', pid:pdoc.docId, tid:tdoc.docId})) }}
|
||||||
{{ set(UiContext, 'getRecordDetailUrl', url('record_detail', rid='{rid}', query={tid:tdoc.docId})) }}
|
{{ set(UiContext, 'getRecordDetailUrl', url('record_detail', rid='{rid}', query={tid:tdoc.docId})) }}
|
||||||
{{ set(UiContext, 'pretestConnUrl', "/record-conn?pretest=1&uidOrName=" + handler.user._id + "&pid=" + pdoc.docId + "&domainId=" + handler.domainId + "&tid=" + tdoc.docId) }}
|
{{ set(UiContext, 'pretestConnUrl', "/record-conn?pretest=1&uidOrName=" + handler.user._id + "&pid=" + pdoc.docId + "&domainId=" + handler.domainId + "&tid=" + tdoc.docId) }}
|
||||||
{{ set(UiContext, 'tdoc', tdoc) }}
|
{{ set(UiContext, 'tdoc', tdoc) }}
|
||||||
|
|||||||
@@ -45,32 +45,26 @@
|
|||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="section__body typo">
|
<div class="section__body typo no-media">
|
||||||
<dl class="large horizontal">
|
<dl class="large horizontal">
|
||||||
<dt>{{ _('Submit By') }}</dt>
|
<dt>{{ _('Submit By') }}</dt>
|
||||||
<dd>{{ user.render_inline(udoc, modbadge=false) }}</dd>
|
<dd>{{ user.render_inline(udoc, modbadge=false) }}</dd>
|
||||||
{% if pdoc %}
|
{% if pdoc %}
|
||||||
<dt>{{ _('Problem') }}</dt>
|
<dt>{{ _('Problem') }}</dt>
|
||||||
<dd>
|
<dd>
|
||||||
{{ problem.render_problem_title(pdoc, tdoc, show_tags=false, show_invisible_flag=false, rp=none) }}
|
{{ problem.render_problem_title(pdoc, tdoc, show_tags=false, show_invisible_flag=false) }}
|
||||||
</dd>
|
</dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if tdoc %}
|
{% if tdoc %}
|
||||||
<dt>{{ _('Contest') if tdoc.docType == model.document.TYPE_CONTEST else _('Homework') }}</dt>
|
<dt>{{ _('Homework') if tdoc.rule == 'homework' else _('Contest') }}</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<a href="{{ url('contest_detail' if tdoc.docType == model.document.TYPE_CONTEST else 'homework_detail', tid=tdoc.docId) }}">{{ tdoc.title }}</a>
|
<a href="{{ url('homework_detail' if tdoc.rule == 'homework' else 'contest_detail', tid=tdoc.docId) }}">{{ tdoc.title }}</a>
|
||||||
</dd>
|
</dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<dt>{{ _('Language') }}</dt>
|
<dt>{{ _('Language') }}</dt>
|
||||||
<dd>
|
<dd>{{ model.setting.langs[rdoc.lang].display }}</dd>
|
||||||
{{ model.setting.langs[rdoc.lang].display }}
|
<dt>{{ _('Submit At') }}</dt>
|
||||||
</dd>
|
<dd>{{ datetimeSpan(rdoc._id)|safe }}</dd>
|
||||||
<dt>
|
|
||||||
{{ _('Submit At') }}
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
{{ datetimeSpan(rdoc._id)|safe }}
|
|
||||||
</dd>
|
|
||||||
{% if rdoc.judgeAt %}
|
{% if rdoc.judgeAt %}
|
||||||
<dt>{{ _('Judged At') }}</dt>
|
<dt>{{ _('Judged At') }}</dt>
|
||||||
<dd>{{ datetimeSpan(rdoc.judgeAt)|safe }}</dd>
|
<dd>{{ datetimeSpan(rdoc.judgeAt)|safe }}</dd>
|
||||||
|
|||||||
Reference in new issue
Block a user