pub async fn get_my_grades(
__arg0: State<AppState>,
__arg1: Extension<AuthUser>,
__arg2: Query<GetGradesQuery>,
) -> impl IntoResponse
Expand description
GET /api/me/grades
Retrieves a paginated list of grades for the authenticated user.
The behavior of this endpoint changes based on the role
query parameter,
allowing users to view grades based on their permissions.
§Authorization
Requires a valid bearer token.
§Query Parameters
page
(optional, u64, min: 1): The page number for pagination. Defaults to 1.per_page
(optional, u64, min: 1, max: 100): The number of items per page. Defaults to 20.query
(optional, string): A search term to filter grades by assignment title, student username, or module code.role
(optional, string): The role to filter by. Can beStudent
,Tutor
,AssistantLecturer
, orLecturer
. Defaults toStudent
.- If
Student
, returns only the authenticated user’s grades. - If
Lecturer
,Tutor
, etc., returns grades for all students in modules where the user holds that role.
- If
year
(optional, i32): Filters grades by the module’s academic year.sort
(optional, string): A comma-separated list of fields to sort by. Prefix with-
for descending order.- Allowed fields:
score
,created_at
.
- Allowed fields:
§Response: 200 OK
Returns a paginated list of grades.
{
"success": true,
"message": "Grades retrieved successfully",
"data": {
"grades": [
{
"id": 1,
"score": {
"earned": 85,
"total": 100
},
"percentage": 85.0,
"created_at": "2025-08-17T10:00:00",
"updated_at": "2025-08-17T11:30:00",
"module": {
"id": 101,
"code": "CS101"
},
"assignment": {
"id": 201,
"title": "Introduction to Programming"
},
"user": {
"id": 42,
"username": "student_user"
}
}
],
"page": 1,
"per_page": 20,
"total": 1
}
}
§Error Responses
400 Bad Request
: Invalid query parameters (e.g.,page
out of range).403 Forbidden
: Missing or invalid authentication token.500 Internal Server Error
: Database or other internal errors.