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

# Grade Module Quiz

> Grade a module-quiz attempt against its server-persisted served set.

Auth: portal API key + X-Learner-Email header.

Request body: {attempt_id, answers} where `attempt_id` is the id returned
by the serve endpoint above and `answers` is [{question_id, answer}] with
question_id = the served question's string id. The client cannot shrink
or alter the grading denominator by omitting or relabeling questions: the
server reloads the exact question set it persisted as served_question_ids
at serve time and grades against THAT, not against whatever `answers`
contains. Any served question left unanswered scores 0.

Errors: 404 "Not enrolled in this course" if the header learner has no
enrollment; 404 "Attempt not found" if attempt_id does not belong to this
learner's enrollment for this module (co-learner isolation); 409
attempt_already_graded if the attempt was already finished (grade is
one-shot per attempt -- call serve again to get a new attempt); 503
grading_unavailable (retryable) if the AI grader is transiently down.

Returns 200 {score, max_score, percentage, passed, pass_threshold,
completion_pct}. Also recomputes and persists enrollment completion_pct,
and lazily issues the certificate if this grade completes eligibility
(see get_certificate).



## OpenAPI

````yaml /openapi.yaml post /api/v1/learn/courses/{course_id}/quiz/modules/{module_num}/grade
openapi: 3.1.0
info:
  title: Mahara Platform
  description: >
    AI Sales Training Course Generator, a Coursera-style platform.


    ## Authentication


    Every request must carry your API key as a Bearer token:


    `Authorization: Bearer sk_live_your_key_here`


    ## Getting an API key


    API keys are provisioned by our team. They are not self-service, so there is
    no signup page to apply on. To request access, email **sales@myustadia.com**
    and we will issue a key for your account.
  version: 1.0.0
servers: []
security: []
paths:
  /api/v1/learn/courses/{course_id}/quiz/modules/{module_num}/grade:
    post:
      tags:
        - B2B Learn
      summary: Grade Module Quiz
      description: >-
        Grade a module-quiz attempt against its server-persisted served set.


        Auth: portal API key + X-Learner-Email header.


        Request body: {attempt_id, answers} where `attempt_id` is the id
        returned

        by the serve endpoint above and `answers` is [{question_id, answer}]
        with

        question_id = the served question's string id. The client cannot shrink

        or alter the grading denominator by omitting or relabeling questions:
        the

        server reloads the exact question set it persisted as
        served_question_ids

        at serve time and grades against THAT, not against whatever `answers`

        contains. Any served question left unanswered scores 0.


        Errors: 404 "Not enrolled in this course" if the header learner has no

        enrollment; 404 "Attempt not found" if attempt_id does not belong to
        this

        learner's enrollment for this module (co-learner isolation); 409

        attempt_already_graded if the attempt was already finished (grade is

        one-shot per attempt -- call serve again to get a new attempt); 503

        grading_unavailable (retryable) if the AI grader is transiently down.


        Returns 200 {score, max_score, percentage, passed, pass_threshold,

        completion_pct}. Also recomputes and persists enrollment completion_pct,

        and lazily issues the certificate if this grade completes eligibility

        (see get_certificate).
      operationId: >-
        grade_module_quiz_api_v1_learn_courses__course_id__quiz_modules__module_num__grade_post
      parameters:
        - name: course_id
          in: path
          required: true
          schema:
            type: string
            title: Course Id
        - name: module_num
          in: path
          required: true
          schema:
            type: integer
            title: Module Num
        - name: X-Learner-Email
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Learner-Email
        - name: X-Learner-Sig
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Learner-Sig
        - name: X-Learner-Sig-Ts
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Learner-Sig-Ts
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LearnerGradeRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    LearnerGradeRequest:
      properties:
        attempt_id:
          type: integer
          title: Attempt Id
          description: The attempt_id returned by the serve endpoint
        answers:
          items:
            additionalProperties: true
            type: object
          type: array
          maxItems: 500
          title: Answers
          description: '[{question_id, answer}] where question_id = the served question id'
      type: object
      required:
        - attempt_id
      title: LearnerGradeRequest
      description: >-
        Body for the learner grade endpoints. The served set is SERVER-persisted

        (quiz_attempts.served_question_ids), so the client only echoes the
        attempt_id

        + its answers -- it cannot shrink the denominator by omitting questions.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````