fix: 阶段二循环上界填空题面与答案大小写口径不一致 - #59
Merged
XiaoCow666 merged 1 commit intoSep 19, 2026
Merged
Conversation
XiaoCow666
approved these changes
Sep 19, 2026
XiaoCow666
left a comment
Owner
There was a problem hiding this comment.
CodeSense 自动评审
未发现会阻塞合并的安全风险、功能回归或运行错误;核心目标已通过更新阶段二题面完成。新增回归测试与 PR 描述中的验证结果一致,剩余仅为测试实现层面的可维护性改进。
合并后可以继续改进的地方
- 回归测试通过正则和固定文本标记解析种子源文件,若后续调整代码格式或改用变量构造题面,测试可能在行为未回归时失效;可考虑补充基于实际播种结果的断言。
已有验证信息
- PR 描述提供:pytest tests/test_demo_stage2_loop_bound_prompt.py -q,改动后 2 passed。
- PR 描述提供:pytest tests/test_demo_experience.py tests/test_demo_guided_learning.py tests/test_demo_database_isolation.py -q,13 passed。
- PR 描述说明未运行全量 800+ 测试;该范围未验证不构成当前一行题面改动的阻塞问题。
评审事件:38fea250-b3cf-11f1-92c1-d86d75cb63de
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景(一次真实操作发现的卡点)
通过线上站点 https://saucodesense.com 的「学生体验」入口完整走核心学习路径时,在三阶段辅导的阶段二(积木编程)遇到一处明显阻力。
改动前的操作路径
上下文仅显示:
for (int i = 2; i < _; ++i) { ... },看不到变量声明N→ 点击「验证代码」学生因题面自身的大小写矛盾平白多一次错误尝试:题面和另外两题全部使用大写 N(数学符号),但程序实际声明的是
int n;,填空上下文又看不到声明。根因
预置数据
services/demo_experience.py的第 2 个 quiz step:question写「第 N 项」(大写)correct_answer为'n'(小写,与参考程序int n;一致,本身正确)判题先做精确比对再走 AI 等价性检查;真实运行中 AI 将 N/n 判为不等价。问题不在判题(C 语言标识符本就大小写敏感),而在题面没有告诉学生程序变量的真实名字。
改动(一个提示,一行)
services/demo_experience.py:补全循环条件,确保从第三项计算到第 N 项。补全循环条件,确保从第三项计算到第 N 项(程序读入的变量名为小写 n)。保留数学符号 N,同时显式给出程序变量名,学生第一次就能填对。
correct_answer仍是n(保证生成代码可编译)。改动后的操作路径(预期)
阶段二第 2 题题面 → 看到「程序读入的变量名为小写 n」→ 填入
n→ 验证代码 → 一次通过,不再出现由产品内容导致的误判。验证(实际结果)
tests/test_demo_stage2_loop_bound_prompt.py(纯标准库,仅读取种子源文件文本;不 import Flask、不连数据库/Redis、不启动应用),共 2 个测试:pytest tests/test_demo_stage2_loop_bound_prompt.py -q→ 1 failed, 1 passed(旧题面不含「小写 n」)pytest tests/test_demo_experience.py tests/test_demo_guided_learning.py tests/test_demo_database_isolation.py -q→ 13 passed(覆盖种子幂等写入、引导学习渲染、临时库隔离)未验证范围
回退
单提交、一行改动,revert 即可。