# API Documentation

## Base URL
- Local: `http://localhost/neet/api/`
- Network: `http://YOUR_IP/neet/api/`

## Endpoints

### 1. Login
**POST** `/login.php`

Request Body:
```json
{
  "username": "admin",
  "password": "admin123"
}
```

Response:
```json
{
  "success": true,
  "data": {
    "user_id": 1,
    "full_name": "Admin User",
    "grade": 10
  }
}
```

### 2. Get Exams
**GET** `/get_exams.php?user_id=1`

Response:
```json
{
  "success": true,
  "data": [
    {
      "exam_id": 1,
      "exam_name": "NEET Full Mock Test",
      "exam_type": "NEET",
      "duration_minutes": 180,
      "total_questions": 200,
      "positive_marks": 4.00,
      "negative_marks": -1.00
    }
  ]
}
```

### 3. Start Exam
**POST** `/start_exam.php`

Request Body:
```json
{
  "user_id": 1,
  "exam_id": 1
}
```

Response:
```json
{
  "success": true,
  "data": {
    "result_id": 1,
    "exam_name": "NEET Full Mock Test",
    "duration_minutes": 180,
    "questions": [...]
  }
}
```

### 4. Submit Exam
**POST** `/submit_exam.php`

Request Body:
```json
{
  "result_id": 1,
  "answers": [
    {
      "question_id": 1,
      "selected_answer": "A"
    }
  ]
}
```

Response:
```json
{
  "success": true,
  "data": {
    "result_id": 1,
    "total_score": 12.00,
    "correct_count": 3,
    "incorrect_count": 1,
    "unattempted_count": 0
  }
}
```

### 5. Get Result Details
**GET** `/get_result_details.php?result_id=1`

Response:
```json
{
  "success": true,
  "data": {
    "result_id": 1,
    "exam_name": "NEET Full Mock Test",
    "exam_type": "NEET",
    "total_score": 12.00,
    "correct_count": 3,
    "incorrect_count": 1,
    "unattempted_count": 0,
    "subject_wise_scores": {
      "Physics": 4.00,
      "Chemistry": 4.00,
      "Biology": 4.00
    },
    "answer_details": [...]
  }
}
```

### 6. Upload Questions (CSV)
**POST** `/upload_questions.php`

Form Data:
- `csv_file`: CSV file with questions

CSV Format:
```csv
topic_id,question_text,option_a,option_b,option_c,option_d,correct_answer,explanation,difficulty_level
1,"What is force?","Newton","Joule","Watt","Pascal","A","Force is measured in Newtons","Easy"
```

