Appearance
试题 Question
试题是题目结构的根节点,支持任意层级嵌套(综合题的子题即嵌套的 question)。
由 QuestionKit 自动注册,通常无需单独配置。
节点定义
| 项 | 值 |
|---|---|
| content | 'questionNumber questionMain' |
| 其他 | defining、isolating |
| HTML | <div class="qp-question"> |
命令
| 命令 | 说明 |
|---|---|
setQuestion() | 将当前节点转换为试题 |
insertQuestion(options?) | 按指定类型插入一道结构完整的试题,见下表 |
deleteQuestion() | 删除当前试题 |
InsertQuestionOptions
| 名称 | 类型 | 说明 |
|---|---|---|
type | QuestionType | 试题类型,决定预置结构 |
pos | number | 插入位置,默认为当前选区末尾 |
insertQuestion 按类型预置结构(不自动附加答案/解析,可后续用 insertQuestionExtra 手动添加):
QuestionType 取值
| 值 | 预置结构 |
|---|---|
'choice' | 题干 + 选项组(4 个空选项,一行四列) |
'trueOrFalse' | 题干 + 选项组(「正确」「错误」两个选项,一行两列) |
'fillInTheBlank' | 仅题干 |
'shortAnswer' | 仅题干 |
'comprehensive' | 题干 + 一道嵌套的子选择题(4 个选项、一行四列) |
ts
editor.commands.insertQuestion({ type: 'choice' })