考试: - 新增 src/exam-plan.js(纯函数)判定结果页处置:只有本页确实点过 「提交考试/确定交卷」才算一次空卷交卷,平台恢复的旧结果页先回 「考试说明页」重进,不再在结果页和课程页之间空转 - 重试也不会好的确定性失败(交卷次数到上限、说明页无「开始考试」、 答卷页无「提交考试」、结果页反复回退)改为本轮跳过该课继续下一门, 记录在 S.skippedCourses(sessionStorage),不会停下整轮刷课 - 新一轮开跑时清空 skippedCourses / examEmptySubmits,人工处理后可重试 - 补 dev/tests/exam-test.mjs(npm run test:exam,5 条用例) 构建: - 新增 scripts/build-docker.mjs/.cmd/.sh(npm run docker:build): 国内换源、按包版本打标签、构建后自检、--dry-run - Dockerfile 增加 APT_MIRROR / NPM_REGISTRY 构建参数, docker-compose.yml 透传三个 build args,.env.example 补说明
39 lines
1.5 KiB
JavaScript
39 lines
1.5 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* 考试结果页处置(src/exam-plan.js)自测:纯决策逻辑,不需要浏览器。
|
|
*
|
|
* 钉住的回归:重进课程时平台会恢复上次的考试结果页。那一页不是本页交的卷,
|
|
* 不能计入「空卷交卷」次数,否则 maxExamTries 失效且会在结果页↔课程页之间死循环。
|
|
*
|
|
* 用法:
|
|
* node dev/tests/exam-test.mjs
|
|
* npm run test:exam
|
|
*/
|
|
import { planExamResult } from '../../src/exam-plan.js';
|
|
|
|
let failed = 0;
|
|
function eq(actual, expect, name) {
|
|
if (actual === expect) console.log(' ✔ ' + name);
|
|
else {
|
|
failed++;
|
|
console.log(' ✘ ' + name + ' → 期望 ' + JSON.stringify(expect) +
|
|
',实际 ' + JSON.stringify(actual));
|
|
}
|
|
}
|
|
|
|
console.log('考试结果页');
|
|
eq(planExamResult({ submitted: true, complete: false }), 'count', '本页交的卷、平台未记账 → 计一次空卷交卷');
|
|
eq(planExamResult({ submitted: true, complete: true }), 'complete', '本页交的卷、平台已记账 → 直接收课');
|
|
eq(planExamResult({ submitted: false, complete: false, staleTries: 0 }), 'reback',
|
|
'平台恢复的旧结果页 → 回考试说明页重进,不计交卷');
|
|
eq(planExamResult({ submitted: false, complete: false, staleTries: 2 }), 'skip',
|
|
'反复回不到考试说明页 → 跳过该课等人工');
|
|
eq(planExamResult({ submitted: false, complete: true }), 'complete',
|
|
'没交卷但平台已算完成 → 直接收课');
|
|
|
|
if (failed) {
|
|
console.log('\n失败 ' + failed + ' 项');
|
|
process.exit(1);
|
|
}
|
|
console.log('\n全部通过');
|