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
20 changes: 0 additions & 20 deletions src/app/services/teacherProjectService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ describe('TeacherProjectService', () => {
service.applicationNodes = [];
});
registerNewProject();
isNodeIdUsed();
isNodeIdToInsertTargetNotSpecified();
testGetNodeIdAfter();
testCreateNodeAfter();
Expand Down Expand Up @@ -131,25 +130,6 @@ function registerNewProject() {
});
}

function isNodeIdUsed() {
describe('isNodeIdUsed', () => {
beforeEach(() => {
service.setProject(demoProjectJSON);
});
it('should find used node id in active nodes', () => {
expect(service.isNodeIdUsed('node1')).toEqual(true);
});

it('should find used node id in inactive nodes', () => {
expect(service.isNodeIdUsed('node789')).toEqual(true);
});

it('should not find used node id in active or inactive nodes', () => {
expect(service.isNodeIdUsed('nodedoesnotexist')).toEqual(false);
});
});
}

function isNodeIdToInsertTargetNotSpecified() {
describe('isNodeIdToInsertTargetNotSpecified', () => {
it('should return true for null, inactive nodes, steps, and activities', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,35 @@ import { provideHttpClientTesting } from '@angular/common/http/testing';
import { CopyNodesService } from '../../../services/copyNodesService';
import { StudentTeacherCommonServicesModule } from '../../../../../app/student-teacher-common-services.module';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { Node } from '../../../common/Node';

let component: GradingEditComponentMaxScoreComponent;
let fixture: ComponentFixture<GradingEditComponentMaxScoreComponent>;
let saveProjectSpy;
let setMaxScoreForComponentSpy;
let getNodeSpy;
let projectService: TeacherProjectService;

describe('GradingEditComponentMaxScoreComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [GradingEditComponentMaxScoreComponent],
schemas: [NO_ERRORS_SCHEMA],
imports: [StudentTeacherCommonServicesModule],
providers: [CopyNodesService, TeacherProjectService, provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()]
});
declarations: [GradingEditComponentMaxScoreComponent],
schemas: [NO_ERRORS_SCHEMA],
imports: [StudentTeacherCommonServicesModule],
providers: [
CopyNodesService,
TeacherProjectService,
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting()
]
});
projectService = TestBed.inject(TeacherProjectService);
fixture = TestBed.createComponent(GradingEditComponentMaxScoreComponent);
component = fixture.componentInstance;
component.componentId = 'c1';
saveProjectSpy = spyOn(projectService, 'saveProject').and.callFake(() => new Promise(() => {}));
setMaxScoreForComponentSpy = spyOn(
projectService,
'setMaxScoreForComponent'
).and.callFake(() => {});
const node = new Node();
node.components = [{ id: 'c1' }];
getNodeSpy = spyOn(projectService, 'getNode').and.returnValue(node);
});
saveMaxScore();
});
Expand All @@ -48,13 +54,13 @@ function saveMaxScore() {

function shouldSave(maxScore: number) {
setMaxScoreAndSave(maxScore);
expect(setMaxScoreForComponentSpy).toHaveBeenCalled();
expect(getNodeSpy).toHaveBeenCalled();
expect(saveProjectSpy).toHaveBeenCalled();
}

function shouldNotSave(maxScore: number) {
setMaxScoreAndSave(maxScore);
expect(setMaxScoreForComponentSpy).not.toHaveBeenCalled();
expect(getNodeSpy).not.toHaveBeenCalled();
expect(saveProjectSpy).not.toHaveBeenCalled();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ import { TeacherProjectService } from '../../../services/teacherProjectService';

@Component({
selector: 'grading-edit-component-max-score',
styles: [`
/* TODO(mdc-migration): The following rule targets internal classes of form-field that may no longer apply for the MDC version. */
.mat-form-field-infix { width: inherit; }`],
styles: [
`
/* TODO(mdc-migration): The following rule targets internal classes of form-field that may no longer apply for the MDC version. */
.mat-form-field-infix {
width: inherit;
}
`
],
templateUrl: 'grading-edit-component-max-score.component.html',
encapsulation: ViewEncapsulation.None
})
Expand Down Expand Up @@ -37,7 +42,7 @@ export class GradingEditComponentMaxScoreComponent {
saveMaxScore(): void {
const maxScore = Number(this.maxScore);
if (maxScore >= 0) {
this.projectService.setMaxScoreForComponent(this.nodeId, this.componentId, maxScore);
this.projectService.getNode(this.nodeId).getComponent(this.componentId).maxScore = maxScore;
this.projectService.saveProject();
this.maxScore = this.maxScore || 0;
}
Expand Down
21 changes: 0 additions & 21 deletions src/assets/wise5/services/teacherProjectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,20 +207,6 @@ export class TeacherProjectService extends ProjectService {
return false;
}

/**
* Check if a node id is already being used in the project
* @param nodeId check if this node id is already being used in the project
* @return whether the node id is already being used in the project
*/
isNodeIdUsed(nodeId) {
for (const node of this.getNodes().concat(this.getInactiveNodes())) {
if (node.id === nodeId) {
return true;
}
}
return false;
}

/**
* Set a field in the transition logic of a node
*/
Expand Down Expand Up @@ -1738,13 +1724,6 @@ export class TeacherProjectService extends ProjectService {
}
}

setMaxScoreForComponent(nodeId: string, componentId: string, maxScore: number): void {
const component = this.getComponent(nodeId, componentId);
if (component != null) {
component.maxScore = maxScore;
}
}

hasGroupStartId(nodeId) {
const startId = this.getGroupStartId(nodeId);
return startId != null && startId != '';
Expand Down