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

# 提交作答判定

> 把本次作答的判定写下来：是否掌握，以及错因。

要带 `expectedRevision`，与打开作答纸时用的是同一个版本号。

出现下列情形时判定不会写下：

- `PRACTICE_CONFIG_UNAVAILABLE`：当前场景没有给该插件声明标签前缀与错因清单。该项配置取自 `GET /immersive/template` 的 `plugins[].config`。
- `PRACTICE_TOPIC_CHANGED`：这道题不属于当前学习集。须刷新重读后重新提交，原地重试得到同样的结果。
- `PRACTICE_KEY_INVALID`：身份无法写出。

后两者发生在写入之前，没有任何改动生效。




## OpenAPI

````yaml /openapi/plugin-api.yaml post /notes/{noteid}/practice-verdict
openapi: 3.1.0
info:
  title: 场景插件 API
  summary: 场景插件在网页面板里可以调用的接口。
  description: >
    场景插件的面板是一个网页。页面里向 `/bridge/v1` 发请求，就能读写 MarginNote 里的数据。

    请求由 MarginNote 处理，与外部命令行工具共用同一套处理代码。外部工具要带令牌，面板不必带。

    面板页面从 `mnpanel://panel/index.html` 加载，因此 `fetch('/bridge/v1' + path)`
    属于同源请求。


    面板调用受这些条件约束：


    - 请求不带令牌，本文件也不声明安全方案。

    - 页面能调用哪些接口，取决于两份名单。模板里的 `plugins` 名单和沉浸态决定面板能不能建好，
      网页面板白名单决定页面能调哪些接口。不在白名单里的请求返回 `403`，
      错误码为 `IN_PROCESS_NOT_ALLOWED`。
    - `GET /capabilities` 里的 `requiresMax` 只约束外部 Agent。面板的请求在 MarginNote 进程内处理，
      不受令牌、订阅状态与跨设备批准的限制，能否调用只看该路径是否在白名单内。
    - 写操作里的 `addon`，MarginNote 会改写为当前面板所属插件的 id；`confirm` 由 MarginNote 补上。
      页面填的值不会生效。

    用 `mn.api(path, opts)` 读取数据。该方法始终将 Response Body 按 JSON 解析，相当于

    `fetch('/bridge/v1' + path, opts).then(r => r.json())`。


    响应的内容不是 JSON 的接口，改用 `fetch`：


    - `GET /guide` 返回 Markdown 正文。

    - `GET /notes/{noteid}/render` 返回卡片长图或 PDF。

    - `GET /documents/{bookmd5}/pages/{index}/content/{contentId}` 返回图片。

    - `GET /bundles/{bundleId}/files` 带 `?path=` 时返回该文件的原始字节。


    调用失败时 Promise 不会进入 reject。MarginNote 把错误对象

    `{"error":{"code":"…","message":"…"}}` 当作 Response Body 返回，因此结果落在 resolve 里。

    判断调用结果看响应里是否带 `error`，写操作另看响应里的 `persisted`。


    接口清单、各项上限与 Request Body 结构随 MarginNote 的版本变化，运行时以 `GET /capabilities` 与

    `GET /guide` 返回的内容为准。
  version: '0.91'
servers: []
security: []
tags:
  - name: 能力与状态
    description: 读取 MarginNote 的能力、版本与当前上下文。调用其他接口之前先读这组。
  - name: 卡片与摘录
    description: 卡片的读取与写入、摘录的创建、批注、标签、元数据与留白。
  - name: 手写会话
    description: 手写层、作答纸、练习准备清单与会话记录的读取与提交。
  - name: 学习集与卡组
    description: 学习集结构、脑图树、子脑图、色板、快照与复习卡组。
  - name: 文档与页面
    description: 文档目录、页文本、页内注释面、摘录清单与同步诊断。
  - name: 导出与 Anki
    description: 文档导出计划、导出文件、Anki 导出能力、作业与产物。
  - name: 查找
    description: 跨库搜索、文件夹列表与学习集列表。
  - name: 界面与模板
    description: 读取当前界面状态与沉浸模板。
  - name: 插件辅助
    description: 面板辅助脚本、已配对设备与本机 helper 信息。
  - name: 任务包与同步诊断
    description: 拆书任务包与旧 CloudKit 同步诊断。
