mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
修复一些错误
This commit is contained in:
1 parent
bc50913e6e
commit
2b6a510c1e
23 files changed
+321
-191
No files matched your search
@@ -5,6 +5,7 @@ const {
|
|||||||
const { PERM_CREATE_CONTEST, PERM_EDIT_CONTEST } = require('../permission');
|
const { PERM_CREATE_CONTEST, PERM_EDIT_CONTEST } = require('../permission');
|
||||||
const paginate = require('../lib/paginate');
|
const paginate = require('../lib/paginate');
|
||||||
const contest = require('../model/contest');
|
const contest = require('../model/contest');
|
||||||
|
const document = require('../model/document');
|
||||||
const problem = require('../model/problem');
|
const problem = require('../model/problem');
|
||||||
const record = require('../model/record');
|
const record = require('../model/record');
|
||||||
const user = require('../model/user');
|
const user = require('../model/user');
|
||||||
@@ -241,14 +242,11 @@ class ContestProblemSubmitHandler extends ContestProblemHandler {
|
|||||||
pid: this.pdoc.docId,
|
pid: this.pdoc.docId,
|
||||||
uid: this.user._id,
|
uid: this.user._id,
|
||||||
tid: this.tdoc.docId,
|
tid: this.tdoc.docId,
|
||||||
|
ttype: document.TYPE_CONTEST,
|
||||||
lang,
|
lang,
|
||||||
code,
|
code,
|
||||||
hidden: true,
|
|
||||||
});
|
});
|
||||||
await Promise.all([
|
await contest.updateStatus(domainId, this.tdoc.docId, this.user._id, rid, this.pdoc.docId);
|
||||||
record.judge(domainId, rid),
|
|
||||||
contest.updateStatus(domainId, this.tdoc.docId, this.user._id, rid, this.pdoc.docId),
|
|
||||||
]);
|
|
||||||
if (!this.canShowRecord(this.tdoc)) {
|
if (!this.canShowRecord(this.tdoc)) {
|
||||||
this.response.body = { tid };
|
this.response.body = { tid };
|
||||||
this.response.redirect = `/c/${tid}`;
|
this.response.redirect = `/c/${tid}`;
|
||||||
|
|||||||
+121
-94
@@ -1,3 +1,4 @@
|
|||||||
|
const yaml = require('js-yaml');
|
||||||
const {
|
const {
|
||||||
ValidationError, HomeworkNotLiveError, ProblemNotFoundError,
|
ValidationError, HomeworkNotLiveError, ProblemNotFoundError,
|
||||||
HomeworkNotAttendedError,
|
HomeworkNotAttendedError,
|
||||||
@@ -5,6 +6,7 @@ const {
|
|||||||
const {
|
const {
|
||||||
PERM_VIEW_HOMEWORK, PERM_ATTEND_HOMEWORK, PERM_VIEW_PROBLEM,
|
PERM_VIEW_HOMEWORK, PERM_ATTEND_HOMEWORK, PERM_VIEW_PROBLEM,
|
||||||
PERM_SUBMIT_PROBLEM, PERM_CREATE_HOMEWORK, PERM_EDIT_HOMEWORK,
|
PERM_SUBMIT_PROBLEM, PERM_CREATE_HOMEWORK, PERM_EDIT_HOMEWORK,
|
||||||
|
PERM_VIEW_HOMEWORK_SCOREBOARD,
|
||||||
} = require('../permission');
|
} = require('../permission');
|
||||||
const { Route, Handler } = require('../service/server');
|
const { Route, Handler } = require('../service/server');
|
||||||
const system = require('../model/system');
|
const system = require('../model/system');
|
||||||
@@ -15,16 +17,8 @@ const problem = require('../model/problem');
|
|||||||
const record = require('../model/record');
|
const record = require('../model/record');
|
||||||
const document = require('../model/document');
|
const document = require('../model/document');
|
||||||
const paginate = require('../lib/paginate');
|
const paginate = require('../lib/paginate');
|
||||||
|
const misc = require('../lib/misc');
|
||||||
function _formatPenaltyRules(penaltyRules) {
|
const ranked = require('../lib/rank');
|
||||||
let doc = '';
|
|
||||||
for (const time in penaltyRules) {
|
|
||||||
const coefficient = penaltyRules[time];
|
|
||||||
const parsedTime = Math.round(parseFloat(time) / 36) / 100;
|
|
||||||
doc += '{0}: {1}\n'.format(parsedTime, coefficient);
|
|
||||||
}
|
|
||||||
return doc;
|
|
||||||
}
|
|
||||||
|
|
||||||
const HomeworkHandler = contest.ContestHandlerMixin(Handler);
|
const HomeworkHandler = contest.ContestHandlerMixin(Handler);
|
||||||
|
|
||||||
@@ -35,7 +29,7 @@ class HomeworkMainHandler extends HomeworkHandler {
|
|||||||
for (const tdoc of tdocs) {
|
for (const tdoc of tdocs) {
|
||||||
console.log(tdoc);
|
console.log(tdoc);
|
||||||
const cal = { ...tdoc };
|
const cal = { ...tdoc };
|
||||||
if (contest.isHomeWorkExtended(tdoc) || contest.isDone(tdoc)) {
|
if (contest.isHomeworkExtended(tdoc) || contest.isDone(tdoc)) {
|
||||||
cal.endAt = tdoc.endAt;
|
cal.endAt = tdoc.endAt;
|
||||||
cal.penaltySince = tdoc.penaltySince;
|
cal.penaltySince = tdoc.penaltySince;
|
||||||
} else {
|
} else {
|
||||||
@@ -60,14 +54,14 @@ class HomeworkDetailHandler extends HomeworkHandler {
|
|||||||
let attended = false;
|
let attended = false;
|
||||||
if (tsdoc) {
|
if (tsdoc) {
|
||||||
attended = tsdoc.attend === 1;
|
attended = tsdoc.attend === 1;
|
||||||
for (const pdetail of tsdoc.detail || []) {
|
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 };
|
||||||
}
|
}
|
||||||
if (this.canShowRecord(tdoc) && tsdoc.detail) {
|
if (this.canShowRecord(tdoc) && tsdoc.journal) {
|
||||||
rdict = await record.getList(
|
rdict = await record.getList(
|
||||||
domainId,
|
domainId,
|
||||||
tsdoc.detail.map((pdetail) => pdetail.rid),
|
tsdoc.journal.map((pdetail) => pdetail.rid),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -94,9 +88,7 @@ class HomeworkDetailHandler extends HomeworkHandler {
|
|||||||
async postAttend({ domainId, tid }) {
|
async postAttend({ domainId, tid }) {
|
||||||
this.checkPerm(PERM_ATTEND_HOMEWORK);
|
this.checkPerm(PERM_ATTEND_HOMEWORK);
|
||||||
const tdoc = await contest.get(domainId, tid, document.TYPE_HOMEWORK);
|
const tdoc = await contest.get(domainId, tid, document.TYPE_HOMEWORK);
|
||||||
if (contest.isDone(tdoc)) {
|
if (contest.isDone(tdoc)) throw new HomeworkNotLiveError(tdoc.docId);
|
||||||
throw new HomeworkNotLiveError(tdoc.docId);
|
|
||||||
}
|
|
||||||
await contest.attend(domainId, tdoc.docId, this.user._id, document.TYPE_HOMEWORK);
|
await contest.attend(domainId, tdoc.docId, this.user._id, document.TYPE_HOMEWORK);
|
||||||
this.back();
|
this.back();
|
||||||
}
|
}
|
||||||
@@ -105,18 +97,16 @@ class HomeworkDetailHandler extends HomeworkHandler {
|
|||||||
class HomeworkDetailProblemHandler extends HomeworkHandler {
|
class HomeworkDetailProblemHandler extends HomeworkHandler {
|
||||||
async prepare({ domainId, tid, pid }) {
|
async prepare({ domainId, tid, pid }) {
|
||||||
this.checkPerm(PERM_VIEW_PROBLEM);
|
this.checkPerm(PERM_VIEW_PROBLEM);
|
||||||
[this.tdoc, this.pdoc] = await Promise.all([
|
[this.tdoc, this.pdoc, this.tsdoc] = await Promise.all([
|
||||||
contest.get(domainId, tid, document.TYPE_HOMEWORK),
|
contest.get(domainId, tid, document.TYPE_HOMEWORK),
|
||||||
problem.get(domainId, pid, this.user._id),
|
problem.get(domainId, pid, this.user._id),
|
||||||
|
contest.getStatus(domainId, tid, this.user._id, document.TYPE_HOMEWORK),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async get({ domainId, tid, pid }) {
|
async get({ domainId, tid, pid }) {
|
||||||
const [tsdoc, udoc] = await Promise.all(
|
const udoc = await user.getById(domainId, this.tdoc.owner);
|
||||||
contest.getStatus(domainId, tid, this.user._id, document.TYPE_HOMEWORK),
|
const attended = this.tsdoc && this.tsdoc.attend === 1;
|
||||||
user.getById(domainId, this.tdoc.owner),
|
|
||||||
);
|
|
||||||
const attended = tsdoc && tsdoc.attend === 1;
|
|
||||||
if (!contest.isDone(this.tdoc)) {
|
if (!contest.isDone(this.tdoc)) {
|
||||||
if (!attended) throw new HomeworkNotAttendedError(tid);
|
if (!attended) throw new HomeworkNotAttendedError(tid);
|
||||||
if (!contest.isOngoing(this.tdoc)) throw new HomeworkNotLiveError(tid);
|
if (!contest.isOngoing(this.tdoc)) throw new HomeworkNotLiveError(tid);
|
||||||
@@ -129,41 +119,31 @@ class HomeworkDetailProblemHandler extends HomeworkHandler {
|
|||||||
];
|
];
|
||||||
this.response.template = 'problem_detail.html';
|
this.response.template = 'problem_detail.html';
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
tdoc: this.tdoc, pdoc: this.pdoc, tsdoc, udoc, attended, path,
|
tdoc: this.tdoc, pdoc: this.pdoc, tsdoc: this.tsdoc, udoc, attended, path,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class HomeworkDetailProblemSubmitHandler extends HomeworkHandler {
|
class HomeworkDetailProblemSubmitHandler extends HomeworkDetailProblemHandler {
|
||||||
async get({ domainId, tid, pid }) {
|
async get({ domainId, tid, pid }) {
|
||||||
const uid = this.user._id;
|
const udoc = await user.getById(domainId, this.tdoc.owner);
|
||||||
const [tdoc, pdoc] = await Promise.all([
|
const attended = this.tsdoc && this.tsdoc.attend === 1;
|
||||||
contest.get(domainId, tid, document.TYPE_HOMEWORK),
|
if (!attended) throw new HomeworkNotAttendedError(tid);
|
||||||
problem.get(domainId, pid, uid),
|
if (!contest.isOngoing(this.tdoc)) throw new HomeworkNotLiveError(tid);
|
||||||
]);
|
if (!this.tdoc.pids.includes(pid)) throw new ProblemNotFoundError(domainId, pid, tid);
|
||||||
const [tsdoc, udoc] = await Promise.all([
|
const rdocs = this.canShowRecord(this.tdoc)
|
||||||
contest.getStatus(domainId, tdoc.docId, this.user._id, document.TYPE_HOMEWORK),
|
? await record.getUserInProblemMulti(domainId, this.user._id, pid, true)
|
||||||
user.get_by_uid(tdoc.owner),
|
.sort('_id', -1).limit(10).toArray()
|
||||||
]);
|
|
||||||
const attended = tsdoc && tsdoc.attend === 1;
|
|
||||||
if (!attended) { throw new HomeworkNotAttendedError(tdoc.docId); }
|
|
||||||
if (!contest.isOngoing(tdoc)) { throw new HomeworkNotLiveError(tdoc.docId); }
|
|
||||||
if (!tdoc.pids.includes(pid)) { throw new ProblemNotFoundError(domainId, pid, tdoc.docId); }
|
|
||||||
const rdocs = this.canShowRecord(tdoc)
|
|
||||||
? await record.getUserInProblemMulti(domainId, uid, pdoc.docId, true)
|
|
||||||
.sort('_id', -1)
|
|
||||||
.limit(10)
|
|
||||||
.toArray()
|
|
||||||
: [];
|
: [];
|
||||||
const path = [
|
const path = [
|
||||||
['homework_main', '/homework'],
|
['homework_main', '/homework'],
|
||||||
[tdoc.title, `/homework/${tid}`, true],
|
[this.tdoc.title, `/homework/${tid}`, true],
|
||||||
[pdoc.title, `/homework/${tid}/p/${pid}`, true],
|
[this.pdoc.title, `/homework/${tid}/p/${pid}`, true],
|
||||||
['homework_detail_problem_submit', null],
|
['homework_detail_problem_submit', null],
|
||||||
];
|
];
|
||||||
this.response.template = 'problem_submit.html';
|
this.response.template = 'problem_submit.html';
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
tdoc, pdoc, rdocs, tsdoc, udoc, attended, path,
|
tdoc: this.tdoc, pdoc: this.pdoc, tsdoc: this.tsdoc, udoc, attended, path, rdocs,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,11 +200,11 @@ class HomeworkCreateHandler extends HomeworkHandler {
|
|||||||
try {
|
try {
|
||||||
penaltySince = new Date(Date.parse(`${penaltySinceDate} ${penaltySinceTime.replace('-', ':')}`));
|
penaltySince = new Date(Date.parse(`${penaltySinceDate} ${penaltySinceTime.replace('-', ':')}`));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new ValidationError('end_at_date', 'end_at_time');
|
throw new ValidationError('endAtDate', 'endAtTime');
|
||||||
}
|
}
|
||||||
const endAt = penaltySince.delta({ days: extensionDays });
|
const endAt = penaltySince.delta({ days: extensionDays });
|
||||||
if (beginAt >= penaltySince) { throw new ValidationError('end_at_date', 'end_at_time'); }
|
if (beginAt >= penaltySince) { throw new ValidationError('endAtDate', 'endAtTime'); }
|
||||||
if (penaltySince > endAt) throw new ValidationError('extension_days');
|
if (penaltySince > endAt) throw new ValidationError('extensionDays');
|
||||||
await this.verifyProblems(domainId, pids);
|
await this.verifyProblems(domainId, pids);
|
||||||
const tid = await contest.add(domainId, title, content, this.user._id,
|
const tid = await contest.add(domainId, title, content, this.user._id,
|
||||||
'homework', beginAt, endAt, pids, { penaltySince, penaltyRules }, document.TYPE_HOMEWORK);
|
'homework', beginAt, endAt, pids, { penaltySince, penaltyRules }, document.TYPE_HOMEWORK);
|
||||||
@@ -253,7 +233,7 @@ class HomeworkEditHandler extends HomeworkHandler {
|
|||||||
datePenaltyText: tdoc.penaltySince.format('%Y-%m-%d'),
|
datePenaltyText: tdoc.penaltySince.format('%Y-%m-%d'),
|
||||||
timePenaltyText: tdoc.penaltySince.format('%H:%M'),
|
timePenaltyText: tdoc.penaltySince.format('%H:%M'),
|
||||||
extensionDays,
|
extensionDays,
|
||||||
penaltyRules: _formatPenaltyRules(tdoc.penaltyRules),
|
penaltyRules: yaml.safeDump(tdoc.penaltyRules),
|
||||||
pids: tdoc.pids.join(','),
|
pids: tdoc.pids.join(','),
|
||||||
path,
|
path,
|
||||||
};
|
};
|
||||||
@@ -295,8 +275,25 @@ class HomeworkEditHandler extends HomeworkHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class HomeworkScoreboardHandler extends HomeworkHandler {
|
||||||
|
async get({ domainId, tid }) {
|
||||||
|
const [tdoc, rows, udict] = await this.getScoreboard(
|
||||||
|
domainId, tid, false, document.TYPE_HOMEWORK,
|
||||||
|
);
|
||||||
|
const path = [
|
||||||
|
['homework_main', '/homework'],
|
||||||
|
[tdoc.title, `/homework/${tid}`, true],
|
||||||
|
['homework_scoreboard', null],
|
||||||
|
];
|
||||||
|
this.response.template = 'contest_scoreboard.html';
|
||||||
|
this.response.body = {
|
||||||
|
tdoc, rows, path, udict,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function apply() {
|
async function apply() {
|
||||||
contest.isHomeWorkExtended = (tdoc) => {
|
contest.isHomeworkExtended = (tdoc) => {
|
||||||
const now = new Date().getTime();
|
const now = new Date().getTime();
|
||||||
return tdoc.penaltySince.getTime() <= now && now < tdoc.endAt.getTime();
|
return tdoc.penaltySince.getTime() <= now && now < tdoc.endAt.getTime();
|
||||||
};
|
};
|
||||||
@@ -342,46 +339,93 @@ async function apply() {
|
|||||||
detail,
|
detail,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
showScoreboard(tdoc, now) {
|
showScoreboard: () => true,
|
||||||
return now > tdoc.endAt;
|
showRecord: () => true,
|
||||||
},
|
|
||||||
showRecord(tdoc, now) {
|
|
||||||
return now > tdoc.endAt;
|
|
||||||
},
|
|
||||||
scoreboard(isExport, _, tdoc, rankedTsdocs, udict, pdict) {
|
scoreboard(isExport, _, tdoc, rankedTsdocs, udict, pdict) {
|
||||||
const columns = [
|
const columns = [
|
||||||
{ type: 'rank', value: _('Rank') },
|
{ type: 'rank', value: _('Rank') },
|
||||||
{ type: 'user', value: _('User') },
|
{ type: 'user', value: _('User') },
|
||||||
{ type: 'total_score', value: _('Total Score') },
|
{ type: 'total_score', value: _('Score') },
|
||||||
];
|
];
|
||||||
for (const i in tdoc.pids) {
|
if (isExport) {
|
||||||
|
columns.push(
|
||||||
|
{ type: 'total_original_score', value: _('Original Score') },
|
||||||
|
{ type: 'total_time', value: _('Total Time (Seconds)') },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
for (const index in tdoc.pids) {
|
||||||
|
const pid = tdoc.pids[index];
|
||||||
if (isExport) {
|
if (isExport) {
|
||||||
columns.push({
|
columns.push(
|
||||||
type: 'problem_score',
|
{
|
||||||
value: '#{0} {1}'.format(i + 1, pdict[tdoc.pids[i]].title),
|
type: 'problem_score',
|
||||||
});
|
value: '#{0} {1}'.format(index + 1, pdict[pid].title),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'problem_original_score',
|
||||||
|
value: '#{0} {1}'.format(index + 1, _('Original Score')),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'problem_time',
|
||||||
|
value: '#{0} {1}'.format(index + 1, _('Time (Seconds)')),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'problem_time_str',
|
||||||
|
value: '#{0} {1}'.format(index + 1, _('Time')),
|
||||||
|
},
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
columns.push({
|
columns.push({
|
||||||
type: 'problem_detail',
|
type: 'problem_detail',
|
||||||
value: '#{0}'.format(i + 1),
|
value: '#{0}'.format(index + 1),
|
||||||
raw: pdict[tdoc.pids[i]],
|
raw: pdict[pid],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const rows = [columns];
|
const rows = [columns];
|
||||||
for (const [rank, tsdoc] of rankedTsdocs) {
|
for (const rank in rankedTsdocs) {
|
||||||
|
const tsdoc = rankedTsdocs[rank];
|
||||||
const tsddict = {};
|
const tsddict = {};
|
||||||
if (tsdoc.journal) { for (const item of tsdoc.journal) tsddict[item.pid] = item; }
|
for (const item of tsdoc.journal || []) {
|
||||||
const row = [];
|
tsddict[item.pid] = item;
|
||||||
row.push({ type: 'string', value: rank });
|
}
|
||||||
row.push({ type: 'user', value: udict[tsdoc.uid].uname, raw: udict[tsdoc.uid] });
|
const row = [
|
||||||
row.push({ type: 'string', value: tsdoc.score || 0 });
|
{ type: 'string', value: rank + 1 },
|
||||||
|
{
|
||||||
|
type: 'user',
|
||||||
|
value: udict[tsdoc.uid].uname,
|
||||||
|
raw: udict[tsdoc.uid],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'string',
|
||||||
|
value: tsdoc.penaltyScore || 0,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
if (isExport) {
|
||||||
|
row.push({ type: 'string', value: tsdoc.score || 0 });
|
||||||
|
row.push({ type: 'string', value: tsdoc.time || 0.0 });
|
||||||
|
}
|
||||||
|
row.push({ type: 'string', value: misc.formatSeconds(tsdoc.time || 0) });
|
||||||
for (const pid of tdoc.pids) {
|
for (const pid of tdoc.pids) {
|
||||||
row.push({
|
const rdoc = (tsddict[pid] || {}).rid;
|
||||||
type: 'record',
|
const colScore = (tsddict[pid] || {}).penaltyScore || '-';
|
||||||
value: (tsddict[pid] || {}).score || '-',
|
const colOriginalScore = (tsddict[pid] || {}).score || '-';
|
||||||
raw: (tsddict[pid] || {}).rid || null,
|
const colTime = (tsddict[pid] || {}).time || '-';
|
||||||
});
|
const colTimeStr = colTime !== '-' ? misc.formatSeconds(colTime) : '-';
|
||||||
|
if (isExport) {
|
||||||
|
row.push(
|
||||||
|
{ type: 'string', value: colScore },
|
||||||
|
{ type: 'string', value: colOriginalScore },
|
||||||
|
{ type: 'string', value: colTime },
|
||||||
|
{ type: 'string', value: colTimeStr },
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
row.push({
|
||||||
|
type: 'record',
|
||||||
|
value: '{0} / {1}\n{2}'.format(colScore, colOriginalScore, colTimeStr),
|
||||||
|
raw: rdoc,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rows.push(row);
|
rows.push(row);
|
||||||
}
|
}
|
||||||
@@ -392,6 +436,7 @@ async function apply() {
|
|||||||
Route('/homework', HomeworkMainHandler, PERM_VIEW_HOMEWORK);
|
Route('/homework', HomeworkMainHandler, PERM_VIEW_HOMEWORK);
|
||||||
Route('/homework/create', HomeworkCreateHandler, PERM_CREATE_HOMEWORK);
|
Route('/homework/create', HomeworkCreateHandler, PERM_CREATE_HOMEWORK);
|
||||||
Route('/homework/:tid', HomeworkDetailHandler, PERM_VIEW_HOMEWORK);
|
Route('/homework/:tid', HomeworkDetailHandler, PERM_VIEW_HOMEWORK);
|
||||||
|
Route('/homework/:tid/scoreboard', HomeworkScoreboardHandler, PERM_VIEW_HOMEWORK_SCOREBOARD);
|
||||||
Route('/homework/:tid/p/:pid', HomeworkDetailProblemHandler, PERM_VIEW_HOMEWORK);
|
Route('/homework/:tid/p/:pid', HomeworkDetailProblemHandler, PERM_VIEW_HOMEWORK);
|
||||||
Route('/homework/:tid/p/:pid/submit', HomeworkDetailProblemSubmitHandler, PERM_SUBMIT_PROBLEM);
|
Route('/homework/:tid/p/:pid/submit', HomeworkDetailProblemSubmitHandler, PERM_SUBMIT_PROBLEM);
|
||||||
Route('/homework/:tid/edit', HomeworkEditHandler);
|
Route('/homework/:tid/edit', HomeworkEditHandler);
|
||||||
@@ -436,24 +481,6 @@ class HomeworkCodeHandler(base.OperationHandler):
|
|||||||
file_name='{}.zip'.format(tdoc['title']))
|
file_name='{}.zip'.format(tdoc['title']))
|
||||||
|
|
||||||
|
|
||||||
@app.route('/homework/{tid}/scoreboard', 'homework_scoreboard')
|
|
||||||
class HomeworkScoreboardHandler(contest.ContestMixin, base.Handler):
|
|
||||||
@base.route_argument
|
|
||||||
@base.require_perm(builtin.PERM_VIEW_HOMEWORK)
|
|
||||||
@base.require_perm(builtin.PERM_VIEW_HOMEWORK_SCOREBOARD)
|
|
||||||
@base.sanitize
|
|
||||||
async def get(this, *, tid: objectid.ObjectId):
|
|
||||||
tdoc, rows, udict = await this.get_scoreboard(document.TYPE_HOMEWORK, tid)
|
|
||||||
page_title = this.translate('homework_scoreboard')
|
|
||||||
path_components = this.build_path(
|
|
||||||
(this.translate('homework_main'), this.reverse_url('homework_main')),
|
|
||||||
(tdoc['title'], this.reverse_url('homework_detail', tid=tdoc['docId'])),
|
|
||||||
(page_title, None))
|
|
||||||
dudict = await domain.get_dict_user_by_uid(domain_id=domainId, uids=udict.keys())
|
|
||||||
this.render('contest_scoreboard.html', tdoc=tdoc, rows=rows, dudict=dudict,
|
|
||||||
page_title=page_title, path_components=path_components)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/homework/{tid}/scoreboard/download/{ext}', 'homework_scoreboard_download')
|
@app.route('/homework/{tid}/scoreboard/download/{ext}', 'homework_scoreboard_download')
|
||||||
class HomeworkScoreboardDownloadHandler(contest.ContestMixin, base.Handler):
|
class HomeworkScoreboardDownloadHandler(contest.ContestMixin, base.Handler):
|
||||||
def _export_status_as_csv(this, rows):
|
def _export_status_as_csv(this, rows):
|
||||||
|
|||||||
@@ -16,7 +16,10 @@ async function _postJudge(rdoc) {
|
|||||||
const tasks = [];
|
const tasks = [];
|
||||||
if (rdoc.tid) {
|
if (rdoc.tid) {
|
||||||
tasks.push(
|
tasks.push(
|
||||||
contest.updateStatus(rdoc.domainId, rdoc.tid, rdoc.uid, rdoc._id, rdoc.pid, accept, rdoc.score),
|
contest.updateStatus(
|
||||||
|
rdoc.domainId, rdoc.tid, rdoc.uid,
|
||||||
|
rdoc._id, rdoc.pid, accept, rdoc.score, rdoc.ttype,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (await problem.updateStatus(rdoc.pid, rdoc.uid, rdoc._id, rdoc.status)) {
|
if (await problem.updateStatus(rdoc.pid, rdoc.uid, rdoc._id, rdoc.status)) {
|
||||||
|
|||||||
+38
-32
@@ -6,7 +6,7 @@ const { Route, Handler } = require('../service/server');
|
|||||||
const { PERM_MANAGE } = require('../permission');
|
const { PERM_MANAGE } = require('../permission');
|
||||||
const hpm = require('../lib/hpm');
|
const hpm = require('../lib/hpm');
|
||||||
const loader = require('../loader');
|
const loader = require('../loader');
|
||||||
const { RoleAlreadyExistError, ValidationError } = require('../error');
|
const { RoleAlreadyExistError, ValidationError, PermissionError } = require('../error');
|
||||||
|
|
||||||
class ManageHandler extends Handler {
|
class ManageHandler extends Handler {
|
||||||
async prepare({ domainId }) {
|
async prepare({ domainId }) {
|
||||||
@@ -58,13 +58,16 @@ class ManageUserHandler extends ManageHandler {
|
|||||||
const uids = [];
|
const uids = [];
|
||||||
const rudocs = {};
|
const rudocs = {};
|
||||||
const [udocs, roles] = await Promise.all([
|
const [udocs, roles] = await Promise.all([
|
||||||
user.getMulti(domainId, { role: { $nin: ['default', 'guest'] } }).toArray(),
|
user.getInDomain(domainId),
|
||||||
user.getRoles(domainId),
|
user.getRoles(domainId),
|
||||||
]);
|
]);
|
||||||
for (const role of roles) rudocs[role._id] = [];
|
for (const role of roles) rudocs[role._id] = [];
|
||||||
for (const udoc of udocs) {
|
for (const udoc of udocs) {
|
||||||
uids.push(udoc._id);
|
uids.push(udoc.uid);
|
||||||
rudocs[udoc.role].push(udoc);
|
// TODO Improve here
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
const ud = await user.getById(domainId, udoc.uid);
|
||||||
|
rudocs[udoc.role].push({ ...ud, role: udoc.role });
|
||||||
}
|
}
|
||||||
const rolesSelect = roles.map((role) => [role._id, role._id]);
|
const rolesSelect = roles.map((role) => [role._id, role._id]);
|
||||||
const udict = await user.getList(domainId, uids);
|
const udict = await user.getList(domainId, uids);
|
||||||
@@ -79,17 +82,17 @@ class ManageUserHandler extends ManageHandler {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async postSetUser({ uid, role }) {
|
async postSetUser({ domainId, uid, role }) {
|
||||||
await user.setRole(uid, role);
|
await user.setRole(domainId, uid, role);
|
||||||
this.back();
|
this.back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ManagePermissionHandler extends ManageHandler {
|
class ManagePermissionHandler extends ManageHandler {
|
||||||
async get({ domainId }) {
|
async get({ domainId }) {
|
||||||
const [roles, sys] = await Promise.all([
|
const [roles, d] = await Promise.all([
|
||||||
user.getRoles(domainId),
|
user.getRoles(domainId),
|
||||||
user.getById(domainId, 0),
|
domain.get(domainId),
|
||||||
]);
|
]);
|
||||||
const path = [
|
const path = [
|
||||||
['Hydro', '/'],
|
['Hydro', '/'],
|
||||||
@@ -97,27 +100,26 @@ class ManagePermissionHandler extends ManageHandler {
|
|||||||
['manage_permission', null],
|
['manage_permission', null],
|
||||||
];
|
];
|
||||||
this.response.template = 'manage_permission.html';
|
this.response.template = 'manage_permission.html';
|
||||||
this.response.body = { roles, system: sys, path };
|
this.response.body = { roles, domain: d, path };
|
||||||
}
|
}
|
||||||
|
|
||||||
async post({ roles }) {
|
async post({ domainId }) {
|
||||||
for (const role of roles) {
|
const roles = {};
|
||||||
let perms = '';
|
for (const role in this.request.body) {
|
||||||
for (const perm of roles) {
|
if (this.request.body[role] instanceof Array) {
|
||||||
perms += perm;
|
roles[role] = this.request.body[role].join('');
|
||||||
}
|
}
|
||||||
roles[role] = perms;
|
|
||||||
}
|
}
|
||||||
await user.setRoles(roles);
|
await user.setRoles(domainId, roles);
|
||||||
this.back();
|
this.back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ManageRoleHandler extends ManageHandler {
|
class ManageRoleHandler extends ManageHandler {
|
||||||
async get({ domainId }) {
|
async get({ domainId }) {
|
||||||
const [roles, sys] = await Promise.all([
|
const [roles, d] = await Promise.all([
|
||||||
user.getRoles(domainId),
|
user.getRoles(domainId),
|
||||||
user.getById(domainId, 0),
|
domain.get(domainId),
|
||||||
]);
|
]);
|
||||||
const path = [
|
const path = [
|
||||||
['Hydro', '/'],
|
['Hydro', '/'],
|
||||||
@@ -125,16 +127,16 @@ class ManageRoleHandler extends ManageHandler {
|
|||||||
['manage_role', null],
|
['manage_role', null],
|
||||||
];
|
];
|
||||||
this.response.template = 'manage_role.html';
|
this.response.template = 'manage_role.html';
|
||||||
this.response.body = { roles, system: sys, path };
|
this.response.body = { roles, domain: d, path };
|
||||||
}
|
}
|
||||||
|
|
||||||
async postAdd({ role }) {
|
async postAdd({ domainId, role }) {
|
||||||
const [r, u] = await Promise.all([
|
const [r, u] = await Promise.all([
|
||||||
user.getRole(role),
|
user.getRole(domainId, role),
|
||||||
user.getRole('default'),
|
user.getRole(domainId, 'default'),
|
||||||
]);
|
]);
|
||||||
if (r) throw new RoleAlreadyExistError(role);
|
if (r) throw new RoleAlreadyExistError(role);
|
||||||
await user.addRole(role, u.perm);
|
await user.addRole(domainId, role, u.perm);
|
||||||
this.back();
|
this.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +151,13 @@ class ManageRoleHandler extends ManageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ManageModuleHandler extends ManageHandler {
|
class SystemHandler extends Handler {
|
||||||
|
async prepare() {
|
||||||
|
if (!this.user.priv) throw new PermissionError('???');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SystemModuleHandler extends SystemHandler {
|
||||||
async get() {
|
async get() {
|
||||||
const installed = await hpm.getInstalled();
|
const installed = await hpm.getInstalled();
|
||||||
const path = [
|
const path = [
|
||||||
@@ -172,7 +180,7 @@ class ManageModuleHandler extends ManageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ManageSettingHandler extends ManageHandler {
|
class SystemSettingHandler extends SystemHandler {
|
||||||
async get() {
|
async get() {
|
||||||
this.response.template = 'manage_settings.html';
|
this.response.template = 'manage_settings.html';
|
||||||
const current = {};
|
const current = {};
|
||||||
@@ -180,9 +188,7 @@ class ManageSettingHandler extends ManageHandler {
|
|||||||
for (const s of settings) {
|
for (const s of settings) {
|
||||||
current[s.key] = await system.get(s.key);
|
current[s.key] = await system.get(s.key);
|
||||||
}
|
}
|
||||||
this.response.body = {
|
this.response.body = { current, settings };
|
||||||
current, settings,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async post(args) {
|
async post(args) {
|
||||||
@@ -208,8 +214,8 @@ async function apply() {
|
|||||||
Route('/manage/user', module.exports.ManageUserHandler);
|
Route('/manage/user', module.exports.ManageUserHandler);
|
||||||
Route('/manage/permission', module.exports.ManagePermissionHandler);
|
Route('/manage/permission', module.exports.ManagePermissionHandler);
|
||||||
Route('/manage/role', module.exports.ManageRoleHandler);
|
Route('/manage/role', module.exports.ManageRoleHandler);
|
||||||
Route('/manage/module', module.exports.ManageModuleHandler);
|
Route('/manage/module', SystemModuleHandler);
|
||||||
Route('/manage/setting', module.exports.ManageSettingHandler);
|
Route('/manage/setting', SystemSettingHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
global.Hydro.handler.manage = module.exports = {
|
global.Hydro.handler.manage = module.exports = {
|
||||||
@@ -219,7 +225,7 @@ global.Hydro.handler.manage = module.exports = {
|
|||||||
ManageUserHandler,
|
ManageUserHandler,
|
||||||
ManagePermissionHandler,
|
ManagePermissionHandler,
|
||||||
ManageRoleHandler,
|
ManageRoleHandler,
|
||||||
ManageModuleHandler,
|
SystemModuleHandler,
|
||||||
ManageSettingHandler,
|
SystemSettingHandler,
|
||||||
apply,
|
apply,
|
||||||
};
|
};
|
||||||
+16
-5
@@ -12,10 +12,15 @@ const {
|
|||||||
Route, Handler, Connection, ConnectionHandler,
|
Route, Handler, Connection, ConnectionHandler,
|
||||||
} = require('../service/server');
|
} = require('../service/server');
|
||||||
|
|
||||||
class RecordListHandler extends Handler {
|
const RecordHandler = contest.ContestHandlerMixin(Handler);
|
||||||
async get({ domainId, page = 1 }) {
|
|
||||||
|
class RecordListHandler extends RecordHandler {
|
||||||
|
async get({
|
||||||
|
domainId, page = 1, tid, uname_or_uid,
|
||||||
|
}) {
|
||||||
this.response.template = 'record_main.html';
|
this.response.template = 'record_main.html';
|
||||||
const q = {};
|
const q = { tid };
|
||||||
|
if (uname_or_uid) q.$or = [{ unameLower: uname_or_uid.toLowerCase() }, { _id: parseInt(uname_or_uid) }];
|
||||||
const rdocs = await record.getMany(domainId, q, { _id: -1 }, page, await system.get('RECORD_PER_PAGE'));
|
const rdocs = await record.getMany(domainId, q, { _id: -1 }, page, await system.get('RECORD_PER_PAGE'));
|
||||||
const [udict, pdict] = await Promise.all([
|
const [udict, pdict] = await Promise.all([
|
||||||
user.getList(domainId, rdocs.map((rdoc) => rdoc.uid)),
|
user.getList(domainId, rdocs.map((rdoc) => rdoc.uid)),
|
||||||
@@ -31,11 +36,14 @@ class RecordListHandler extends Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RecordDetailHandler extends Handler {
|
class RecordDetailHandler extends RecordHandler {
|
||||||
async get({ domainId, rid }) {
|
async get({ domainId, rid }) {
|
||||||
this.response.template = 'record_detail.html';
|
this.response.template = 'record_detail.html';
|
||||||
const rdoc = await record.get(domainId, rid);
|
const rdoc = await record.get(domainId, rid);
|
||||||
if (rdoc.hidden) this.checkPerm(PERM_VIEW_CONTEST_HIDDEN_SCOREBOARD);
|
if (rdoc.tid) {
|
||||||
|
const tdoc = await contest.get(domainId, rdoc.tid, rdoc.ttype);
|
||||||
|
if (!this.canShowRecord(tdoc, true)) throw new PermissionError(rid);
|
||||||
|
}
|
||||||
if (rdoc.uid !== this.user.uid && !this.user.hasPerm(PERM_READ_RECORD_CODE)) {
|
if (rdoc.uid !== this.user.uid && !this.user.hasPerm(PERM_READ_RECORD_CODE)) {
|
||||||
rdoc.code = null;
|
rdoc.code = null;
|
||||||
}
|
}
|
||||||
@@ -128,6 +136,9 @@ async function apply() {
|
|||||||
Route('/r', module.exports.RecordListHandler);
|
Route('/r', module.exports.RecordListHandler);
|
||||||
Route('/r/:rid', module.exports.RecordDetailHandler);
|
Route('/r/:rid', module.exports.RecordDetailHandler);
|
||||||
Route('/r/:rid/rejudge', module.exports.RecordRejudgeHandler);
|
Route('/r/:rid/rejudge', module.exports.RecordRejudgeHandler);
|
||||||
|
Route('/record', module.exports.RecordListHandler);
|
||||||
|
Route('/record/:rid', module.exports.RecordDetailHandler);
|
||||||
|
Route('/record/:rid/rejudge', module.exports.RecordRejudgeHandler);
|
||||||
Connection('/record-conn', module.exports.RecordConnectionHandler);
|
Connection('/record-conn', module.exports.RecordConnectionHandler);
|
||||||
Connection('/record-detail-conn', module.exports.RecordDetailConnectionHandler);
|
Connection('/record-detail-conn', module.exports.RecordDetailConnectionHandler);
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -49,6 +49,11 @@ function size(s, base = 1) {
|
|||||||
return '{0} {1}'.format(Math.round(s * unit), unitNames[unitNames.length - 1]);
|
return '{0} {1}'.format(Math.round(s * unit), unitNames[unitNames.length - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatSeconds(seconds) {
|
||||||
|
seconds = parseInt(seconds);
|
||||||
|
return '{:02}:{:02}:{:02}'.format(Math.floor(seconds / 3600), Math.floor((seconds % 3600) / 60), seconds % 60);
|
||||||
|
}
|
||||||
|
|
||||||
global.Hydro.lib.misc = module.exports = {
|
global.Hydro.lib.misc = module.exports = {
|
||||||
gravatar, datetimeSpan, paginate, size,
|
gravatar, datetimeSpan, paginate, size, formatSeconds,
|
||||||
};
|
};
|
||||||
+11
-16
@@ -74,7 +74,7 @@ const acm = {
|
|||||||
const rows = [columns];
|
const rows = [columns];
|
||||||
for (const [rank, tsdoc] of rankedTsdocs) {
|
for (const [rank, tsdoc] of rankedTsdocs) {
|
||||||
const tsddict = {};
|
const tsddict = {};
|
||||||
if (tdoc.detail) { for (const item of tsdoc.detail) tsddict[item.pid] = item; }
|
if (tdoc.detail) { for (const item of tsdoc.journal) tsddict[item.pid] = item; }
|
||||||
const row = [];
|
const row = [];
|
||||||
row.push(
|
row.push(
|
||||||
{ type: 'string', value: rank },
|
{ type: 'string', value: rank },
|
||||||
@@ -229,13 +229,8 @@ function add(domainId, title, content, owner, rule,
|
|||||||
* @returns {Tdoc} tdoc after modification
|
* @returns {Tdoc} tdoc after modification
|
||||||
*/
|
*/
|
||||||
async function edit(domainId, tid, $set, type = document.TYPE_CONTEST) {
|
async function edit(domainId, tid, $set, type = document.TYPE_CONTEST) {
|
||||||
if ($set.title) validator.checkTitle($set.title);
|
if ($set.rule) {
|
||||||
if ($set.content) validator.checkIntro($set.content);
|
if (!this.RULES[$set.rule]) throw new ValidationError('rule');
|
||||||
if ($set.rule) { if (!this.RULES[$set.rule]) throw new ValidationError('rule'); }
|
|
||||||
if ($set.beginAt && $set.endAt) {
|
|
||||||
if ($set.beginAt >= $set.endAt) {
|
|
||||||
throw new ValidationError('beginAt', 'endAt');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const tdoc = await document.get(domainId, type, tid);
|
const tdoc = await document.get(domainId, type, tid);
|
||||||
if (!tdoc) throw new ContestNotFoundError(tid);
|
if (!tdoc) throw new ContestNotFoundError(tid);
|
||||||
@@ -259,7 +254,7 @@ async function updateStatus(
|
|||||||
domainId, tid, uid, rid, pid,
|
domainId, tid, uid, rid, pid,
|
||||||
accept = false, score = 0, type = document.TYPE_CONTEST,
|
accept = false, score = 0, type = document.TYPE_CONTEST,
|
||||||
) {
|
) {
|
||||||
await get(domainId, tid);
|
await get(domainId, tid, type);
|
||||||
const tsdoc = await document.revPushStatus(domainId, type, tid, uid, 'journal', {
|
const tsdoc = await document.revPushStatus(domainId, type, tid, uid, 'journal', {
|
||||||
rid, pid, accept, score,
|
rid, pid, accept, score,
|
||||||
});
|
});
|
||||||
@@ -287,8 +282,8 @@ async function attend(domainId, tid, uid, type = document.TYPE_CONTEST) {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMultiStatus(query) {
|
function getMultiStatus(domainId, query, docType = document.TYPE_CONTEST) {
|
||||||
return document.getMultiStatus(query);
|
return document.getMultiStatus(domainId, docType, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isNew(tdoc, days = 1) {
|
function isNew(tdoc, days = 1) {
|
||||||
@@ -329,10 +324,10 @@ const ContestHandlerMixin = (c) => class extends c {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getScoreboard(domainId, tid, isExport = false) {
|
async getScoreboard(domainId, tid, isExport = false, docType = document.TYPE_CONTEST) {
|
||||||
const tdoc = await get(domainId, tid);
|
const tdoc = await get(domainId, tid, docType);
|
||||||
if (!this.canShowScoreboard(tdoc)) throw new ContestScoreboardHiddenError(tid);
|
if (!this.canShowScoreboard(tdoc)) throw new ContestScoreboardHiddenError(tid);
|
||||||
const tsdocs = await getMultiStatus(domainId, tid)
|
const tsdocs = await getMultiStatus(domainId, tid, docType)
|
||||||
.sort(RULES[tdoc.rule].statusSort).toArray();
|
.sort(RULES[tdoc.rule].statusSort).toArray();
|
||||||
const uids = [];
|
const uids = [];
|
||||||
for (const tsdoc of tsdocs) uids.push(tsdoc.uid);
|
for (const tsdoc of tsdocs) uids.push(tsdoc.uid);
|
||||||
@@ -375,10 +370,10 @@ function _getStatusJournal(tsdoc) {
|
|||||||
async function recalcStatus(domainId, tid, type) {
|
async function recalcStatus(domainId, tid, type) {
|
||||||
const [tdoc, tsdocs] = await Promise.all([
|
const [tdoc, tsdocs] = await Promise.all([
|
||||||
document.get(domainId, type, tid),
|
document.get(domainId, type, tid),
|
||||||
document.getMultiStatus(domainId, type, { docId: tid }),
|
document.getMultiStatus(domainId, type, { docId: tid }).toArray(),
|
||||||
]);
|
]);
|
||||||
const tasks = [];
|
const tasks = [];
|
||||||
for (const tsdoc of tsdocs) {
|
for (const tsdoc of tsdocs || []) {
|
||||||
if (tsdoc.journal) {
|
if (tsdoc.journal) {
|
||||||
const journal = _getStatusJournal(tsdoc);
|
const journal = _getStatusJournal(tsdoc);
|
||||||
const stats = RULES[tdoc.rule].stat(tdoc, journal);
|
const stats = RULES[tdoc.rule].stat(tdoc, journal);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ function get(domainId, docType, docId) {
|
|||||||
async function set(domainId, docType, docId, args) {
|
async function set(domainId, docType, docId, args) {
|
||||||
const res = await coll.findOneAndUpdate(
|
const res = await coll.findOneAndUpdate(
|
||||||
{ domainId, docType, docId },
|
{ domainId, docType, docId },
|
||||||
{ $set: { args } },
|
{ $set: args },
|
||||||
{ returnOriginal: false },
|
{ returnOriginal: false },
|
||||||
);
|
);
|
||||||
return res.value;
|
return res.value;
|
||||||
|
|||||||
+14
-3
@@ -26,7 +26,19 @@ async function add(domainId, data) {
|
|||||||
judger: null,
|
judger: null,
|
||||||
judgeAt: null,
|
judgeAt: null,
|
||||||
});
|
});
|
||||||
const res = await coll.insertOne(data);
|
const [pdoc, res] = await Promise.all([
|
||||||
|
problem.get(domainId, data.pid),
|
||||||
|
coll.insertOne(data),
|
||||||
|
]);
|
||||||
|
await task.add({
|
||||||
|
type: 'judge',
|
||||||
|
rid: res.insertedId,
|
||||||
|
domainId,
|
||||||
|
pid: data.pid,
|
||||||
|
data: pdoc.data,
|
||||||
|
lang: data.lang,
|
||||||
|
code: data.code,
|
||||||
|
});
|
||||||
return res.insertedId;
|
return res.insertedId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,11 +47,10 @@ async function add(domainId, data) {
|
|||||||
* @param {ObjectID} rid
|
* @param {ObjectID} rid
|
||||||
* @returns {import('../interface').Record}
|
* @returns {import('../interface').Record}
|
||||||
*/
|
*/
|
||||||
async function get(domainId, rid, showHidden = false) {
|
async function get(domainId, rid) {
|
||||||
const _id = new ObjectID(rid);
|
const _id = new ObjectID(rid);
|
||||||
const rdoc = await coll.findOne({ domainId, _id });
|
const rdoc = await coll.findOne({ domainId, _id });
|
||||||
if (!rdoc) throw new RecordNotFoundError(rid);
|
if (!rdoc) throw new RecordNotFoundError(rid);
|
||||||
if (rdoc.hidden && !showHidden) throw new PermissionError(rid);
|
|
||||||
return rdoc;
|
return rdoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ class USER {
|
|||||||
this.salt = () => user.salt;
|
this.salt = () => user.salt;
|
||||||
this.hash = () => user.hash;
|
this.hash = () => user.hash;
|
||||||
this.perm = user.perm;
|
this.perm = user.perm;
|
||||||
|
this.priv = user.priv;
|
||||||
|
this.role = user.role;
|
||||||
this.viewLang = user.language || 'zh_CN';
|
this.viewLang = user.language || 'zh_CN';
|
||||||
this.codeLang = user.codeLang || 'c';
|
this.codeLang = user.codeLang || 'c';
|
||||||
this.codeTemplate = user.codeTemplate || '';
|
this.codeTemplate = user.codeTemplate || '';
|
||||||
@@ -161,6 +163,16 @@ function setRole(domainId, uid, role) {
|
|||||||
return document.setStatus(domainId, document.TYPE_DOMAIN_ROLE, 0, uid, { role });
|
return document.setStatus(domainId, document.TYPE_DOMAIN_ROLE, 0, uid, { role });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setRoles(domainId, roles) {
|
||||||
|
const tasks = [];
|
||||||
|
for (const role in roles) {
|
||||||
|
tasks.push(document.set(
|
||||||
|
domainId, document.TYPE_DOMAIN_ROLE, role, { content: roles[role] },
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return Promise.all(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
async function getRoles(domainId) {
|
async function getRoles(domainId) {
|
||||||
const docs = await document.getMulti(domainId, document.TYPE_DOMAIN_ROLE).sort('_id', 1).toArray();
|
const docs = await document.getMulti(domainId, document.TYPE_DOMAIN_ROLE).sort('_id', 1).toArray();
|
||||||
const roles = [];
|
const roles = [];
|
||||||
@@ -174,6 +186,10 @@ function getRole(domainId, name) {
|
|||||||
return document.get(domainId, document.TYPE_DOMAIN_ROLE, name);
|
return document.get(domainId, document.TYPE_DOMAIN_ROLE, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getInDomain(domainId) {
|
||||||
|
return document.getMultiStatus(domainId, document.TYPE_DOMAIN_ROLE).toArray();
|
||||||
|
}
|
||||||
|
|
||||||
function addRole(domainId, name, permission) {
|
function addRole(domainId, name, permission) {
|
||||||
return document.add(domainId, permission, 1, document.TYPE_DOMAIN_ROLE, name);
|
return document.add(domainId, permission, 1, document.TYPE_DOMAIN_ROLE, name);
|
||||||
}
|
}
|
||||||
@@ -205,9 +221,11 @@ global.Hydro.model.user = module.exports = {
|
|||||||
setPassword,
|
setPassword,
|
||||||
getPrefixList,
|
getPrefixList,
|
||||||
setRole,
|
setRole,
|
||||||
|
setRoles,
|
||||||
getRole,
|
getRole,
|
||||||
getList,
|
getList,
|
||||||
getRoles,
|
getRoles,
|
||||||
|
getInDomain,
|
||||||
addRole,
|
addRole,
|
||||||
deleteRoles,
|
deleteRoles,
|
||||||
ensureIndexes,
|
ensureIndexes,
|
||||||
|
|||||||
+10
-4
@@ -40,6 +40,8 @@ const perm = {
|
|||||||
PERM_CREATE_HOMEWORK: 'f',
|
PERM_CREATE_HOMEWORK: 'f',
|
||||||
PERM_EDIT_HOMEWORK: 'g',
|
PERM_EDIT_HOMEWORK: 'g',
|
||||||
PERM_ATTEND_HOMEWORK: 'h',
|
PERM_ATTEND_HOMEWORK: 'h',
|
||||||
|
PERM_VIEW_HOMEWORK_SCOREBOARD: 'i',
|
||||||
|
PERM_VIEW_HOMEWORK_HIDDEN_SCOREBOARD: 'j',
|
||||||
PERM_JUDGE: 'd',
|
PERM_JUDGE: 'd',
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -83,9 +85,12 @@ const PERMS = [
|
|||||||
Permission('perm_contest', perm.PERM_CREATE_CONTEST, 'Create contests'),
|
Permission('perm_contest', perm.PERM_CREATE_CONTEST, 'Create contests'),
|
||||||
Permission('perm_contest', perm.PERM_ATTEND_CONTEST, 'Attend contests'),
|
Permission('perm_contest', perm.PERM_ATTEND_CONTEST, 'Attend contests'),
|
||||||
Permission('perm_contest', perm.PERM_EDIT_CONTEST, 'Edit any contests'),
|
Permission('perm_contest', perm.PERM_EDIT_CONTEST, 'Edit any contests'),
|
||||||
Permission('perm_training', perm.PERM_VIEW_TRAINING, 'View training plans'),
|
Permission('perm_homework', perm.PERM_VIEW_HOMEWORK, 'View homework'),
|
||||||
Permission('perm_training', perm.PERM_CREATE_TRAINING, 'Create training plans'),
|
Permission('perm_homework', perm.PERM_VIEW_HOMEWORK_SCOREBOARD, 'View homework scoreboard'),
|
||||||
Permission('perm_training', perm.PERM_EDIT_TRAINING, 'Edit training plans'),
|
Permission('perm_homework', perm.PERM_VIEW_HOMEWORK_HIDDEN_SCOREBOARD, 'View hidden homework submission status and scoreboard'),
|
||||||
|
Permission('perm_homework', perm.PERM_CREATE_HOMEWORK, 'Create homework'),
|
||||||
|
Permission('perm_homework', perm.PERM_ATTEND_HOMEWORK, 'Claim homework'),
|
||||||
|
Permission('perm_homework', perm.PERM_EDIT_HOMEWORK, 'Edit any homework'),
|
||||||
];
|
];
|
||||||
|
|
||||||
const PERMS_BY_FAMILY = {};
|
const PERMS_BY_FAMILY = {};
|
||||||
@@ -101,7 +106,8 @@ perm.PERM_BASIC = perm.PERM_VIEW_PROBLEM
|
|||||||
+ perm.PERM_VIEW_TRAINING
|
+ perm.PERM_VIEW_TRAINING
|
||||||
+ perm.PERM_VIEW_CONTEST
|
+ perm.PERM_VIEW_CONTEST
|
||||||
+ perm.PERM_VIEW_CONTEST_SCOREBOARD
|
+ perm.PERM_VIEW_CONTEST_SCOREBOARD
|
||||||
+ perm.PERM_VIEW_HOMEWORK;
|
+ perm.PERM_VIEW_HOMEWORK
|
||||||
|
+ perm.PERM_VIEW_HOMEWORK_SCOREBOARD;
|
||||||
|
|
||||||
perm.PERM_DEFAULT = perm.PERM_BASIC
|
perm.PERM_DEFAULT = perm.PERM_BASIC
|
||||||
+ perm.PERM_SUBMIT_PROBLEM
|
+ perm.PERM_SUBMIT_PROBLEM
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ const validate = {
|
|||||||
pid: (pid) => (Number.isSafeInteger(parseInt(pid)) ? parseInt(pid) : pid),
|
pid: (pid) => (Number.isSafeInteger(parseInt(pid)) ? parseInt(pid) : pid),
|
||||||
content: validator.checkContent,
|
content: validator.checkContent,
|
||||||
title: validator.checkTitle,
|
title: validator.checkTitle,
|
||||||
uid: parseInt(validator.checkUid),
|
uid: (uid) => parseInt(validator.checkUid(uid)),
|
||||||
password: validator.checkPassword,
|
password: validator.checkPassword,
|
||||||
mail: validator.checkEmail,
|
mail: validator.checkEmail,
|
||||||
uname: validator.checkUname,
|
uname: validator.checkUname,
|
||||||
@@ -58,12 +58,14 @@ const validate = {
|
|||||||
if (duration <= 0) throw new ValidationError('duration');
|
if (duration <= 0) throw new ValidationError('duration');
|
||||||
return duration;
|
return duration;
|
||||||
},
|
},
|
||||||
pids: (pids) => pids.split(',').map((i) => i.trim()),
|
pids: (pids) => {
|
||||||
role: validator.checkRole,
|
const res = pids.split(',').map((i) => i.trim());
|
||||||
roles: (roles) => {
|
for (const i in res) {
|
||||||
for (const i of roles) validator.checkRole(i);
|
if (Number.isSafeInteger(parseInt(res[i]))) res[i] = parseInt(res[i]);
|
||||||
return roles;
|
}
|
||||||
|
return res;
|
||||||
},
|
},
|
||||||
|
role: validator.checkRole,
|
||||||
penaltyRules: (penaltyRules) => {
|
penaltyRules: (penaltyRules) => {
|
||||||
try {
|
try {
|
||||||
penaltyRules = yaml.safeLoad(penaltyRules);
|
penaltyRules = yaml.safeLoad(penaltyRules);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
{% macro render_problem_title(pdoc, tdoc=none, show_tags=true, show_invisible_flag=true, rp=none, invalid=false) %}
|
{% macro render_problem_title(pdoc, tdoc=none, prefix='/c', show_tags=true, show_invisible_flag=true, rp=none, invalid=false) %}
|
||||||
{%- if not invalid %}
|
{%- if not invalid %}
|
||||||
<a
|
<a
|
||||||
{%- if tdoc %}
|
{%- if tdoc %}
|
||||||
href="/c/{{ tdoc.docId }}/p/{{ pdoc.docId }}"
|
href="{{ prefix }}/{{ tdoc.docId }}/p/{{ pdoc.docId }}"
|
||||||
{%- else %}
|
{%- else %}
|
||||||
href="/p/{{ pdoc.pid }}"
|
href="/p/{{ pdoc.pid }}"
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
{% if handler.canShowRecord(tdoc) %}
|
{% if handler.canShowRecord(tdoc) %}
|
||||||
{{ record.render_status_td(rdoc) }}
|
{{ record.render_status_td(rdoc) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
<td class="col--status record-status--border"><a href="/r/{{ rdoc._id }}">{{ _('Submitted') }}</a></td>
|
<td class="col--status record-status--border"><a href="/record/{{ rdoc._id }}">{{ _('Submitted') }}</a></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td class="col--submit-at">{{ datetimeSpan(rdoc['_id'])|safe }}</td>
|
<td class="col--submit-at">{{ datetimeSpan(rdoc['_id'])|safe }}</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<td class="col--problem col--problem-name">
|
<td class="col--problem col--problem-name">
|
||||||
#{{ loop.index }}:
|
#{{ loop.index }}:
|
||||||
{{ problem.render_problem_title(pdict[pid], tdoc=tdoc, show_invisible_flag=false, show_tags=false) }}
|
{{ problem.render_problem_title(pdict[pid], tdoc=tdoc, prefix='/homework', show_invisible_flag=false, show_tags=false) }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
{% import "components/user.html" as user %}
|
{% import "components/user.html" as user %}
|
||||||
{% extends "manage_base.html" %}
|
{% extends "manage_base.html" %}
|
||||||
{% block manage_content %}
|
{% block manage_content %}
|
||||||
{% if system.bio %}
|
{% if domain.bulletin %}
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<div class="section__body typo">
|
<div class="section__body typo">
|
||||||
{{ system.bio|markdown|safe }}
|
{{ domain.bulletin|markdown|safe }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -14,8 +14,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="section__body typo">
|
<div class="section__body typo">
|
||||||
<dl class="large horizontal">
|
<dl class="large horizontal">
|
||||||
<dt>{{ _('Gravatar') }}</dt><dd><img src="{{ gravatar(system.gravatar) }}" width="32" height="32"></dd>
|
<dt>{{ _('Gravatar') }}</dt><dd><img src="{{ gravatar(domain.gravatar) }}" width="32" height="32"></dd>
|
||||||
<dt>{{ _('Name') }}</dt><dd>{{ system.uname }}</dd>
|
<dt>{{ _('Name') }}</dt><dd>{{ domain.name }}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<form method="post">
|
<form method="post">
|
||||||
{{ form.form_text({
|
{{ form.form_text({
|
||||||
label:'Name',
|
label:'Name',
|
||||||
name:'uname',
|
name:'name',
|
||||||
value:system.uname,
|
value:domain.name,
|
||||||
autofocus:true,
|
autofocus:true,
|
||||||
required:true
|
required:true
|
||||||
}) }}
|
}) }}
|
||||||
@@ -15,13 +15,13 @@
|
|||||||
label:'Gravatar Email',
|
label:'Gravatar Email',
|
||||||
help_text:'Will be used as the system icon.',
|
help_text:'Will be used as the system icon.',
|
||||||
name:'gravatar',
|
name:'gravatar',
|
||||||
value:system.gravatar
|
value:domain.gravatar
|
||||||
}) }}
|
}) }}
|
||||||
{{ form.form_textarea({
|
{{ form.form_textarea({
|
||||||
columns:12,
|
columns:12,
|
||||||
label:'Bulletin',
|
label:'Bulletin',
|
||||||
name:'bio',
|
name:'bulletin',
|
||||||
value:system.bio,
|
value:domain.bulletin,
|
||||||
markdown:true,
|
markdown:true,
|
||||||
required:false
|
required:false
|
||||||
}) }}
|
}) }}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<div class="section__header">
|
<div class="section__header">
|
||||||
<h1 class="section__title">{{ _('{0}: Permissions').format(system.uname) }}</h1>
|
<h1 class="section__title">{{ _('{0}: Permissions').format(domain.name) }}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="section__body no-padding domain-users">
|
<div class="section__body no-padding domain-users">
|
||||||
<table class="data-table">
|
<table class="data-table">
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
{% for role in roles %}
|
{% for role in roles %}
|
||||||
<td class="col--p">
|
<td class="col--p">
|
||||||
<label class="compact checkbox">
|
<label class="compact checkbox">
|
||||||
<input name="{{ role._id }}" data-checkbox-group="{{ role._id }}" data-checkbox-range value="{{ perm.key }}" type="checkbox"{% if role.perm.includes(perm.key) %} checked{% endif %}{% if role._id == 'root' %} disabled{% endif %}>
|
<input name="{{ role._id }}" data-checkbox-group="{{ role._id }}" data-checkbox-range value="{{ perm.key }}" type="checkbox"{% if role.perm.includes(perm.key) %} checked{% endif %}{% if role._id == 'admin' %} disabled{% endif %}>
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<div class="section__header">
|
<div class="section__header">
|
||||||
<h1 class="section__title">{{ _('{0}: Roles').format(system.uname) }}</h1>
|
<h1 class="section__title">{{ _('{0}: Roles').format(domain.name) }}</h1>
|
||||||
<div class="section__tools">
|
<div class="section__tools">
|
||||||
<button class="primary rounded button" name="create_role">{{ _('Create Role') }}</button>
|
<button class="primary rounded button" name="create_role">{{ _('Create Role') }}</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for role in roles %}
|
{% for role in roles %}
|
||||||
{% set isBuiltin = role._id not in ['default', 'guest', 'root'] %}
|
{% set isBuiltin = role._id in ['default', 'guest', 'admin'] %}
|
||||||
<tr{% if isBuiltin %} data-role="{{ role._id }}"{% endif %}>
|
<tr{% if isBuiltin %} data-role="{{ role._id }}"{% endif %}>
|
||||||
<td class="col--checkbox">
|
<td class="col--checkbox">
|
||||||
<label class="compact checkbox">
|
<label class="compact checkbox">
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<div class="section__header">
|
<div class="section__header">
|
||||||
<h1 class="section__title">{{ _('{0}: Users').format(system.uname) }}</h1>
|
<h1 class="section__title">{{ _('{0}: Users').format(domain.name) }}</h1>
|
||||||
<div class="section__tools">
|
<div class="section__tools">
|
||||||
<button class="primary rounded button" name="add_user">{{ _('Add User') }}</button>
|
<button class="primary rounded button" name="add_user">{{ _('Add User') }}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% if user._id == tdoc.owner or handler.hasPerm(perm.PERM_EDIT_CONTEST) %}
|
{% if user._id == tdoc.owner or handler.hasPerm(perm.PERM_EDIT_CONTEST) %}
|
||||||
<li class="menu__item"><a class="menu__link" href="/c/{{ tdoc.docId }}/edit">
|
<li class="menu__item"><a class="menu__link" href="/c/{{ tdoc.docId }}/edit">
|
||||||
<span class="icon icon-edit"></span> {{ _('Edit Contest') }}
|
<span class="icon icon-edit"></span> {{ _('Edit Contest') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if handler.hasPerm(perm.PERM_READ_RECORD_CODE) %}
|
{% if handler.hasPerm(perm.PERM_READ_RECORD_CODE) %}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% if tdoc.owner == handler.user._id or handler.hasPerm(perm.PERM_EDIT_HOMEWORK) %}
|
{% if tdoc.owner == handler.user._id or handler.hasPerm(perm.PERM_EDIT_HOMEWORK) %}
|
||||||
<li class="menu__item"><a class="menu__link" href="/homework/{{ tdoc.docId }}/edit">
|
<li class="menu__item"><a class="menu__link" href="/homework/{{ tdoc.docId }}/edit">
|
||||||
<span class="icon icon-edit"></span> {{ _('Edit Homework') }}
|
<span class="icon icon-edit"></span> {{ _('Edit Homework') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if handler.hasPerm(perm.PERM_READ_RECORD_CODE) %}
|
{% if handler.hasPerm(perm.PERM_READ_RECORD_CODE) %}
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
{% if tdoc %}
|
{% if tdoc %}
|
||||||
{% include "partials/problem_sidebar_contest.html" %}
|
{% if tdoc.docType == 60 %}
|
||||||
{% set owner_udoc = udoc %}
|
{% include "partials/problem_sidebar_homework.html" %}
|
||||||
{% include "partials/contest_sidebar.html" %}
|
{% set owner_udoc = udoc %}
|
||||||
|
{% include "partials/homework_sidebar.html" %}
|
||||||
|
{% else %}
|
||||||
|
{% include "partials/problem_sidebar_contest.html" %}
|
||||||
|
{% set owner_udoc = udoc %}
|
||||||
|
{% include "partials/contest_sidebar.html" %}
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% include "partials/problem_sidebar_normal.html" %}
|
{% include "partials/problem_sidebar_normal.html" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
{% import "components/user.html" as user with context %}
|
||||||
|
<div class="section side section--problem-sidebar">
|
||||||
|
{% if page_name != 'problem_detail' and page_name != 'homework_detail_problem' %}
|
||||||
|
<div class="section__header">
|
||||||
|
<h1 class="section__title">{{ pdoc['title'] }}</h1>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div>
|
||||||
|
<ol class="menu">
|
||||||
|
{% if model.contest.isOngoing(tdoc) or model.contest.isHomeworkExtended(tdoc) %}
|
||||||
|
{% if page_name == 'homework_detail_problem' %}
|
||||||
|
<li class="menu__item scratchpad--hide"><a class="menu__link highlight" name="problem-sidebar__open-scratchpad" href="javascript:;" data-global-hotkey="alt+e">
|
||||||
|
<span class="icon icon-enlarge"></span> {{ _('Open Scratchpad') }} (Alt+E)
|
||||||
|
</a></li>
|
||||||
|
<li class="menu__item non-scratchpad--hide"><a class="menu__link" name="problem-sidebar__quit-scratchpad" href="javascript:;" data-global-hotkey="alt+q">
|
||||||
|
<span class="icon icon-enlarge"></span> {{ _('Quit Scratchpad') }} (Alt+Q)
|
||||||
|
</a></li>
|
||||||
|
{% else %}
|
||||||
|
<li class="menu__item"><a class="menu__link" href="/homework/{{ tdoc.docId }}/p/{{ pdoc.docId }}">
|
||||||
|
<span class="icon icon-flag"></span> {{ _('View Problem') }}
|
||||||
|
</a></li>
|
||||||
|
{% endif %}
|
||||||
|
<li class="menu__item scratchpad--hide"><a class="menu__link{% if page_name == 'homework_detail_problem_submit' %} active{% endif %}" href="/homework/{{ tdoc.docId }}/p/{{ pdoc.docId }}/submit">
|
||||||
|
<span class="icon icon-send"></span> {{ _('Submit') }}
|
||||||
|
</a></li>
|
||||||
|
{% elif model.contest.isDone(tdoc) %}
|
||||||
|
<li class="menu__item scratchpad--hide"><a class="menu__link" href="/p/{{ pdoc.pid }}">
|
||||||
|
<span class="icon icon-send"></span> {{ _('Open in Problem Set') }}
|
||||||
|
</a></li>
|
||||||
|
{% endif %}
|
||||||
|
{% if pdoc.owner == handler.user._id or handler.hasPerm(perm.PERM_EDIT_PROBLEM) %}
|
||||||
|
<li class="menu__seperator"></li>
|
||||||
|
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_edit' %} active{% endif %}" href="/p/{{ pdoc.pid }}/edit">
|
||||||
|
<span class="icon icon-edit"></span> {{ _('Edit') }}
|
||||||
|
</a></li>
|
||||||
|
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_settings' %} active{% endif %}" href="/p/{{ pdoc.pid }}/settings">
|
||||||
|
<span class="icon icon-wrench"></span> {{ _('Settings') }}
|
||||||
|
</a></li>
|
||||||
|
{% endif %}
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Reference in new issue
Block a user