> ## Documentation Index
> Fetch the complete documentation index at: https://memberpulseptyltd.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Question Generation

> Generate quiz questions automatically using AI

Use AI to automatically generate quiz questions from course content.

## Features

### Content Analysis

Upload or paste content and AI generates:

* Multiple choice questions
* True/false questions
* Fill-in-the-blank questions

#### Acceptance Criteria

##### Frontend

* [ ] UI supports the workflows described in this feature.

##### Backend / API

* [ ] Backend behavior supports this feature as documented.

##### Permissions

* [ ] Access is restricted per the Capabilities matrix on this page (or equivalent role rules).

##### Business Rules

* [ ] All business rules for this feature are enforced.

##### Error Handling

* [ ] Error states return clear messages and appropriate HTTP status codes.

### Question Types

| Type            | Description              |
| --------------- | ------------------------ |
| Multiple Choice | 4 options, 1 correct     |
| True/False      | Binary choice            |
| Multi-Select    | Multiple correct answers |

#### Acceptance Criteria

##### Frontend

* [ ] UI supports the workflows described in this feature.

##### Backend / API

* [ ] Backend behavior supports this feature as documented.

##### Permissions

* [ ] Access is restricted per the Capabilities matrix on this page (or equivalent role rules).

##### Business Rules

* [ ] All business rules for this feature are enforced.

##### Error Handling

* [ ] Error states return clear messages and appropriate HTTP status codes.

## UI Spec (from supplied spreadsheet)

The spreadsheet defines quiz/question configuration under "Courses" (subject section):

| Field              | Input Type   | Required | Notes                                                            |
| ------------------ | ------------ | -------- | ---------------------------------------------------------------- |
| Questions Required | True / False | Required | model: `isQuestionsRequired` (shows/hides question UI)           |
| How many questions | Number       | Required | model: `numberOfQuestions`                                       |
| Generate with AI   | Yes / No     | Required | model: `generateWithAI` (triggers AI generation)                 |
| Question Type      | Selector     | Required | model: `questionType` (enum: `single_answer`, `multiple_answer`) |

#### Data Model Cross‑Reference (Entities)

Quiz/question configuration is stored on the course/subject structure: [`Course`](/entities/core/course)

### Quality Controls

* Review generated questions before use
* Edit questions and answers
* Set difficulty level
* Add explanations

#### Acceptance Criteria

##### Frontend

* [ ] Quality Controls workflow is implemented in the UI as described.

##### Backend / API

* [ ] Backend behavior supports Quality Controls as documented.

##### Permissions

* [ ] Access is restricted per the Capabilities matrix on this page (or equivalent role rules).

##### Business Rules

* [ ] All business rules for this feature are enforced.

##### Error Handling

* [ ] Error states return clear messages and appropriate HTTP status codes.

## Workflow

<Steps>
  <Step title="Input Content">
    Paste text or upload PDF/document
  </Step>

  <Step title="Configure">
    Select question types, quantity, difficulty
  </Step>

  <Step title="Generate">
    AI creates questions based on content
  </Step>

  <Step title="Review">
    Edit, approve, or regenerate questions
  </Step>

  <Step title="Add to Course">
    Insert approved questions into quiz
  </Step>
</Steps>

## Implementation Contracts

### Backend (API)

```
POST   /api/ai/generate-questions            # Generate questions
{
  "content": "string or file reference",
  "questionCount": 10,
  "questionTypes": ["multiple_choice", "true_false"],
  "difficulty": "medium"
}

POST   /api/courses/{id}/quizzes/{quizId}/import-ai
```
