From 9e9cc2b78e26125a93ceffa99f01eca5bb0031dd Mon Sep 17 00:00:00 2001 From: Allan Otodi Opeto <103313919+AllanOXDi@users.noreply.github.com> Date: Mon, 5 Feb 2024 23:01:32 +0300 Subject: [PATCH] number of selected execrises display correctly per topic --- .../views/plan/CreateExamPage/ResourceSelection.vue | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ResourceSelection.vue b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ResourceSelection.vue index e67384a5eb1..3dd276b4628 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ResourceSelection.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ResourceSelection.vue @@ -372,9 +372,18 @@ }, selectionMetadata(content) { if (content.kind === ContentNodeKinds.TOPIC) { - const count = this.workingResourcePool.length; const total = content.num_exercises; - return this.selectedResourcesInformation$({ count, total }); + const numberOfresourcesSelected = this.workingResourcePool.reduce((acc, wr) => { + if (wr.ancestors.map(ancestor => ancestor.id).includes(content.id)) { + return acc + 1; + } + return acc; + }, 0); + + return this.selectedResourcesInformation$({ + count: numberOfresourcesSelected, + total: total, + }); } return ''; },