DocGuard
AI and plagiarism detection for PDF and Word document submissions. Extracts text from student-submitted files, detects question/answer sections, and scores each answer across 12 independent signals — producing a Low / Medium / High risk badge per submission with a full per-question breakdown report.
⭐ Why this plugin is unlike anything else available
Detects AI-assisted document submissions without an external service
▸ DocGuard analyses the linguistic patterns of submitted documents — perplexity, burstiness, sentence-length distribution, and vocabulary entropy — to identify characteristics consistent with AI-generated or AI-assisted writing. All analysis runs inside Moodle with no external API call.
▸ Works on uploaded file submissions (DOCX, PDF, TXT) not just typed text. Students who use AI to generate a document, then upload it as their own work, are flagged at the same rate as students who type AI text directly.
▸ Results are probabilistic, not binary. The report shows a confidence score with the specific signals that contributed to it — giving teachers the context to make a professional judgment, not a system verdict.
DocGuard is a Moodle™ Plagiarism Plugin that analyses the text content of student-submitted PDF and Word (.docx) files for signs of AI-generated content and student-to-student copying. Unlike Essay Guard which monitors the live typing process, DocGuard works on the finished document — making it ideal for assessments where students upload files rather than type directly into Moodle™.
When a student uploads a file to a Moodle™ Assignment, DocGuard extracts the text, detects the question structure, and scores each answer section independently across 12 linguistic and similarity signals. Teachers see a Low / Medium / High risk badge next to each submission in the grading interface, with a detailed per-question breakdown report one click away.
The Problem
- Students submit AI-generated PDFs and Word documents
- Text similarity tools miss original AI content — it's never been seen before
- Teachers have no way to quickly flag suspicious file submissions
- Cross-student sharing of answers is hard to detect at scale
- Reviewing dozens of documents manually for AI markers is time-consuming
The Solution
- Automatically extracts text from PDF and .docx submissions
- Detects question/answer sections — each answer scored independently
- 12-signal scoring: AI vocabulary, style consistency, cross-student similarity
- Low / Medium / High badge visible to teachers in the grading interface
- Detailed per-question breakdown report with evidence excerpts
- No external service — all analysis runs inside Moodle™
When a student uploads a .pdf or .docx file to a Moodle™ Assignment, DocGuard's event observer fires automatically via Moodle's assignsubmission_file_uploaded event.
DOCX files are unzipped and parsed via PHP's ZipArchive and DOMDocument — no external libraries required. PDF files are converted to text using the pdftotext command-line tool (if installed on the server) with a pure-PHP FlateDecode stream fallback for basic PDFs.
DocGuard scans the text for common question patterns — 'Question 1', 'Q 1:', 'Activity 2', 'Task 3', numbered list items. If no structure is found, the whole document is treated as a single section.
Each question/answer section is run through the 12-signal analyser independently. Signals check for AI vocabulary markers, sentence uniformity, transition word overuse, contraction absence, passive voice ratio, template phrases, trigram repetition, and more.
After each submission is processed, Signal 12 compares bigram (two-word pair) overlap between all students in the same assignment using Jaccard similarity. This catches shared content even when lightly paraphrased.
The final weighted score (0–100) maps to Low (0–34), Medium (35–64), or High (65–100) risk. A coloured badge appears inline next to the student's file in the assignment grading interface. Only teachers with the plagiarism/docguard:viewreport capability see the badge — students do not.
Linguistic signals consistent with genuine student writing. Low likelihood of AI-generated or copied content.
One or more signals present. Warrants a closer look at the submission alongside the detailed report.
Multiple strong indicators detected. Recommended for academic integrity review.
Extracted using PHP's built-in ZipArchive and DOMDocument. DOCX files are internally ZIP archives containing an XML document — DocGuard parses the word/document.xml file directly. No external libraries or server software required.
Primary extraction uses pdftotext (part of the poppler-utils package). If pdftotext is not installed, a pure-PHP FlateDecode stream parser is used as a fallback for basic PDFs. Complex PDFs with scanned images (no text layer) are not supported.
Moodle™ Assignment only. DocGuard works with the Moodle™ Assignment activity using file submissions. It does not analyse text typed directly into online text submissions — that is Essay Guard's role.
Every answer section is scored across 12 independent signals. The total weighted score (0–100) determines the risk level. No single signal is definitive — the risk level reflects the combined weight of multiple indicators.
AI Marker Vocabulary
Checks for 50+ ChatGPT/LLM characteristic phrases — 'delve into', 'it is important to note', 'in the realm of', 'comprehensive understanding', 'leverage', 'multifaceted', 'nuanced approach', 'it is worth noting', and similar terms that appear disproportionately in AI-generated text. Each phrase hit adds to the score.
Sentence Length Uniformity
Measures the standard deviation of sentence lengths across the answer. Human writers vary their sentence length naturally — short punchy sentences mixed with longer explanatory ones. AI-generated text tends to produce sentences of unnaturally consistent length. A low standard deviation scores higher.
Type-Token Ratio Uniformity
Splits the answer into paragraphs and checks how consistently the unique-words-to-total-words ratio (TTR) appears in each. Humans have natural vocabulary variation across paragraphs. AI tends to produce eerily consistent TTR across all sections. Low variance between paragraph TTR scores triggers this signal.
Formal Transition Overuse
Counts transition phrases per 100 words — 'Furthermore', 'Moreover', 'Additionally', 'In addition', 'Consequently', 'Subsequently', 'Nevertheless', 'Notwithstanding'. AI uses these at roughly 3–5× the rate of human writers. Answers exceeding the threshold score points on this signal.
Contraction Absence
Checks for contractions (don't, it's, we're, can't, won't, I'd, they've) in answers over 150 words. Human writers naturally use contractions in informal assessment responses. AI almost exclusively writes in formal full forms. An answer with zero contractions in a long response is flagged.
Passive Voice Ratio
Calculates the percentage of sentences using passive voice constructions ('was completed by', 'is considered to be', 'have been identified as', 'it is suggested that'). AI generates passive voice at roughly 2× the human rate. Answers over the threshold score on this signal.
Template Pattern Detection
Detects generic AI intro and conclusion templates: 'This essay will discuss...', 'In conclusion, it can be seen that...', 'This response will explore...', 'To summarise the above...', 'In the context of this question...'. These formulaic openers and closers are a strong AI indicator when found in short assessment answers.
Trigram Repetition
Counts the ratio of unique three-word sequences (trigrams) to total trigrams across the answer. AI text reuses certain three-word patterns more than human writing. A low uniqueness ratio — meaning many trigrams are repeated — scores on this signal.
Sentence-Start Uniformity
Analyses how sentences begin across the answer. AI tends to start sentences with the same words or types of phrases repeatedly (e.g., multiple sentences beginning with 'The', 'This', 'In', 'It'). A high repetition rate in sentence-opening words scores on this signal.
Vocabulary Richness Extremity
Flags answers that are either suspiciously sophisticated (type-token ratio far above class average, suggesting AI-generated advanced vocabulary) or suspiciously plain (very low TTR suggesting templated/repetitive language). Both extremes relative to the submission context are scored.
Cross-Section Style Inconsistency
Compares the linguistic style between different questions/sections in the same document. If Question 1 reads like a nervous student and Question 4 reads like a PhD thesis, it suggests the student only AI-generated some answers. Detects significant style shifts using vocabulary and sentence structure comparison.
Cross-Student Jaccard Similarity
Compares every student's answer to every other student's answer using bigram (two-word pair) overlap — the Jaccard similarity index. Catches copy-paste sharing between students even when surface text has been lightly paraphrased. The most heavily weighted signal because shared content between students is the most reliable indicator of academic misconduct.
Risk Level Thresholds (score out of 100)
Risk Badge (Grading Interface)
A Low / Medium / High badge appears inline next to each student's uploaded file in the Assignment grading interface. Clicking the badge opens the full report. Only users with the plagiarism/docguard:viewreport capability can see it — students cannot.
Per-Student Report
The full report shows a section-by-section breakdown: which signals fired on each question, the score each signal contributed, and example text excerpts from the student's own document as evidence. Colour-coded by signal severity.
Class Report & Similarity Matrix
The class report lists all students with their overall risk score and per-question breakdown. A cross-student similarity matrix highlights which pairs of students had high bigram overlap — the fastest way to spot shared answers across the cohort.
Section-Level Scoring
Each detected question/answer section gets its own score. If a student genuinely answered Q1 but used AI for Q3, the per-section scoring will show Q1 as Low and Q3 as High — rather than averaging everything into a misleading overall score.
