Ver código fonte

fix: load teacher units for selected student

彭峰 1 mês atrás
pai
commit
23a9aeb690

+ 1 - 0
projects/xiaoshu-mobile/src/app/core/home-learning-modules.integration.spec.ts

@@ -537,6 +537,7 @@ describe('home learning modules', () => {
     await harness.navigateByUrl('/pages/stu/stu_list?nid=801&bindingId=701');
     await harness.fixture.whenStable();
     harness.fixture.detectChanges();
+    expect((TestBed.inject(ApiService) as unknown as LearningModulesApiService).lastNodeParams['userId']).toBe(100);
     const units = harness.routeNativeElement?.querySelectorAll('.node-list button') as NodeListOf<HTMLButtonElement>;
     units[0].click();
     units[1].click();

+ 7 - 1
projects/xiaoshu-mobile/src/app/features/learning/learning-page.component.ts

@@ -977,8 +977,14 @@ export class LearningPageComponent implements OnInit, OnDestroy {
       : this.query('nid') || this.query('pid');
     const params: Record<string, unknown> = { pid, cpage: 1, psize: 100 };
     if (this.isUnitListPage) {
+      const learner = this.canStartPointReading ? this.session.student() : this.session.user();
+      if (!learner?.userId) {
+        this.loading.set(false);
+        this.error.set('未找到当前学员,请返回学习记录重新选择学员');
+        return;
+      }
       params['ifunit'] = 1;
-      params['userId'] = this.session.user()?.userId;
+      params['userId'] = learner.userId;
       params['bindingId'] = this.query('bindingId');
     }
     this.api.get<unknown>('node_list', params).pipe(finalize(() => this.loading.set(false))).subscribe({