> ## 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 - Student Assignment Sheet

>  The API allows clients to upload and associate documents with an existing student assignment sheet for a specific assignment. Only one type of file format (either PDF or multiple images like JPEG) is allowed for a single assignment sheet. Mixing formats in a single assignment sheet is not permitted. 

**Scenarios:**

1. **Uploading PDF Document to a Student’s assignment Sheet:**
   - The teacher provides the assignment Sheet ID and uploads a PDF.
   - **Outcome:**
     - The student’s scanned assignment sheet is successfully uploaded in PDF format, replacing the placeholder document.

2. **Uploading Multiple JPEG Images for a Student’s assignment Sheet:**
   - A student’s handwritten assignment sheet is scanned in parts and saved as multiple JPEG images.
   - The teacher uploads each image sequentially using the same assignment Sheet ID.
   - **Outcome:**
     - All images are uploaded, completing the student's assignment sheet and associating them for grading.

**Note:**
- After setting `isFinal` to `true`, the AI extraction process begins. This process may take some time to complete.
- To streamline workflows, the system supports a webhook feature. Upon successful extraction, a notification is sent to the configured webhook URL. 
 - Only one of `documents` or `isFinal` can be processed at a time. 

 <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> 



## OpenAPI

````yaml PATCH /assignment-evaluation/v1/assignment/{id}/answer-sheet/{assignmentSheetId}/
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:
  /assignment-evaluation/v1/assignment/{id}/answer-sheet/{assignmentSheetId}/:
    patch:
      tags:
        - Assignments
      summary: Update Assignment Answer Sheet
      operationId: updateAssignmentAnswerSheet
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Unique identifier of the assignment
        - name: assignmentSheetId
          in: path
          required: true
          schema:
            type: string
          description: Unique identifier of the answer sheet
      requestBody:
        required: false
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                documents:
                  type: array
                  items:
                    type: string
                    format: binary
                  description: List of answer sheet documents to upload (if any).
                isFinal:
                  type: boolean
                  example: true
                  description: >-
                    Flag to trigger evaluation if set to 'true'. Only one of
                    documents, or isFinal is allowed.
      responses:
        '200':
          description: Answer sheet uploaded successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    example: 57387c68-0706-4a9d-834a-237b6b63cb5d
                    description: Unique identifier for the answer sheet.
                  status:
                    type: integer
                    example: 0
                    description: >-
                      Status of the answer sheet [(refer this doc to get the
                      constants)](https://docs.crazygoldfish.com/api-reference/endpoint/assignments/v1-constants)
                  studentId:
                    type: string
                    example: '12345'
                    description: Unique identifier of the student.
                  name:
                    type: string
                    example: John Doe
                    description: Name of the student.
                  batchId:
                    type: string
                    example: batch_1
                    nullable: true
                    description: Unique identifier of the batch.
                  sessionId:
                    type: string
                    example: session_1
                    nullable: true
                    description: Unique identifier of the session.
                  documents:
                    type: array
                    description: List of documents associated with the assignment.
                    items:
                      $ref: '#/components/schemas/AssignmentDocument'
        '400':
          description: Bad request (validation error or business logic conflict).
          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: >-
                                Only one of documents, or isFinal can be
                                provided
        '403':
          description: Authentication failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/403Response'
        '404':
          description: Assignment 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: Assignment is not found
      security:
        - bearerAuth: []
components:
  schemas:
    AssignmentDocument:
      type: object
      properties:
        id:
          type: string
          format: uuid
          example: bec0d0bf-fff6-40de-9750-65f5dcaf470d
          description: Unique identifier for the document.
        status:
          type: integer
          example: 1
          description: Status of the document.
        pageNo:
          nullable: true
          type: integer
          example: 1
        uploadTime:
          type: string
          format: date-time
          example: '2025-04-06T09:04:11.716434Z'
          description: Upload time of the document.
        url:
          type: string
          format: uri
          example: >-
            https://cgfblob.blob.core.windows.net/documents/assignment-evaluation/olfactory_imagery_HW_PDF_2_questions_1_H7dPCAd.pdf
          description: URL of the document.
        fileType:
          type: integer
          example: 1
          description: Type of the file.
    403Response:
      type: object
      properties:
        detail:
          type: string
          example: Token has expired
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````