Skip to content

Commit 54b2a92

Browse files
AllanOXDirtibbles
authored andcommitted
adds no learners enrolled string
disabled the add quiz button do not show routerlink link when there is no resource
1 parent 831e516 commit 54b2a92

File tree

2 files changed

+109
-2
lines changed

2 files changed

+109
-2
lines changed

kolibri/plugins/coach/assets/src/views/plan/CoachExamsPage/index.vue

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,31 @@
77
:tabsId="PLAN_TABS_ID"
88
:activeTabId="PlanTabs.QUIZZES"
99
>
10+
<div
11+
v-if="hasNoChannels && !isLoading"
12+
class="alert banner-spacing"
13+
:style="{ backgroundColor: $themePalette.yellow.v_200 }"
14+
>
15+
<div>
16+
<KIcon
17+
icon="warning"
18+
class="warning-icon"
19+
:color="$themePalette.yellow.v_600"
20+
/>
21+
</div>
22+
23+
<div
24+
v-if="hasNoChannels"
25+
class="error-message"
26+
>
27+
<p>{{ noResourcesAvailable$() }}</p>
28+
<KExternalLink
29+
v-if="deviceContentUrl"
30+
:text="$tr('adminLink')"
31+
:href="deviceContentUrl"
32+
/>
33+
</div>
34+
</div>
1035
<div class="classname-quiz-button-div">
1136
<div>
1237
<KIcon
@@ -17,6 +42,7 @@
1742
</div>
1843
<KButtonGroup v-if="practiceQuizzesExist">
1944
<KButton
45+
v-if="!hasNoChannels"
2046
primary
2147
hasDropdown
2248
appearance="raised-button"
@@ -36,6 +62,7 @@
3662
class="button"
3763
>
3864
<KRouterLink
65+
v-if="!hasNoChannels"
3966
:primary="true"
4067
appearance="raised-button"
4168
:to="newExamRoute"
@@ -205,11 +232,14 @@
205232
import { getCurrentInstance, ref } from 'kolibri.lib.vueCompositionApi';
206233
import CoreTable from 'kolibri.coreVue.components.CoreTable';
207234
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
208-
import { ExamResource, UserSyncStatusResource } from 'kolibri.resources';
235+
import { ExamResource, UserSyncStatusResource, ChannelResource } from 'kolibri.resources';
209236
import plugin_data from 'plugin_data';
210237
import bytesForHumans from 'kolibri.utils.bytesForHumans';
211238
import { mapState, mapGetters } from 'kolibri.lib.vuex';
212239
import useSnackbar from 'kolibri.coreVue.composables.useSnackbar';
240+
import urls from 'kolibri.urls';
241+
import useUser from 'kolibri.coreVue.composables.useUser';
242+
import { enhancedQuizManagementStrings } from 'kolibri-common/strings/enhancedQuizManagementStrings';
213243
import { PageNames } from '../../../constants';
214244
import { PLAN_TABS_ID, PlanTabs } from '../../../constants/tabsConstants';
215245
import { coachStrings } from '../../common/commonCoachStrings';
@@ -247,6 +277,8 @@
247277
const showCloseConfirmationModal = ref(false);
248278
const activeQuiz = ref(null);
249279
const learnOnlyDevicesExist = ref(false);
280+
const { noResourcesAvailable$ } = enhancedQuizManagementStrings;
281+
const { canManageContent } = useUser();
250282
251283
initClassInfo().then(() => store.dispatch('notLoading'));
252284
@@ -329,6 +361,7 @@
329361
recipientsLabel$,
330362
sizeLabel$,
331363
canNoLongerEditQuizNotice$,
364+
noResourcesAvailable$,
332365
statusLabel$,
333366
newQuizAction$,
334367
filterQuizStatus$,
@@ -337,6 +370,13 @@
337370
avgScoreLabel$,
338371
entireClassLabel$,
339372
recipientSelected,
373+
canManageContent,
374+
};
375+
},
376+
data() {
377+
return {
378+
channels: [],
379+
isLoading: true,
340380
};
341381
},
342382
computed: {
@@ -458,8 +498,20 @@
458498
const size = bytesForHumans(sum);
459499
return size;
460500
},
501+
deviceContentUrl() {
502+
const deviceContentUrl = urls['kolibri:kolibri.plugins.device:device_management'];
503+
if (deviceContentUrl && this.canManageContent) {
504+
return `${deviceContentUrl()}#/content`;
505+
}
506+
507+
return '';
508+
},
509+
hasNoChannels() {
510+
return this.channels.length === 0;
511+
},
461512
},
462513
mounted() {
514+
this.fetchResources(); // Call the method to fetch the resources
463515
if (this.$route.query.snackbar) {
464516
this.createSnackbar(this.$route.query.snackbar);
465517
}
@@ -522,6 +574,18 @@
522574
nextRoute.name = nextRouteName;
523575
this.$router.push(nextRoute);
524576
},
577+
fetchResources() {
578+
this.isLoading = true;
579+
ChannelResource.fetchCollection({
580+
getParams: {
581+
contains_exercise: true,
582+
available: true,
583+
},
584+
}).then(data => {
585+
this.channels = data;
586+
this.isLoading = false;
587+
});
588+
},
525589
},
526590
$trs: {
527591
noExams: {
@@ -547,6 +611,10 @@
547611
context:
548612
"Title that displays on a printed copy of the 'Reports' > 'Lessons' page. This shows if the user uses the 'Print' option by clicking on the printer icon.",
549613
},
614+
adminLink: {
615+
message: 'Import channels to your device',
616+
context: 'Message for admin indicating the possibility of importing channels into Kolibri.',
617+
},
550618
},
551619
};
552620
@@ -577,4 +645,30 @@
577645
margin-bottom: 0.5em;
578646
}
579647
648+
.alert {
649+
position: relative;
650+
width: 100%;
651+
max-width: 1000px;
652+
padding: 0.5em;
653+
padding-left: 2em;
654+
margin: 1em auto 0;
655+
}
656+
657+
.warning-icon {
658+
position: absolute;
659+
top: 1em;
660+
left: 1em;
661+
width: 24px;
662+
height: 24px;
663+
}
664+
665+
.error-message {
666+
margin-left: 3em;
667+
font-size: 14px;
668+
}
669+
670+
.banner-spacing {
671+
margin: 0 0 1em;
672+
}
673+
580674
</style>

