diff --git a/src/app/services/graphService.spec.ts b/src/app/services/graphService.spec.ts index 5d11594baf..23f65a8df5 100644 --- a/src/app/services/graphService.spec.ts +++ b/src/app/services/graphService.spec.ts @@ -63,6 +63,7 @@ function createComponentState(studentData: any, isSubmit: boolean = false) { function createComponentContent(series: any[] = [], xAxis: any = {}, yAxis: any = {}) { return { + connectedComponents: [], series: series, xAxis: xAxis, yAxis: yAxis @@ -205,16 +206,17 @@ function hasSubmitComponentState() { } function canEdit() { - function expectCanEdit(component: any, expectedResult: boolean) { - expect(service.canEdit(component)).toEqual(expectedResult); - } - it('should check if the student can edit the graph when they can not edit', () => { - const multipleSeries = [createSingleSeries([], false), createSingleSeries([], false)]; - expectCanEdit(createComponentContent(multipleSeries), false); - }); - it('should check if the student can edit the graph when they can edit', () => { - const multipleSeries = [createSingleSeries([], false), createSingleSeries([], true)]; - expectCanEdit(createComponentContent(multipleSeries), true); + describe('canEdit()', () => { + it('should return false when they can not edit', () => { + const multipleSeries = [createSingleSeries([], false), createSingleSeries([], false)]; + const content = createComponentContent(multipleSeries); + content.connectedComponents = [{ type: 'showWork' }]; + expect(service.canEdit(content)).toEqual(false); + }); + it('should return true when they can edit', () => { + const multipleSeries = [createSingleSeries([], false), createSingleSeries([], true)]; + expect(service.canEdit(createComponentContent(multipleSeries))).toEqual(true); + }); }); } diff --git a/src/app/services/labelService.spec.ts b/src/app/services/labelService.spec.ts index 1f60f460d0..891ab0e24d 100644 --- a/src/app/services/labelService.spec.ts +++ b/src/app/services/labelService.spec.ts @@ -4,13 +4,11 @@ import { ConfigService } from '../../assets/wise5/services/configService'; import { ProjectService } from '../../assets/wise5/services/projectService'; import { StudentAssetService } from '../../assets/wise5/services/studentAssetService'; import { TagService } from '../../assets/wise5/services/tagService'; -import { UtilService } from '../../assets/wise5/services/utilService'; import { LabelService } from '../../assets/wise5/components/label/labelService'; import { TestBed } from '@angular/core/testing'; import { SessionService } from '../../assets/wise5/services/sessionService'; let service: LabelService; -let utilService: UtilService; let label1: any; let label2: any; let label1Text: any = 'Label 1'; @@ -46,12 +44,10 @@ describe('LabelService', () => { ProjectService, SessionService, StudentAssetService, - TagService, - UtilService + TagService ] }); - service = TestBed.get(LabelService); - utilService = TestBed.get(UtilService); + service = TestBed.inject(LabelService); label1 = createLabel(label1Text, label1PointX, label1PointY, label1TextX, label1TextY, color1); label2 = createLabel(label2Text, label2PointX, label2PointY, label2TextX, label2TextY, color2); }); @@ -233,15 +229,13 @@ function componentStateHasLabel() { } function canEdit() { - it(`should check if the component can be edited when it does not have a show work connected - component`, () => { - spyOn(utilService, 'hasShowWorkConnectedComponent').and.returnValue(false); - expect(service.canEdit({})).toEqual(true); - }); - it(`should check if the component can be edited when it does have a show work connected - component`, () => { - spyOn(utilService, 'hasShowWorkConnectedComponent').and.returnValue(true); - expect(service.canEdit({})).toEqual(false); + describe('canEdit()', () => { + it(`should return true when it does not have a show work connected component`, () => { + expect(service.canEdit({})).toEqual(true); + }); + it(`should return false when it does have a show work connected component`, () => { + expect(service.canEdit({ connectedComponents: [{ type: 'showWork' }] })).toEqual(false); + }); }); } diff --git a/src/assets/wise5/common/ComponentContent.spec.ts b/src/assets/wise5/common/ComponentContent.spec.ts new file mode 100644 index 0000000000..e5fe1c99a6 --- /dev/null +++ b/src/assets/wise5/common/ComponentContent.spec.ts @@ -0,0 +1,18 @@ +import { ComponentContent, hasConnectedComponent } from './ComponentContent'; + +describe('ComponentContent', () => { + describe('hasConnectedComponent()', () => { + it('returns false when content does not have any connected components', () => { + const content = {} as ComponentContent; + expect(hasConnectedComponent(content, 'importWork')).toBeFalse(); + }); + it('returns false when content does not have the specified connected component type', () => { + const content = { connectedComponents: [{ type: 'showWork' }] } as ComponentContent; + expect(hasConnectedComponent(content, 'importWork')).toBeFalse(); + }); + it('returns true when content has the specified connected component type', () => { + const content = { connectedComponents: [{ type: 'importWork' }] } as ComponentContent; + expect(hasConnectedComponent(content, 'importWork')).toBeTrue(); + }); + }); +}); diff --git a/src/assets/wise5/common/ComponentContent.ts b/src/assets/wise5/common/ComponentContent.ts index f292f63a21..a99923736f 100644 --- a/src/assets/wise5/common/ComponentContent.ts +++ b/src/assets/wise5/common/ComponentContent.ts @@ -15,3 +15,13 @@ export interface ComponentContent { showSubmitButton?: boolean; type: string; } + +export function hasConnectedComponent( + content: ComponentContent, + connectedComponentType: 'importWork' | 'showWork' +): boolean { + return ( + content.connectedComponents != null && + content.connectedComponents.some((c) => c.type === connectedComponentType) + ); +} diff --git a/src/assets/wise5/components/animation/animation-student/animation-student.component.ts b/src/assets/wise5/components/animation/animation-student/animation-student.component.ts index 332701525a..bee57e4cfe 100644 --- a/src/assets/wise5/components/animation/animation-student/animation-student.component.ts +++ b/src/assets/wise5/components/animation/animation-student/animation-student.component.ts @@ -7,10 +7,10 @@ import { NodeService } from '../../../services/nodeService'; import { NotebookService } from '../../../services/notebookService'; import { StudentAssetService } from '../../../services/studentAssetService'; import { StudentDataService } from '../../../services/studentDataService'; -import { UtilService } from '../../../services/utilService'; import { ComponentStudent } from '../../component-student.component'; import { ComponentService } from '../../componentService'; import { AnimationService } from '../animationService'; +import { hasConnectedComponent } from '../../../common/ComponentContent'; @Component({ selector: 'animation-student', @@ -52,8 +52,7 @@ export class AnimationStudent extends ComponentStudent { protected NodeService: NodeService, protected NotebookService: NotebookService, protected StudentAssetService: StudentAssetService, - protected StudentDataService: StudentDataService, - protected UtilService: UtilService + protected StudentDataService: StudentDataService ) { super( AnnotationService, @@ -77,7 +76,7 @@ export class AnimationStudent extends ComponentStudent { this.svgId = this.AnimationService.getSvgId(domIdEnding); this.initializeCoordinates(); - if (this.UtilService.hasShowWorkConnectedComponent(this.componentContent)) { + if (hasConnectedComponent(this.componentContent, 'showWork')) { this.handleConnectedComponents(); } else if ( this.AnimationService.componentStateHasStudentWork(this.componentState, this.componentContent) diff --git a/src/assets/wise5/components/audioOscillator/audio-oscillator-student/audio-oscillator-student.component.ts b/src/assets/wise5/components/audioOscillator/audio-oscillator-student/audio-oscillator-student.component.ts index bd84122492..43df0856c0 100644 --- a/src/assets/wise5/components/audioOscillator/audio-oscillator-student/audio-oscillator-student.component.ts +++ b/src/assets/wise5/components/audioOscillator/audio-oscillator-student/audio-oscillator-student.component.ts @@ -7,10 +7,10 @@ import { NodeService } from '../../../services/nodeService'; import { NotebookService } from '../../../services/notebookService'; import { StudentAssetService } from '../../../services/studentAssetService'; import { StudentDataService } from '../../../services/studentDataService'; -import { UtilService } from '../../../services/utilService'; import { ComponentStudent } from '../../component-student.component'; import { ComponentService } from '../../componentService'; import { AudioOscillatorService } from '../audioOscillatorService'; +import { hasConnectedComponent } from '../../../common/ComponentContent'; @Component({ selector: 'audio-oscillator-student', @@ -71,8 +71,7 @@ export class AudioOscillatorStudent extends ComponentStudent { protected NodeService: NodeService, protected NotebookService: NotebookService, protected StudentAssetService: StudentAssetService, - protected StudentDataService: StudentDataService, - protected UtilService: UtilService + protected StudentDataService: StudentDataService ) { super( AnnotationService, @@ -97,7 +96,7 @@ export class AudioOscillatorStudent extends ComponentStudent { this.setButtonTextToPlay(); this.setParametersFromComponentContent(); - if (this.UtilService.hasShowWorkConnectedComponent(this.componentContent)) { + if (hasConnectedComponent(this.componentContent, 'showWork')) { this.handleConnectedComponents(); } else if ( this.AudioOscillatorService.componentStateHasStudentWork( diff --git a/src/assets/wise5/components/conceptMap/concept-map-student/concept-map-student.component.ts b/src/assets/wise5/components/conceptMap/concept-map-student/concept-map-student.component.ts index 3105796a6b..0d2559b54d 100644 --- a/src/assets/wise5/components/conceptMap/concept-map-student/concept-map-student.component.ts +++ b/src/assets/wise5/components/conceptMap/concept-map-student/concept-map-student.component.ts @@ -9,13 +9,13 @@ import { NotebookService } from '../../../services/notebookService'; import { ProjectService } from '../../../services/projectService'; import { StudentAssetService } from '../../../services/studentAssetService'; import { StudentDataService } from '../../../services/studentDataService'; -import { UtilService } from '../../../services/utilService'; import { ComponentStudent } from '../../component-student.component'; import { ComponentService } from '../../componentService'; import { ConceptMapService } from '../conceptMapService'; import { DialogWithCloseComponent } from '../../../directives/dialog-with-close/dialog-with-close.component'; import { copy } from '../../../common/object/object'; import { convertToPNGFile } from '../../../common/canvas/canvas'; +import { hasConnectedComponent } from '../../../common/ComponentContent'; @Component({ selector: 'concept-map-student', @@ -75,8 +75,7 @@ export class ConceptMapStudent extends ComponentStudent { protected NotebookService: NotebookService, private ProjectService: ProjectService, protected StudentAssetService: StudentAssetService, - protected StudentDataService: StudentDataService, - protected UtilService: UtilService + protected StudentDataService: StudentDataService ) { super( AnnotationService, @@ -156,7 +155,7 @@ export class ConceptMapStudent extends ComponentStudent { initializeSVG(): void { this.setupSVG(); - if (this.UtilService.hasShowWorkConnectedComponent(this.componentContent)) { + if (hasConnectedComponent(this.componentContent, 'showWork')) { this.handleConnectedComponents(); } else if (this.componentStateHasStudentWork(this.componentState, this.componentContent)) { this.componentState = this.ProjectService.injectAssetPaths(this.componentState); diff --git a/src/assets/wise5/components/draw/draw-student/draw-student.component.spec.ts b/src/assets/wise5/components/draw/draw-student/draw-student.component.spec.ts index 9d92261de8..2c84d24c6e 100644 --- a/src/assets/wise5/components/draw/draw-student/draw-student.component.spec.ts +++ b/src/assets/wise5/components/draw/draw-student/draw-student.component.spec.ts @@ -6,7 +6,6 @@ import { StudentTeacherCommonServicesModule } from '../../../../../app/student-t import { Component } from '../../../common/Component'; import { ProjectService } from '../../../services/projectService'; import { StudentDataService } from '../../../services/studentDataService'; -import { UtilService } from '../../../services/utilService'; import { DrawService } from '../drawService'; import { DrawStudent } from './draw-student.component'; @@ -87,9 +86,8 @@ function createCanvasObject(type: string): any { function initializeStudentData() { it('should initialize student data when there is a show work connected component', () => { component.componentContent.connectedComponents = [ - { nodeId: 'node', componentId: 'component1' } + { nodeId: 'node', componentId: 'component1', type: 'showWork' } ]; - spyOn(TestBed.inject(UtilService), 'hasShowWorkConnectedComponent').and.returnValue(true); spyOn( TestBed.inject(StudentDataService), 'getLatestComponentStateByNodeIdAndComponentId' diff --git a/src/assets/wise5/components/draw/draw-student/draw-student.component.ts b/src/assets/wise5/components/draw/draw-student/draw-student.component.ts index cbcad3bde3..8b39604f97 100644 --- a/src/assets/wise5/components/draw/draw-student/draw-student.component.ts +++ b/src/assets/wise5/components/draw/draw-student/draw-student.component.ts @@ -7,13 +7,13 @@ import { NotebookService } from '../../../services/notebookService'; import { ProjectService } from '../../../services/projectService'; import { StudentAssetService } from '../../../services/studentAssetService'; import { StudentDataService } from '../../../services/studentDataService'; -import { UtilService } from '../../../services/utilService'; import { ComponentStudent } from '../../component-student.component'; import { ComponentService } from '../../componentService'; import { DrawService } from '../drawService'; import { MatDialog } from '@angular/material/dialog'; import { copy } from '../../../common/object/object'; import { convertToPNGFile } from '../../../common/canvas/canvas'; +import { hasConnectedComponent } from '../../../common/ComponentContent'; @Component({ selector: 'draw-student', @@ -41,8 +41,7 @@ export class DrawStudent extends ComponentStudent { protected NotebookService: NotebookService, private ProjectService: ProjectService, protected StudentAssetService: StudentAssetService, - protected StudentDataService: StudentDataService, - protected UtilService: UtilService + protected StudentDataService: StudentDataService ) { super( AnnotationService, @@ -113,7 +112,7 @@ export class DrawStudent extends ComponentStudent { } initializeStudentData(): void { - if (this.UtilService.hasShowWorkConnectedComponent(this.componentContent)) { + if (hasConnectedComponent(this.componentContent, 'showWork')) { this.handleConnectedComponents(); } else if ( this.DrawService.componentStateHasStudentWork(this.componentState, this.componentContent) diff --git a/src/assets/wise5/components/graph/graphService.ts b/src/assets/wise5/components/graph/graphService.ts index ddeeea9a8d..d38dcb9c17 100644 --- a/src/assets/wise5/components/graph/graphService.ts +++ b/src/assets/wise5/components/graph/graphService.ts @@ -4,10 +4,10 @@ import * as html2canvas from 'html2canvas'; import { Injectable } from '@angular/core'; import { ComponentService } from '../componentService'; import { StudentAssetService } from '../../services/studentAssetService'; -import { UtilService } from '../../services/utilService'; import { ConfigService } from '../../services/configService'; import { HttpClient } from '@angular/common/http'; import { convertToPNGFile } from '../../common/canvas/canvas'; +import { hasConnectedComponent } from '../../common/ComponentContent'; @Injectable() export class GraphService extends ComponentService { @@ -16,8 +16,7 @@ export class GraphService extends ComponentService { constructor( private configService: ConfigService, private http: HttpClient, - private StudentAssetService: StudentAssetService, - protected UtilService: UtilService + private StudentAssetService: StudentAssetService ) { super(); } @@ -128,17 +127,14 @@ export class GraphService extends ComponentService { * @param component The component content. * @return Whether the student can perform any work on this component. */ - canEdit(component: any) { + canEdit(component: any): boolean { const series = component.series; for (const singleSeries of series) { if (singleSeries.canEdit) { return true; } } - if (this.UtilService.hasImportWorkConnectedComponent(component)) { - return true; - } - return false; + return hasConnectedComponent(component, 'importWork'); } hasSeriesData(studentData: any) { diff --git a/src/assets/wise5/components/label/label-student/label-student.component.ts b/src/assets/wise5/components/label/label-student/label-student.component.ts index 644a1b895b..ed11ad4adc 100644 --- a/src/assets/wise5/components/label/label-student/label-student.component.ts +++ b/src/assets/wise5/components/label/label-student/label-student.component.ts @@ -5,7 +5,6 @@ import { ConfigService } from '../../../services/configService'; import { NodeService } from '../../../services/nodeService'; import { NotebookService } from '../../../services/notebookService'; import { StudentDataService } from '../../../services/studentDataService'; -import { UtilService } from '../../../services/utilService'; import { ComponentStudent } from '../../component-student.component'; import { ComponentService } from '../../componentService'; import { LabelService } from '../labelService'; @@ -13,6 +12,7 @@ import { StudentAssetService } from '../../../services/studentAssetService'; import { MatDialog } from '@angular/material/dialog'; import { convertToPNGFile } from '../../../common/canvas/canvas'; import { wordWrap } from '../../../common/string/string'; +import { hasConnectedComponent } from '../../../common/ComponentContent'; @Component({ selector: 'label-student', @@ -55,8 +55,7 @@ export class LabelStudent extends ComponentStudent { protected NodeService: NodeService, protected NotebookService: NotebookService, protected StudentAssetService: StudentAssetService, - protected StudentDataService: StudentDataService, - protected UtilService: UtilService + protected StudentDataService: StudentDataService ) { super( AnnotationService, @@ -287,7 +286,7 @@ export class LabelStudent extends ComponentStudent { } initializeStudentWork(componentContent: any, componentState: any): void { - if (this.UtilService.hasShowWorkConnectedComponent(componentContent)) { + if (hasConnectedComponent(componentContent, 'showWork')) { this.handleConnectedComponents(); } else if (this.LabelService.componentStateHasStudentWork(componentState, componentContent)) { this.setStudentWork(componentState); diff --git a/src/assets/wise5/components/label/labelService.ts b/src/assets/wise5/components/label/labelService.ts index 13122960f6..ef1a054046 100644 --- a/src/assets/wise5/components/label/labelService.ts +++ b/src/assets/wise5/components/label/labelService.ts @@ -5,9 +5,9 @@ import SVG from 'svg.js'; import { ComponentService } from '../componentService'; import { StudentAssetService } from '../../services/studentAssetService'; import { Injectable } from '@angular/core'; -import { UtilService } from '../../services/utilService'; import { convertToPNGFile } from '../../common/canvas/canvas'; import { wordWrap } from '../../common/string/string'; +import { hasConnectedComponent } from '../../common/ComponentContent'; @Injectable() export class LabelService extends ComponentService { @@ -16,10 +16,7 @@ export class LabelService extends ComponentService { circleZIndex: number = 2; defaultTextBackgroundColor: string = 'blue'; - constructor( - private StudentAssetService: StudentAssetService, - protected UtilService: UtilService - ) { + constructor(private StudentAssetService: StudentAssetService) { super(); } @@ -83,8 +80,8 @@ export class LabelService extends ComponentService { * @param component The component content. * @return Whether the student can perform any work on this component. */ - canEdit(component: any) { - return !this.UtilService.hasShowWorkConnectedComponent(component); + canEdit(component: any): boolean { + return !hasConnectedComponent(component, 'showWork'); } componentStateHasStudentWork(componentState: any, componentContent: any): boolean { diff --git a/src/assets/wise5/components/match/match-student/match-student-default/match-student-default.component.ts b/src/assets/wise5/components/match/match-student/match-student-default/match-student-default.component.ts index 6edb06865e..833cddef1e 100644 --- a/src/assets/wise5/components/match/match-student/match-student-default/match-student-default.component.ts +++ b/src/assets/wise5/components/match/match-student/match-student-default/match-student-default.component.ts @@ -16,7 +16,6 @@ import { NotebookService } from '../../../../services/notebookService'; import { ProjectService } from '../../../../services/projectService'; import { StudentAssetService } from '../../../../services/studentAssetService'; import { StudentDataService } from '../../../../services/studentDataService'; -import { UtilService } from '../../../../services/utilService'; import { ComponentStudent } from '../../../component-student.component'; import { ComponentService } from '../../../componentService'; import { Choice, createChoiceFromNotebookItem } from '../../choice'; @@ -26,6 +25,7 @@ import { copy } from '../../../../common/object/object'; import { MatchCdkDragDrop } from '../MatchCdkDragDrop'; import { Container } from '../container'; import { Item } from '../item'; +import { hasConnectedComponent } from '../../../../common/ComponentContent'; @Component({ templateUrl: 'match-student-default.component.html', @@ -58,8 +58,7 @@ export class MatchStudentDefault extends ComponentStudent { protected notebookService: NotebookService, private projectService: ProjectService, protected studentAssetService: StudentAssetService, - protected studentDataService: StudentDataService, - protected utilService: UtilService + protected studentDataService: StudentDataService ) { super( annotationService, @@ -86,7 +85,7 @@ export class MatchStudentDefault extends ComponentStudent { this.subscribeToNewNotes(); } this.initializeBuckets(); - if (this.utilService.hasShowWorkConnectedComponent(this.componentContent)) { + if (hasConnectedComponent(this.componentContent, 'showWork')) { this.handleConnectedComponents(); } else if ( this.matchService.componentStateHasStudentWork(this.componentState, this.componentContent) diff --git a/src/assets/wise5/components/multipleChoice/multiple-choice-student/multiple-choice-student.component.ts b/src/assets/wise5/components/multipleChoice/multiple-choice-student/multiple-choice-student.component.ts index 599d3e6ded..4789bf14ba 100644 --- a/src/assets/wise5/components/multipleChoice/multiple-choice-student/multiple-choice-student.component.ts +++ b/src/assets/wise5/components/multipleChoice/multiple-choice-student/multiple-choice-student.component.ts @@ -9,12 +9,12 @@ import { NotebookService } from '../../../services/notebookService'; import { ProjectService } from '../../../services/projectService'; import { StudentAssetService } from '../../../services/studentAssetService'; import { StudentDataService } from '../../../services/studentDataService'; -import { UtilService } from '../../../services/utilService'; import { ComponentStudent } from '../../component-student.component'; import { ComponentService } from '../../componentService'; import { MultipleChoiceComponent } from '../MultipleChoiceComponent'; import { MultipleChoiceService } from '../multipleChoiceService'; import { MultipleChoiceContent } from '../MultipleChoiceContent'; +import { hasConnectedComponent } from '../../../common/ComponentContent'; @Component({ selector: 'multiple-choice-student', @@ -42,8 +42,7 @@ export class MultipleChoiceStudent extends ComponentStudent { protected notebookService: NotebookService, private projectService: ProjectService, protected studentAssetService: StudentAssetService, - protected studentDataService: StudentDataService, - protected utilService: UtilService + protected studentDataService: StudentDataService ) { super( annotationService, @@ -70,7 +69,7 @@ export class MultipleChoiceStudent extends ComponentStudent { this.component.id ) as MultipleChoiceContent; - if (this.utilService.hasShowWorkConnectedComponent(this.componentContent)) { + if (hasConnectedComponent(this.componentContent, 'showWork')) { this.handleConnectedComponents(); } else if (this.componentStateHasStudentWork(this.componentState, this.componentContent)) { this.setStudentWork(this.componentState); diff --git a/src/assets/wise5/components/openResponse/open-response-student/open-response-student.component.ts b/src/assets/wise5/components/openResponse/open-response-student/open-response-student.component.ts index a716d72273..f8fec484ec 100644 --- a/src/assets/wise5/components/openResponse/open-response-student/open-response-student.component.ts +++ b/src/assets/wise5/components/openResponse/open-response-student/open-response-student.component.ts @@ -11,7 +11,6 @@ import { NotificationService } from '../../../services/notificationService'; import { ProjectService } from '../../../services/projectService'; import { StudentAssetService } from '../../../services/studentAssetService'; import { StudentDataService } from '../../../services/studentDataService'; -import { UtilService } from '../../../services/utilService'; import { ComponentStudent } from '../../component-student.component'; import { ComponentService } from '../../componentService'; import { CRaterResponse } from '../../common/cRater/CRaterResponse'; @@ -21,6 +20,7 @@ import { FeedbackRuleComponent } from '../../feedbackRule/FeedbackRuleComponent' import { OpenResponseService } from '../openResponseService'; import { copy } from '../../../common/object/object'; import { RawCRaterResponse } from '../../common/cRater/RawCRaterResponse'; +import { hasConnectedComponent } from '../../../common/ComponentContent'; @Component({ selector: 'open-response-student', @@ -47,8 +47,7 @@ export class OpenResponseStudent extends ComponentStudent { private NotificationService: NotificationService, private ProjectService: ProjectService, protected StudentAssetService: StudentAssetService, - protected StudentDataService: StudentDataService, - protected UtilService: UtilService + protected StudentDataService: StudentDataService ) { super( AnnotationService, @@ -64,7 +63,7 @@ export class OpenResponseStudent extends ComponentStudent { ngOnInit(): void { super.ngOnInit(); - if (this.UtilService.hasShowWorkConnectedComponent(this.componentContent)) { + if (hasConnectedComponent(this.componentContent, 'showWork')) { this.handleConnectedComponents(); } else if ( this.componentState != null && diff --git a/src/assets/wise5/components/table/table-student/table-student.component.ts b/src/assets/wise5/components/table/table-student/table-student.component.ts index 1dd2d24289..2cc3fc3801 100644 --- a/src/assets/wise5/components/table/table-student/table-student.component.ts +++ b/src/assets/wise5/components/table/table-student/table-student.component.ts @@ -8,7 +8,6 @@ import { NotebookService } from '../../../services/notebookService'; import { ProjectService } from '../../../services/projectService'; import { StudentAssetService } from '../../../services/studentAssetService'; import { StudentDataService } from '../../../services/studentDataService'; -import { UtilService } from '../../../services/utilService'; import { ComponentStudent } from '../../component-student.component'; import { ComponentService } from '../../componentService'; import { TableService } from '../tableService'; @@ -17,6 +16,7 @@ import { TabulatorData } from '../TabulatorData'; import { TabulatorDataService } from '../tabulatorDataService'; import { copy } from '../../../common/object/object'; import { convertToPNGFile } from '../../../common/canvas/canvas'; +import { hasConnectedComponent } from '../../../common/ComponentContent'; @Component({ selector: 'table-student', @@ -63,8 +63,7 @@ export class TableStudent extends ComponentStudent { protected StudentAssetService: StudentAssetService, protected StudentDataService: StudentDataService, private TableService: TableService, - private TabulatorDataService: TabulatorDataService, - protected UtilService: UtilService + private TabulatorDataService: TabulatorDataService ) { super( AnnotationService, @@ -100,7 +99,7 @@ export class TableStudent extends ComponentStudent { this.isSaveButtonVisible = this.componentContent.showSaveButton; this.isSubmitButtonVisible = this.componentContent.showSubmitButton; - if (this.UtilService.hasShowWorkConnectedComponent(this.componentContent)) { + if (hasConnectedComponent(this.componentContent, 'showWork')) { // we will show work from another component this.handleConnectedComponents(); } else if ( diff --git a/src/assets/wise5/services/utilService.ts b/src/assets/wise5/services/utilService.ts index 8ffb93d26a..2d96a6e4f6 100644 --- a/src/assets/wise5/services/utilService.ts +++ b/src/assets/wise5/services/utilService.ts @@ -6,42 +6,6 @@ import '../lib/jquery/jquery-global'; @Injectable() export class UtilService { constructor() {} - - /** - * Determine whether the component has been authored to import work. - * @param componentContent The component content. - * @return Whether to import work in this component. - */ - hasImportWorkConnectedComponent(componentContent) { - return this.hasXConnectedComponent(componentContent, 'importWork'); - } - - /** - * Determine whether the component has been authored to show work. - * @param componentContent The component content. - * @return Whether to show work in this component. - */ - hasShowWorkConnectedComponent(componentContent) { - return this.hasXConnectedComponent(componentContent, 'showWork'); - } - - /** - * Determine whether the component has a connected component of the given type. - * @param componentContent The component content. - * @param connectedComponentType The connected component type. - * @return Whether the component has a connected component of the given type. - */ - hasXConnectedComponent(componentContent, connectedComponentType) { - if (componentContent.connectedComponents != null) { - let connectedComponents = componentContent.connectedComponents; - for (let connectedComponent of connectedComponents) { - if (connectedComponent.type == connectedComponentType) { - return true; - } - } - } - return false; - } } declare global { diff --git a/src/messages.xlf b/src/messages.xlf index b3c8990e7b..b4417ecbcd 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -9205,7 +9205,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it. src/assets/wise5/components/conceptMap/concept-map-student/concept-map-student.component.ts - 397 + 396 @@ -9263,7 +9263,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it. src/assets/wise5/components/match/match-student/match-student-default/match-student-default.component.ts - 394 + 393 @@ -14489,15 +14489,15 @@ Are you sure you want to proceed? You do not have any more chances to receive feedback on your answer. src/assets/wise5/components/animation/animation-student/animation-student.component.ts - 908 + 907 src/assets/wise5/components/openResponse/open-response-student/open-response-student.component.ts - 159 + 158 src/assets/wise5/components/openResponse/open-response-student/open-response-student.component.ts - 175 + 174 @@ -14506,7 +14506,7 @@ Are you sure you want to proceed? Are you ready to receive feedback on this answer? src/assets/wise5/components/animation/animation-student/animation-student.component.ts - 911 + 910 @@ -14515,11 +14515,11 @@ Are you ready to receive feedback on this answer? Are you ready to receive feedback on this answer? src/assets/wise5/components/animation/animation-student/animation-student.component.ts - 915 + 914 src/assets/wise5/components/conceptMap/concept-map-student/concept-map-student.component.ts - 331 + 330 @@ -14772,14 +14772,14 @@ Are you ready to receive feedback on this answer? Play src/assets/wise5/components/audioOscillator/audio-oscillator-student/audio-oscillator-student.component.ts - 281 + 280 Stop src/assets/wise5/components/audioOscillator/audio-oscillator-student/audio-oscillator-student.component.ts - 285 + 284 @@ -15374,7 +15374,7 @@ Label: You have no more chances to receive feedback on your answer. src/assets/wise5/components/conceptMap/concept-map-student/concept-map-student.component.ts - 325 + 324 @@ -15383,22 +15383,22 @@ Label: Are you ready to receive feedback on this answer? src/assets/wise5/components/conceptMap/concept-map-student/concept-map-student.component.ts - 328 + 327 src/assets/wise5/components/openResponse/open-response-student/open-response-student.component.ts - 162 + 161 Feedback src/assets/wise5/components/conceptMap/concept-map-student/concept-map-student.component.ts - 406 + 405 src/assets/wise5/components/conceptMap/concept-map-student/concept-map-student.component.ts - 415 + 414 src/assets/wise5/directives/componentAnnotations/component-annotations.component.ts @@ -15409,7 +15409,7 @@ Are you ready to receive feedback on this answer? Are you sure you want to reset your work? src/assets/wise5/components/conceptMap/concept-map-student/concept-map-student.component.ts - 1414 + 1413 @@ -16223,14 +16223,14 @@ Category Name: Are you sure you want to clear your drawing? src/assets/wise5/components/draw/draw-student/draw-student.component.ts - 199 + 198 Do you want to update the connected drawing? src/assets/wise5/components/draw/draw-student/draw-student.component.ts - 286 + 285 @@ -17145,42 +17145,42 @@ Category Name: Graph src/assets/wise5/components/graph/graphService.ts - 26 + 25 Time (seconds) src/assets/wise5/components/graph/graphService.ts - 48 + 47 s src/assets/wise5/components/graph/graphService.ts - 53 + 52 Position (meters) src/assets/wise5/components/graph/graphService.ts - 60 + 59 m src/assets/wise5/components/graph/graphService.ts - 73 + 72 Prediction src/assets/wise5/components/graph/graphService.ts - 79 + 78 @@ -17379,7 +17379,7 @@ Category Name: src/assets/wise5/components/label/label-student/label-student.component.ts - 740 + 739 @@ -17400,28 +17400,28 @@ Category Name: A New Label src/assets/wise5/components/label/label-student/label-student.component.ts - 487 + 486 Are you sure you want to reset to the initial state? src/assets/wise5/components/label/label-student/label-student.component.ts - 846 + 845 Are you sure you want to delete the background image? src/assets/wise5/components/label/label-student/label-student.component.ts - 907 + 906 Label src/assets/wise5/components/label/labelService.ts - 27 + 24 @@ -17723,14 +17723,14 @@ Warning: This will delete all existing choices and buckets in this component.Correct bucket but wrong position src/assets/wise5/components/match/match-student/match-student-default/match-student-default.component.ts - 488 + 487 Correct src/assets/wise5/components/match/match-student/match-student-default/match-student-default.component.ts - 495 + 494 src/assets/wise5/directives/summary-display/summary-display.component.ts @@ -17745,7 +17745,7 @@ Warning: This will delete all existing choices and buckets in this component.Incorrect src/assets/wise5/components/match/match-student/match-student-default/match-student-default.component.ts - 495 + 494 src/assets/wise5/directives/summary-display/summary-display.component.ts @@ -18339,7 +18339,7 @@ Current Score: Are you ready to receive feedback on this answer? src/assets/wise5/components/openResponse/open-response-student/open-response-student.component.ts - 166 + 165 @@ -18348,7 +18348,7 @@ Are you ready to receive feedback on this answer? Are you ready to receive feedback on this answer? src/assets/wise5/components/openResponse/open-response-student/open-response-student.component.ts - 178 + 177 @@ -18357,21 +18357,21 @@ Are you ready to receive feedback on this answer? Are you ready to submit this answer? src/assets/wise5/components/openResponse/open-response-student/open-response-student.component.ts - 182 + 181 We are scoring your work... src/assets/wise5/components/openResponse/open-response-student/open-response-student.component.ts - 296 + 295 Please Wait src/assets/wise5/components/openResponse/open-response-student/open-response-student.component.ts - 297 + 296 @@ -18379,7 +18379,7 @@ Are you ready to submit this answer? If this problem continues, let your teacher know and move on to the next activity. Your work will still be saved. src/assets/wise5/components/openResponse/open-response-student/open-response-student.component.ts - 319 + 318