소스 검색

Mark legacy reading and writing as mapped per appointment

彭峰 1 시간 전
부모
커밋
5731f3bf62

+ 1 - 0
projects/xiaoshu-admin/src/app/admin.models.ts

@@ -734,6 +734,7 @@ export interface CourseTeachingMapping extends Record<string, unknown> {
   categoryConfirmed: boolean;
   stageConfirmed: boolean;
   confirmed: boolean;
+  confirmByAppointment?: boolean;
   updatedAt: string;
 }
 

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 1
projects/xiaoshu-admin/src/app/pages/operations-payroll.component.html


+ 1 - 1
projects/xiaoshu-admin/src/app/pages/operations-payroll.component.ts

@@ -100,7 +100,7 @@ export class OperationsPayrollComponent implements OnInit,OnDestroy{
  creditSummary(rule:TeachingRule):string{return rule.creditCosts.map((item)=>`${item.label} -${item.amount}`).join('+');}
  editMatrixRule(row:TeachingRateMatrixRow,delivery:'online'|'offline'):void{const rule=row[delivery];this.ruleCategoryKey.set(row.categoryKey);this.ruleDuration.set(row.durationMinutes);this.ruleDelivery.set(delivery);this.rulePay.set(rule?.teacherPay||0);this.effectiveFrom.set(localDateKey(new Date()));}
  updateRuleCategory(categoryKey:string):void{this.ruleCategoryKey.set(categoryKey);const durations=TEACHING_CATEGORY_DURATIONS[categoryKey]||[];if(!durations.includes(this.ruleDuration()))this.ruleDuration.set(durations[0]||30);}
- mappingCategories(row:CourseTeachingMapping):TeachingCourseCategory[]{if(!row.stageConfirmed&&/语法|写作|作文|强化/.test(row.courseName))return [];return this.activeCategories().filter((category)=>!TEACHING_CATEGORY_STAGE[category.key]||TEACHING_CATEGORY_STAGE[category.key]===row.stageKey);}
+ mappingCategories(row:CourseTeachingMapping):TeachingCourseCategory[]{if(row.confirmByAppointment||(!row.stageConfirmed&&/语法|写作|作文|强化/.test(row.courseName)))return [];return this.activeCategories().filter((category)=>!TEACHING_CATEGORY_STAGE[category.key]||TEACHING_CATEGORY_STAGE[category.key]===row.stageKey);}
  mappingCategoryUnavailable(row:CourseTeachingMapping):boolean{return Boolean(row.categoryKey&&!this.mappingCategories(row).some((category)=>category.key===row.categoryKey));}
  setMapping(courseId:number,categoryKey:string):void{this.mappingSelections.update((value)=>({...value,[courseId]:categoryKey}));}
  async saveTeachingRule():Promise<void>{this.saving.set(true);this.error.set('');try{await this.operations.mutate('ops/teaching-rules/save','',`调整 ${this.ruleCategoryKey()} ${this.ruleDuration()}分钟${this.ruleDelivery()==='online'?'线上':'线下'}标准`,{categoryKey:this.ruleCategoryKey(),durationMinutes:this.ruleDuration(),deliveryMode:this.ruleDelivery(),teacherPay:this.rulePay(),creditCosts:this.creditCosts(),effectiveFrom:this.effectiveFrom(),active:true});this.message.set('费用与课时规则已保存,历史版本已保留');await this.load();}catch(error){this.error.set(error instanceof Error?error.message:'规则保存失败');}finally{this.saving.set(false);}}

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
scripts/deploy-admin-functions.mjs


+ 18 - 3
scripts/tests/teaching-course-mapping.test.mjs

@@ -13,7 +13,7 @@ context.companyIdOf = () => 'company-a';
 context.companyPointer = () => 'company-a';
 context.requireRole = () => {};
 context.reasonOf = () => 'mapping test';
-context.newClassObjects = async name => name === 'CourseTeachingProfile' ? [profile(454, 'word'), profile(464, 'word'), profile(398, 'word')] : [];
+context.newClassObjects = async name => name === 'CourseTeachingProfile' ? [profile(454, 'word'), profile(464, 'word')] : [];
 before(async () => {
   await db.exec(`
     CREATE TABLE "Node" (company text,"nodeId" numeric,"parentId" numeric,"nodeName" text,zstatus numeric);
@@ -21,7 +21,8 @@ before(async () => {
     CREATE TABLE "CourseBinding" ("objectId" text,company text,id numeric,yhid text,kcid text,"categoryKey" text,"categoryName" text,"enrollmentStatus" text,"updatedAt" timestamptz);
     CREATE TABLE "CourseAppointment" (company text,id numeric,kcid text);
     CREATE TABLE "CommonModel" ("objectId" text,company text,"modelId" numeric,"itemId" numeric,status numeric,subtitle text);
-    INSERT INTO "Node" VALUES ('company-a',8,0,'小学',99),('company-a',81,8,'小学语法写作课',99),('company-b',464,0,'其他帐套课程',99);
+    INSERT INTO "Node" VALUES ('company-a',8,0,'小学',99),('company-a',81,8,'小学语法写作课',99),
+      ('company-a',380,0,'写作',99),('company-a',398,380,'阅读写作',99),('company-b',464,0,'其他帐套课程',99);
     INSERT INTO "_User" VALUES ('company-a',20,false,false);
     INSERT INTO "CourseBinding" ("objectId",company,id,yhid,kcid,"enrollmentStatus") VALUES ('binding-81','company-a',81,20,'81','pending'),('binding-active','company-a',82,99,'81','active');
     INSERT INTO "CourseAppointment" VALUES ('company-a',1,'398'),('company-a',2,'454'),('company-a',3,'464'),('company-a',4,'999'),('company-b',5,'455');
@@ -48,9 +49,23 @@ test('real course query recovers missing Node courses, preserves tenant isolatio
   assert.equal(byId.has(999), false);
   assert.equal(byId.has(455), false);
 });
+test('cross-stage reading and writing is handled by appointment without a confirmed course category', async () => {
+  const standards = await context.teachingStandardsData({}, {});
+  const course = standards.mappings.find(row => row.courseId === 398);
+  assert.equal(course.stageName, '写作');
+  assert.equal(course.confirmByAppointment, true);
+  assert.equal(course.categoryKey, '');
+  assert.equal(course.confirmed, false);
+  assert.equal(standards.summary.courseCount, 4);
+  assert.equal(standards.summary.confirmedCount, 2);
+  assert.equal(standards.summary.unmappedCount, 1);
+  assert.equal(standards.mappings.find(row => row.courseId === 81).confirmByAppointment, undefined);
+});
 test('mapping rejects cross-stage writing, unknown courses and generic writing before saving', async () => {
   await assert.rejects(context.commitCourseMappings({}, {}, { items: [{ courseId: 81, categoryKey: 'high_writing' }] }), /语法写作分类必须/);
-  await assert.rejects(context.commitCourseMappings({}, {}, { items: [{ courseId: 398, categoryKey: 'word' }] }), /语法写作课程缺少学段/);
+  for (const categoryKey of ['word', 'primary_writing', 'middle_writing', 'high_writing']) {
+    await assert.rejects(context.commitCourseMappings({}, {}, { items: [{ courseId: 398, categoryKey }] }), /跨学段.*按预约确认/);
+  }
   await assert.rejects(context.commitCourseMappings({}, {}, { items: [{ courseId: 999, categoryKey: 'word' }] }), /未找到该课程/);
 });
 test('confirmed course mapping activates a valid unambiguous historical binding', async () => {

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.