> ## 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 - Model Answer

> The API allows updating an existing model answer sheet for an exam. This API is used to:
 - Add or replace associated documents for the model answer sheet.
 - Update the **isFinal** status of the model answer sheet..

 **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 using **`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).


**Scenarios:**

1. **Finalizing the Model Answer Sheet and Triggering AI Extraction:**
   - Teachers finalize the model answer sheet by setting `isFinal` to `true` in the PATCH API request.
   - **Outcome:**
     - AI extracts structured data such as model answers, step-wise marking schemes, and instructions, readying them for evaluation workflows.

2. **Sequential Upload of JPEG Documents:**
   - For handwritten model answer sheets, teachers upload JPEG images one at a time via the API.
   - After uploading all images, `isFinal` is set to `true` to initiate AI extraction.
   - **Outcome:**
     - AI processes the images, extracting structured content for evaluation.

**Example Workflow:**
   1. The teacher uploads a model answer document (PDF or JPEG) via this API.
   2. Calls the API with `{ "isFinal": true }` to trigger AI extraction.
   3. The extracted content is reviewed and used for grading purposes.

 

 <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/E1fsNZNRmok" title="Evaluation Platform | PATCH | Model Answer | 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/{examId}/model-answer/{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/{examId}/model-answer/{id}/:
    patch:
      summary: Update model answer for an exam
      operationId: update_model_answer
      parameters:
        - name: examId
          in: path
          required: true
          schema:
            type: string
            example: 4340132f-50fa-4877-9ffa-e9b7ee59d51f
        - in: path
          name: id
          required: true
          schema:
            type: string
            example: 287117d6-0135-4329-b5a7-d46e42948a14
      requestBody:
        description: The details to update for the model answer.
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                documents:
                  type: string
                  format: binary
                  description: The model answer file to be uploaded.
                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`. The URL must be publicly accessible without
                    authentication and must end with a `.pdf` extension.
                  example: https://cdn.example.com/model-answer/model-answer-101.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/model-answer/model-answer-101.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: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: Unique identifier of the model answer
                    example: 287117d6-0135-4329-b5a7-d46e42948a14
                  documents:
                    type: array
                    description: List of documents associated with the model answer
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          description: Unique identifier of the document
                          example: 10d5661d-df3a-4d22-aa58-fddfa1230040
                        status:
                          type: integer
                          description: Status of the document
                          example: 1
                        pageNo:
                          type: integer
                          nullable: true
                          description: Page number of the document
                          example: null
                        uploadTime:
                          type: string
                          format: date-time
                          description: Time of document upload
                          example: '2025-01-06T12:28:22.992639Z'
                        url:
                          type: string
                          description: URL of the document
                          example: >-
                            https://cgfblob.blob.core.windows.net/ielts/evaluation/CBSE_10_Science_-_Mock_Test_A_Solutions.pdf
                        fileType:
                          type: integer
                          description: Type of the document
                          example: 1
        '400':
          description: Invalid input provided, including blurred image error.
          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
              example:
                error:
                  code: 400
                  message:
                    non_field_errors:
                      - Blured image, Please try to capture the image again
        '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: Model Answer 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: Model Answer not found
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````