From e88220c42403125ec901ee5beb38d69c188d8f50 Mon Sep 17 00:00:00 2001 From: undefined Date: Sun, 4 Jun 2023 12:35:50 +0800 Subject: [PATCH] ui: add submission language not available warning --- packages/hydrooj/src/handler/problem.ts | 4 +++- packages/ui-default/locales/zh.yaml | 3 ++- .../ui-default/templates/partials/problem_description.html | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index 26f78c3e..352cca9d 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -340,7 +340,8 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler { let baseLangs; if (this.pdoc.config.type === 'remote_judge') { const p = this.pdoc.config.subType; - const dl = [p, ...Object.keys(setting.langs).filter((i) => i.startsWith(`${p}.`) || setting.langs[i].validAs[p])]; + const dl = Object.keys(setting.langs).filter((i) => i.startsWith(`${p}.`) || setting.langs[i].validAs[p]); + if (setting.langs[p]) dl.push(p); baseLangs = dl; } else { baseLangs = Object.keys(setting.langs).filter((i) => !setting.langs[i].remote); @@ -478,6 +479,7 @@ export class ProblemSubmitHandler extends ProblemDetailHandler { async prepare(domainId: string, tid?: ObjectId) { if (tid && !contest.isOngoing(this.tdoc, this.tsdoc)) throw new ContestNotLiveError(this.tdoc.docId); if (typeof this.pdoc.config === 'string') throw new ProblemConfigError(); + if (this.pdoc.config.langs && !this.pdoc.config.langs.length) throw new ProblemConfigError(); } async get() { diff --git a/packages/ui-default/locales/zh.yaml b/packages/ui-default/locales/zh.yaml index 8d6bfe27..9d6477ad 100644 --- a/packages/ui-default/locales/zh.yaml +++ b/packages/ui-default/locales/zh.yaml @@ -560,6 +560,7 @@ No Permission to Create a Discussion: 您没有权限创建讨论 No Permission to Submit: 您没有权限递交 No problem.: 没有题目。 No solutions so far...: 目前还没有题解... +No submission language available for this problem.: 本题没有可用的提交语言。 No Submissions: 没有递交 No target available: 无可用目标 No testcase here: 此处没有测试点 @@ -577,9 +578,9 @@ objective: 客观题 Oh, the user doesn't have any contributions!: 啊哦,这个用户还没贡献过题目~ Oh, the user hasn't created any discussions yet!: 这个用户还没有发布过讨论 Oh, the user hasn't submitted yet!: 这个用户还没有交过题 _(:зゝ∠)_ +Oh, there are no tasks that match the filter!: 喔,目前没有符合过滤条件的任务。 Oh, there is no submission!: 喔,还没有评测记录呢! Oh, there is no task in the queue!: 喔,队列中目前没有任务。 -Oh, there are no tasks that match the filter!: 喔,目前没有符合过滤条件的任务。 Ok: 确定 Only A-Z, a-z, 0-9 and _ are accepted: 只接受 A-Z, a-z, 0-9 和 _ Oops, there are no results.: 呀,没有结果。 diff --git a/packages/ui-default/templates/partials/problem_description.html b/packages/ui-default/templates/partials/problem_description.html index ea2a0fcb..be436070 100644 --- a/packages/ui-default/templates/partials/problem_description.html +++ b/packages/ui-default/templates/partials/problem_description.html @@ -9,6 +9,11 @@

{{ pdoc.config }}

{% endif %} + {% if pdoc.config.langs and not pdoc.config.langs|length %} +
+

{{ _('No submission language available for this problem.') }}

+
+ {% endif %} {% if tdoc and tdoc.docType == model.document.TYPE_CONTEST and model.contest.isDone(tdoc) %}

{{ _('You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.') }}