How fossee/online_test works
Project type and purpose
• This is a full-stack, monolithic Django web application (“online_test”) that exposes both web pages (via Django templates and static assets) and a REST-style API, and supports interactive, language-agnostic programming quizzes.
• It features synchronous web interactions (course/quiz creation, browsing) and asynchronous code evaluation via Celery/Redis and an isolated code server.
Core components
a. Clients
• Web Browser (Teacher, Student, Admin)
• Optional: CLI or SDK consuming the REST API
b. Django Web Application
• online_test project (settings, URLs, WSGI entry point)
• Django apps (“yaksh” core, “api”, “grades”, “stats”, “upload”)
• Templates & static files (JavaScript, CSS, CodeMirror, TinyMCE)
c. Database
• Relational database (e.g., PostgreSQL/MySQL) storing users, courses, questions, submissions, grades
d. Message Broker / Cache
• Redis used as Celery broker and cache
e. Asynchronous Workers
• Celery worker processes (spawned via “celery -A online_test worker -B”)
• Periodic tasks (Beat scheduler) for regrading, notifications, email sending
f. Code Execution Service (“Code Server”)
• Containerized sandbox (Docker) or local unsafe server
• Exposes an API over HTTP or TCP for running user code in isolated environments
g. External services
• Email server (SMTP) for notifications, password resets
• Optional: Docker daemon for sandboxing
Interactions & data flow
1. User → Browser → HTTP request → Django Web App (Gunicorn/uWSGI)
– Authentication, page rendering (templates) or JSON API (api/serializers & views).
2. Quiz submission → Django view enqueues Celery task → message posted to Redis.
3. Celery worker subscribes to Redis → picks up evaluation task → requests code execution from Code Server → receives verdict → updates database.
4. Django Web App polls or listens (WebSockets or AJAX) to display results to user.
5. Periodic tasks (Beat) handle email reminders/regrading, using Redis scheduler → tasks.py/send_emails.py.
6. Admin interface uses built-in Django admin & custom admin apps (grades, stats).
Architectural patterns & design principles
• Modular monolith: independent Django apps (“yaksh” core, API, grading, stats, upload) arranged by feature.
• Asynchronous processing: Celery + Redis decouple user requests from compute-heavy evaluations.
• Microservice for sandboxing: Code Server isolated via Docker to securely execute untrusted code.
• Configuration & Deployment: Docker Compose orchestrates web, worker, Redis, code server; .sampleenv, docker-compose.yml for env vars & container setup.
Technologies & frameworks
• Backend: Python 3.6+, Django 3.0.3
• Asynchronous queue: Celery 4.4.2, Redis
• Containerization: Docker, Docker Compose
• Web assets: CodeMirror, TinyMCE, Bootstrap, jQuery
• Testing: pytest/unittest in *-tests.py, Django test runner
• Documentation: Sphinx (Yaksh docs), reStructuredText
Final checklist
• [ ] Annotations for tech stack (Django, Celery, Redis, Docker)