pub async fn create_assignment(
__arg0: State<AppState>,
__arg1: Path<i64>,
__arg2: Json<AssignmentRequest>,
) -> impl IntoResponse
Expand description
POST /api/modules/{module_id}/assignments
Create a new assignment in a module.
The assignment is always created in the setup
state by default.
Only accessible by lecturers or admins assigned to the module.
§Path Parameters
module_id
(i64
): The ID of the module to create the assignment in.
§Request Body (JSON)
name
(string
, required): The name of the assignment.description
(string
, optional): A description of the assignment.assignment_type
(string
, required): The type of assignment. Must be either"assignment"
or"practical"
.available_from
(string
, required): The date/time from which the assignment is available (ISO 8601 format).due_date
(string
, required): The due date/time for the assignment (ISO 8601 format).
§Responses
200 OK
{
"success": true,
"message": "Assignment created successfully",
"data": {
"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"
}
}
400 Bad Request
{
"success": false,
"message": "Invalid available_from datetime" // or "Invalid due_date datetime" or "assignment_type must be 'assignment' or 'practical'"
}
500 Internal Server Error
{
"success": false,
"message": "Assignment could not be inserted" // or "Database error"
}