paths:
  /notes/{noteid}/practice-verdict:
    post:
      tags:
        - 卡片与摘录
      summary: 提交作答判定
      description: >
        把本次作答的判定写下来：是否掌握，以及错因。


        要带 `expectedRevision`，与打开作答纸时用的是同一个版本号。


        出现下列情形时判定不会写下：


        - `PRACTICE_CONFIG_UNAVAILABLE`：当前场景没有给该插件声明标签前缀与错因清单。该项配置取自 `GET
        /immersive/template` 的 `plugins[].config`。

        - `PRACTICE_TOPIC_CHANGED`：这道题不属于当前学习集。须刷新重读后重新提交，原地重试得到同样的结果。

        - `PRACTICE_KEY_INVALID`：身份无法写出。


        后两者发生在写入之前，没有任何改动生效。
      operationId: postNotesNoteidPracticeVerdict
      parameters:
        - $ref: '#/components/parameters/Noteid'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PracticeVerdictRequest'
            examples:
              again:
                summary: 还要练，错因是粗心
                value:
                  commentId: 1F4C2A90-6C2B-4E1F-9F3A-2B7C1D5E8A44
                  expectedRevision: '3'
                  practice:
                    topic: 77012CA0-48E8-4D29-B5F5-1EEA927AE086
                  self: again
                  reason: careless
                  confirm: true
      responses:
        '200':
          description: 响应。可能还有未列出的字段。
          content:
            application/json:
              schema:
                type: object
                properties:
                  noteid:
                    type: string
                    description: 作答所属的卡片。
                  hashtags:
                    type: array
                    items:
                      type: string
                    description: 判定写完之后该卡上的标签。前缀、状态与错因三段来自场景模板的配置。
                  persisted:
                    type: boolean
                    description: 判定是否已经落盘。
                  tagsChanged:
                    type: boolean
                    description: 本次调用是否改动了标签。
                  commentsRevision:
                    type: string
                    description: 写完之后该卡批注的新版本。字符串形态，回传时原样带回。
                  practice:
                    type: object
                    properties:
                      reason:
                        type:
                          - 'null'
                          - string
                        description: 错因代码。判定为掌握时该字段与 `reasonLabel` 同为 `null`。
                      card:
                        type: string
                        description: 判定所属的卡片。
                      topic:
                        type: string
                        description: 判定所属的学习集。
                      self:
                        type: string
                        enum:
                          - got
                          - again
                        description: 写下的判定结论。`got` 表示掌握，`again` 表示仍需练习。
                      reasonLabel:
                        type:
                          - 'null'
                          - string
                        description: 错因在界面上显示的名字。判定为掌握时为 `null`。
                      at:
                        type: number
                        description: 判定写下的时间，Unix 秒级时间戳，带小数。
                      addon:
                        type: string
                        description: 判定的归属插件。
                    required:
                      - reason
                      - card
                      - topic
                      - self
                      - reasonLabel
                      - at
                      - addon
                    description: 写下的判定内容。
                  commentId:
                    type: string
                  bridgeApiVersion:
                    type: string
                required:
                  - noteid
                  - hashtags
                  - persisted
                  - tagsChanged
                  - commentsRevision
                  - practice
                  - commentId
                  - bridgeApiVersion
              examples:
                assembled:
                  summary: 构造示例，未实测
                  value:
                    persisted: true
                    noteid: B9F3696A-AF8A-43B2-A8A2-2791717F1695
                    commentId: 1F4C2A90-6C2B-4E1F-9F3A-2B7C1D5E8A44
                    practice:
                      addon: mn.cardpractice
                      topic: 77012CA0-48E8-4D29-B5F5-1EEA927AE086
                      card: B9F3696A-AF8A-43B2-A8A2-2791717F1695
                      self: again
                      reason: careless
                      reasonLabel: 粗心
                      at: 1791273090
                    hashtags:
                      - '#practice/question'
                      - '#practice/again'
                      - '#practice/error/careless'
                    tagsChanged: true
                    commentsRevision: '4'
                    bridgeApiVersion: '0.91'
                measured:
                  summary: 实测于 2026-10-07，App 0.91
                  value:
                    noteid: EB3BA5C0-4850-4713-9A73-BAE677983F5E
                    hashtags:
                      - '#practice/question'
                      - '#practice/todo'
                      - '#practice/error/careless'
                    persisted: true
                    tagsChanged: true
                    commentsRevision: >-
                      af25c5a48b79e08478453a6c9de74a2d3aabbf779138ab5f0406caec2b59ad34
                    practice:
                      reason: careless
                      card: EB3BA5C0-4850-4713-9A73-BAE677983F5E
                      topic: 180F6ADB-5F06-4F09-9DA0-EEB6A967EF28
                      self: again
                      reasonLabel: 粗心
                      at: 1791372760.493465
                      addon: mn.cardpractice
                    commentId: 98EC2729-4BA1-4EE7-8CDE-172FA41ABFCE
                    bridgeApiVersion: '0.91'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
        '500':
          $ref: '#/components/responses/InternalError'
      x-codeSamples:
        - lang: javascript
          label: 记录判定
          source: |
            await mn.api('/notes/' + noteid + '/practice-verdict', {
              method: 'POST',
              body: {
                commentId, expectedRevision: rev,
                practice: { topic: topicid },
                self: 'again', reason: 'careless',
                confirm: true
              }
            });
