Moodle ×
Unity Integration

A full-stack educational pipeline connecting Moodle to a Unity math game via a custom FastAPI token server. The system authenticates learners through Moodle and tracks gameplay progress back into the LMS using the xAPI / LRS standard.

Python FastAPI C# Unity SQLite xAPI LRS Moodle

Unity · C# · Educational

Unity Math Game

The learner-facing component — a Unity game designed to deliver math content in an interactive format. Built for students to launch directly from a Moodle course activity. The game manages its own session state, progress tracking, and includes a pause menu with a graceful exit path back to Moodle.

Unity C# Educational Game Session Management Pause Menu xAPI Reporting

Python · FastAPI · SQLite

FastAPI Token Server

A Python FastAPI service that sits between Moodle and the Unity client. When a student launches the game activity in Moodle, the LMS requests a one-time token from this server. The token is generated, persisted in SQLite with expiry metadata, and returned to Moodle to be embedded in the game launch URL — every request and outcome is fully logged.

FastAPI Python SQLite One-time Tokens Expiry Metadata Request Logging

Endpoint

Moodle → Server

Moodle sends a token request when launching the game for a learner. The server creates a unique token, stores it in SQLite, and returns it for Moodle to embed in the game's launch URL.

Storage

SQLite Persistence

Each token is stored with its creation time, expiry window, and used flag. Expired or already-redeemed tokens are rejected at verification time, preventing replay attacks.

C# · Unity · xAPI

TokenRedeemer.cs

The Unity-side C# script that closes the loop. On game launch, TokenRedeemer.cs extracts the token from the launch URL and sends a redemption request to the FastAPI server. The server validates the token, marks it as used to prevent replay, and responds with session credentials. Invalid or expired tokens are caught with logged errors and a clean failure state. Once verified, gameplay progress is reported back to Moodle's LRS as xAPI statements.

C# Unity TokenRedeemer.cs Replay Prevention xAPI LRS Reporting Error Handling

Redemption

Unity → Server

Token extracted from the URL, POST request sent to the FastAPI server. Server checks existence, expiry, and used status — marks it used on success, returns session credentials, rejects on any failure condition.

Reporting

xAPI → Moodle LRS

Gameplay events are sent back to Moodle's Learning Record Store as xAPI statements, so the instructor sees live progress data without any manual export step.

Unity · C# · UI Systems

3D Computer Interaction System

A Unity system that projects a standard 2D Canvas onto a 3D mesh via RenderTexture, with UV-to-canvas input passthrough so normal UI components work on in-world computer screens. Built to support interactive in-game interfaces without rebuilding the UI layer from scratch for 3D space.

Unity C# RenderTexture Canvas UI UV Mapping Input Passthrough