Function get_assignments

Source
pub async fn get_assignments(
    __arg0: State<AppState>,
    __arg1: Path<i64>,
    __arg2: Query<FilterReq>,
) -> impl IntoResponse
Expand description

GET /api/modules/{module_id}/assignments

Retrieve a paginated and optionally filtered list of assignments for a module. Accessible to users assigned to the module.

§Path Parameters

  • module_id (i64): The ID of the module to retrieve assignments from

§Query Parameters

  • page (optional, i32): Page number for pagination. Defaults to 1, minimum value is 1
  • per_page (optional, i32): Number of items per page. Defaults to 20, maximum is 100, minimum is 1
  • sort (optional, string): Comma-separated list of fields to sort by. Prefix with - for descending order (e.g., -due_date)
  • query (optional, string): Case-insensitive substring match applied to both name and description
  • name (optional, string): Case-insensitive filter to match assignment names
  • assignment_type (optional, string): Filter by assignment type (“Assignment” or “Practical”)
  • available_before (optional, string): Filter assignments available before this date/time (ISO 8601)
  • available_after (optional, string): Filter assignments available after this date/time (ISO 8601)
  • due_before (optional, string): Filter assignments due before this date/time (ISO 8601)
  • due_after (optional, string): Filter assignments due after this date/time (ISO 8601)

Allowed sort fields: name, description, due_date, available_from, assignment_type, created_at, updated_at

§Responses

  • 200 OK
{
  "success": true,
  "message": "Assignments retrieved successfully",
  "data": {
    "assignments": [
      {
        "id": 123,
        "module_id": 456,
        "name": "Assignment 1",
        "description": "This is a sample assignment",
        "assignment_type": "Assignment",
        "available_from": "2024-01-01T00:00:00Z",
        "due_date": "2024-01-31T23:59:59Z",
        "created_at": "2024-01-01T00:00:00Z",
        "updated_at": "2024-01-01T00:00:00Z"
      }
    ],
    "page": 1,
    "per_page": 20,
    "total": 1
  }
}
  • 400 Bad Request
{
  "success": false,
  "message": "Invalid field used" // or "Invalid assignment_type"
}
  • 500 Internal Server Error
{
  "success": false,
  "message": "<database error details>"
}