Skip to content

Commit

Permalink
Use plugin_data to query db for folders with practice quizzes
Browse files Browse the repository at this point in the history
  • Loading branch information
sairina committed Nov 16, 2021
1 parent 21e85b0 commit 71d4f37
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,11 @@
import CoreTable from 'kolibri.coreVue.components.CoreTable';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import { ContentNodeKinds } from 'kolibri.coreVue.vuex.constants';
import { ContentNodeResource, ExamResource } from 'kolibri.resources';
import { mapGetters } from 'vuex';
import { ExamResource } from 'kolibri.resources';
import { PageNames } from '../../../constants';
import commonCoach from '../../common';
import PlanHeader from '../../plan/PlanHeader';
import plugin_data from 'plugin_data';
export default {
name: 'CoachExamsPage',
Expand All @@ -175,14 +174,15 @@
// },
showOpenConfirmationModal: false,
showCloseConfirmationModal: false,
practiceQuizzesExist: true,
};
},
computed: {
...mapGetters(['getChannels']),
sortedExams() {
return this._.orderBy(this.exams, ['date_created'], ['desc']);
},
practiceQuizzesExist() {
return plugin_data.practice_quizzes_exist;
},
// Hidden temporarily per https://github.com/learningequality/kolibri/issues/6174
// Uncomment this once we use the filters again.
/*
Expand Down Expand Up @@ -228,34 +228,6 @@
];
},
},
mounted() {
this.$nextTick(() => {
let channelIds = this.getChannels.map(channel => channel.id);
let array = [];
let results = channelIds.map(id => {
return ContentNodeResource.fetchCollection({
getParams: {
parent: id,
kind_in: [ContentNodeKinds.TOPIC, ContentNodeKinds.EXERCISE],
contains_quiz: true,
},
}).then(results => {
if (results.length !== 0) {
array.push(results);
}
});
});
Promise.all(results)
.then(() => {
if (array.length === 0) {
this.practiceQuizzesExist = false;
}
})
.catch(err => console.log(err));
});
},
methods: {
handleOpenQuiz(quizId) {
let promise = ExamResource.saveModel({
Expand Down
11 changes: 11 additions & 0 deletions kolibri/plugins/coach/kolibri_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,14 @@ class CoachNavItem(NavigationHook):
@register_hook
class CoachAsset(webpack_hooks.WebpackBundleHook):
bundle_id = "app"

@property
def plugin_data(self):
from kolibri.core.content.models import ContentNode

practice_quizzes_exist = ContentNode.objects.filter(
available=True, options__contains='"modality": "QUIZ"'
).exists()
return {
"practice_quizzes_exist": practice_quizzes_exist,
}

0 comments on commit 71d4f37

Please sign in to comment.