feat(SCUEC): 输出单双周标记,避免 App 把双周显示成 2、4、6… - #11
Merged
Conversation
中南民大教务课表里整段同奇偶的课程写作「1-16周(双)」,parseWeeks 会把它 展开成 [2,4,6,8,10,12,14,16],App 拿到 weeks 数组后逐周罗列,用户看到的 是「第2、4、6、8、10、12、14、16周」而不是「第2-16周 双周」。 - 新增 getWeekParity(weeks):整段同奇偶时返回 '单' / '双',否则 null; 少于 2 周不判定(避免「第3-3周 双周」这种怪显示) - parseSingleCourse / extractUnscheduledCourses 据此输出 isOddWeek / isEvenWeek(TestTool popup 已把这俩列为软件支持的扩展字段, CQUET 脚本也在输出,App 侧可直接显示「第x-y周 双周」) - weeks 仍按升序展开保留,兼容只认 weeks 的导入实现 - 课程详情日志附带 (单)/(双) 实测 2026-2027-1:16 门课中 3 门标为双周(数字电子技术(B)、复变函数(B)、 数字电子技术(B)(实验)),与页面原始 (双) 标记数一致;2025-2026-2 无单双周课, 19 门课标记数 0,均无回归。
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.
问题
中南民族大学教务课表里,整段同奇偶的课程写作
1-16周(双),脚本parseWeeks会把它展开成[2,4,6,8,10,12,14,16],只输出weeks数组。导入 App 后周次是逐周罗列的:1-16周(双)1-16周(双)9-16周(双)改动(
resources/SCUEC/scuec.js,+29 −2)getWeekParity(weeks):整段周次同奇偶时返回'单'/'双',否则null;少于 2 周不判定(避免出现「第3-3周 双周」这种怪显示)。parseSingleCourse()与extractUnscheduledCourses()据此输出isOddWeek/isEvenWeek。weeks仍按升序展开保留,兼容只认weeks的导入实现(桥接最低字段不变)。(单)/(双),方便调试。isOddWeek/isEvenWeek是仓库里已在使用的约定字段:tools/CourseImporterTestTool/popup.js的「软件支持的课程扩展字段」已列出这两个字段,resources/CQUET/cquet_01.js也在输出(weeks.every(w => w % 2 === 1/0))。验证
用真实课表 HTML(
jsdom加载)跑改动后的脚本:(双)标记数一致;3 门双周的weeks均为完整偶数序列,无误判。isOddWeek/isEvenWeek与weeks奇偶性完全一致(53 项断言全通过)。getWeekParity单元用例:1-16周(双)→双、1-15周(单)→单、1-16周→null、[2,4,6,10]→null、[3]→null等 10 项全通过。node --check通过。配套
App 侧(mikcb
lib/screens/course_import_screen.dart的_parseWarehouseCourses)目前只读weeks,会把它整个塞进customWeeks,所以只改脚本不会改变显示——customWeeks一旦有值,courseWeekDescription()就走「逐周罗列」分支,isEvenWeek的双周后缀永远轮不到。所以本 PR 只是把数据补全(脚本侧准备好
isOddWeek/isEvenWeek,对其它学校只认weeks的实现零影响);要在界面上真正看到「双周」,还需要 App 端在解析桥接课程时读取这两个字段(同 CQUET 的用法)。App 端改动我可以另开 PR。