Skip to content

Update quiz

Updates a quiz's settings and questions.

Needs the quiz:write scope.

Rich text (blocks[].content) is HTML in a closed format: p, h1 to h3, br, strong, em, u, s, sup, sub, code, a (href), span (style color, background-color), text-align on p and h1 to h3, ul, ol, li (data-checked), table rows and cells, pre with code, blockquote, hr, details with summary, figure with figcaption, and for images, videos, audio, slideshows, formulas, diagrams and other blocks, their props as getBodySchema lists them; anything else is refused with its path and reason. E.g.

Intro

Read this first.

Set text_format to “markdown” to write Markdown instead.

Call

  • Tool: update_quiz
  • Scope: quiz:write
  • Writes, and may change or remove what is there.
  • Acts on a store.

Arguments

Name Type Required Description
store string No The store to act on.
text_format "html" or "markdown" No The format the rich text fields are written in: the rich text format’s HTML, or Markdown converted into it before it is validated. A text already stored in the format (starting with <rich-text) is kept as it is either way.
product object Yes
quiz object Yes
full true No Answers the texts, attachments and file lists the short answer leaves out.
title string or null No
settings object No
blocks array of object No New questions, for a version nobody sat; a key the schema does not know is refused.
replaces object No The body asset the new questions replace; another one there refuses them.
newest boolean No Refuse unless the version is still the entry’s newest.
entry object Yes
{
  "type": "object",
  "properties": {
    "store": {
      "type": "string",
      "description": "The store to act on."
    },
    "text_format": {
      "type": "string",
      "enum": [
        "html",
        "markdown"
      ],
      "default": "html",
      "description": "The format the rich text fields are written in: the rich text format’s HTML, or Markdown converted into it before it is validated. A text already stored in the format (starting with `<rich-text`) is kept as it is either way."
    },
    "product": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            }
          },
          "required": [
            "id"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "slug": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            }
          },
          "required": [
            "slug"
          ],
          "additionalProperties": false
        }
      ]
    },
    "quiz": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 512
        }
      },
      "required": [
        "id"
      ],
      "additionalProperties": false
    },
    "full": {
      "description": "Answers the texts, attachments and file lists the short answer leaves out.",
      "type": "boolean",
      "const": true
    },
    "title": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        {
          "type": "null"
        }
      ]
    },
    "settings": {
      "type": "object",
      "properties": {
        "attempts_allowed": {
          "description": "Null is unlimited.",
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            },
            {
              "type": "null"
            }
          ]
        },
        "pass_mark": {
          "description": "Percent needed to pass; null passes any finished sitting.",
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            },
            {
              "type": "null"
            }
          ]
        },
        "show_answers": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "blocks": {
      "description": "New questions, for a version nobody sat; a key the schema does not know is refused.",
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "multiple_choice"
              },
              "id": {
                "type": "string"
              },
              "question": {
                "type": "string"
              },
              "options": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "text": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "text"
                  ],
                  "additionalProperties": false
                },
                "minItems": 2,
                "maxItems": 100
              },
              "correctOptionId": {
                "type": "string"
              },
              "weight": {
                "type": "number"
              },
              "hint": {
                "type": "string"
              },
              "explanation": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "id",
              "question",
              "options",
              "correctOptionId",
              "weight"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "scale"
              },
              "id": {
                "type": "string"
              },
              "question": {
                "type": "string"
              },
              "min": {
                "type": "number"
              },
              "max": {
                "type": "number"
              },
              "correctValue": {
                "type": "number"
              },
              "weight": {
                "type": "number"
              },
              "hint": {
                "type": "string"
              },
              "explanation": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "id",
              "question",
              "min",
              "max",
              "correctValue",
              "weight"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "static_text"
              },
              "id": {
                "type": "string"
              },
              "content": {
                "description": "The text a sitter reads, in the rich text format with the blocks a lesson takes, showing a reader at most 500 characters (UTF-16 units).",
                "type": "string",
                "x-rich-text": "text"
              }
            },
            "required": [
              "type",
              "id",
              "content"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "section_break"
              },
              "id": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "id"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "separator"
              },
              "id": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "id"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "true_false"
              },
              "id": {
                "type": "string"
              },
              "question": {
                "type": "string"
              },
              "correctAnswer": {
                "type": "boolean"
              },
              "weight": {
                "type": "number"
              },
              "hint": {
                "type": "string"
              },
              "explanation": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "id",
              "question",
              "correctAnswer",
              "weight"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "short_text"
              },
              "id": {
                "type": "string"
              },
              "question": {
                "type": "string"
              },
              "acceptedAnswers": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "text": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "text"
                  ],
                  "additionalProperties": false
                },
                "minItems": 1,
                "maxItems": 100
              },
              "weight": {
                "type": "number"
              },
              "hint": {
                "type": "string"
              },
              "explanation": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "id",
              "question",
              "acceptedAnswers",
              "weight"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "free_text"
              },
              "id": {
                "type": "string"
              },
              "question": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "id",
              "question"
            ],
            "additionalProperties": false
          }
        ]
      },
      "minItems": 1,
      "maxItems": 50
    },
    "replaces": {
      "description": "The body asset the new questions replace; another one there refuses them.",
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 512
        }
      },
      "required": [
        "id"
      ],
      "additionalProperties": false
    },
    "newest": {
      "description": "Refuse unless the version is still the entry's newest.",
      "type": "boolean"
    },
    "entry": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 512
        }
      },
      "required": [
        "id"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "product",
    "quiz",
    "entry"
  ],
  "additionalProperties": false
}

Answer

Name Type Required Description
id string Yes
created_at string or null Yes
updated_at string or null Yes
settings object Yes
product_id string Yes
entry_id string Yes
version number Yes
certificates array of object Yes
question_count number Yes How many of its blocks are questions a sitter answers.
sittings number Yes
body object Yes
files object No The files its static text names, as its save bound them; answered only with full.
created array of object Yes The attachments the write bound: the files its new static text names.

The answer’s full shape is on its API reference page.

Errors

A refused call is a tool error. Its structuredContent holds a code and its context, except for client-fault. This tool may answer:

  • invalid: an argument is malformed; context.path names it.
  • invalid at ["store"]: store is missing while the connection reaches more than one store, or names a store it doesn’t reach.
  • not_found: nothing matches a reference given.
  • conflict: the call clashes with the current state; context names the field and, where it helps, its current value, and for a from, live, expect or version that no longer matches, the argument (path) and what it takes (reason).
  • not_permitted: this connection may not make this call. When context.reason is limit, too many calls: retry_after says when to try again.
  • internal or unavailable: the call failed inside Sherpo, and the write may have landed. This write takes no idempotency key, so read the state back before trying again.
  • client-fault: the server failed around the call. core_answer ok means the write landed, so don’t send it again. When reached_core is false, nothing happened and the call may be made again. Otherwise, this write takes no idempotency key, so read the state back before trying again.
  • HTTP 403 with insufficient_scope: the connection lacks the scope this tool needs.
  • HTTP 401 with invalid_token: the access token expired or the connection ended. Refresh the token, and connect again if the refresh fails or the new token is refused too.

Any other code may come back too, such as a conflict when the state changed under the call. When the answer was already streaming, a 401 or 403 comes back as a tool error with only its text. See Errors for every code and its context.

Type to search…

↑↓ navigate↵ selectEsc close