How to Bring AI Detection Into a Large Intro CS Course

The scale problem

Picture an introductory Python course with several hundred students each term, lab sections run by a large group of TAs, and a programming assignment every week. For years the integrity process has been familiar: run MOSS when something looks suspicious, follow up on near-identical code, escalate clear cases.

Large language models changed the picture. Some submissions are now too clean, too uniformly commented and suspiciously free of the small logic errors that mark a beginner still working things out. A perfect solution to a problem that usually produces off-by-one errors is a hunch, not proof, and hunches pile up faster than anyone can investigate them. At this scale you need a method that runs in batches, returns results a TA can review quickly and understands source code, not just prose.

Why code-specific detection matters

Detectors built for prose often perform poorly on source code. A Python script is not an essay: the repeated punctuation, rigid grammar and small vocabulary produce a different statistical signature, and a prose detector may return vague mid-range scores on hand-written code. A detector designed for code, such as Codequiry's AI code detector, looks at token patterns, structure and style signals in the code itself.

Structure-aware signals also hold up better when a student renames every variable in a generated solution, because renaming does not change control flow or token order.

Pilot with known samples first

Before running anything on live student work, build a small ground-truth set:

  • Human-written files from a previous term, ideally written under supervised conditions.
  • Files generated by current models from the assignment prompts, with a few prompt variations.
  • Blended files where a human-written stub was completed or "cleaned up" by a model.

Run them through the detector without labels, then compare. Check how many human files score high (your false positive risk), how many generated files score high (recall), and where blended files land. Blended files often fall in a middle band, which can be the most useful range for a teaching conversation rather than a disciplinary one. Repeat this check each term, because models change.

Codequiry AI code detection report with average and highest AI probability and a risk distribution
AI code detection: probability scores per file, flagging submissions likely written by ChatGPT, Copilot, Claude or Gemini.

What AI-generated Python tends to look like

Take a week-four assignment to process a list of bank transactions. A file like this stands out:


def process_transactions(initial_balance, transactions):
    """
    Processes a list of transaction tuples and returns the final balance
    along with a summary of deposit and withdrawal totals.

    Args:
        initial_balance (float): The starting account balance.
        transactions (list of tuple): Each tuple contains (type, amount)
            where type is 'deposit' or 'withdrawal'.

    Returns:
        tuple: (final_balance, total_deposits, total_withdrawals)
    """
    balance = initial_balance
    total_deposits = 0.0
    total_withdrawals = 0.0

    for txn_type, amount in transactions:
        if txn_type == 'deposit':
            balance += amount
            total_deposits += amount
        elif txn_type == 'withdrawal':
            if amount <= balance:
                balance -= amount
                total_withdrawals += amount
    return balance, total_deposits, total_withdrawals

The code works. In an introductory course, though, a Google-style docstring, type descriptions, an unrequested overdraft check and zero rough edges make the file an outlier against typical beginner work, which often still has inconsistent naming or leftover debugging. None of those traits proves anything alone. Together they are a reason to look more closely.

Combine signals: similarity, web matches and AI scores

AI detection works best alongside the checks you already run. Run each submission through peer similarity (token and AST fingerprinting), a web-source comparison against public repositories and answer sites, and the AI score, and read the three side by side. A file with a moderate AI score and a strong match to a public gist tells a different story from a file with a high AI score, low peer similarity and no web matches.

Codequiry result driller showing a code viewer, match explorer and per-submission analytics
Codequiry's result driller: the matched code, its source, and per-submission analytics on one screen.

Stacking signals also separates cases that look alike at first glance. A cluster of students who all copied the same Stack Overflow answer is web plagiarism, not AI use. A file with a moderate AI score and no other matches may be a student who accepted some autocomplete suggestions inside mostly self-written work, which is exactly the grey zone a policy needs to address.

Write the policy like a specification

A detector cannot decide what is allowed. The syllabus has to. State plainly what students may use AI for, for example explaining error messages, suggesting libraries or generating test cases with a citation in a comment, and what they may not, for example generating complete solution functions. Then define the review path:

  1. A TA reviews the code and the score.
  2. Above a set threshold, the TA has a short conversation with the student and asks them to walk through the code.
  3. Only clear cases, or cases where the student acknowledges prohibited use, go to the instructor's formal process.

A conversational middle step turns many flags into teaching moments. Students who did not understand the policy usually change after one conversation, and the formal process is kept for deliberate misuse.

Make the TA workflow fast

Without tooling, a TA who suspects AI use may spend a long time gathering circumstantial evidence for a single file. A batch scan reduces that to one run per section. With an API connection, the submission system can trigger the scan automatically, and TAs see a pre-sorted list with the highest scores at the top and a side-by-side view for each match. The time saved goes into conversations with students instead of detective work.

Codequiry dashboard home with recent checks showing peer, web and AI similarity scores
The Codequiry dashboard: recent checks at a glance with peer, web and AI similarity scores.

Track your own numbers

Measure your flag rate per assignment, how many flags hold up after review, and how often students who clearly wrote their own code score high. Re-run your ground-truth set each term. Many courses find that publishing the policy and explaining the checks early changes behaviour, but measure it in your own course rather than assuming. The code plagiarism checker for teachers keeps these results together across assignments.

Frequently Asked Questions

Can an AI code detector handle assignments of only 10 to 20 lines?

It will produce a score, but short files carry less signal, so confidence is lower. Treat a high score on a tiny fragment as "needs a conversation," not as a finding, and combine it with a web search and the student's earlier work.

Does it work beyond Python?

Codequiry's AI detector supports the languages commonly taught in CS courses, including Java, C++ and JavaScript. Run your own small pilot in each language you use, since signals differ between languages and assignment types.

What if a student used AI only for debugging and still gets flagged?

The detector scores the final code, not the process. A student who reads an AI explanation and then writes their own fix usually keeps the marks of human authorship. If a score is ambiguous, a citation requirement in the policy and a short walkthrough of the code give you the context the score cannot.

If your course faces the same scale problem, you can try combined AI code detection and similarity checking on a past assignment before rolling it out.