|
@@ -35,6 +35,7 @@ class LearningModulesApiService {
|
|
|
lastStudyQuery: Record<string, unknown> = {};
|
|
lastStudyQuery: Record<string, unknown> = {};
|
|
|
reviewPageResponse: Subject<ApiEnvelope<unknown>> | null = null;
|
|
reviewPageResponse: Subject<ApiEnvelope<unknown>> | null = null;
|
|
|
courseWords: Record<string, unknown>[] | null = null;
|
|
courseWords: Record<string, unknown>[] | null = null;
|
|
|
|
|
+ recognizedWords = new Set<string>();
|
|
|
courseIncrements = new Map<string, number>();
|
|
courseIncrements = new Map<string, number>();
|
|
|
courseBookCounts: number[] | null = null;
|
|
courseBookCounts: number[] | null = null;
|
|
|
unitRows: Record<string, unknown>[] = [
|
|
unitRows: Record<string, unknown>[] = [
|
|
@@ -127,11 +128,11 @@ class LearningModulesApiService {
|
|
|
: [
|
|
: [
|
|
|
{ GeneralID: 1001, NodeID: 811, Title: 'apple', sy: 'n. 苹果', yp: 'apple.mp3', w_learned: 1 },
|
|
{ GeneralID: 1001, NodeID: 811, Title: 'apple', sy: 'n. 苹果', yp: 'apple.mp3', w_learned: 1 },
|
|
|
{ GeneralID: 1002, NodeID: 812, Title: 'banana', sy: 'n. 香蕉', yp: 'banana.mp3', w_learned: 0 },
|
|
{ GeneralID: 1002, NodeID: 812, Title: 'banana', sy: 'n. 香蕉', yp: 'banana.mp3', w_learned: 0 },
|
|
|
- ])).map((word: Record<string, unknown>) => ({...word,w_learned:(Number(word['w_learned'])||0)+(this.courseIncrements.get(String(word['GeneralID']))||0)}));
|
|
|
|
|
|
|
+ ])).map((word: Record<string, unknown>) => ({...word,recognized:this.recognizedWords.has(String(word['GeneralID'])),w_learned:(Number(word['w_learned'])||0)+(this.courseIncrements.get(String(word['GeneralID']))||0)}));
|
|
|
const pageIndex = Math.max(1, Number(params['cpage'] ?? 1));
|
|
const pageIndex = Math.max(1, Number(params['cpage'] ?? 1));
|
|
|
const pageSize = Math.max(1, Number(params['psize'] ?? 30));
|
|
const pageSize = Math.max(1, Number(params['psize'] ?? 30));
|
|
|
- const passCounts = [0,1,2,3].map(pass => allWords.filter(word => Math.min(3,Number(word['w_learned']) || 0) === pass).length);
|
|
|
|
|
- const filtered = params['learningPass'] == null ? allWords : allWords.filter(word => Math.min(3,Number(word['w_learned']) || 0) === Number(params['learningPass']));
|
|
|
|
|
|
|
+ const passCounts = [0,1,2,3,4].map(pass => allWords.filter(word => (word.recognized ? 4 : Math.min(3,Number(word['w_learned']) || 0)) === pass).length);
|
|
|
|
|
+ const filtered = params['learningPass'] == null ? allWords : allWords.filter(word => (word.recognized ? 4 : Math.min(3,Number(word['w_learned']) || 0)) === Number(params['learningPass']));
|
|
|
const result = filtered.slice((pageIndex - 1) * pageSize, pageIndex * pageSize);
|
|
const result = filtered.slice((pageIndex - 1) * pageSize, pageIndex * pageSize);
|
|
|
return of({
|
|
return of({
|
|
|
retcode: 1,
|
|
retcode: 1,
|
|
@@ -169,7 +170,8 @@ class LearningModulesApiService {
|
|
|
}
|
|
}
|
|
|
if (action === 'e_add_words') {
|
|
if (action === 'e_add_words') {
|
|
|
this.lastLearningWordUpdate = params;
|
|
this.lastLearningWordUpdate = params;
|
|
|
- if (params['save'] === 1) for (const id of String(params['wordsId']).split(',')) this.courseIncrements.set(id,(this.courseIncrements.get(id)||0)+1);
|
|
|
|
|
|
|
+ if (params['recognized'] === true) for (const id of String(params['wordsId']).split(',')) this.recognizedWords.add(id);
|
|
|
|
|
+ else if (params['save'] === 1) for (const id of String(params['wordsId']).split(',')) this.courseIncrements.set(id,(this.courseIncrements.get(id)||0)+1);
|
|
|
return this.result<T>({ affected: String(params['wordsId'] ?? '').split(',').filter(Boolean).length });
|
|
return this.result<T>({ affected: String(params['wordsId'] ?? '').split(',').filter(Boolean).length });
|
|
|
}
|
|
}
|
|
|
if (action === 'content_add_zt') {
|
|
if (action === 'content_add_zt') {
|
|
@@ -1408,12 +1410,12 @@ describe('home learning modules', () => {
|
|
|
user.set({userId:300,groupId:3});session.groupId.set(3);session.student.set({userId:100,groupId:1});
|
|
user.set({userId:300,groupId:3});session.groupId.set(3);session.student.set({userId:100,groupId:1});
|
|
|
const api=TestBed.inject(ApiService) as unknown as LearningModulesApiService;
|
|
const api=TestBed.inject(ApiService) as unknown as LearningModulesApiService;
|
|
|
api.courseWords=[{GeneralID:1001,NodeID:811,Title:'apple',w_learned:1},{GeneralID:1002,NodeID:811,Title:'banana',w_learned:2},{GeneralID:1003,NodeID:811,Title:'pear',w_learned:3}];
|
|
api.courseWords=[{GeneralID:1001,NodeID:811,Title:'apple',w_learned:1},{GeneralID:1002,NodeID:811,Title:'banana',w_learned:2},{GeneralID:1003,NodeID:811,Title:'pear',w_learned:3}];
|
|
|
- api.courseBookCounts=[1,1,1,1]; // An unselected unit still has a first-pass word.
|
|
|
|
|
|
|
+ api.courseBookCounts=[1,1,1,1,0]; // An unselected unit still has a first-pass word.
|
|
|
const harness=await RouterTestingHarness.create('/pages/stu/stu_abc?nids=811&pnid=801&bindingId=701');
|
|
const harness=await RouterTestingHarness.create('/pages/stu/stu_abc?nids=811&pnid=801&bindingId=701');
|
|
|
const learning=()=>harness.fixture.debugElement.query(By.directive(LearningPageComponent)).componentInstance as LearningPageComponent;
|
|
const learning=()=>harness.fixture.debugElement.query(By.directive(LearningPageComponent)).componentInstance as LearningPageComponent;
|
|
|
const tab=(n:number)=>(harness.routeNativeElement!.querySelectorAll('.course-pass-tabs button')[n] as HTMLButtonElement);
|
|
const tab=(n:number)=>(harness.routeNativeElement!.querySelectorAll('.course-pass-tabs button')[n] as HTMLButtonElement);
|
|
|
harness.fixture.detectChanges();
|
|
harness.fixture.detectChanges();
|
|
|
- expect(harness.routeNativeElement!.querySelectorAll('.course-pass-tabs button').length).toBe(4);
|
|
|
|
|
|
|
+ expect(harness.routeNativeElement!.querySelectorAll('.course-pass-tabs button').length).toBe(5);
|
|
|
tab(1).click();harness.fixture.detectChanges();
|
|
tab(1).click();harness.fixture.detectChanges();
|
|
|
expect(harness.routeNativeElement!.querySelector('.word-select-check')).not.toBeNull();
|
|
expect(harness.routeNativeElement!.querySelector('.word-select-check')).not.toBeNull();
|
|
|
expect(harness.routeNativeElement!.textContent).toContain('选择单词开始第二遍学习');
|
|
expect(harness.routeNativeElement!.textContent).toContain('选择单词开始第二遍学习');
|
|
@@ -1460,7 +1462,7 @@ describe('home learning modules', () => {
|
|
|
expect(learning().words().find(word=>word.word==='apple')?.['w_learned']).toBe(3);
|
|
expect(learning().words().find(word=>word.word==='apple')?.['w_learned']).toBe(3);
|
|
|
expect(harness.routeNativeElement!.querySelector('.word-select-check')).toBeNull();
|
|
expect(harness.routeNativeElement!.querySelector('.word-select-check')).toBeNull();
|
|
|
expect(learning().firstPassProgress()).toBe(75);
|
|
expect(learning().firstPassProgress()).toBe(75);
|
|
|
- api.courseBookCounts=[0,0,1,3];tab(0).click();tab(3).click();harness.fixture.detectChanges();
|
|
|
|
|
|
|
+ api.courseBookCounts=[0,0,1,3,0];tab(0).click();tab(3).click();harness.fixture.detectChanges();
|
|
|
expect(learning().firstPassProgress()).toBe(100);
|
|
expect(learning().firstPassProgress()).toBe(100);
|
|
|
},30000);
|
|
},30000);
|
|
|
|
|
|
|
@@ -2117,16 +2119,14 @@ describe('home learning modules', () => {
|
|
|
(firstWord.querySelector('.known-button') as HTMLButtonElement).click();
|
|
(firstWord.querySelector('.known-button') as HTMLButtonElement).click();
|
|
|
harness.fixture.detectChanges();
|
|
harness.fixture.detectChanges();
|
|
|
expect(harness.routeNativeElement?.querySelectorAll('.pending-column .word-refine-item').length).toBe(0);
|
|
expect(harness.routeNativeElement?.querySelectorAll('.pending-column .word-refine-item').length).toBe(0);
|
|
|
- expect(harness.routeNativeElement?.querySelector('.selection-header .primary-button')?.textContent).toContain('保存识词结果');
|
|
|
|
|
- (harness.routeNativeElement?.querySelectorAll('.word-selection-tabs button')[1] as HTMLButtonElement).click();
|
|
|
|
|
|
|
+ (harness.routeNativeElement?.querySelectorAll('.word-selection-tabs button')[4] as HTMLButtonElement).click();
|
|
|
harness.fixture.detectChanges();
|
|
harness.fixture.detectChanges();
|
|
|
- expect(harness.routeNativeElement?.querySelectorAll('.completed-column .word-refine-item').length).toBe(2);
|
|
|
|
|
- (harness.routeNativeElement?.querySelector('.completed-column .word-assessment:has(.known-button.active) .unknown-button') as HTMLButtonElement).click();
|
|
|
|
|
|
|
+ expect(harness.routeNativeElement?.querySelector('.completed-column')?.textContent).toContain('banana');
|
|
|
|
|
+ (harness.routeNativeElement?.querySelectorAll('.word-selection-tabs button')[1] as HTMLButtonElement).click();
|
|
|
harness.fixture.detectChanges();
|
|
harness.fixture.detectChanges();
|
|
|
expect(harness.routeNativeElement?.querySelectorAll('.completed-column .word-refine-item').length).toBe(1);
|
|
expect(harness.routeNativeElement?.querySelectorAll('.completed-column .word-refine-item').length).toBe(1);
|
|
|
- (harness.routeNativeElement?.querySelectorAll('.word-selection-tabs button')[0] as HTMLButtonElement).click();
|
|
|
|
|
|
|
+ (harness.routeNativeElement?.querySelector('.completed-column .unknown-button') as HTMLButtonElement).click();
|
|
|
harness.fixture.detectChanges();
|
|
harness.fixture.detectChanges();
|
|
|
- expect(harness.routeNativeElement?.querySelectorAll('.pending-column .word-refine-item').length).toBe(1);
|
|
|
|
|
(harness.routeNativeElement?.querySelector('.selection-header .primary-button') as HTMLButtonElement).click();
|
|
(harness.routeNativeElement?.querySelector('.selection-header .primary-button') as HTMLButtonElement).click();
|
|
|
await harness.fixture.whenStable();
|
|
await harness.fixture.whenStable();
|
|
|
harness.fixture.detectChanges();
|
|
harness.fixture.detectChanges();
|
|
@@ -2316,17 +2316,16 @@ describe('home learning modules', () => {
|
|
|
harness.fixture.detectChanges();
|
|
harness.fixture.detectChanges();
|
|
|
(pendingWord.querySelector('.known-button') as HTMLButtonElement).click();
|
|
(pendingWord.querySelector('.known-button') as HTMLButtonElement).click();
|
|
|
harness.fixture.detectChanges();
|
|
harness.fixture.detectChanges();
|
|
|
- (harness.routeNativeElement?.querySelector('.selection-header .primary-button') as HTMLButtonElement).click();
|
|
|
|
|
await harness.fixture.whenStable();
|
|
await harness.fixture.whenStable();
|
|
|
harness.fixture.detectChanges();
|
|
harness.fixture.detectChanges();
|
|
|
|
|
|
|
|
const api = TestBed.inject(ApiService) as unknown as LearningModulesApiService;
|
|
const api = TestBed.inject(ApiService) as unknown as LearningModulesApiService;
|
|
|
- expect(api.lastLearningWordUpdate).toEqual(jasmine.objectContaining({ uid: 100, wordsId: '1002', kcid: '801', save: 1 }));
|
|
|
|
|
|
|
+ expect(api.lastLearningWordUpdate).toEqual(jasmine.objectContaining({ uid: 100, wordsId: '1002', kcid: '801', save: 1, recognized: true }));
|
|
|
expect(TestBed.inject(Router).url).toContain('/pages/stu/stu_abc');
|
|
expect(TestBed.inject(Router).url).toContain('/pages/stu/stu_abc');
|
|
|
expect(harness.routeNativeElement?.querySelector('.completed-column')).toBeNull();
|
|
expect(harness.routeNativeElement?.querySelector('.completed-column')).toBeNull();
|
|
|
- (harness.routeNativeElement?.querySelectorAll('.word-selection-tabs button')[1] as HTMLButtonElement).click();
|
|
|
|
|
|
|
+ (harness.routeNativeElement?.querySelectorAll('.word-selection-tabs button')[4] as HTMLButtonElement).click();
|
|
|
harness.fixture.detectChanges();
|
|
harness.fixture.detectChanges();
|
|
|
- expect(harness.routeNativeElement?.querySelectorAll('.completed-column .word-refine-item').length).toBe(2);
|
|
|
|
|
|
|
+ expect(harness.routeNativeElement?.querySelectorAll('.completed-column .word-refine-item').length).toBe(1);
|
|
|
expect(harness.routeNativeElement?.querySelector('.pending-column')).toBeNull();
|
|
expect(harness.routeNativeElement?.querySelector('.pending-column')).toBeNull();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -2600,7 +2599,7 @@ describe('home learning modules', () => {
|
|
|
expect(row.querySelector('.word-refine-main .known-button')?.textContent?.trim()).toBe('认识');
|
|
expect(row.querySelector('.word-refine-main .known-button')?.textContent?.trim()).toBe('认识');
|
|
|
expect(row.querySelector('.word-refine-main .unknown-button')?.textContent?.trim()).toBe('不认识');
|
|
expect(row.querySelector('.word-refine-main .unknown-button')?.textContent?.trim()).toBe('不认识');
|
|
|
(row.querySelector('.known-button') as HTMLButtonElement).click(); harness.fixture.detectChanges();
|
|
(row.querySelector('.known-button') as HTMLButtonElement).click(); harness.fixture.detectChanges();
|
|
|
- expect(component.coursePassCount(1)).toBe(1);
|
|
|
|
|
|
|
+ expect(component.coursePassCount(4)).toBe(1);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('saves 205 accumulated known words in bounded requests without losing words', async () => {
|
|
it('saves 205 accumulated known words in bounded requests without losing words', async () => {
|
|
@@ -2614,10 +2613,10 @@ describe('home learning modules', () => {
|
|
|
for(const word of component.words())component.markWordKnown(word);
|
|
for(const word of component.words())component.markWordKnown(word);
|
|
|
component.startSelected();await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
component.startSelected();await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
|
expect(sizes).toEqual([100,100,5]);
|
|
expect(sizes).toEqual([100,100,5]);
|
|
|
- expect(api.courseIncrements.size).toBe(205);
|
|
|
|
|
- expect([...api.courseIncrements.values()].every(n=>n===1)).toBeTrue();
|
|
|
|
|
|
|
+ expect(api.recognizedWords.size).toBe(205);
|
|
|
|
|
+ expect(api.courseIncrements.size).toBe(0);
|
|
|
expect(component.newlyKnownWords().length).toBe(0);
|
|
expect(component.newlyKnownWords().length).toBe(0);
|
|
|
- expect(component.coursePassCount(1)).toBe(205);
|
|
|
|
|
|
|
+ expect(component.coursePassCount(4)).toBe(205);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('retains successful known-word batches when a later request fails and retries only remaining words', async () => {
|
|
it('retains successful known-word batches when a later request fails and retries only remaining words', async () => {
|
|
@@ -2635,15 +2634,15 @@ describe('home learning modules', () => {
|
|
|
for(const word of component.words())component.markWordKnown(word);
|
|
for(const word of component.words())component.markWordKnown(word);
|
|
|
component.startSelected();await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
component.startSelected();await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
|
expect(component.newlyKnownWords().length).toBe(105);
|
|
expect(component.newlyKnownWords().length).toBe(105);
|
|
|
- expect(component.coursePassCounts()?.[1]).toBe(100);
|
|
|
|
|
|
|
+ expect(component.coursePassCounts()?.[4]).toBe(100);
|
|
|
expect(component.submitting()).toBeFalse();
|
|
expect(component.submitting()).toBeFalse();
|
|
|
expect(TestBed.inject(Router).url).toContain('/pages/stu/stu_abc');
|
|
expect(TestBed.inject(Router).url).toContain('/pages/stu/stu_abc');
|
|
|
component.startSelected();await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
component.startSelected();await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
|
expect(requests.map(p=>String(p['wordsId']).split(',').length)).toEqual([100,100,100,5]);
|
|
expect(requests.map(p=>String(p['wordsId']).split(',').length)).toEqual([100,100,100,5]);
|
|
|
expect(requests[2]['requestKey']).toBe(requests[1]['requestKey']);
|
|
expect(requests[2]['requestKey']).toBe(requests[1]['requestKey']);
|
|
|
- expect(api.courseIncrements.size).toBe(205);
|
|
|
|
|
- expect([...api.courseIncrements.values()].every(n=>n===1)).toBeTrue();
|
|
|
|
|
- expect(component.coursePassCount(1)).toBe(205);
|
|
|
|
|
|
|
+ expect(api.recognizedWords.size).toBe(205);
|
|
|
|
|
+ expect(api.courseIncrements.size).toBe(0);
|
|
|
|
|
+ expect(component.coursePassCount(4)).toBe(205);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('selects the visible words, allows exceptions, then saves known words and trains only exceptions', async () => {
|
|
it('selects the visible words, allows exceptions, then saves known words and trains only exceptions', async () => {
|
|
@@ -2659,16 +2658,16 @@ describe('home learning modules', () => {
|
|
|
expect(TestBed.inject(Router).url).toContain('/pages/stu/stu_con');
|
|
expect(TestBed.inject(Router).url).toContain('/pages/stu/stu_con');
|
|
|
const learning=harness.fixture.debugElement.query(By.directive(LearningPageComponent)).componentInstance as LearningPageComponent;
|
|
const learning=harness.fixture.debugElement.query(By.directive(LearningPageComponent)).componentInstance as LearningPageComponent;
|
|
|
expect(learning.words().map(w=>w.wordId).sort()).toEqual(['1002','1007']);
|
|
expect(learning.words().map(w=>w.wordId).sort()).toEqual(['1002','1007']);
|
|
|
- expect([...api.courseIncrements.keys()].sort()).toEqual(['1001','1003','1004','1005','1006','1008']);
|
|
|
|
|
|
|
+ expect([...api.recognizedWords.keys()].sort()).toEqual(['1001','1003','1004','1005','1006','1008']);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- it('saves all-known words and opens the learned pass without creating an empty learning round', async () => {
|
|
|
|
|
|
|
+ it('saves all-known words and opens the recognized tab without creating an empty learning round', async () => {
|
|
|
const {api,harness,component}=await teacherSelection(8);
|
|
const {api,harness,component}=await teacherSelection(8);
|
|
|
(harness.routeNativeElement!.querySelector('.bulk-select-toggle') as HTMLButtonElement)?.click();harness.fixture.detectChanges();
|
|
(harness.routeNativeElement!.querySelector('.bulk-select-toggle') as HTMLButtonElement)?.click();harness.fixture.detectChanges();
|
|
|
(harness.routeNativeElement!.querySelector('.bulk-assessment .known-button') as HTMLButtonElement)?.click();
|
|
(harness.routeNativeElement!.querySelector('.bulk-assessment .known-button') as HTMLButtonElement)?.click();
|
|
|
await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
|
- expect(api.courseIncrements.size).toBe(8);
|
|
|
|
|
- expect(component.coursePass()).toBe(1);
|
|
|
|
|
|
|
+ expect(api.recognizedWords.size).toBe(8);
|
|
|
|
|
+ expect(component.coursePass()).toBe(4);
|
|
|
expect(component.visibleCourseWords().length).toBe(8);
|
|
expect(component.visibleCourseWords().length).toBe(8);
|
|
|
expect(TestBed.inject(Router).url).toContain('/pages/stu/stu_abc');
|
|
expect(TestBed.inject(Router).url).toContain('/pages/stu/stu_abc');
|
|
|
});
|
|
});
|
|
@@ -2682,7 +2681,7 @@ describe('home learning modules', () => {
|
|
|
(harness.routeNativeElement!.querySelector('.bulk-assessment .unknown-button') as HTMLButtonElement)?.click();harness.fixture.detectChanges();
|
|
(harness.routeNativeElement!.querySelector('.bulk-assessment .unknown-button') as HTMLButtonElement)?.click();harness.fixture.detectChanges();
|
|
|
expect(toast).toHaveBeenCalledWith(jasmine.stringMatching(/100/),'error');
|
|
expect(toast).toHaveBeenCalledWith(jasmine.stringMatching(/100/),'error');
|
|
|
expect(harness.routeNativeElement!.querySelectorAll('.word-select-check[aria-pressed="true"]').length).toBe(100);
|
|
expect(harness.routeNativeElement!.querySelectorAll('.word-select-check[aria-pressed="true"]').length).toBe(100);
|
|
|
- expect(component.selected().size).toBe(1);expect(api.courseIncrements.size).toBe(0);
|
|
|
|
|
|
|
+ expect(component.selected().size).toBe(1);expect(api.recognizedWords.size).toBe(0);
|
|
|
component.selectCoursePass(1);await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
component.selectCoursePass(1);await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
|
expect(harness.routeNativeElement!.querySelector('.bulk-assessment')).toBeNull();
|
|
expect(harness.routeNativeElement!.querySelector('.bulk-assessment')).toBeNull();
|
|
|
component.selectCoursePass(0);await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
component.selectCoursePass(0);await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
@@ -2724,14 +2723,14 @@ describe('home learning modules', () => {
|
|
|
await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
|
expect(harness.routeNativeElement!.querySelector('.selection-retry-note')?.textContent).toContain('尚待确认');
|
|
expect(harness.routeNativeElement!.querySelector('.selection-retry-note')?.textContent).toContain('尚待确认');
|
|
|
expect(harness.routeNativeElement!.querySelector('.selection-header .primary-button')?.textContent).toContain('重试保存');
|
|
expect(harness.routeNativeElement!.querySelector('.selection-header .primary-button')?.textContent).toContain('重试保存');
|
|
|
- expect(api.courseIncrements.size).toBe(100);
|
|
|
|
|
|
|
+ expect(api.recognizedWords.size).toBe(100);
|
|
|
component.markWordUnknown(first);component.toggleWord(first);component.selectCoursePass(1);component.loadMoreSelection();
|
|
component.markWordUnknown(first);component.toggleWord(first);component.selectCoursePass(1);component.loadMoreSelection();
|
|
|
expect(component.selectionAssessment()[first.id]).toBe('known');expect(component.selected().size).toBe(0);expect(component.coursePass()).toBe(0);
|
|
expect(component.selectionAssessment()[first.id]).toBe('known');expect(component.selected().size).toBe(0);expect(component.coursePass()).toBe(0);
|
|
|
component.startSelected();await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
component.startSelected();await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
|
expect(requests[1]['requestKey']).toBe(requests[0]['requestKey']);
|
|
expect(requests[1]['requestKey']).toBe(requests[0]['requestKey']);
|
|
|
expect(requests[1]['wordsId']).toBe(requests[0]['wordsId']);
|
|
expect(requests[1]['wordsId']).toBe(requests[0]['wordsId']);
|
|
|
- expect(api.courseIncrements.size).toBe(205);expect([...api.courseIncrements.values()].every(n=>n===1)).toBeTrue();
|
|
|
|
|
- expect(component.coursePass()).toBe(1);expect(harness.routeNativeElement!.querySelector('.selection-retry-note')).toBeNull();
|
|
|
|
|
|
|
+ expect(api.recognizedWords.size).toBe(205);expect(api.courseIncrements.size).toBe(0);
|
|
|
|
|
+ expect(component.coursePass()).toBe(4);expect(harness.routeNativeElement!.querySelector('.selection-retry-note')).toBeNull();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('rebases pending pages after saving known words without skipping remaining vocabulary or selections', async () => {
|
|
it('rebases pending pages after saving known words without skipping remaining vocabulary or selections', async () => {
|
|
@@ -2742,7 +2741,7 @@ describe('home learning modules', () => {
|
|
|
(view().querySelector('.bulk-select-toggle') as HTMLButtonElement).click();harness.fixture.detectChanges();
|
|
(view().querySelector('.bulk-select-toggle') as HTMLButtonElement).click();harness.fixture.detectChanges();
|
|
|
for(let i=60;i<100;i++)checks()[i].click();harness.fixture.detectChanges();
|
|
for(let i=60;i<100;i++)checks()[i].click();harness.fixture.detectChanges();
|
|
|
(view().querySelector('.bulk-assessment .known-button') as HTMLButtonElement).click();await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
(view().querySelector('.bulk-assessment .known-button') as HTMLButtonElement).click();await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
|
- expect(TestBed.inject(Router).url).toContain('/pages/stu/stu_abc');expect(api.courseIncrements.size).toBe(60);
|
|
|
|
|
|
|
+ expect(TestBed.inject(Router).url).toContain('/pages/stu/stu_abc');expect(api.recognizedWords.size).toBe(60);
|
|
|
const get=api.get.bind(api);let failed=false;
|
|
const get=api.get.bind(api);let failed=false;
|
|
|
spyOn(api,'get').and.callFake(((action:string,params:Record<string,unknown>={})=>{
|
|
spyOn(api,'get').and.callFake(((action:string,params:Record<string,unknown>={})=>{
|
|
|
if(action==='e_ck_list'&&Number(params['cpage'])===1&&!failed){failed=true;return throwError(()=>new Error('刷新第一页失败'));}
|
|
if(action==='e_ck_list'&&Number(params['cpage'])===1&&!failed){failed=true;return throwError(()=>new Error('刷新第一页失败'));}
|
|
@@ -2764,7 +2763,7 @@ describe('home learning modules', () => {
|
|
|
expect(harness.routeNativeElement!.querySelector('.word-select-check')?.getAttribute('aria-pressed')).toBe('false');
|
|
expect(harness.routeNativeElement!.querySelector('.word-select-check')?.getAttribute('aria-pressed')).toBe('false');
|
|
|
(harness.routeNativeElement!.querySelector('.bulk-assessment .known-button') as HTMLButtonElement).click();await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
(harness.routeNativeElement!.querySelector('.bulk-assessment .known-button') as HTMLButtonElement).click();await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
|
const learning=harness.fixture.debugElement.query(By.directive(LearningPageComponent)).componentInstance as LearningPageComponent;
|
|
const learning=harness.fixture.debugElement.query(By.directive(LearningPageComponent)).componentInstance as LearningPageComponent;
|
|
|
- expect(learning.words().map(w=>w.wordId)).toEqual(['1001']);expect([...api.courseIncrements.keys()].sort()).toEqual(['1002','1003']);
|
|
|
|
|
|
|
+ expect(learning.words().map(w=>w.wordId)).toEqual(['1001']);expect([...api.recognizedWords.keys()].sort()).toEqual(['1002','1003']);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('starts a valid bulk unknown selection without marking those words learned', async () => {
|
|
it('starts a valid bulk unknown selection without marking those words learned', async () => {
|
|
@@ -2773,12 +2772,12 @@ describe('home learning modules', () => {
|
|
|
(harness.routeNativeElement!.querySelector('.bulk-assessment .unknown-button') as HTMLButtonElement).click();await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
(harness.routeNativeElement!.querySelector('.bulk-assessment .unknown-button') as HTMLButtonElement).click();await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
|
expect(TestBed.inject(Router).url).toContain('/pages/stu/stu_con');
|
|
expect(TestBed.inject(Router).url).toContain('/pages/stu/stu_con');
|
|
|
const learning=harness.fixture.debugElement.query(By.directive(LearningPageComponent)).componentInstance as LearningPageComponent;
|
|
const learning=harness.fixture.debugElement.query(By.directive(LearningPageComponent)).componentInstance as LearningPageComponent;
|
|
|
- expect(learning.words().length).toBe(3);expect(api.courseIncrements.size).toBe(0);
|
|
|
|
|
|
|
+ expect(learning.words().length).toBe(3);expect(api.recognizedWords.size).toBe(0);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
for(const pass of [1,2]) {
|
|
for(const pass of [1,2]) {
|
|
|
- it('bulk assesses learned pass '+pass+' and advances only recognized words by one pass', async () => {
|
|
|
|
|
|
|
+ it('bulk assesses learned pass '+pass+' and moves only recognized words into their own tab', async () => {
|
|
|
const {api,harness,component}=await teacherSelection(4,pass);
|
|
const {api,harness,component}=await teacherSelection(4,pass);
|
|
|
const view=()=>harness.routeNativeElement!;
|
|
const view=()=>harness.routeNativeElement!;
|
|
|
expect(view().querySelector('.bulk-select-toggle')).not.toBeNull();
|
|
expect(view().querySelector('.bulk-select-toggle')).not.toBeNull();
|
|
@@ -2790,8 +2789,8 @@ describe('home learning modules', () => {
|
|
|
expect(TestBed.inject(Router).url).toContain('/pages/stu/stu_con');
|
|
expect(TestBed.inject(Router).url).toContain('/pages/stu/stu_con');
|
|
|
const learning=harness.fixture.debugElement.query(By.directive(LearningPageComponent)).componentInstance as LearningPageComponent;
|
|
const learning=harness.fixture.debugElement.query(By.directive(LearningPageComponent)).componentInstance as LearningPageComponent;
|
|
|
expect(learning.words().map(w=>w.wordId)).toEqual(['1004']);
|
|
expect(learning.words().map(w=>w.wordId)).toEqual(['1004']);
|
|
|
- expect([...api.courseIncrements.keys()].sort()).toEqual(['1001','1002','1003']);
|
|
|
|
|
- expect(component.coursePassCount(pass)).toBe(1);expect(component.coursePassCount(pass+1)).toBe(3);
|
|
|
|
|
|
|
+ expect([...api.recognizedWords.keys()].sort()).toEqual(['1001','1002','1003']);
|
|
|
|
|
+ expect(component.coursePassCount(pass)).toBe(1);expect(component.coursePassCount(4)).toBe(3);
|
|
|
expect(component.firstPassProgress()).toBe(100);
|
|
expect(component.firstPassProgress()).toBe(100);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -2804,8 +2803,8 @@ describe('home learning modules', () => {
|
|
|
(harness.routeNativeElement!.querySelector('.bulk-select-toggle') as HTMLButtonElement).click();harness.fixture.detectChanges();
|
|
(harness.routeNativeElement!.querySelector('.bulk-select-toggle') as HTMLButtonElement).click();harness.fixture.detectChanges();
|
|
|
(harness.routeNativeElement!.querySelector('.bulk-assessment .known-button') as HTMLButtonElement).click();
|
|
(harness.routeNativeElement!.querySelector('.bulk-assessment .known-button') as HTMLButtonElement).click();
|
|
|
await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
|
- expect(api.courseIncrements.size).toBe(20);expect(component.selected().size).toBe(0);
|
|
|
|
|
- expect(component.coursePassCounts()).toEqual([80,20,0,0]);
|
|
|
|
|
|
|
+ expect(api.recognizedWords.size).toBe(20);expect(component.selected().size).toBe(0);
|
|
|
|
|
+ expect(component.coursePassCounts()).toEqual([80,0,0,0,20]);
|
|
|
expect(TestBed.inject(Router).url).toContain('/pages/stu/stu_abc');
|
|
expect(TestBed.inject(Router).url).toContain('/pages/stu/stu_abc');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -2974,28 +2973,21 @@ describe('home learning modules', () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- it('uses different save identities for consecutive learned passes and leaves the third pass read-only', async () => {
|
|
|
|
|
|
|
+ it('saves an individual recognition immediately and keeps the word out of later passes after reload', async () => {
|
|
|
const {api,harness,component}=await teacherSelection(2,1);
|
|
const {api,harness,component}=await teacherSelection(2,1);
|
|
|
- spyOn(TestBed.inject(PlatformService),'toast'); // Two consecutive saves test state, not toast dismissal timers.
|
|
|
|
|
- const original=api.post.bind(api),saved=new Map<string,Observable<ApiEnvelope<any>>>(),keys:string[]=[];
|
|
|
|
|
- spyOn(api,'post').and.callFake(((action:string,params:Record<string,unknown>={})=>{
|
|
|
|
|
- if(action!=='e_add_words')return original(action,params);
|
|
|
|
|
- const key=String(params['requestKey']);keys.push(key);if(saved.has(key))return saved.get(key)!;
|
|
|
|
|
- const result=original(action,params);saved.set(key,result);return result;
|
|
|
|
|
- }) as typeof api.post);
|
|
|
|
|
- for(const expectedPass of [2,3]){
|
|
|
|
|
- (harness.routeNativeElement!.querySelector('.bulk-select-toggle') as HTMLButtonElement)?.click();harness.fixture.detectChanges();
|
|
|
|
|
- (harness.routeNativeElement!.querySelector('.bulk-assessment .known-button') as HTMLButtonElement)?.click();await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
|
|
|
- expect(component.coursePass()).toBe(expectedPass);expect(component.visibleCourseWords().length).toBe(2);
|
|
|
|
|
|
|
+ (harness.routeNativeElement!.querySelector('.known-button') as HTMLButtonElement).click();
|
|
|
|
|
+ await harness.fixture.whenStable();
|
|
|
|
|
+ expect(api.recognizedWords.has('1001')).toBeTrue();
|
|
|
|
|
+ expect(component.visibleCourseWords().map(w=>w.wordId)).toEqual(['1002']);
|
|
|
|
|
+ component.load();await harness.fixture.whenStable();
|
|
|
|
|
+ for(const pass of [1,2,3]){
|
|
|
|
|
+ component.selectCoursePass(pass);await harness.fixture.whenStable();
|
|
|
|
|
+ expect(component.visibleCourseWords().some(w=>w.wordId==='1001')).toBeFalse();
|
|
|
}
|
|
}
|
|
|
- expect(keys.length).toBe(2);expect(new Set(keys).size).toBe(2);
|
|
|
|
|
- expect([...api.courseIncrements.values()]).toEqual([2,2]);
|
|
|
|
|
- expect(component.coursePassCount(3)).toBe(2);expect(component.coursePassCount(0)).toBe(0);
|
|
|
|
|
- expect(harness.routeNativeElement!.querySelector('.bulk-select-toggle')).toBeNull();
|
|
|
|
|
- expect(harness.routeNativeElement!.querySelector('.word-select-check')).toBeNull();
|
|
|
|
|
|
|
+ component.selectCoursePass(4);await harness.fixture.whenStable();harness.fixture.detectChanges();
|
|
|
|
|
+ expect(component.visibleCourseWords().map(w=>w.wordId)).toEqual(['1001']);
|
|
|
expect(harness.routeNativeElement!.querySelector('.word-assessment')).toBeNull();
|
|
expect(harness.routeNativeElement!.querySelector('.word-assessment')).toBeNull();
|
|
|
- component.toggleBulkSelection();component.applyBulkAssessment('known');
|
|
|
|
|
- expect(keys.length).toBe(2);
|
|
|
|
|
|
|
+ expect(api.courseIncrements.size).toBe(0);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
});
|
|
});
|