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