components:
  parameters:
    Noteid:
      name: noteid
      in: path
      required: true
      description: >-
        卡片的 noteid。取自卡片命令响应的 `noteid`、`POST /notes/batch-get` 响应里
        `items[].noteid`，或 `GET /ui-state` 的 `state.focusnoteid`。
      schema:
        type: string
  schemas:
    PracticeVerdictRequest:
      type: object
      required:
        - commentId
        - expectedRevision
        - practice
        - self
        - confirm
      properties:
        commentId:
          type: string
          description: 本次作答纸的身份。
        expectedRevision:
          type: string
          description: 版本号，同 `annotation-editor`。
        practice:
          type: object
          description: 判定的归属与所在学习集。只含 `addon` 与 `topic` 两项。
          required:
            - topic
          properties:
            addon:
              type: string
              description: >-
                判定的归属插件，取值是场景模板里为该场景配置的插件 id。面板发起的调用由宿主注入，命令行发起的调用须自行写入，缺少该字段时返回
                `INVALID_INPUT`。
            topic:
              type: string
              description: 这道题所在的学习集。
        self:
          type: string
          enum:
            - got
            - again
          description: 判定结论。`got` 表示掌握，`again` 表示仍需练习。
        reason:
          type: string
          description: 错因。可以不传，也可以写成 `null`。
        confirm:
          type: boolean
          description: 必填。由 MarginNote 自动补上。
    ErrorEnvelope:
      type: object
      description: >-
        失败时的 Response Body。MarginNote 将其当作正常 Response Body 返回，因此落在 resolve 里而不是
        reject 里。
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorObject'
    ErrorObject:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: 错误码。判断写入是否发生看该字段，不看 HTTP 状态码。
        message:
          type: string
          description: 人可读的说明。文案随 MarginNote 的版本变化，不要用该字段做分支判断。
        retryable:
          type: boolean
          description: >-
            是否明确可以稍后再试。只有外部调用的响应带该字段，面板本地调用的响应只有 `code` 与
            `message`。该布尔值表达不了结果未定，这类情况按各接口的说明处理，例如手写会话族看响应里的
            `layerLeaseUnresolved`。
        details:
          type: object
          description: >-
            附加事实。例如 `SCAN_BUSY` 带 `retryAfterSeconds`，`HASHTAG_ROUTE_REQUIRED` 带
            `writeRoute`。
          additionalProperties: true
  responses:
    Conflict:
      description: 读取到写入之间的这段时间里目标被改过，本次调用没有写入任何内容。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            contentChanged:
              summary: 内容已被改过
              value:
                error:
                  code: CONTENT_CHANGED
                  message: 目标内容在这期间被改过，请重读后再发。
    UnprocessableEntity:
      description: 字段合法但组合不成立，例如缺少 `confirm`、序号越界、或写入顺序违反约定。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            confirmRequired:
              summary: 没有带 confirm
              value:
                error:
                  code: CONFIRM_REQUIRED
                  message: 本次调用会改动数据，需要带 confirm。
            invalidOrder:
              summary: 写入顺序不成立
              value:
                error:
                  code: INVALID_ORDER
                  message: deleteComment 必须排在 removeHashtags 之前。
    InternalError:
      description: 写入后重新读取核对不通过，或写入过程报错。返回该响应表示写入未成功。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            saveFailed:
              summary: 写入磁盘后重新读取不一致
              value:
                error:
                  code: SAVE_FAILED
                  message: 写入之后重新读取核对不通过，碰过的卡已整体恢复。
                  retryable: false

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.