From 242fa35500b04ed83881ff9f05000debb5a20ad9 Mon Sep 17 00:00:00 2001 From: undefined Date: Fri, 5 Dec 2025 18:31:56 +0800 Subject: [PATCH] core&ui: allow missing problem in training (fix #542) --- packages/hydrooj/src/handler/training.ts | 5 +++-- packages/ui-default/locales/zh.yaml | 1 + packages/ui-default/templates/training_detail.html | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/hydrooj/src/handler/training.ts b/packages/hydrooj/src/handler/training.ts index 223a408fc..754c43d14 100644 --- a/packages/hydrooj/src/handler/training.ts +++ b/packages/hydrooj/src/handler/training.ts @@ -112,10 +112,11 @@ class TrainingDetailHandler extends Handler { const [udoc, udict, pdict, psdict, selfPsdict] = await Promise.all([ user.getById(domainId, tdoc.owner), user.getListForRender(domainId, enrollUsers, this.user.hasPerm(PERM.PERM_VIEW_USER_PRIVATE_INFO)), - problem.getList(domainId, pids, canViewHidden, true), + problem.getList(domainId, pids, canViewHidden, false), problem.getListStatus(domainId, uid, pids), shouldCompare ? problem.getListStatus(domainId, this.user._id, pids) : {}, ]); + const missing = pids.filter((pid) => !pdict[pid]?.docId); const donePids = new Set(); const progPids = new Set(); for (const pid in psdict) { @@ -151,7 +152,7 @@ class TrainingDetailHandler extends Handler { const groups = this.user.hasPerm(PERM.PERM_EDIT_DOMAIN) ? await user.listGroup(domainId) : []; this.response.body = { - tdoc, tsdoc, pids, pdict, psdict, ndict, nsdict, udoc, udict, selfPsdict, groups, + tdoc, tsdoc, pids, pdict, psdict, ndict, nsdict, udoc, udict, selfPsdict, groups, missing, }; this.response.body.tdoc.description = this.response.body.tdoc.description .replace(/\(file:\/\//g, `(./${tdoc.docId}/file/`) diff --git a/packages/ui-default/locales/zh.yaml b/packages/ui-default/locales/zh.yaml index 21b638056..b4efbe8b0 100644 --- a/packages/ui-default/locales/zh.yaml +++ b/packages/ui-default/locales/zh.yaml @@ -892,6 +892,7 @@ Solutions Liked: 题解被赞 Solutions: 题解 Solve: 解决 Solved: 解决 +Some problems in the training are missing or you do not have permission to view them.: 训练中某些题目缺失或您没有权限查看。 Sorry, there are no problems in the problem set.: 题库中没有题目 Sorry, there are no training plans.: 目前没有训练计划。 Sorry, there are no users in this domain.: 对不起,此域中没有用户。 diff --git a/packages/ui-default/templates/training_detail.html b/packages/ui-default/templates/training_detail.html index 8f68ef55e..051350b36 100644 --- a/packages/ui-default/templates/training_detail.html +++ b/packages/ui-default/templates/training_detail.html @@ -55,6 +55,12 @@

{{ _('page.training_detail.invalid_when_not_enrolled') }}

{% endif %} + {% if missing.length %} +
+

{{ _('Some problems in the training are missing or you do not have permission to view them.') }}

+

{{ missing|join(', ') }}

+
+ {% endif %} {{ tdoc.description|default('')|markdown|safe }}