Skip to content

Commit

Permalink
lessons can be filter by recipents
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanOXDi committed Dec 5, 2024
1 parent de0c759 commit 7055012
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions kolibri/plugins/coach/assets/src/views/lessons/LessonsRootPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
:inline="true"
/>
<KSelect
v-model="filterRecipents"
:value="{ label: coreString('allLabel'), value: coreString('allLabel') }"
class="select"
:label="coachString('recipientsLabel')"
:options="[]"
:options="recipientOptions"
:inline="true"
/>
</div>
Expand Down Expand Up @@ -196,6 +197,7 @@
import useSnackbar from 'kolibri/composables/useSnackbar';
import CoachAppBarPage from '../CoachAppBarPage';
import commonCoach from '../common';
import { coachStrings } from '../common/commonCoachStrings';
import AssignmentDetailsModal from '../common/assignments/AssignmentDetailsModal';
import { useLessons } from '../../composables/useLessons';
import ReportsControls from '../common/ReportsControls';
Expand All @@ -216,10 +218,11 @@
mixins: [commonCoach, commonCoreStrings],
setup() {
const { show } = useKShow();
const { entireClassLabel$ } = coachStrings;
const { lessonsAreLoading } = useLessons();
const { createSnackbar } = useSnackbar();
const { windowIsSmall } = useKResponsiveWindow();
return { show, lessonsAreLoading, createSnackbar, windowIsSmall };
return { show, lessonsAreLoading, createSnackbar, windowIsSmall, entireClassLabel$ };
},
data() {
return {
Expand All @@ -228,6 +231,10 @@
showLessonIsNotVisibleModal: false,
activeLesson: null,
filterSelection: {},
filterRecipents: {
label: this.entireClassLabel$(),
value: this.entireClassLabel$(),
},
detailsModalIsDisabled: false,
dontShowAgainChecked: false,
learnOnlyDevicesExist: false,
Expand All @@ -241,7 +248,7 @@
...mapState('lessonsRoot', ['lessons', 'learnerGroups']),
sortedLessons() {
const sorted = this._.orderBy(this.lessons, ['date_created'], ['desc']);
return sorted.map(lesson => {
const allLessons = sorted.map(lesson => {
const learners = this.getLearnersForLesson(lesson);
const sortedLesson = {
totalLearners: learners.length,
Expand All @@ -253,6 +260,13 @@
Object.assign(sortedLesson, lesson);
return sortedLesson;
});
if(this.filterRecipents.label === this.entireClassLabel$()){
return allLessons;
}
return allLessons.filter(lesson=>{
return lesson.recipientNames.includes(this.filterRecipents.label);
});
},
userHasDismissedModal() {
return Lockr.get(LESSON_VISIBILITY_MODAL_DISMISSED);
Expand Down Expand Up @@ -301,6 +315,27 @@
}
return null;
},
recipientOptions(){
const groupOptions = this.groups.map(group => ({
label: group.name,
value: group.id,
}));
const learnerOptions = this.learners.map(learner => ({
label: learner.name,
value: learner.id,
}));
return [
{
label: this.entireClassLabel$(),
value: this.entireClassLabel$(),
},
...groupOptions,
...learnerOptions,
];
},
},
beforeMount() {
this.filterSelection = this.filterOptions[0];
Expand Down

0 comments on commit 7055012

Please sign in to comment.