# 👨‍💼 ADMIN GUIDE: Setting Up Zoom Integration

This guide is for **administrators** who want to enable Zoom meeting creation for their users.

---

## 🎯 Overview

With Zoom integration enabled:
- ✅ Users can create Zoom meetings for their quizzes
- ✅ Meeting links are automatically generated
- ✅ Students can join meetings directly from quiz pages
- ✅ All meetings are managed through one admin account

---

## 📋 Prerequisites

1. **Zoom Account** (Free or Pro)
2. **Admin Access** to your Amanfo Online Classroom application
3. **5-10 minutes** to complete setup

---

## 🚀 STEP-BY-STEP SETUP

### Step 1: Run Database Migration

Open terminal in your project folder and run:

```bash
php artisan migrate
```

This adds Zoom configuration fields to your database.

---

### Step 2: Get Zoom API Credentials

#### 2.1 Go to Zoom Marketplace
Visit: **https://marketplace.zoom.us/**

#### 2.2 Sign In
Log in with your Zoom account (the account that will host all meetings)

#### 2.3 Create an App
1. Click **"Develop"** → **"Build App"**
2. Choose **"Server-to-Server OAuth"** (recommended)
3. Click **"Create"**

#### 2.4 Enter App Information
- **App Name:** `Amanfo Online Classroom` (or your school name)
- **Short Description:** `Quiz platform with Zoom integration`
- **Company Name:** Your school/organization name
- **Developer Contact:** Your email address

#### 2.5 Get Your Credentials
After creating the app, you'll see:
- **Account ID**
- **Client ID** ← This is your API Key
- **Client Secret** ← This is your API Secret

**Copy both Client ID and Client Secret** - you'll need them in the next step.

#### 2.6 Add Required Scopes
1. Go to the **"Scopes"** tab
2. Click **"Add Scopes"**
3. Add these three scopes:
   - `meeting:write:admin` - Create meetings
   - `meeting:read:admin` - Read meeting details
   - `meeting:delete:admin` - Delete meetings
4. Click **"Done"**

#### 2.7 Activate Your App
1. Click **"Continue"**
2. Review the information
3. Click **"Activate your app"**

---

### Step 3: Configure Zoom in Admin Panel

#### 3.1 Login to Admin Panel
1. Go to your application: `http://127.0.0.1:8000`
2. Login with your **admin account**

#### 3.2 Navigate to Zoom Settings
1. Click **"Settings"** in the sidebar
2. Click **"Zoom Settings"**

#### 3.3 Enter Your Credentials
1. Toggle **"Enable Zoom Integration"** to ON
2. Paste your **Client ID** in the "Zoom API Key" field
3. Paste your **Client Secret** in the "Zoom API Secret" field
4. Click **"Save Settings"**

✅ **Done!** Zoom integration is now enabled for all users.

---

## 👥 How Users Will Use It

### For Teachers/Quiz Creators:

1. **Create Zoom Meeting:**
   - Go to: `http://127.0.0.1:8000/zoom/meetings/create`
   - Select a quiz
   - Enter meeting details (topic, date, time, duration)
   - Click "Create Zoom Meeting"

2. **Get Meeting Link:**
   - Copy the generated join URL
   - Share with students via WhatsApp, email, or SMS

3. **Students Join:**
   - Students click the meeting link
   - They join the Zoom meeting directly

---

## 🔒 Security Best Practices

### ✅ DO:
- Keep your API Secret confidential
- Use a dedicated Zoom account for the platform
- Regularly review created meetings
- Enable waiting room in Zoom settings
- Use meeting passwords

### ❌ DON'T:
- Share API credentials with users
- Post credentials in public places
- Use personal Zoom account
- Disable security features

---

## 🔧 Troubleshooting

### Issue: "Zoom integration is not enabled"

**Solution:**
1. Check if toggle is ON in Zoom Settings
2. Verify API credentials are entered correctly
3. Make sure Zoom app is activated in marketplace
4. Clear cache: `php artisan config:clear`

---

### Issue: "Failed to create meeting"

**Solution:**
1. Check if Zoom app has required scopes
2. Verify API credentials are correct
3. Ensure Zoom account is active
4. Check if you have meeting creation limits

---

### Issue: Users can't see the Zoom option

**Solution:**
1. Ensure migration was run: `php artisan migrate`
2. Check if Zoom is enabled in admin settings
3. Verify users are logged in
4. Clear browser cache

---

## 📊 Managing Meetings

### View All Meetings
Currently, meetings are stored in the `zoom_meetings` table in your database.

### Delete a Meeting
Users can delete their own meetings through the API endpoint.

### Meeting Limits
- Free Zoom accounts: 40-minute limit for 3+ participants
- Pro accounts: No time limit
- Meeting capacity depends on your Zoom plan

---

## 🎓 Training Your Users

### Quick Start Guide for Users:

**Share this with your teachers:**

1. Login to your account
2. Go to: `http://127.0.0.1:8000/zoom/meetings/create`
3. Select your quiz from the dropdown
4. Fill in meeting details:
   - **Topic:** What the meeting is about
   - **Start Time:** When it begins
   - **Duration:** How long (in minutes)
5. Click "Create Zoom Meeting"
6. Copy the join URL and share with students

---

## 📞 Support

### Check Logs
If something goes wrong, check:
```
storage/logs/laravel.log
```

### Zoom API Documentation
https://marketplace.zoom.us/docs/api-reference/zoom-api

### Test the Integration
1. Create a test quiz
2. Create a test meeting
3. Try joining the meeting link
4. Verify everything works

---

## ✅ Checklist

Before going live, ensure:

- [ ] Database migration completed
- [ ] Zoom app created in marketplace
- [ ] Required scopes added to Zoom app
- [ ] Zoom app is activated
- [ ] API credentials entered in admin panel
- [ ] Zoom integration toggle is ON
- [ ] Test meeting created successfully
- [ ] Meeting link works when clicked
- [ ] Users can access the creation page
- [ ] Instructed users on how to use it

---

## 🎉 You're All Set!

Your users can now create Zoom meetings for their quizzes. All meetings will be hosted under your Zoom account, and users will get automatic meeting links to share with their students.

**Admin Panel:** Settings → Zoom Settings  
**User Creation Page:** http://127.0.0.1:8000/zoom/meetings/create

---

## 💡 Pro Tips

1. **Use a Pro Zoom Account** for unlimited meeting duration
2. **Enable waiting room** for better security
3. **Set default meeting settings** in your Zoom account
4. **Monitor meeting usage** through Zoom dashboard
5. **Backup meeting data** regularly from your database

---

## 🔄 Disabling Zoom Integration

If you need to disable Zoom temporarily:

1. Go to **Settings → Zoom Settings**
2. Toggle **"Enable Zoom Integration"** to OFF
3. Click **"Save Settings"**

Users will see a message that Zoom is not available.

---

**Questions?** Check the logs or contact support.
