AI Question Generator

A powerful PHP-based educational tool that uses OpenRouter AI to generate customized questions for educators.

System Requirements

  • PHP 7.4 or higher
  • SQLite3
  • OpenRouter API Key
  • Modern web browser

Features

Installation

  1. Upload all files to your web server
  2. Create a copy of .env.example as .env
  3. Set your OpenRouter API key in the .env file:
    OPENROUTER_API_KEY="your-api-key-here"
    OPENROUTER_API_URL="https://openrouter.ai/api/v1/chat/completions"
    AI_MODEL="microsoft/phi-4"
    ADMIN_USERNAME="admin"
    ADMIN_PASSWORD="admin123"
  4. Ensure the following directories are writable:
    • uploads/
    • Root directory (for SQLite database)
  5. Access the admin panel at /admin.php using:
    • Username: admin
    • Password: admin123

Configuration

Environment Variables

Variable Description Default
OPENROUTER_API_KEY Your OpenRouter API key -
OPENROUTER_API_URL OpenRouter API endpoint https://openrouter.ai/api/v1/chat/completions
AI_MODEL Default AI model to use microsoft/phi-4
ADMIN_USERNAME Admin panel username admin
ADMIN_PASSWORD Admin panel password admin123

Database Structure

The application uses SQLite3 with the following tables:

settings

- id (INTEGER PRIMARY KEY)
- setting_key (TEXT UNIQUE)
- setting_value (TEXT)
- updated_at (DATETIME)

custom_forms

- id (INTEGER PRIMARY KEY)
- name (TEXT)
- description (TEXT)
- form_fields (TEXT)
- ai_prompt (TEXT)
- is_default (INTEGER)
- created_at (DATETIME)
- updated_at (DATETIME)

pages

- id (INTEGER PRIMARY KEY)
- slug (TEXT UNIQUE)
- title (TEXT)
- content (TEXT)
- show_in_footer (INTEGER)
- created_at (DATETIME)
- updated_at (DATETIME)

hero_sections

- id (INTEGER PRIMARY KEY)
- title (TEXT)
- subtitle (TEXT)
- button_text (TEXT)
- button_url (TEXT)
- is_active (INTEGER)
- created_at (DATETIME)
- updated_at (DATETIME)

features

- id (INTEGER PRIMARY KEY)
- title (TEXT)
- description (TEXT)
- icon (TEXT)
- sort_order (INTEGER)
- created_at (DATETIME)
- updated_at (DATETIME)

faqs

- id (INTEGER PRIMARY KEY)
- question (TEXT)
- answer (TEXT)
- sort_order (INTEGER)
- created_at (DATETIME)
- updated_at (DATETIME)

about_sections

- id (INTEGER PRIMARY KEY)
- title (TEXT)
- content (TEXT)
- is_active (INTEGER)
- created_at (DATETIME)
- updated_at (DATETIME)

OpenRouter Integration

The application integrates with OpenRouter AI for question generation. The integration is handled through:

API Usage

// Example API call
$ch = curl_init('https://openrouter.ai/api/v1/chat/completions');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $api_key,
    'HTTP-Referer: http://localhost',
    'Content-Type: application/json'
]);

Admin Panel

The admin panel (/admin.php) provides the following features:

Customization

Themes

The application uses Bootstrap 5 for styling. You can customize the appearance by:

Templates

Key template files: