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

# PATCH - Exam

>  This API allows updating an existing exam. You can:  
 - Mark an exam as final.  
 - Upload associated documents. 
 - Modify exam attributes such as examType.  

 **Key Notes:** 
 - Only one type of document (**pdf** and **jpeg**) can be uploaded for an exam. 
 - For **jpeg** files, multiple images can be uploaded sequentially, one at a time. 
 - You can supply a PDF with **`fileUrl`** instead of uploading via `documents`. 
 - **`fileUrl`** must be a **public** HTTPS URL, and the URL path must end with **`.pdf`**. 
 - Use only one of **`documents`**, **`fileUrl`**, or **`isFinal`** in a single request (do not combine them). 

 **Scenario: Finalizing an Exam and Triggering AI Extraction** 

 This API allows a teacher to finalize an exam by setting the `final` attribute to `true` using the PATCH Update Exams API.

**Outcome:**
- Finalizing triggers the AI extraction process to analyze uploaded documents (e.g., PDFs or JPEGs) and extract key details such as questions, marks distribution, and instructions.
- The extracted data is stored for workflows like grading and reporting.

**Note:**
- After setting `isFinal` to `true`, the AI extraction process is initiated. This process may take some time to complete.
- To facilitate seamless integration, we provide a webhook feature. Once the extraction is successfully completed, the system will send a notification to the configured webhook URL. 
 - Only one of `documents` or `isFinal` can be processed at a time. 

**Example Workflow:**
1. Create an exam and upload the question paper.
2. Finalize the exam with `{ "isFinal": true }`.
3. AI processes the content for automated and accurate extraction.
4. Receive a webhook notification upon successful extraction completion. 

 <Danger> If both `documents` and `isFinal` are provided in the same request, a validation error is returned. Use either `documents` to upload, or `isFinal` to trigger extraction — **not both together**. </Danger> 

<div
  style={{
background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
borderRadius: '16px',
padding: '4px',
marginTop: '20px',
marginBottom: '20px',
boxShadow: '0 10px 40px rgba(102, 126, 234, 0.3)'
}}
>
  <iframe className="w-full aspect-video rounded-xl" src="https://www.youtube.com/embed/eA1lUvP0DO4" title="Evaluation Platform | PATCH | Exam | API Reference Guide" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />
</div>


## OpenAPI

````yaml PATCH /evaluation-platform/v1/exam/{id}/
openapi: 3.0.1
info:
  title: Evaluation Report API
  description: An API for retrieving evaluation reports.
  version: 1.0.0
servers:
  - url: https://api-staging.crazygoldfish.com
    description: SandBox endpoint
  - url: https://api.crazygoldfish.com
    description: Prod End Point
security: []
paths:
  /evaluation-platform/v1/exam/{id}/:
    patch:
      summary: Update exam paper details
      description: >-
        Updates various details related to an exam paper such as class, subject,
        exam type, etc.
      operationId: updateExamPaper
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            example: 4340132f-50fa-4877-9ffa-e9b7ee59d51f
      requestBody:
        description: The details to update for the exam paper.
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                documents:
                  type: string
                  format: binary
                  description: The exam paper file to be uploaded.
                grade:
                  type: integer
                  description: The class the exam paper belongs to.
                  example: 12
                subject:
                  type: integer
                  description: The subject of the exam paper.
                  example: 1
                examType:
                  type: integer
                  description: The type of the exam.
                  example: 1
                examSet:
                  type: string
                  description: The set of the exam.
                  example: C
                examDate:
                  type: string
                  format: date
                  description: >-
                    Date of the exam (should be in the format format -
                    'YYYY-MM-DD')
                classSection:
                  type: string
                  description: The section of the class.
                  example: A
                isFinal:
                  type: boolean
                  description: >-
                    After successfully uploaded files pass this parameter as
                    **true** for the extraction for your exam.
                  example: true
                fileUrl:
                  type: string
                  format: uri
                  description: >-
                    Public HTTPS URL to a PDF. Use instead of uploading
                    `documents` (images or a single PDF). The URL must be
                    publicly accessible without authentication and must end with
                    a `.pdf` extension. Mutually exclusive with `documents` in
                    the same request.
                  example: https://cdn.example.com/exams/question-paper.pdf
          application/json:
            schema:
              type: object
              properties:
                fileUrl:
                  type: string
                  format: uri
                  description: >-
                    Public HTTPS URL to a PDF. Alternative to
                    `multipart/form-data` file uploads via `documents`. The URL
                    must be publicly accessible without authentication and must
                    end with a `.pdf` extension. Mutually exclusive with
                    `documents` in the same request.
                  example: https://cdn.example.com/exams/question-paper.pdf
                isFinal:
                  type: boolean
                  description: >-
                    After successfully uploaded files pass this parameter as
                    **true** for the extraction for your exam.
                  example: true
      responses:
        '200':
          description: Successfully updated exam details.
          content:
            application/json:
              schema:
                type: object
                properties:
                  examId:
                    type: string
                    example: 4340132f-50fa-4877-9ffa-e9b7ee59d51f
                    description: The unique identifier for the updated exam.
                  documents:
                    type: array
                    description: Details of the documents attached to the exam.
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          description: The unique identifier of the document.
                        status:
                          type: integer
                          description: The status of the document.
                        pageNo:
                          type: integer
                          description: The page number of the document
                          nullable: true
                        uploadTime:
                          type: string
                          description: The time the document was uploaded.
                          format: date-time
                        url:
                          type: string
                          format: uri
                          description: The URL to access the document.
                        fileType:
                          description: The type of the document.
                          type: integer
                    example:
                      - id: 628f10af-59b5-44f2-b27a-fdf30d254fd5
                        status: 0
                        pageNo: null
                        uploadTime: '2025-01-02T11:03:30.034720Z'
                        url: >-
                          https://cgfblob.blob.core.windows.net/ielts/evaluation/CBSE_10_Maths_-_Mock_Test_A_SjFa0sA.pdf
                        fileType: 1
        '400':
          description: >-
            Invalid input provided, including blurred image error and invalid
            exam type.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: integer
                        example: 400
                      message:
                        type: object
                        properties:
                          non_field_errors:
                            type: array
                            items:
                              type: string
                              example: >-
                                Blured image, Please try to capture the image
                                again
                          exam_type:
                            type: array
                            items:
                              type: string
                              example: 'Invalid value: 100. Must be one of [1].'
              example:
                error:
                  code: 400
                  message:
                    non_field_errors:
                      - Blured image, Please try to capture the image again
                    exam_type:
                      - 'Invalid value: 100. Must be one of [1].'
        '403':
          description: Authentication failed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: Token has expired
              example:
                detail: Token has expired
        '404':
          description: Exam not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: integer
                        example: 404
                      message:
                        type: object
                        properties:
                          non_field_errors:
                            type: array
                            items:
                              type: string
                              example: Exam not found
              example:
                error:
                  code: 404
                  message:
                    non_field_errors:
                      - Exam not found
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````