Function run_moss_check

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

POST /api/modules/{module_id}/assignments/{assignment_id}/plagiarism/moss

Runs a MOSS check on the latest submission for every student on the assignment, then parses the report and auto-creates plagiarism cases for each matched pair. Each created case is inserted with:

  • status = "review"
  • similarity as a float percentage (0.0–100.0) taken from MOSS’ total_percent
  • a generated, human-readable description

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 submissions

§Request Body

None. The programming language is read from the assignment configuration (project.language) persisted for this assignment.

§Returns

  • 200 OK on success with details about the MOSS run and case creation:
    {
      "success": true,
      "message": "MOSS check completed successfully; cases created from report",
      "data": {
        "report_url": "http://moss.stanford.edu/results/123456789",
        "cases_created": 7,
        "cases_skipped": 2,
        "title": "moss results for ... (optional)"
      }
    }
  • 500 INTERNAL SERVER ERROR for MOSS server errors, parsing failures, or other unexpected failures. The response body contains an error message.

§Notes

  • Language is taken from the saved assignment config (project.language).
  • Base (starter) files attached to the assignment are included in the comparison if present.
  • The selected submissions are the most recent (highest attempt) per user.
  • Case creation is deduplicated per pair of submissions (order-independent).
  • similarity is stored as an f32 percent, clamped to 0.0–100.0.
  • Newly created cases start in "review" status and can be managed via the plagiarism cases API/UI.