mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
ui: assign for contest&homework
This commit is contained in:
1 parent
db0aff4d33
commit
dad34de9c7
6 files changed
+43
-28
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "3.3.12",
|
||||
"version": "3.3.13",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -78,7 +78,7 @@ export class ContestDetailHandler extends Handler {
|
||||
@param('page', Types.PositiveInt, true)
|
||||
async prepare(domainId: string, tid: ObjectID) {
|
||||
const tdoc = await contest.get(domainId, tid);
|
||||
if (tdoc.assign) {
|
||||
if (tdoc.assign?.length) {
|
||||
const groups = await user.listGroup(domainId, this.user._id);
|
||||
if (!Set.intersection(tdoc.assign, groups.map((i) => i.name)).size) {
|
||||
throw new ForbiddenError('You are not assigned.');
|
||||
@@ -214,16 +214,6 @@ export class ContestEditHandler extends Handler {
|
||||
this.response.template = 'contest_edit.html';
|
||||
const rules = {};
|
||||
for (const i in contest.RULES) rules[i] = contest.RULES[i].TEXT;
|
||||
const path = [
|
||||
['Hydro', 'homepage'],
|
||||
['contest_main', 'contest_main'],
|
||||
...tid
|
||||
? [
|
||||
[this.tdoc.title, 'contest_detail', { tid: this.tdoc.docId }, true],
|
||||
['contest_edit', null],
|
||||
]
|
||||
: [['contest_create', null]],
|
||||
];
|
||||
let ts = new Date().getTime();
|
||||
ts = ts - (ts % (15 * Time.minute)) + 15 * Time.minute;
|
||||
const dt = this.tdoc?.beginAt || new Date(ts);
|
||||
@@ -231,7 +221,6 @@ export class ContestEditHandler extends Handler {
|
||||
rules,
|
||||
tdoc: this.tdoc,
|
||||
duration: tid ? (this.tdoc.endAt.getTime() - this.tdoc.beginAt.getTime()) / Time.hour : 2,
|
||||
path,
|
||||
pids: tid ? this.tdoc.pids.join(',') : '',
|
||||
date_text: dt.format('%Y-%m-%d'),
|
||||
time_text: dt.format('%H:%M'),
|
||||
@@ -250,7 +239,7 @@ export class ContestEditHandler extends Handler {
|
||||
@param('rated', Types.Boolean)
|
||||
@param('code', Types.String, true)
|
||||
@param('autoHide', Types.String, true)
|
||||
@param('assign', Types.Array, true)
|
||||
@param('assign', Types.CommaSeperatedArray, true)
|
||||
async post(
|
||||
domainId: string, tid: ObjectID, beginAtDate: string, beginAtTime: string, duration: number,
|
||||
title: string, content: string, rule: string, _pids: string, rated = false,
|
||||
|
||||
@@ -45,7 +45,7 @@ class HomeworkDetailHandler extends Handler {
|
||||
async prepare(domainId: string, tid: ObjectID) {
|
||||
const tdoc = await contest.get(domainId, tid);
|
||||
if (tdoc.rule !== 'homework') throw new ContestNotFoundError(domainId, tid);
|
||||
if (tdoc.assign) {
|
||||
if (tdoc.assign?.length) {
|
||||
if (!Set.intersection(tdoc.assign, this.user.group).size) {
|
||||
throw new ForbiddenError('You are not assigned.');
|
||||
}
|
||||
@@ -151,10 +151,12 @@ class HomeworkEditHandler extends Handler {
|
||||
@param('content', Types.Content)
|
||||
@param('pids', Types.Content)
|
||||
@param('rated', Types.Boolean)
|
||||
@param('assign', Types.CommaSeperatedArray, true)
|
||||
async post(
|
||||
domainId: string, tid: ObjectID, beginAtDate: string, beginAtTime: string,
|
||||
penaltySinceDate: string, penaltySinceTime: string, extensionDays: number,
|
||||
penaltyRules: PenaltyRules, title: string, content: string, _pids: string, rated = false,
|
||||
assign: string[] = [],
|
||||
) {
|
||||
const pids = _pids.replace(/,/g, ',').split(',').map((i) => +i).filter((i) => i);
|
||||
const tdoc = tid ? await contest.get(domainId, tid) : null;
|
||||
@@ -172,10 +174,18 @@ class HomeworkEditHandler extends Handler {
|
||||
if (!tid) {
|
||||
tid = await contest.add(domainId, title, content, this.user._id,
|
||||
'homework', beginAt.toDate(), endAt.toDate(), pids, rated,
|
||||
{ penaltySince: penaltySince.toDate(), penaltyRules });
|
||||
{ penaltySince: penaltySince.toDate(), penaltyRules, assign });
|
||||
} else {
|
||||
await contest.edit(domainId, tid, {
|
||||
title, content, beginAt: beginAt.toDate(), endAt: endAt.toDate(), pids, penaltySince: penaltySince.toDate(), penaltyRules, rated,
|
||||
title,
|
||||
content,
|
||||
beginAt: beginAt.toDate(),
|
||||
endAt: endAt.toDate(),
|
||||
pids,
|
||||
penaltySince: penaltySince.toDate(),
|
||||
penaltyRules,
|
||||
rated,
|
||||
assign,
|
||||
});
|
||||
if (tdoc.beginAt !== beginAt.toDate()
|
||||
|| tdoc.endAt !== endAt.toDate()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.30.2",
|
||||
"version": "4.30.3",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "hydro.js",
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
{{ form.form_text({
|
||||
columns:4,
|
||||
columns:3,
|
||||
label:'Begin Date',
|
||||
name:'beginAtDate',
|
||||
placeholder:'YYYY-mm-dd',
|
||||
@@ -51,7 +51,7 @@
|
||||
row:false
|
||||
}) }}
|
||||
{{ form.form_text({
|
||||
columns:4,
|
||||
columns:3,
|
||||
label:'Begin Time',
|
||||
name:'beginAtTime',
|
||||
placeholder:'HH:MM',
|
||||
@@ -60,12 +60,19 @@
|
||||
row:false
|
||||
}) }}
|
||||
{{ form.form_text({
|
||||
columns:4,
|
||||
columns:2,
|
||||
label:'Duration (hours)',
|
||||
name:'duration',
|
||||
value:duration|default('3'),
|
||||
row:false
|
||||
}) }}
|
||||
{{ form.form_text({
|
||||
columns:4,
|
||||
label:'Assign',
|
||||
name:'assign',
|
||||
value:tdoc.assign|default(''),
|
||||
row:false
|
||||
}) }}
|
||||
</div>
|
||||
<div class="row">
|
||||
{{ form.form_text({
|
||||
|
||||
@@ -54,16 +54,25 @@
|
||||
row:false
|
||||
}) }}
|
||||
</div>
|
||||
{{ form.form_text({
|
||||
columns:4,
|
||||
label:'Extension (days)',
|
||||
name:'extensionDays',
|
||||
value:extension_days
|
||||
}) }}
|
||||
<div class="row">
|
||||
{{ form.form_text({
|
||||
row:false,
|
||||
columns:4,
|
||||
label:'Extension (days)',
|
||||
name:'extensionDays',
|
||||
value:extension_days
|
||||
}) }}
|
||||
{{ form.form_text({
|
||||
columns:4,
|
||||
label:'Assign',
|
||||
name:'assign',
|
||||
value:tdoc.assign|default('')
|
||||
}) }}
|
||||
</div>
|
||||
<div class="row"><div class="columns">
|
||||
<label>
|
||||
{{ _('Extension Score Penalty') }}
|
||||
<textarea name="penaltyRules" class="monospace textbox">{% if tdoc %}{{ penaltyRules }}{% else %}{% include 'partials/homework_default_penalty_rules.yaml' %}{% endif %}</textarea>
|
||||
<textarea name="penaltyRules" class="monospace textbox" data-yaml>{% if tdoc %}{{ penaltyRules }}{% else %}{% include 'partials/homework_default_penalty_rules.yaml' %}{% endif %}</textarea>
|
||||
</label>
|
||||
</div></div>
|
||||
{{ form.form_text({
|
||||
|
||||
Reference in new issue
Block a user