Function edit_assignment

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

PUT /api/modules/{module_id}/assignments/{assignment_id}

Edit an existing assignment in a module. Only accessible by lecturers or admins assigned to the module.

This endpoint allows updating general details of the assignment but does not allow editing its status. Status transitions (e.g., from setup to ready) are handled automatically based on readiness checks.

§Path Parameters

  • module_id (i64): The ID of the module containing the assignment.
  • assignment_id (i64): The ID of the assignment to edit.

§Request Body (JSON)

  • name (string, required): The new name of the assignment.
  • description (string, optional): The new description of the assignment.
  • assignment_type (string, required): The type of assignment. Must be either "assignment" or "practical".
  • available_from (string, required): The new date/time from which the assignment is available (ISO 8601 format).
  • due_date (string, required): The new due date/time for the assignment (ISO 8601 format).

§Responses

  • 200 OK
{
  "success": true,
  "message": "Assignment updated successfully",
  "data": { /* updated assignment details */ }
}
  • 400 Bad Request
{
  "success": false,
  "message": "Invalid available_from datetime format"
}
  • 404 Not Found
{
  "success": false,
  "message": "Assignment not found"
}
  • 500 Internal Server Error
{
  "success": false,
  "message": "Failed to update assignment"
}

§Notes

  • The status field of the assignment cannot be updated with this endpoint.
  • Status is managed automatically by the system when all readiness checks pass.