Sfoglia il codice sorgente

fix(teaching): show legacy writing confirmation handoff

彭峰 1 ora fa
parent
commit
ee8dfa7b76
2 ha cambiato i file con 22 aggiunte e 1 eliminazioni
  1. 6 1
      scripts/cloud/lesson-workflow.js
  2. 16 0
      scripts/tests/lesson-workflow.test.mjs

+ 6 - 1
scripts/cloud/lesson-workflow.js

@@ -82,7 +82,12 @@ async function lessonOrderCapabilities(order, current) {
     else if (status === 0 && (preparationReason||(!state.bindingId&&!freeWriting) || !Array.isArray(state.creditCostsSnapshot) || !state.creditCostsSnapshot.length || state.creditHoldStatus && state.creditHoldStatus !== 'ready')) blockedReason = preparationReason||state.creditHoldReason||'开课记录或课时凭据尚未核实,请联系管理员';
     else if (status === 0) actions.push('start');
     if (status === 10) actions.push('continue','complete');
-    if ([11,20].includes(status)) actions.push('complete');
+    if ([11,20].includes(status)) {
+      const endedInLegacyWriting = String(state.kcid)==='398' && state.sourceKey==='legacy:model:54:general:'+id
+        && lesson && state.kssj && state.jssj && !state.creditCostsSnapshot?.length;
+      if (endedInLegacyWriting) blockedReason = '本节课已在旧系统结束,请在旧系统完成课后确认';
+      else actions.push('complete');
+    }
     if ([30,40].includes(status) && !feedbackLocked) actions.push('editFeedback');
   }
   if (!order.cancelled && student && [30,40].includes(status) && !reviewed) actions.push('review');

+ 16 - 0
scripts/tests/lesson-workflow.test.mjs

@@ -416,6 +416,22 @@ test('教师可以开始免教材语法写作,单词课仍要求有效开课
  state.kcid='0';state.courseCategoryKey='word';assert.ok(!(await context.lessonOrderCapabilities(order,teacher)).allowedActions.includes('start'));
  state.courseCategoryKey='high_writing';state.creditHoldStatus='insufficient';assert.ok(!(await context.lessonOrderCapabilities(order,teacher)).allowedActions.includes('start'));
 });
+test('已在旧系统结束的写作课提示回旧系统确认,不再展示新系统结课',async()=>{
+ const {default:vm}=await import('node:vm');
+ const state={kcid:'398',sourceKey:'legacy:model:54:general:123',kssj:'2026-11-08 10:43',jssj:'2026-11-08 11:40',creditCostsSnapshot:null};
+ const lesson={pf:null};
+ const context={DEFAULT_COMPANY_ID:'co',number:Number,ownLegacyId:()=>30,fail:(_c,m)=>{throw Error(m);},
+  Psql:{oneOrNone:async(sql)=>sql.includes('FROM "CourseAppointment"')?state:sql.includes('FROM "LessonRecord"')?lesson:null}};
+ vm.createContext(context);
+ vm.runInContext(readFileSync(new URL('../cloud/lesson-workflow.js',import.meta.url),'utf8'),context);
+ const teacher={get:k=>k==='company'?{id:'co'}:null},order={GeneralID:123,pl:30,szyh:20,dszt:11};
+ const legacy=await context.lessonOrderCapabilities(order,teacher);
+ assert.deepEqual(Array.from(legacy.allowedActions),[]);
+ assert.match(legacy.blockedReason,/旧系统.*确认/);
+ state.creditCostsSnapshot=[{account:'SilverCoin',amount:1}];
+ assert.ok((await context.lessonOrderCapabilities(order,teacher)).allowedActions.includes('complete'));
+});
+
 test('确认学段的旧阅读写作课保留原课程编号,开始结课后生成十轮复习',async()=>{
  await db.exec('BEGIN');try{
   await db.exec('ALTER TABLE "CourseAppointment" ADD COLUMN IF NOT EXISTS "categoryEvidence" text');