kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Backend: Course assignment API endpoints

Open rtibbles opened this issue 1 month ago • 0 comments

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:

  1. kolibri/core/courses/viewsets.py

    • Create CourseAssignmentSerializer
    • Create CourseAssignmentViewSet with KolibriAuthPermissions
    • Filter queryset to only show assignments for accessible collections
  2. kolibri/core/courses/api_urls.py

    • Register CourseAssignmentViewSet with router
    • Register URLs in main Kolibri API configuration
  3. 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

  1. Use KolibriAuthPermissions - Defers to model's RoleBasedPermissions

  2. Handle missing courses - Return semantic 400 error when assignment references a ContentNode that doesn't exist on the device

  3. 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

rtibbles avatar Dec 05 '25 02:12 rtibbles