|
|
@@ -405,6 +405,48 @@ describe('home learning modules', () => {
|
|
|
expect(play).toHaveBeenCalledTimes(2);
|
|
|
});
|
|
|
|
|
|
+ it('keeps the spoken word among listening choices and discards answers from an earlier question', async () => {
|
|
|
+ const prefix = 'xiaoshu.learning.100.100.practice.';
|
|
|
+ const selectedWords = [
|
|
|
+ { GeneralID: 1001, Title: 'apple', sy: '苹果', yp: 'apple.mp3' },
|
|
|
+ { GeneralID: 1002, Title: 'banana', sy: '香蕉', yp: 'banana.mp3' },
|
|
|
+ ];
|
|
|
+ localStorage.setItem(prefix + 'learn_mode', 'newword');
|
|
|
+ localStorage.setItem(prefix + 'choose_newword_learn', JSON.stringify(selectedWords));
|
|
|
+ localStorage.setItem(prefix + '_page_word_orilist', JSON.stringify([selectedWords]));
|
|
|
+ localStorage.setItem(prefix + '_page_current_learn', '1');
|
|
|
+ const responses = [new Subject<ApiEnvelope<any>>(), new Subject<ApiEnvelope<any>>()];
|
|
|
+ let requestCount = 0;
|
|
|
+ const api = TestBed.inject(ApiService) as unknown as LearningModulesApiService;
|
|
|
+ const get = api.get.bind(api);
|
|
|
+ spyOn(api, 'get').and.callFake((action, params) => action === 'content_list' && params?.['orders'] === 'NEWID()'
|
|
|
+ ? responses[requestCount++] ?? of({ retcode: 1, result: [] } as ApiEnvelope<any>)
|
|
|
+ : get(action, params));
|
|
|
+ spyOn(TestBed.inject(PlatformService), 'play');
|
|
|
+ const harness = await RouterTestingHarness.create();
|
|
|
+ await harness.navigateByUrl('/pages/stu/stu4');
|
|
|
+ const learning = harness.fixture.debugElement.query(By.directive(LearningPageComponent)).componentInstance as LearningPageComponent;
|
|
|
+ const firstWord = learning.current()!;
|
|
|
+ const firstResponse = responses[0];
|
|
|
+ expect(requestCount).toBe(1);
|
|
|
+ expect(learning.choiceOptions().some((option) => option.id === firstWord.id)).toBeTrue();
|
|
|
+ learning.chooseMeaning(firstWord);
|
|
|
+ const secondWord = learning.current()!;
|
|
|
+ expect(secondWord.id).not.toBe(firstWord.id);
|
|
|
+ const secondResponse = responses[1];
|
|
|
+ firstResponse?.next({ retcode: 1, result: [{ GeneralID: 201, Title: 'meeting', sy: '集会' }] });
|
|
|
+ expect(learning.choiceOptions().some((option) => option.id === secondWord.id)).toBeTrue();
|
|
|
+ secondResponse?.next({ retcode: 1, result: Array.from({ length: 8 }, (_, index) => ({
|
|
|
+ GeneralID: 301 + index, Title: `extra-${index}`, sy: `干扰项 ${index}`,
|
|
|
+ })) });
|
|
|
+ expect(learning.choiceOptions().length).toBe(4);
|
|
|
+ expect(learning.choiceOptions().some((option) => option.id === secondWord.id)).toBeTrue();
|
|
|
+ localStorage.removeItem(prefix + 'learn_mode');
|
|
|
+ localStorage.removeItem(prefix + 'choose_newword_learn');
|
|
|
+ localStorage.removeItem(prefix + '_page_word_orilist');
|
|
|
+ localStorage.removeItem(prefix + '_page_current_learn');
|
|
|
+ });
|
|
|
+
|
|
|
it('lets a student study selected words from their wordbook while keeping course stages teacher-led', async () => {
|
|
|
localStorage.removeItem('xiaoshu.learning.100.100.practice.learn_mode');
|
|
|
localStorage.removeItem('xiaoshu.learning.100.100.practice.choose_newword_learn');
|