diff --git a/src/app/teacher/teacher-authoring.module.ts b/src/app/teacher/teacher-authoring.module.ts index 7d081fd5705..6c9506626f1 100644 --- a/src/app/teacher/teacher-authoring.module.ts +++ b/src/app/teacher/teacher-authoring.module.ts @@ -35,6 +35,7 @@ import { ComponentInfoService } from '../../assets/wise5/services/componentInfoS import { TeacherProjectTranslationService } from '../../assets/wise5/services/teacherProjectTranslationService'; import { DeleteTranslationsService } from '../../assets/wise5/services/deleteTranslationsService'; import { CopyTranslationsService } from '../../assets/wise5/services/copyTranslationsService'; +import { NotifyAuthorService } from '../../assets/wise5/services/notifyAuthorService'; @NgModule({ imports: [StudentTeacherCommonModule, AuthoringToolModule, RouterModule, AuthoringRoutingModule], @@ -56,6 +57,7 @@ import { CopyTranslationsService } from '../../assets/wise5/services/copyTransla MilestoneReportService, MoveNodesService, { provide: NodeService, useExisting: TeacherNodeService }, + NotifyAuthorService, ProjectAssetService, SpaceService, DeleteTranslationsService, diff --git a/src/assets/wise5/authoringTool/components/top-bar/top-bar.component.spec.ts b/src/assets/wise5/authoringTool/components/top-bar/top-bar.component.spec.ts index 1896301a7c2..307dec80a80 100644 --- a/src/assets/wise5/authoringTool/components/top-bar/top-bar.component.spec.ts +++ b/src/assets/wise5/authoringTool/components/top-bar/top-bar.component.spec.ts @@ -14,6 +14,7 @@ import { TeacherWebSocketService } from '../../../services/teacherWebSocketServi import { ClassroomStatusService } from '../../../services/classroomStatusService'; import { MatDialogModule } from '@angular/material/dialog'; import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'; +import { NotifyAuthorService } from '../../../services/notifyAuthorService'; describe('TopBarComponent', () => { let component: TopBarComponent; @@ -21,22 +22,25 @@ describe('TopBarComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [TopBarComponent], - imports: [MatDialogModule, + declarations: [TopBarComponent], + imports: [ + MatDialogModule, MatIconModule, MatMenuModule, MatToolbarModule, MatTooltipModule, - StudentTeacherCommonServicesModule], - providers: [ + StudentTeacherCommonServicesModule + ], + providers: [ ClassroomStatusService, + NotifyAuthorService, TeacherDataService, TeacherProjectService, TeacherWebSocketService, provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting() - ] -}).compileComponents(); + ] + }).compileComponents(); }); beforeEach(() => { diff --git a/src/assets/wise5/authoringTool/components/top-bar/top-bar.component.ts b/src/assets/wise5/authoringTool/components/top-bar/top-bar.component.ts index a27e37c0bae..e9944f7b73c 100644 --- a/src/assets/wise5/authoringTool/components/top-bar/top-bar.component.ts +++ b/src/assets/wise5/authoringTool/components/top-bar/top-bar.component.ts @@ -10,6 +10,7 @@ import { ProjectLocale } from '../../../../../app/domain/projectLocale'; import { Language } from '../../../../../app/domain/language'; import { Subscription } from 'rxjs'; import { TeacherDataService } from '../../../services/teacherDataService'; +import { NotifyAuthorService } from '../../../services/notifyAuthorService'; @Component({ selector: 'at-top-bar', @@ -34,6 +35,7 @@ export class TopBarComponent implements OnInit { constructor( private configService: ConfigService, private dataService: TeacherDataService, + private notifyAuthorService: NotifyAuthorService, private projectService: TeacherProjectService, private router: Router, private sessionService: SessionService @@ -108,7 +110,7 @@ export class TopBarComponent implements OnInit { } protected goHome(): void { - this.projectService.notifyAuthorProjectEnd().then(() => { + this.notifyAuthorService.editEnd(this.projectId).then(() => { this.sessionService.goHome(); }); } diff --git a/src/assets/wise5/authoringTool/concurrent-authors-message/concurrent-authors-message.component.spec.ts b/src/assets/wise5/authoringTool/concurrent-authors-message/concurrent-authors-message.component.spec.ts index 091d1496986..6e3ae833297 100644 --- a/src/assets/wise5/authoringTool/concurrent-authors-message/concurrent-authors-message.component.spec.ts +++ b/src/assets/wise5/authoringTool/concurrent-authors-message/concurrent-authors-message.component.spec.ts @@ -7,6 +7,7 @@ import { of } from 'rxjs'; import { SessionService } from '../../services/sessionService'; import { provideHttpClientTesting } from '@angular/common/http/testing'; import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'; +import { NotifyAuthorService } from '../../services/notifyAuthorService'; class MockConfigService { getMyUsername(): string { @@ -24,16 +25,17 @@ let fixture: ComponentFixture; describe('ConcurrentAuthorsMessageComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ConcurrentAuthorsMessageComponent], - imports: [], - providers: [ + declarations: [ConcurrentAuthorsMessageComponent], + imports: [], + providers: [ { provide: ConfigService, useClass: MockConfigService }, + NotifyAuthorService, SessionService, { provide: TeacherProjectService, useClass: MockTeacherProjectService }, provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting() - ] -}); + ] + }); fixture = TestBed.createComponent(ConcurrentAuthorsMessageComponent); component = fixture.componentInstance; }); diff --git a/src/assets/wise5/authoringTool/concurrent-authors-message/concurrent-authors-message.component.ts b/src/assets/wise5/authoringTool/concurrent-authors-message/concurrent-authors-message.component.ts index 22623892cc1..413305c4097 100644 --- a/src/assets/wise5/authoringTool/concurrent-authors-message/concurrent-authors-message.component.ts +++ b/src/assets/wise5/authoringTool/concurrent-authors-message/concurrent-authors-message.component.ts @@ -4,6 +4,7 @@ import { RxStomp } from '@stomp/rx-stomp'; import { Message } from '@stomp/stompjs'; import { TeacherProjectService } from '../../services/teacherProjectService'; import { SessionService } from '../../services/sessionService'; +import { NotifyAuthorService } from '../../services/notifyAuthorService'; @Component({ selector: 'concurrent-authors-message', @@ -17,6 +18,7 @@ export class ConcurrentAuthorsMessageComponent { constructor( private configService: ConfigService, + private notifyAuthorService: NotifyAuthorService, private projectService: TeacherProjectService, private sessionService: SessionService ) { @@ -29,7 +31,7 @@ export class ConcurrentAuthorsMessageComponent { ngOnInit() { this.rxStomp.activate(); this.rxStomp.connected$.subscribe(() => { - this.projectService.notifyAuthorProjectBegin(this.projectId); + this.notifyAuthorService.editBegin(this.projectId); }); this.subscribeToCurrentAuthors(); this.subscribeToSessionExit(); @@ -49,7 +51,7 @@ export class ConcurrentAuthorsMessageComponent { private subscribeToSessionExit(): void { this.sessionService.exit$.subscribe(() => { - this.projectService.notifyAuthorProjectEnd(); + this.notifyAuthorService.editEnd(this.projectId); }); } diff --git a/src/assets/wise5/authoringTool/project-authoring-parent/project-authoring-parent.component.ts b/src/assets/wise5/authoringTool/project-authoring-parent/project-authoring-parent.component.ts index 67250d38acc..904e7097eed 100644 --- a/src/assets/wise5/authoringTool/project-authoring-parent/project-authoring-parent.component.ts +++ b/src/assets/wise5/authoringTool/project-authoring-parent/project-authoring-parent.component.ts @@ -1,5 +1,5 @@ import { Component, Input } from '@angular/core'; -import { TeacherProjectService } from '../../services/teacherProjectService'; +import { NotifyAuthorService } from '../../services/notifyAuthorService'; @Component({ templateUrl: './project-authoring-parent.component.html', @@ -8,17 +8,17 @@ import { TeacherProjectService } from '../../services/teacherProjectService'; export class ProjectAuthoringParentComponent { @Input('unitId') protected projectId?: number; - constructor(private projectService: TeacherProjectService) {} + constructor(private notifyAuthorService: NotifyAuthorService) {} ngOnInit(): void { this.projectId = Number(this.projectId); - this.projectService.notifyAuthorProjectBegin(this.projectId); + this.notifyAuthorService.editBegin(this.projectId); window.onbeforeunload = (event) => { - this.projectService.notifyAuthorProjectEnd(this.projectId); + this.notifyAuthorService.editEnd(this.projectId); }; } ngOnDestroy(): void { - this.projectService.notifyAuthorProjectEnd(this.projectId); + this.notifyAuthorService.editEnd(this.projectId); } } diff --git a/src/assets/wise5/services/notifyAuthorService.ts b/src/assets/wise5/services/notifyAuthorService.ts new file mode 100644 index 00000000000..5f07c234be2 --- /dev/null +++ b/src/assets/wise5/services/notifyAuthorService.ts @@ -0,0 +1,22 @@ +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; + +@Injectable() +export class NotifyAuthorService { + constructor(private http: HttpClient) {} + + editBegin(projectId: number): void { + this.http.post(`/api/author/project/notify/${projectId}/true`, null).subscribe(); + } + + editEnd(projectId: number): Promise { + return new Promise((resolve, reject) => { + if (projectId == null) { + resolve(); + } + this.http.post(`/api/author/project/notify/${projectId}/false`, null).subscribe(() => { + resolve(); + }); + }); + } +} diff --git a/src/assets/wise5/services/teacherProjectService.ts b/src/assets/wise5/services/teacherProjectService.ts index e4899477205..d257de2a80d 100644 --- a/src/assets/wise5/services/teacherProjectService.ts +++ b/src/assets/wise5/services/teacherProjectService.ts @@ -45,29 +45,6 @@ export class TeacherProjectService extends ProjectService { super(branchService, componentServiceLookupService, http, configService, pathService); } - notifyAuthorProjectBeginEnd(projectId, isBegin) { - return this.http.post(`/api/author/project/notify/${projectId}/${isBegin}`, null).toPromise(); - } - - notifyAuthorProjectBegin(projectId) { - return this.notifyAuthorProjectBeginEnd(projectId, true); - } - - notifyAuthorProjectEnd(projectId = null) { - return new Promise((resolve, reject) => { - if (projectId == null) { - if (this.project != null) { - projectId = this.configService.getProjectId(); - } else { - resolve({}); - } - } - this.notifyAuthorProjectBeginEnd(projectId, false).then(() => { - resolve({}); - }); - }); - } - /** * Retrieve the project JSON * @param projectId retrieve the project JSON with this id diff --git a/src/messages.xlf b/src/messages.xlf index 21a49bf752e..e0f753ce163 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -10305,14 +10305,14 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.ID: src/assets/wise5/authoringTool/components/top-bar/top-bar.component.ts - 74 + 76 Run ID: | Access Code: src/assets/wise5/authoringTool/components/top-bar/top-bar.component.ts - 76 + 78 src/assets/wise5/classroomMonitor/classroomMonitorComponents/shared/top-bar/top-bar.component.ts @@ -10360,7 +10360,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.. Be careful not to overwrite each other's work! src/assets/wise5/authoringTool/concurrent-authors-message/concurrent-authors-message.component.ts - 43,45 + 45,47 @@ -21948,42 +21948,42 @@ If this problem continues, let your teacher know and move on to the next activit All steps after this one will not be visitable until src/assets/wise5/services/teacherProjectService.ts - 810 + 787 All steps after this one will not be visible until src/assets/wise5/services/teacherProjectService.ts - 813 + 790 All other steps will not be visitable until src/assets/wise5/services/teacherProjectService.ts - 816 + 793 All other steps will not be visible until src/assets/wise5/services/teacherProjectService.ts - 819 + 796 This step will not be visitable until src/assets/wise5/services/teacherProjectService.ts - 822 + 799 This step will not be visible until src/assets/wise5/services/teacherProjectService.ts - 825 + 802