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
- AI-powered question generation using OpenRouter API
- Multiple question types support (multiple choice, short answer, long answer)
- Customizable difficulty levels
- Custom form creation and management
- Dynamic content management (Hero sections, Features, FAQs, About sections)
- Responsive modern UI with Bootstrap 5
- Admin panel for easy management
- SEO-friendly static pages
Installation
- Upload all files to your web server
- Create a copy of
.env.example
as.env
- 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"
- Ensure the following directories are writable:
uploads/
- Root directory (for SQLite database)
- 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:
- Configuration in
.env
file - API calls in
generate.php
- Model selection in admin panel
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:
- Site Settings
- Site title and logo
- SEO settings
- Primary color
- OpenRouter API configuration
- Content Management
- Hero sections
- Features
- About sections
- FAQs
- Static pages
- Form Management
- Custom form creation
- AI prompt customization
- Form field configuration
- Security
- Admin credentials management
- Secure authentication
Customization
Themes
The application uses Bootstrap 5 for styling. You can customize the appearance by:
- Modifying the primary color in admin panel
- Editing
assets/css/style.css
- Customizing Bootstrap variables
Templates
Key template files:
header.php
- Site header and navigationfooter.php
- Site footerindex.php
- Homepage layoutpage.php
- Static page template