kolibri
kolibri copied to clipboard
Backend: Feature flag for courses based on content availability
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
Implement a soft feature flag for course functionality by checking if any courses exist on the device. This enables the courses feature only when course content is available.
Implementation
Add to Coach Plugin Data
File: kolibri/plugins/coach/kolibri_plugin.py
Add a courses_exist check similar to the existing practice_quizzes_exist:
from le_utils.constants import modalities
@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()
courses_exist = ContentNode.objects.filter(
available=True, modality=modalities.COURSE
).exists()
return {
"practice_quizzes_exist": practice_quizzes_exist,
"courses_exist": courses_exist,
}
Note: The practice_quizzes_exist check will be updated to use the modality field in issue #13267.
Benefits
- Automatic enablement: Courses feature appears when course content is imported
- No configuration needed: Works automatically based on content availability
- Performant: Uses indexed
modalityfield for O(log n) check - Consistent pattern: Follows existing
practice_quizzes_existapproach
Frontend Integration
The courses_exist value will be available in the frontend via plugin data and can be used to conditionally show/hide the courses tab.