kolibri
kolibri copied to clipboard
Backend: Course assignment API endpoints
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
Create REST API endpoints for managing course assignments in the kolibri/core/courses/ app, following the pattern established by Lesson and Exam viewsets.
Implementation
Files to create/modify:
-
kolibri/core/courses/viewsets.py- Create
CourseAssignmentSerializer - Create
CourseAssignmentViewSetwithKolibriAuthPermissions - Filter queryset to only show assignments for accessible collections
- Create
-
kolibri/core/courses/api_urls.py- Register
CourseAssignmentViewSetwith router - Register URLs in main Kolibri API configuration
- Register
-
kolibri/core/courses/test/test_api.py- Test CRUD operations
- Test permission checks (coaches/admins can manage, learners cannot)
- Test collection filtering (users only see their accessible assignments)
- Test 400 error when assignment references non-existent ContentNode
Key Requirements
-
Use KolibriAuthPermissions - Defers to model's
RoleBasedPermissions -
Handle missing courses - Return semantic 400 error when assignment references a ContentNode that doesn't exist on the device
-
Filter by collection access - Users only see assignments for collections they can access
API Endpoints
-
GET /api/courseassignment/- List assignments -
POST /api/courseassignment/- Create assignment -
GET /api/courseassignment/{id}/- Get assignment -
PATCH /api/courseassignment/{id}/- Update assignment -
DELETE /api/courseassignment/{id}/- Delete assignment
References
- Lessons viewsets:
kolibri/core/lessons/viewsets.py - Lessons tests:
kolibri/core/lessons/test/test_lesson_api.py - KolibriAuthPermissions:
kolibri/core/auth/api.py