Function get_assignment_stats

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

GET /api/modules/{module_id}/assignments/{assignment_id}/stats

Retrieve submission statistics for a specific assignment. Only accessible by lecturers assigned to the module.

§Path Parameters

  • module_id (i64): The ID of the module containing the assignment
  • assignment_id (i64): The ID of the assignment to get statistics for

§Responses

  • 200 OK
{
  "success": true,
  "message": "Stats retrieved successfully",
  "data": {
    "assignment_id": 123,
    "total_submissions": 15,
    "unique_submitters": 12,
    "late_submissions": 3,
    "per_student_submission_count": [
      {
        "user_id": 456,
        "username": "john.doe",
        "count": 2,
        "latest_at": "2024-01-31T23:59:59Z",
        "latest_late": false
      },
      {
        "user_id": 789,
        "username": "jane.smith",
        "count": 1,
        "latest_at": "2024-02-01T01:30:00Z",
        "latest_late": true
      }
    ]
  }
}
  • 404 Not Found
{
  "success": false,
  "message": "Assignment not found"
}
  • 500 Internal Server Error
{
  "success": false,
  "message": "Database error" // or "Failed to fetch student numbers"
}