Function get_graph

Source
pub async fn get_graph(
    __arg0: State<AppState>,
    __arg1: Path<(i64, i64)>,
    __arg2: Query<PlagiarismQuery>,
) -> impl IntoResponse
Expand description

GET /api/modules/{module_id}/assignments/{assignment_id}/plagiarism/graph

Builds a user-to-user plagiarism graph for the given assignment. Each edge indicates that there is at least one plagiarism case linking submissions from the two users.

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 whose plagiarism graph should be built

§Query Parameters

  • status (optional): Filter edges by case status. One of:
    • "review"
    • "flagged"
    • "reviewed"

§Semantics

  • Nodes are usernames derived from the submissions involved in cases.
  • Each returned Link { source, target } represents a directed edge from source user to target user for at least one case. (If multiple cases exist between the same pair, multiple identical edges may appear; if you prefer deduplication, apply it in your client or adjust the endpoint to de-duplicate.)
  • Only cases where both submissions belong to the specified assignment are considered.

§Returns

  • 200 OK with a links array (possibly empty) on success
  • 400 BAD REQUEST if status is provided but invalid
  • 500 INTERNAL SERVER ERROR if submissions, users, or cases could not be fetched

§Example Request

GET /api/modules/12/assignments/34/plagiarism/graph?status=flagged

§Example Response (200 OK)

{
  "success": true,
  "message": "Plagiarism graph retrieved successfully",
  "data": {
    "links": [
      { "source": "u12345678", "target": "u87654321" },
      { "source": "u13579246", "target": "u24681357" }
    ]
  }
}

§Example Response (Empty Graph)

{
  "success": true,
  "message": "Plagiarism graph retrieved successfully",
  "data": { "links": [] }
}

§Example Response (400 Bad Request)

{
  "success": false,
  "message": "Invalid status parameter"
}

§Notes

  • This endpoint is optimized for visualization. If you need case details, use the list endpoint (GET /plagiarism) instead.
  • Edges are derived from the current cases in the database after any filtering.
  • Usernames are taken from the submissions’ authors at query time.