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

# Serve Module Quiz

> Serve module-quiz questions, creating or reusing the attempt server-side.

Auth: portal API key + X-Learner-Email header. 404 "Not enrolled in this
course" if the header learner has no enrollment row for course_id.

Attempt lifecycle (server-owned, no client input selects questions):
  - If the learner has an in-progress attempt for this module
    (finished_at IS NULL), this call is STICKY: it returns the exact same
    attempt_id + questions that were served when the attempt was created,
    so refreshing the page never reshuffles an in-flight quiz.
  - If there is no in-progress attempt (first attempt, or the previous
    attempt for this module was already graded), a NEW attempt is
    created and stratified-random questions are drawn per difficulty
    tier, EXCLUDING every question_version_id the learner has already
    been served for this module -- so a retry after a finished attempt
    always draws a fresh, previously-unseen set (falls back to repeats
    only once the pool of unseen questions is exhausted).

Returns 200 {attempt_id, questions, pass_threshold}. `questions` is
[{id, question, type, options, max_score}] with every answer-key field
(correct/key_points/rubric) stripped; `id` is str(question_version_id) and
must be echoed back as the answers' question_id on grade. 404
quiz_not_available if the module has no question pool.



## OpenAPI

````yaml /openapi.yaml get /api/v1/learn/courses/{course_id}/quiz/modules/{module_num}
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}:
    get:
      tags:
        - B2B Learn
      summary: Serve Module Quiz
      description: >-
        Serve module-quiz questions, creating or reusing the attempt
        server-side.


        Auth: portal API key + X-Learner-Email header. 404 "Not enrolled in this

        course" if the header learner has no enrollment row for course_id.


        Attempt lifecycle (server-owned, no client input selects questions):
          - If the learner has an in-progress attempt for this module
            (finished_at IS NULL), this call is STICKY: it returns the exact same
            attempt_id + questions that were served when the attempt was created,
            so refreshing the page never reshuffles an in-flight quiz.
          - If there is no in-progress attempt (first attempt, or the previous
            attempt for this module was already graded), a NEW attempt is
            created and stratified-random questions are drawn per difficulty
            tier, EXCLUDING every question_version_id the learner has already
            been served for this module -- so a retry after a finished attempt
            always draws a fresh, previously-unseen set (falls back to repeats
            only once the pool of unseen questions is exhausted).

        Returns 200 {attempt_id, questions, pass_threshold}. `questions` is

        [{id, question, type, options, max_score}] with every answer-key field

        (correct/key_points/rubric) stripped; `id` is str(question_version_id)
        and

        must be echoed back as the answers' question_id on grade. 404

        quiz_not_available if the module has no question pool.
      operationId: >-
        serve_module_quiz_api_v1_learn_courses__course_id__quiz_modules__module_num__get
      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
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    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

````