Skip to content

Commit 07d7624

Browse files
committed
Moved teacher related code from ProjectService to TeacherProjectService. #2676
1 parent 4c15821 commit 07d7624

14 files changed

Lines changed: 3114 additions & 3106 deletions

File tree

src/main/webapp/site/src/app/authoring-tool/add-component/choose-new-component-location/choose-new-component-location.component.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
22
import { TestBed } from '@angular/core/testing';
33
import { UpgradeModule } from '@angular/upgrade/static';
44
import { ConfigService } from '../../../../../../wise5/services/configService';
5-
import { ProjectService } from '../../../../../../wise5/services/projectService';
65
import { TeacherDataService } from '../../../../../../wise5/services/teacherDataService';
6+
import { TeacherProjectService } from '../../../../../../wise5/services/teacherProjectService';
77
import { UtilService } from '../../../../../../wise5/services/utilService';
88
import { ChooseNewComponentLocation } from './choose-new-component-location.component';
99

@@ -42,7 +42,7 @@ class MockUpgradeModule {
4242
}
4343

4444
let component: ChooseNewComponentLocation;
45-
let projectService: ProjectService;
45+
let teacherProjectService: TeacherProjectService;
4646

4747
describe('ChooseNewComponentLocation', () => {
4848
beforeEach(() => {
@@ -51,14 +51,14 @@ describe('ChooseNewComponentLocation', () => {
5151
providers: [
5252
ChooseNewComponentLocation,
5353
ConfigService,
54-
{ provide: ProjectService, useClass: MockProjectService },
54+
{ provide: TeacherProjectService, useClass: MockProjectService },
5555
{ provide: TeacherDataService, useClass: MockTeacherDataService },
5656
{ provide: UpgradeModule, useClass: MockUpgradeModule },
5757
UtilService
5858
]
5959
});
6060
component = TestBed.inject(ChooseNewComponentLocation);
61-
projectService = TestBed.inject(ProjectService);
61+
teacherProjectService = TestBed.inject(TeacherProjectService);
6262
});
6363

6464
it('should have nodeId and components set after initialization', () => {
@@ -68,10 +68,10 @@ describe('ChooseNewComponentLocation', () => {
6868
});
6969

7070
it('insertComponentAfter() should create a new component and save the project', () => {
71-
spyOn(projectService, 'createComponent').and.returnValue({ id: 'comp3', type: 'Discussion' });
72-
spyOn(projectService, 'saveProject').and.returnValue(new Promise(() => {}));
71+
spyOn(teacherProjectService, 'createComponent').and.returnValue({ id: 'comp3', type: 'Discussion' });
72+
spyOn(teacherProjectService, 'saveProject').and.returnValue(new Promise(() => {}));
7373
component.insertComponentAfter('comp2');
74-
expect(projectService.createComponent).toHaveBeenCalled();
75-
expect(projectService.saveProject).toHaveBeenCalled();
74+
expect(teacherProjectService.createComponent).toHaveBeenCalled();
75+
expect(teacherProjectService.saveProject).toHaveBeenCalled();
7676
});
7777
});

src/main/webapp/site/src/app/authoring-tool/add-component/choose-new-component-location/choose-new-component-location.component.ts

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { UtilService } from '../../../../../../wise5/services/utilService';
2-
import { ProjectService } from '../../../../../../wise5/services/projectService';
32
import { TeacherDataService } from '../../../../../../wise5/services/teacherDataService';
43
import { ConfigService } from '../../../../../../wise5/services/configService';
54
import { Component } from '@angular/core';
65
import { UpgradeModule } from '@angular/upgrade/static';
6+
import { TeacherProjectService } from '../../../../../../wise5/services/teacherProjectService';
77

88
@Component({
99
selector: 'choose-new-component-location',
@@ -16,14 +16,14 @@ export class ChooseNewComponentLocation {
1616
constructor(
1717
private upgrade: UpgradeModule,
1818
private ConfigService: ConfigService,
19-
private ProjectService: ProjectService,
19+
private TeacherProjectService: TeacherProjectService,
2020
private TeacherDataService: TeacherDataService,
2121
private UtilService: UtilService
2222
) {}
2323

2424
ngOnInit() {
2525
this.nodeId = this.TeacherDataService.getCurrentNodeId();
26-
this.components = this.ProjectService.getComponentsByNodeId(this.nodeId);
26+
this.components = this.TeacherProjectService.getComponentsByNodeId(this.nodeId);
2727
}
2828

2929
getComponentTypeLabel(componentType) {
@@ -35,20 +35,18 @@ export class ChooseNewComponentLocation {
3535
}
3636

3737
insertComponentAfter(insertAfterComponentId = null) {
38-
const newComponent = this.ProjectService.createComponent(
38+
const newComponent = this.TeacherProjectService.createComponent(
3939
this.nodeId,
4040
this.upgrade.$injector.get('$stateParams').componentType,
4141
insertAfterComponentId
4242
);
43-
this.ProjectService.saveProject().then(() => {
43+
this.TeacherProjectService.saveProject().then(() => {
4444
this.saveAddComponentEvent(newComponent);
45-
this.upgrade.$injector
46-
.get('$state')
47-
.go('root.at.project.node', {
48-
projectId: this.ConfigService.getProjectId(),
49-
nodeId: this.nodeId,
50-
newComponents: [newComponent]
51-
});
45+
this.upgrade.$injector.get('$state').go('root.at.project.node', {
46+
projectId: this.ConfigService.getProjectId(),
47+
nodeId: this.nodeId,
48+
newComponents: [newComponent]
49+
});
5250
});
5351
}
5452

@@ -74,11 +72,9 @@ export class ChooseNewComponentLocation {
7472
}
7573

7674
cancel() {
77-
this.upgrade.$injector
78-
.get('$state')
79-
.go('root.at.project.node', {
80-
projectId: this.ConfigService.getProjectId(),
81-
nodeId: this.nodeId
82-
});
75+
this.upgrade.$injector.get('$state').go('root.at.project.node', {
76+
projectId: this.ConfigService.getProjectId(),
77+
nodeId: this.nodeId
78+
});
8379
}
8480
}

src/main/webapp/site/src/app/preview/modules/choose-branch-path-dialog/choose-branch-path-dialog.component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { Component, OnInit, Inject } from '@angular/core';
22
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
3-
import { NodeService } from '../../../../../../wise5/services/nodeService';
4-
import { ProjectService } from '../../../../../../wise5/services/projectService';
53

64
@Component({
75
selector: 'app-choose-branch-path-dialog',

0 commit comments

Comments
 (0)