Applied Branches Claude Sonnet 4.5

๐ŸŽ“ Skibidi Revision

Skibidi Revision is a mobile-friendly, themeable, browser-based revision quiz platform.

> skibidi-revision-readme.md (177 lines - 12 Nov 25)
# ๐Ÿ“ Skibidi Revision App (Post-Refactor โœ…)

A fun, AI-powered PHP quiz app designed to help students (like Bob!) revise throughout the day โ€” topic by topic, subject by subject โ€” in short bursts. ๐ŸŽ“โœจ

**AUTHOR:** Abstract Warlock 
**CO-DEVELOPMENT:** Claude Sonnet 4.5
**DATE:** 12 November 2025
**LICENSE:** None

---

## ๐Ÿ“Œ Overview

Skibidi Revision is a mobile-friendly, themeable, browser-based revision quiz platform. Built for daily learning motivation, powered by OpenAI for smart feedback, and backed by a clean MySQL structure. Now with **year-level filtering** and **secure password-based login**!

You can:
- Jump into any subject for a specific school year
- Answer as many questions as you want
- Get instant AI-marked feedback
- Track progress live with beautifully styled UI

---

## โœ… Refactored Architecture (2025)

- ๐Ÿ”ฅ Session-less quiz state (only player name stored)
- ๐Ÿ” **Password-based login** for existing users
- ๐Ÿ—“๏ธ **Year-level filtering** for questions and progress
- ๐Ÿ”„ All questions & answers from MySQL
- ๐Ÿ’ก AI-scored answers with detailed feedback
- ๐Ÿ“Š DB-powered daily summary with progress bar
- ๐ŸŽจ Fully themed with Bootstrap 5 and emoji icons
- ๐Ÿ“ Controllers handle logic โ†’ Views handle UI

---

## ๐Ÿงฑ Core Features

### ๐Ÿ“š Daily Quiz Flow
- Select a school year to filter subjects
- Subjects shown as beautiful cards
- Each click = new random question (never repeated today for the selected year/subject)
- Submit answer โ†’ see score + correct answer + AI explanation

### ๐Ÿง  Scoring
- Answers scored by AI out of 5
- Score โ‰ฅ 3 = correct
- Daily stats: correct %, points %, per-subject totals **(now year-specific)**

### ๐ŸŽฏ Clean Views
- `menu`, `question`, `feedback`, `results` all share consistent layout and styling

### ๐ŸŒˆ Themes
- `Teacher`, `Dad`, and `Wife` โ€” can be toggled in UI
- CSS loads via `styles.css?v=<?= time() ?>` for updates

---

## ๐Ÿ—ƒ๏ธ Data Model

### users 

| Field        | Type        |
|--------------|-------------|
| id           | INT (PK)    |
| name         | VARCHAR     |
| password_hash| VARCHAR     | (for secure login)
| created_at   | TIMESTAMP   |

### revision_questions 

| Field       | Type        |
|-------------|-------------|
| id          | INT (PK)    |
| subject     | VARCHAR     |
| topic       | VARCHAR     |
| year        | INT         | (school year level)
| question    | TEXT        |
| answer      | TEXT        |
| type        | VARCHAR     |
| options     | JSON (nullable) |
| created_at  | TIMESTAMP   |

### daily_answers 

| Field        | Type        |
|--------------|-------------|
| id           | INT (PK)    |
| user_id      | INT (FK)    |
| date         | DATE        |
| subject      | VARCHAR     |
| question_id  | INT (FK)    |
| user_answer  | TEXT        |
| ai_score     | INT         |
| ai_feedback  | TEXT        |
| created_at   | TIMESTAMP   |

---

## ๐Ÿง  AI Answer Logic

OpenAI (gpt-4.1-mini) evaluates each answer:

- Uses fixed prompt logic (do not alter the scoring prompt)
- Types: `factual_recall`, `multiple_choice`, `explanation`, etc.
- AI returns:
  - `score` (0โ€“5)
  - `isCorrect`
  - `aiExplanation`

---

## ๐Ÿ–ฅ๏ธ Project Structure

```
/
โ”œโ”€โ”€ index.php                  # Front controller
โ”œโ”€โ”€ config.php                 # DB + OpenAI config
โ”œโ”€โ”€ functions.php              # Utilities + score summary
โ”œโ”€โ”€ openai.php                 # AI scoring
โ”œโ”€โ”€ controllers/
โ”‚   โ”œโ”€โ”€ login_controller.php
โ”‚   โ”œโ”€โ”€ quiz_controller.php
โ”‚   โ”œโ”€โ”€ answer_controller.php
โ”‚   โ”œโ”€โ”€ theme_controller.php
โ”‚   โ””โ”€โ”€ menu_controller.php
โ”œโ”€โ”€ views/
โ”‚   โ”œโ”€โ”€ partials/
โ”‚   โ”‚   โ”œโ”€โ”€ header.php
โ”‚   โ”‚   โ”œโ”€โ”€ footer.php
โ”‚   โ”‚   โ””โ”€โ”€ progress.php
โ”‚   โ”œโ”€โ”€ login_prompt.php
โ”‚   โ”œโ”€โ”€ menu.php
โ”‚   โ”œโ”€โ”€ question.php
โ”‚   โ”œโ”€โ”€ feedback.php
โ”‚   โ””โ”€โ”€ results.php
โ””โ”€โ”€ data/                      # Migration input JSONs (optional)
```

---

## ๐Ÿš€ Setup

1. Clone repo and upload to PHP server
2. Import the DB schema (see `/sql/` or refactor docs) and **ensure you've added the `year` column to `revision_questions` and `password_hash` to `users`**.
3. **Populate the `year` column** in your `revision_questions` table for all relevant questions.
4. Add OpenAI key to `config.php`
5. Ensure `SESSION` and `PDO` are enabled
6. Visit `index.php` and enter your name. **The first time you log in, you will be prompted to set a password.**

---

## ๐Ÿ›  TODO

These are polish/future ideas you may want to add soon:

- [ ] Refactor `results.php` into full `results_controller.php`
- [ ] views/menu.php needs slight width/style tweeks
- [ ] Highlight current subject icon in header
- [ ] Merge daily progress bar into header across all pages
- [ ] Leaderboard (daily/weekly)
- [ ] Optional: Smooth transition animations (between views)
- [ ] Optional: Per-topic completion tracking
- [ ] Optional: Full admin question editor
- [ ] Optional: Theme "Dad Mode" and "Wife Mode" CSS final polish

---

## ๐Ÿ’ฌ Credits

Built with โค๏ธ for Bob โ€” by his team of nerdy, helpful, fun-grown-upsโ„ข.  
If you're reading this and thinking "wow this is actually solid" โ€” we agree.

Want a print version?  
๐Ÿซก Weโ€™ll turn it into a book called *"Refactor Wars: The Session Menace."*

---