Features Architecture Workflow API Deployment Setup GitHub
FastAPI PostgreSQL YOLO + CRNN Moodle LMS

Intelligent Examination Submission Framework

For Learning Management Systems

An AI-powered bridge between physical examination papers and Moodle LMS. Features Smart Scan using YOLO & CRNN models, CIA exam management, attempt control, and automated email notifications.

AI-Powered
Smart Scan
20+
API Endpoints
CIA-1/2
Exam Support
100%
Audit Trail
Upload → Verify → Submit Pipeline
1
Staff Bulk Upload
Drag & drop scanned answer sheets
2
Smart Scan AI
YOLO + CRNN extract register no. & subject
3
Student Verification
Preview PDF & confirm submission
4
Moodle Submission
Auto-submit to correct Moodle assignment

The Problem

Academic institutions transitioning to digital grading face major logistical hurdles with physical answer scripts.

Manual Labor

Individually scanning, renaming, and uploading hundreds of answer scripts is time-consuming and inefficient.

Human Error

Manual processes are prone to uploading wrong files or mislabeling student submissions.

Security & Integrity

Unverified uploads can compromise the chain of custody for examination papers.

No Verification

Students lack a mechanism to verify their paper was scanned correctly before grading.

The Solution

A 3-Step “Upload → Verify → Push” workflow with AI-powered Smart Scan and secure student verification.

1

Bulk Ingestion

Staff uploads scanned PDFs via drag & drop. AI extracts metadata automatically.

2

Intelligent Processing

YOLO detects regions, CRNN reads register numbers and subject codes from paper.

3

Student-Led Submission

Students verify their papers and submit to Moodle, ensuring non-repudiation.

Core Concept

An intelligent intermediary between the physical examination hall and the digital grading environment, ensuring secure validation and student verification at every step.

Non-repudiation Audit Trail Secure Tokens AI Extraction

Key Features

A comprehensive feature set covering the entire examination submission lifecycle.

Smart Scan AI

Scanner agent with YOLO object detection and CRNN text recognition extracts register numbers and subject codes from scanned answer sheets automatically.

HuggingFace Spaces

Bulk Upload

Drag and drop hundreds of scanned files at once. Per-file savepoints ensure partial failures don't lose progress. Duplicate detection built-in.

Staff Portal

CIA-1 / CIA-2 Exams

Full CIA exam type separation. Uniqueness constraints respect exam type. Students can submit CIA-1 and CIA-2 independently.

Exam Management

Attempt Management

Admin-controlled lock/unlock per attempt. Attempt 2 requires Attempt 1 completed. Each attempt creates a separate artifact.

Admin Control

Email Notifications

SendGrid/SMTP integration sends upload confirmation emails to students via Moodle email lookup. Fully async and non-blocking.

SendGrid

Student Portal

Students verify their papers via secure PDF viewer, view dashboard stats, and submit to Moodle — all with real-time status updates.

Moodle SSO

Subject & Student Mapping

Admin maps subject codes to Moodle assignments and register numbers to Moodle usernames. Auto-discover from Moodle courses.

Admin Panel

Database-Backed Storage

Self-healing file persistence for cloud deployments. File content stored in PostgreSQL to survive Render’s ephemeral filesystem.

Cloud-Ready

Security & Audit

bcrypt password hashing, AES-256 token encryption, JWT authentication, SHA-256 file hashing, and complete audit logging.

Enterprise Grade

System Architecture

Designed for data integrity, security, and complete auditability

Physical Layer

Scanned Answer Sheets

PDF/JPG/PNG

FastAPI Middleware

PostgreSQL + JWT

Auth Upload Submit

HuggingFace Spaces

YOLO + CRNN Models

ML Inference

Moodle LMS

Assignment Submissions

Web Services

Database Schema

ModelDescription
ExaminationArtifactCore entity — UUID, file path, SHA-256 hash, metadata, workflow status, exam_type, attempt, file_content (binary)
SubjectMappingMaps Subject Code → Moodle Assignment ID + Course ID with exam_type support
UsernameRegMappingMaps Moodle username → Register Number for student lookup
StaffUserAdmin/staff accounts with bcrypt-hashed passwords and role flags
StudentSessionEphemeral sessions with AES-256 encrypted Moodle access tokens
AuditLogImmutable ledger of all actions with IP addresses and timestamps
SubmissionQueueRetry buffer for Moodle API failures — no submission is lost

bcrypt Hashing

12-round password hashing

AES-256 Encryption

Fernet for Moodle tokens

Audit Logging

Complete chain of custody

JWT Tokens

Short-lived access tokens

SHA-256 Hashing

File integrity verification

CORS Protection

Configurable origin whitelist

Platform Workflow

A streamlined 3-phase process ensuring secure and verified submissions

Phase 1

Administration & Setup

1

Subject Mapping

Map subject codes to Moodle Assignment IDs (auto-discover from Moodle)

2

Student Mapping

Map register numbers to Moodle usernames

3

Scanning

Exam cell scans papers: {RegNo}_{SubCode}.pdf

Phase 2

Staff Operations

1

Login

Staff authenticates via JWT

2

Bulk Upload

Drag & drop scanned files with duplicate detection

3

Validation

Filename validation, SHA-256 hashing, mapping check

4

Smart Scan

Optional AI extraction via scanner agent + HF Spaces

5

Email

SendGrid notifies students of uploaded papers

Phase 3

Student Operations

1

Login

Moodle credentials authentication

2

Dashboard

View papers tagged with register number

3

Review

Secure PDF viewer to verify paper

4

Submit

One-click submission to Moodle LMS

5

Confirmation

Status updates to SUBMITTED_TO_LMS

