How mushaf-khalil/quizvendor_webtechnologies works
Project type and purpose
• QuizVendor is a full-stack web application whose main goal is to let educators and learners generate, take, and review AI-powered quizzes.
• The front end is a set of static HTML/CSS/JS pages; the back end is PHP scripts interacting with a MySQL database and the OpenAI API.
File structure
• A “php/” directory contains all REST-style endpoints:
• db.php (DB connection)
• signup.php, login.php, logout.php, check_session.php (user auth)
• create_quiz.php (AI quiz generation + persistence)
• submit_quiz.php (quiz submission, grading, persistence)
• get_history.php (fetch user’s quiz history)
• Root folder holds individual HTML pages (index.html, getstarted.html, dashboard.html, create_quiz_page.html, takeQuiz.html, history.html, etc.) that call the PHP endpoints via fetch.
README for additional insights
• The system uses XAMPP (Apache + PHP + MySQL) in development; production would swap in a proper LAMP/LEMP stack.
• OpenAI’s GPT-3.5 Turbo provides the quiz content.
• A session mechanism in PHP + client-side JS ensures page-level protection.
• MySQL tables: users, quizzes, questions, choices, quiz_attempts, user_answers.
a. Main components:
• Browser / Frontend (HTML/CSS/JS)
• PHP application server (REST endpoints)
• MySQL database
• External service: OpenAI API
b. Relationships / interactions:
1. User’s browser sends HTTP requests (via fetch) to the PHP endpoints.
2. PHP endpoints read/write to MySQL over a secure connection.
3. create_quiz.php proxies requests to the OpenAI API, parses responses, then persists quiz metadata & questions in MySQL.
4. PHP returns JSON to the browser; the front end renders dynamic quiz content or history.
c. Architectural patterns / design principles:
• Layered architecture:
1. Presentation layer (HTML/JS)
2. Application layer (PHP controllers)
3. Persistence layer (MySQL)
• RESTful endpoints for CRUD operations and AI integration.
• Session management for authentication and authorization.
d. Key technologies:
• Frontend: HTML5, CSS3, Vanilla JavaScript (ES6 fetch)
• Backend: PHP 8.x, session cookies
• Database: MySQL (InnoDB, foreign keys)
• External API: OpenAI GPT-3.5 Turbo
Elements
• Blue rectangles for frontend components
• Green rectangles for backend/PHP services
Detailed breakdown of key interactions
• User clicks “Generate Quiz”:
[Browser: create_quiz_page.html + JS] → POST fetch to create_quiz.php →
• OpenAI responds with quiz JSON → create_quiz.php writes to MySQL (quizzes, questions, choices) →
• create_quiz.php returns quiz (without answers) to browser → JS renders quiz.
• User submits answers:
[Browser] → POST fetch to submit_quiz.php →
• submit_quiz.php writes to quiz_attempts & user_answers, reads correct answers →
• Calculates score → returns result JSON → JS displays results.
• User views history:
[Browser] → GET fetch to get_history.php →
• get_history.php queries quiz_attempts & quizzes → returns JSON → JS populates history.html table.