hypothesis / lms

LTI app for integrating with learning management systems
BSD 2-Clause "Simplified" License
45 stars 14 forks source link

Courses endpoint with pagination #6387

Closed marcospri closed 1 week ago

marcospri commented 2 weeks ago

For:

Expose a API endpoint to list courses with pagination.

The intended use case is to list the courses in a drop down menu or similar to allow for filtering.

Example response

http://localhost:8001/api/dashboard/courses?limit=2

{
  "courses": [
    {
      "id": 1883,
      "title": "Copy of Developer Test Course with Sections Enabled (With Pags)"
    },
    {
      "id": 1829,
      "title": "Course copy LTI1.3"
    }
  ],
  "pagination": {
    "next": "http://localhost:8001/api/dashboard/courses?cursor=%5B%22Course+copy+LTI1.3%22%2C+1829%5D&limit=2"
  }
}

Testing

marcospri commented 1 week ago

Removed the base64-ing of the cursor

Also added the right type annotation to the method that build the pagination parameters. It doesn't takte a list of courses but rather a queryset (just Query[Course] in SQLA)