Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/app/teacher/teacher-authoring.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -56,6 +57,7 @@ import { CopyTranslationsService } from '../../assets/wise5/services/copyTransla
MilestoneReportService,
MoveNodesService,
{ provide: NodeService, useExisting: TeacherNodeService },
NotifyAuthorService,
ProjectAssetService,
SpaceService,
DeleteTranslationsService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,33 @@ 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;
let fixture: ComponentFixture<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(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
Expand Down Expand Up @@ -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();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -24,16 +25,17 @@ let fixture: ComponentFixture<ConcurrentAuthorsMessageComponent>;
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;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -17,6 +18,7 @@ export class ConcurrentAuthorsMessageComponent {

constructor(
private configService: ConfigService,
private notifyAuthorService: NotifyAuthorService,
private projectService: TeacherProjectService,
private sessionService: SessionService
) {
Expand All @@ -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();
Expand All @@ -49,7 +51,7 @@ export class ConcurrentAuthorsMessageComponent {

private subscribeToSessionExit(): void {
this.sessionService.exit$.subscribe(() => {
this.projectService.notifyAuthorProjectEnd();
this.notifyAuthorService.editEnd(this.projectId);
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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);
}
}
22 changes: 22 additions & 0 deletions src/assets/wise5/services/notifyAuthorService.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
return new Promise((resolve, reject) => {
if (projectId == null) {
resolve();
}
this.http.post(`/api/author/project/notify/${projectId}/false`, null).subscribe(() => {
resolve();
});
});
}
}
23 changes: 0 additions & 23 deletions src/assets/wise5/services/teacherProjectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/messages.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -10305,14 +10305,14 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
<source>ID: <x id="PH" equiv-text="this.projectId"/></source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/authoringTool/components/top-bar/top-bar.component.ts</context>
<context context-type="linenumber">74</context>
<context context-type="linenumber">76</context>
</context-group>
</trans-unit>
<trans-unit id="3275557751683993510" datatype="html">
<source>Run ID: <x id="PH" equiv-text="this.runId"/> | Access Code: <x id="PH_1" equiv-text="this.runCode"/></source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/authoringTool/components/top-bar/top-bar.component.ts</context>
<context context-type="linenumber">76</context>
<context context-type="linenumber">78</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/shared/top-bar/top-bar.component.ts</context>
Expand Down Expand Up @@ -10360,7 +10360,7 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
)"/>. Be careful not to overwrite each other&apos;s work!</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/authoringTool/concurrent-authors-message/concurrent-authors-message.component.ts</context>
<context context-type="linenumber">43,45</context>
<context context-type="linenumber">45,47</context>
</context-group>
</trans-unit>
<trans-unit id="5763042719559545946" datatype="html">
Expand Down Expand Up @@ -21948,42 +21948,42 @@ If this problem continues, let your teacher know and move on to the next activit
<source>All steps after this one will not be visitable until </source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/services/teacherProjectService.ts</context>
<context context-type="linenumber">810</context>
<context context-type="linenumber">787</context>
</context-group>
</trans-unit>
<trans-unit id="5548702737138673668" datatype="html">
<source>All steps after this one will not be visible until </source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/services/teacherProjectService.ts</context>
<context context-type="linenumber">813</context>
<context context-type="linenumber">790</context>
</context-group>
</trans-unit>
<trans-unit id="3112051127445790513" datatype="html">
<source>All other steps will not be visitable until </source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/services/teacherProjectService.ts</context>
<context context-type="linenumber">816</context>
<context context-type="linenumber">793</context>
</context-group>
</trans-unit>
<trans-unit id="2264443134334419091" datatype="html">
<source>All other steps will not be visible until </source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/services/teacherProjectService.ts</context>
<context context-type="linenumber">819</context>
<context context-type="linenumber">796</context>
</context-group>
</trans-unit>
<trans-unit id="6819040711904864999" datatype="html">
<source>This step will not be visitable until </source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/services/teacherProjectService.ts</context>
<context context-type="linenumber">822</context>
<context context-type="linenumber">799</context>
</context-group>
</trans-unit>
<trans-unit id="816962217622004346" datatype="html">
<source>This step will not be visible until </source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/services/teacherProjectService.ts</context>
<context context-type="linenumber">825</context>
<context context-type="linenumber">802</context>
</context-group>
</trans-unit>
<trans-unit id="6103908175957925049" datatype="html">
Expand Down