pub async fn edit_task(
__arg0: State<AppState>,
__arg1: Path<(i64, i64, i64)>,
__arg2: Json<EditTaskRequest>,
) -> impl IntoResponse
Expand description
PUT /api/modules/{module_id}/assignments/{assignment_id}/tasks/{task_id}
Edit the command of a specific task within an assignment. Accessible to users with Lecturer or Admin roles assigned to the module.
This endpoint allows updating the command that will be executed during task evaluation. The command can be any shell command that can be executed in the evaluation environment.
§Path Parameters
module_id
(i64): The ID of the module containing the assignmentassignment_id
(i64): The ID of the assignment containing the tasktask_id
(i64): The ID of the task to edit
§Request Body
{
"command": "cargo test --lib --release"
}
§Request Body Fields
command
(string, required): The new command to execute for this task (e.g., test commands, build scripts)
§Example Request
curl -X PUT http://localhost:3000/api/modules/1/assignments/2/tasks/3 \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"command": "cargo test --lib --release"
}'
§Success Response (200 OK)
{
"success": true,
"message": "Task updated successfully",
"data": {
"id": 3,
"task_number": 1,
"command": "cargo test --lib --release",
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T12:30:00Z"
}
}
§Error Responses
400 Bad Request - Invalid JSON body
{
"success": false,
"message": "Invalid JSON body"
}
403 Forbidden - Insufficient permissions
{
"success": false,
"message": "Access denied"
}
404 Not Found - Resource not found
{
"success": false,
"message": "Module not found"
}
or
{
"success": false,
"message": "Assignment not found"
}
or
{
"success": false,
"message": "Task not found"
}
or
{
"success": false,
"message": "Assignment does not belong to this module"
}
or
{
"success": false,
"message": "Task does not belong to this assignment"
}
422 Unprocessable Entity - Validation error
{
"success": false,
"message": "'command' must be a non-empty string"
}
500 Internal Server Error - Database or server error
{
"success": false,
"message": "Database error retrieving module"
}
or
{
"success": false,
"message": "Failed to update task"
}
§Validation Rules
command
must not be empty or whitespace-only- Module must exist
- Assignment must exist and belong to the specified module
- Task must exist and belong to the specified assignment
§Notes
- Only the command field can be updated; task_number and other fields remain unchanged
- The updated task will be used in future assignment evaluations
- Task editing is restricted to users with appropriate module permissions
- The
updated_at
timestamp is automatically set when the task is modified