File Naming Convention

{RegNumber}_{SubCode}.{ext}
611221104088_19AI405.pdf 611221104089_ML.jpg 611221104090_19AI411.png
Register Number: 12 digits Subject Code: 2-10 alphanumeric Extensions: pdf, jpg, jpeg, png

API Endpoints

Complete RESTful API with authentication, file management, extraction, and submission handling

Staff Portal

/portal/staff

Student Portal

/portal/student

API Documentation

/docs

Health Check

/health

Production URL

https://exam-middleware.onrender.com

ML Service

kavinraja-ml-service.hf.space
POST/auth/staff/loginStaff login
POST/auth/staff/registerRegister staff (admin-only)
POST/auth/student/loginStudent login with Moodle creds
POST/auth/student/logoutStudent logout
POST/upload/singleUpload single file
POST/upload/bulkUpload multiple files (with savepoints)
POST/upload/validateValidate filename format
GET/upload/auto-processedList auto-processed (ML) artifacts
POST/upload/scan-uploadSmart Scan: AI process + upload
GET/student/dashboardGet assigned papers & stats
GET/student/paper/{id}/viewSecure PDF viewer
POST/student/submit/{id}Submit paper to Moodle
GET/student/submission/{id}/statusCheck submission status
GET/admin/artifactsList all artifacts (with filters)
DELETE/admin/artifacts/{id}Hard-delete artifact
DELETE/admin/artifacts/purge-allPurge all artifacts
GET/admin/mappingsSubject mappings (CRUD)
GET/admin/username-mappingsStudent mappings (CRUD)
POST/admin/attempt/{id}/lockLock/unlock attempt
GET/admin/statsSystem statistics
POST/extract/processExtract metadata from image via AI
GET/extract/statusHF Spaces health check

Quick API Test

# Staff Login
curl -X POST https://exam-middleware.onrender.com/auth/staff/login \
  -F "username=admin" \
  -F "password=admin123"

# Upload File (with token)
curl -X POST https://exam-middleware.onrender.com/upload/single \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -F "file=@611221104088_19AI405.pdf" \
  -F "exam_type=CIA-1"

# Health Check
curl https://exam-middleware.onrender.com/health

Cloud Deployment

Production-ready on Render.com with ML inference on HuggingFace Spaces

🚀 Render.com

FastAPI application deployed as a Docker web service with managed PostgreSQL. Auto-seeding admin user, database-backed file storage for ephemeral filesystem.

https://exam-middleware.onrender.com
Docker PostgreSQL Auto-seed CORS Health Checks

🤗 HuggingFace Spaces

ML models (YOLO object detection + CRNN text recognition) offloaded to HF Spaces. Eliminates heavy PyTorch/OpenCV packages from the server Dockerfile.

https://kavinraja-ml-service.hf.space
YOLO CRNN GPU Inference REST API

Quick Setup

Get up and running locally in minutes

Prerequisites

Python 3.10+ PostgreSQL 14+ Moodle LMS with Web Services Git
1
Clone Repository
git clone https://github.com/d-kavinraja/Intelligent-Examination-Submission-Framework-for-LMS.git
cd Intelligent-Examination-Submission-Framework-for-LMS/exam_middleware
2
Create Virtual Environment
python -m venv venv

# Windows
.\venv\Scripts\activate

# Linux / Mac
source venv/bin/activate
3
Install Dependencies
pip install -r requirements.txt
4
Configure Environment
copy .env.example .env
Edit .env with your PostgreSQL credentials, Moodle URL, and HF Space URL
5
Setup Database
psql -U postgres -c "CREATE DATABASE exam_middleware;"
python init_db.py
Creates tables, default admin user (admin/admin123), and initial mappings
6
Run Application
python run.py
Server starts at http://localhost:8000 — Staff Portal at /portal/staff, Student Portal at /portal/student

Project Structure

Clean, modular architecture following Python best practices

exam_middleware/
app/ api/routes/ admin.py, auth.py, extract.py, health.py, student.py, upload.py core/ config.py, security.py db/ database.py, models.py schemas/ schemas.py services/ artifact_service.py, extraction_service.py, remote_extraction_service.py file_processor.py, mail_service.py, moodle_client.py notification_service.py, submission_service.py templates/ staff_upload.html, student_portal.html utils/ encryption.py main.py FastAPI application entry models/ YOLO + CRNN model weights scanner_agent.py Smart Scan background agent init_db.py, run.py, requirements.txt, Dockerfile, render.yaml

Moodle Configuration

Required Moodle setup for Web Services integration

1

Enable Web Services

Site administration → Advanced features → Enable web services
2

Create External Service

Site administration → Server → Web services → External services → Create "FileUpload"
core_webservice_get_site_info mod_assign_save_submission mod_assign_submit_for_grading
3

Create Token

Site administration → Server → Web services → Manage tokens → Create for admin user with "FileUpload" service
4

Enable Upload Protocol

Ensure webservice/upload.php is accessible. Configure max upload size in Moodle settings.

🛡️ Security Considerations

Password Hashing

bcrypt with 12 rounds

Token Encryption

AES-256 (Fernet)

JWT Authentication

Short-lived access tokens

File Validation

SHA-256 hash + format checks

Audit Logging

All operations tracked with IP

CORS Protection

Configurable origin whitelist

Contributors

D. Kavinraja

D. Kavinraja

@d-kavinraja
Core features, Smart Scan AI, deployment, bug fixes
Santhan Kumar

Santhan Kumar

@SANTHAN-KUMAR
Email notifications, SendGrid, Dockerfile

Try the Live Demo

Deployed on Render.com with MoodleCloud integration