kolibri/plugins/coach/assets/src/views/plan/assignments/IndividualLearnerSelector.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<template #default="{ items }">
3333
<CoreTable
3434
:selectable="true"
35-
:emptyMessage="$tr('noUsersMatch')"
35+
:emptyMessage="emptyMessage"
3636
>
3737
<template #headers>
3838
<th class="table-checkbox-header">
@@ -92,6 +92,7 @@
9292
import { formatList } from 'kolibri.utils.i18n';
9393
import CoreTable from 'kolibri.coreVue.components.CoreTable';
9494
import PaginatedListContainer from 'kolibri.coreVue.components.PaginatedListContainer';
95+
import { enhancedQuizManagementStrings } from 'kolibri-common/strings/enhancedQuizManagementStrings';
9596
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
9697
import flatMap from 'lodash/flatMap';
9798
import forEach from 'lodash/forEach';
@@ -106,6 +107,13 @@
106107
name: 'IndividualLearnerSelector',
107108
components: { CoreTable, PaginatedListContainer },
108109
mixins: [commonCoreStrings, commonCoachStrings],
110+
setup() {
111+
const { noLearnersEnrolled$ } = enhancedQuizManagementStrings;
112+
113+
return {
114+
noLearnersEnrolled$,
115+
};
116+
},
109117
props: {
110118
// If true, the main checkbox is checked and the list of learners is shown
111119
isVisible: {
@@ -197,6 +205,11 @@
197205
itemsPerPage() {
198206
return DEFAULT_ITEMS_PER_PAGE;
199207
},
208+
emptyMessage() {
209+
return this.allLearners.length
210+
? this.$tr('noUsersMatch')
211+
: this.noLearnersEnrolled$({ className: this.className });
212+
},
200213
},
201214
methods: {
202215
fetchOutsideClassroom() {

0 commit comments

Comments
 (0)