API accepts choice options on a question type that has none

未关闭 适合新手
#3,981 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
php
领域
api, backend

调研方向

从 POST /ocs/v2.php/apps/forms/api/v3/forms/{formId}/questions/{questionId}/options 的 API 路由开始,找到存储选项文本的 controller 方法。阅读问题类型是如何建模的,以及问题现有的类型校验发生在哪里,然后在问题类型不接受任何选择时拒绝创建选项。添加或扩展覆盖 short 问题的 API 测试,并确认它现在返回 400 且没有写入任何行。

由索引模型根据 Issue 内容生成。

描述

Describe the bug

The API accepts choice options on a question type that has no choices. They are stored but never used.

Steps to reproduce
  1. Create a form with a question of type short (short text).
  2. POST /ocs/v2.php/apps/forms/api/v3/forms/{formId}/questions/{questionId}/options with {"optionTexts": ["Coffee", "Tea"]}.
Expected behaviour

400: the question type takes no options.

Actual behaviour
  1. The form still shows a text field, and the two options are stored as dead rows on the question.
Versions

Forms 5.4.2.

主要语言
JavaScript
星标
385
派生
133
平均合并
7 小时 54 分钟
30 天内合并 PR
157

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

nextcloud/forms 的其他 Issue

查看 nextcloud/forms 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。