Function update_plagiarism_case

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

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

Updates an existing plagiarism case’s description, status, and/or similarity percentage. Accessible only to lecturers and assistant lecturers assigned to the module.

§Path Parameters

  • module_id: The ID of the parent module
  • assignment_id: The ID of the assignment containing the plagiarism case
  • case_id: The ID of the plagiarism case to update

§Request Body

Accepts a JSON payload with optional fields (at least one must be provided):

  • description (string): New description for the case
  • status (string): New status (“review”, “flagged”, or “reviewed”)
  • similarity (number): New similarity percentage in [0.0, 100.0]

§Returns

  • 200 OK with the updated plagiarism case on success
  • 400 BAD REQUEST for invalid parameters or missing update fields
  • 403 FORBIDDEN if user lacks required permissions
  • 404 NOT FOUND if the specified plagiarism case doesn’t exist
  • 500 INTERNAL SERVER ERROR for database errors or update failures

§Example Request

{
  "description": "Lecturer has reviewed the case and added comments.",
  "status": "reviewed",
  "similarity": 68.25
}

§Example Response (200 OK)

{
  "success": true,
  "message": "Plagiarism case updated successfully",
  "data": {
    "id": 17,
    "assignment_id": 3,
    "submission_id_1": 42,
    "submission_id_2": 51,
    "description": "Lecturer has reviewed the case and added comments.",
    "status": "reviewed",
    "similarity": 68.25,
    "created_at": "2024-05-20T14:30:00Z",
    "updated_at": "2024-05-20T15:45:00Z"
  }
}

§Example Responses

  • 400 Bad Request (missing update fields)
{
  "success": false,
  "message": "At least one field (description, status, or similarity) must be provided"
}
  • 400 Bad Request (invalid status)
{
  "success": false,
  "message": "Invalid status value. Must be one of: 'review', 'flagged', 'reviewed'"
}
  • 400 Bad Request (invalid similarity)
{
  "success": false,
  "message": "Invalid similarity: must be between 0 and 100"
}
  • 404 Not Found
{
  "success": false,
  "message": "Plagiarism case not found"
}
  • 500 Internal Server Error
{
  "success": false,
  "message": "Failed to update plagiarism case"
}