From aeef127e0eaba01115e05bbf14b0f49216ca1650 Mon Sep 17 00:00:00 2001 From: Geoffrey Kwan Date: Wed, 18 Oct 2023 11:19:18 -0400 Subject: [PATCH 1/7] refactor(NodeService): getNextNodeId() (#1470) --- src/app/services/studentNodeService.spec.ts | 35 +++++++ src/app/services/teacherNodeService.spec.ts | 41 ++++++++ src/assets/wise5/services/nodeService.ts | 94 +------------------ .../wise5/services/studentNodeService.ts | 57 +++++++++++ .../wise5/services/teacherNodeService.ts | 17 ++++ 5 files changed, 152 insertions(+), 92 deletions(-) create mode 100644 src/app/services/teacherNodeService.spec.ts diff --git a/src/app/services/studentNodeService.spec.ts b/src/app/services/studentNodeService.spec.ts index 4bcc1430e97..564ca1847d0 100644 --- a/src/app/services/studentNodeService.spec.ts +++ b/src/app/services/studentNodeService.spec.ts @@ -5,11 +5,15 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { MatDialog, MatDialogModule } from '@angular/material/dialog'; import { NodeStatusService } from '../../assets/wise5/services/nodeStatusService'; import { DataService } from './data.service'; +import { ProjectService } from '../../assets/wise5/services/projectService'; let dataService: DataService; let dialog: MatDialog; +const nodeId2 = 'node2'; let nodeStatusService: NodeStatusService; +let projectService: ProjectService; let service: StudentNodeService; + describe('StudentNodeService', () => { beforeEach(() => { TestBed.configureTestingModule({ @@ -19,8 +23,10 @@ describe('StudentNodeService', () => { dialog = TestBed.inject(MatDialog); service = TestBed.inject(StudentNodeService); nodeStatusService = TestBed.inject(NodeStatusService); + projectService = TestBed.inject(ProjectService); }); setCurrentNode(); + getNextNodeId(); }); function setCurrentNode() { @@ -57,3 +63,32 @@ function spyOnIsVisitable(isVisitable: boolean) { isVisitable: isVisitable }); } + +function getNextNodeId() { + describe('getNextNodeId()', () => { + getNextNodeId_currentNodeHasTransition_getsNodeFromTransition(); + getNextNodeId_previouslyBranched_getsNodeFromPreviousBranchPathTaken(); + }); +} + +function getNextNodeId_previouslyBranched_getsNodeFromPreviousBranchPathTaken() { + describe('has previous branch path taken', () => { + it('gets the node id from the previous branch path taken', async () => { + spyOn(dataService, 'getBranchPathTakenEventsByNodeId').and.returnValue([ + { data: { toNodeId: nodeId2 } } + ]); + expect(await service.getNextNodeId()).toEqual(nodeId2); + }); + }); +} + +function getNextNodeId_currentNodeHasTransition_getsNodeFromTransition() { + describe('current node has a transition', () => { + it('gets the node id from the transition', async () => { + spyOn(projectService, 'getTransitionLogicByFromNodeId').and.returnValue({ + transitions: [{ to: nodeId2 }] + }); + expect(await service.getNextNodeId()).toEqual(nodeId2); + }); + }); +} diff --git a/src/app/services/teacherNodeService.spec.ts b/src/app/services/teacherNodeService.spec.ts new file mode 100644 index 00000000000..c58ae052340 --- /dev/null +++ b/src/app/services/teacherNodeService.spec.ts @@ -0,0 +1,41 @@ +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { TestBed } from '@angular/core/testing'; +import { MatDialogModule } from '@angular/material/dialog'; +import { StudentTeacherCommonServicesModule } from '../student-teacher-common-services.module'; +import { DataService } from './data.service'; +import { ProjectService } from '../../assets/wise5/services/projectService'; +import { TeacherNodeService } from '../../assets/wise5/services/teacherNodeService'; + +let dataService: DataService; +const nodeId1 = 'node1'; +const nodeId2 = 'node2'; +let projectService: ProjectService; +let service: TeacherNodeService; + +describe('TeacherNodeService', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule, MatDialogModule, StudentTeacherCommonServicesModule], + providers: [TeacherNodeService] + }); + dataService = TestBed.inject(DataService); + projectService = TestBed.inject(ProjectService); + service = TestBed.inject(TeacherNodeService); + }); + getNextNodeId(); +}); + +function getNextNodeId() { + describe('getNextNodeId()', () => { + describe('the next node id is a step node', () => { + it('gets the next node id in the unit', async () => { + spyOn(dataService, 'getCurrentNodeId').and.returnValue(nodeId1); + spyOn(projectService, 'isApplicationNode').and.returnValue(true); + projectService.idToOrder = {}; + projectService.idToOrder[nodeId1] = { order: 1 }; + projectService.idToOrder[nodeId2] = { order: 2 }; + expect(await service.getNextNodeId()).toEqual(nodeId2); + }); + }); + }); +} diff --git a/src/assets/wise5/services/nodeService.ts b/src/assets/wise5/services/nodeService.ts index bb5acb9578e..477521006c7 100644 --- a/src/assets/wise5/services/nodeService.ts +++ b/src/assets/wise5/services/nodeService.ts @@ -41,100 +41,10 @@ export class NodeService { } /** - * Get the next node in the project sequence. We return a promise because - * in preview mode we allow the user to specify which branch path they want - * to go to. In all other cases we will resolve the promise immediately. - * @param currentId (optional) - * @returns a promise that returns the next node id + * This function should be implemented by the child service classes */ getNextNodeId(currentId?: string): Promise { - const promise = new Promise((resolve, reject) => { - let nextNodeId = null; - const currentNodeId = currentId ?? this.DataService.getCurrentNodeId(); - if (currentNodeId) { - if (['author', 'classroomMonitor'].includes(this.ConfigService.getMode())) { - const currentNodeOrder = this.ProjectService.getNodeOrderById(currentNodeId); - if (currentNodeOrder) { - const nextId = this.ProjectService.getNodeIdByOrder(currentNodeOrder + 1); - if (nextId) { - nextNodeId = this.ProjectService.isApplicationNode(nextId) - ? nextId - : this.getNextNodeId(nextId); - } - } - resolve(nextNodeId); - } else { - const transitionLogic = this.ProjectService.getTransitionLogicByFromNodeId(currentNodeId); - const branchPathTakenEvents = this.DataService.getBranchPathTakenEventsByNodeId( - currentNodeId - ); - if ( - branchPathTakenEvents != null && - branchPathTakenEvents.length > 0 && - transitionLogic != null && - transitionLogic.canChangePath != true - ) { - // the student has branched on this node before and they are not allowed to change paths - for (let b = branchPathTakenEvents.length - 1; b >= 0; b--) { - const branchPathTakenEvent = branchPathTakenEvents[b]; - if (branchPathTakenEvent != null) { - const data = branchPathTakenEvent.data; - if (data != null) { - const toNodeId = data.toNodeId; - nextNodeId = toNodeId; - resolve(nextNodeId); - break; - } - } - } - } else { - // the student has not branched on this node before - if (transitionLogic != null) { - const transitions = transitionLogic.transitions; - if (transitions == null || transitions.length == 0) { - /* - * this node does not have any transitions so we will - * check if the parent group has transitions - */ - const parentGroupId = this.ProjectService.getParentGroupId(currentNodeId); - let parentHasTransitionLogic = false; - if (parentGroupId != null) { - const parentTransitionLogic = this.ProjectService.getTransitionLogicByFromNodeId( - parentGroupId - ); - if (parentTransitionLogic != null) { - parentHasTransitionLogic = true; - this.chooseTransition(parentGroupId, parentTransitionLogic).then( - (transition) => { - if (transition != null) { - const transitionToNodeId = transition.to; - if (this.ProjectService.isGroupNode(transitionToNodeId)) { - const startId = this.ProjectService.getGroupStartId(transitionToNodeId); - if (startId == null || startId == '') { - nextNodeId = transitionToNodeId; - } else { - nextNodeId = startId; - } - } else { - nextNodeId = transitionToNodeId; - } - } - resolve(nextNodeId); - } - ); - } - } - } else { - this.chooseTransition(currentNodeId, transitionLogic).then((transition) => { - resolve(transition.to); - }); - } - } - } - } - } - }); - return promise; + return null; } /** diff --git a/src/assets/wise5/services/studentNodeService.ts b/src/assets/wise5/services/studentNodeService.ts index 3f3874f4467..a7865291041 100644 --- a/src/assets/wise5/services/studentNodeService.ts +++ b/src/assets/wise5/services/studentNodeService.ts @@ -8,6 +8,7 @@ import { ProjectService } from './projectService'; import { NodeStatusService } from './nodeStatusService'; import { DialogWithCloseComponent } from '../directives/dialog-with-close/dialog-with-close.component'; import { Constraint } from '../../../app/domain/constraint'; +import { TransitionLogic } from '../common/TransitionLogic'; @Injectable() export class StudentNodeService extends NodeService { @@ -69,4 +70,60 @@ export class StudentNodeService extends NodeService { .filter((message) => message != '') .join('
'); } + + /** + * Get the next node in the project sequence. We return a promise because in preview mode we allow + * the user to specify which branch path they want to go to. In all other cases we will resolve + * the promise immediately. + * @param currentId (optional) the current node id + * @returns a promise that returns the next node id + */ + getNextNodeId(currentId?: string): Promise { + return new Promise((resolve, reject) => { + const currentNodeId = currentId ?? this.DataService.getCurrentNodeId(); + const transitionLogic = this.ProjectService.getTransitionLogicByFromNodeId(currentNodeId); + const branchPathTakenEvents = this.DataService.getBranchPathTakenEventsByNodeId( + currentNodeId + ); + if (this.hasPreviouslyBranchedAndCannotChange(branchPathTakenEvents, transitionLogic)) { + resolve(branchPathTakenEvents.at(-1).data.toNodeId); + } else { + this.resolveNextNodeIdFromTransition(resolve, currentNodeId); + } + }); + } + + private hasPreviouslyBranchedAndCannotChange( + branchPathTakenEvents: any[], + transitionLogic: TransitionLogic + ): boolean { + return branchPathTakenEvents.length > 0 && !transitionLogic.canChangePath; + } + + private resolveNextNodeIdFromTransition(resolve: any, currentNodeId: string): void { + const transitionLogic = this.ProjectService.getTransitionLogicByFromNodeId(currentNodeId); + if (transitionLogic.transitions.length == 0) { + this.getNextNodeIdFromParent(resolve, currentNodeId); + } else { + this.chooseTransition(currentNodeId, transitionLogic).then((transition: any) => { + resolve(transition.to); + }); + } + } + + private getNextNodeIdFromParent(resolve: any, currentNodeId: string): void { + const parentGroupId = this.ProjectService.getParentGroupId(currentNodeId); + if (parentGroupId != null) { + const parentTransitionLogic = this.ProjectService.getTransitionLogicByFromNodeId( + parentGroupId + ); + this.chooseTransition(parentGroupId, parentTransitionLogic).then((transition: any) => { + const transitionToNodeId = transition.to; + const startId = this.ProjectService.isGroupNode(transitionToNodeId) + ? this.ProjectService.getGroupStartId(transitionToNodeId) + : null; + resolve(startId == null || startId === '' ? transitionToNodeId : startId); + }); + } + } } diff --git a/src/assets/wise5/services/teacherNodeService.ts b/src/assets/wise5/services/teacherNodeService.ts index dac5c86d3df..202b9c40174 100644 --- a/src/assets/wise5/services/teacherNodeService.ts +++ b/src/assets/wise5/services/teacherNodeService.ts @@ -22,4 +22,21 @@ export class TeacherNodeService extends NodeService { respondStarterState(args: any): void { this.starterStateResponseSource.next(args); } + + getNextNodeId(currentId?: string): Promise { + return new Promise((resolve, reject) => { + let nextNodeId = null; + const currentNodeId = currentId ?? this.DataService.getCurrentNodeId(); + const currentNodeOrder = this.ProjectService.getNodeOrderById(currentNodeId); + if (currentNodeOrder) { + const nextId = this.ProjectService.getNodeIdByOrder(currentNodeOrder + 1); + if (nextId) { + nextNodeId = this.ProjectService.isApplicationNode(nextId) + ? nextId + : this.getNextNodeId(nextId); + } + } + resolve(nextNodeId); + }); + } } From b528bb8067e3fac13e7cff134494544710ab0ee5 Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Wed, 18 Oct 2023 10:54:51 -0700 Subject: [PATCH 2/7] refactor(NodeIconChooser): Move KI icon chooser option to top (#1474) Change node icon choosers to MatChipListbox, which uses listbox accessibility pattern and provides keyboard a11y Co-authored-by: Jonathan Lim-Breitbart --- .../node-icon-chooser-dialog.component.html | 80 ++++++++++--------- src/messages.xlf | 52 ++++++------ 2 files changed, 69 insertions(+), 63 deletions(-) diff --git a/src/assets/wise5/common/node-icon-chooser-dialog/node-icon-chooser-dialog.component.html b/src/assets/wise5/common/node-icon-chooser-dialog/node-icon-chooser-dialog.component.html index b040f2409cb..67e245207ef 100644 --- a/src/assets/wise5/common/node-icon-chooser-dialog/node-icon-chooser-dialog.component.html +++ b/src/assets/wise5/common/node-icon-chooser-dialog/node-icon-chooser-dialog.component.html @@ -1,4 +1,10 @@ -

+

Choose an Icon

-
-
-

Icon:

- - - {{ fontName }} - - -
-
-

Color:

- - - -
-
-

- Or use a Knowledge Integration (KI) icon: + Use a Knowledge Integration (KI) icon: info

- + {{ kiIcon.imgLabel }} - + + +
+
+

Or choose your own icon:

+ + + {{ fontName }} + + +
+
+

Color:

+ + + +
+
diff --git a/src/messages.xlf b/src/messages.xlf index fdb84868f39..420d13b1fd7 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -543,7 +543,7 @@ src/assets/wise5/common/node-icon-chooser-dialog/node-icon-chooser-dialog.component.html - 90 + 96 src/assets/wise5/components/match/match-student/add-match-choice-dialog/add-match-choice-dialog.html @@ -14707,74 +14707,74 @@ Are you sure you want to proceed? Selected icon src/assets/wise5/common/node-icon-chooser-dialog/node-icon-chooser-dialog.component.html - 6 + 12 src/assets/wise5/common/node-icon-chooser-dialog/node-icon-chooser-dialog.component.html - 18 + 24 Choose an Icon src/assets/wise5/common/node-icon-chooser-dialog/node-icon-chooser-dialog.component.html - 21 + 27 - - Icon: + + Use a Knowledge Integration (KI) icon: src/assets/wise5/common/node-icon-chooser-dialog/node-icon-chooser-dialog.component.html - 26 + 31 - - Select an icon + + More about WISE and Knowledge Integration src/assets/wise5/common/node-icon-chooser-dialog/node-icon-chooser-dialog.component.html - 27 + 35 - - Color: + + Select a KI icon src/assets/wise5/common/node-icon-chooser-dialog/node-icon-chooser-dialog.component.html - 42 + 44 - - Select a color + + Or choose your own icon: src/assets/wise5/common/node-icon-chooser-dialog/node-icon-chooser-dialog.component.html - 43 + 64 - - Or use a Knowledge Integration (KI) icon: + + Select an icon src/assets/wise5/common/node-icon-chooser-dialog/node-icon-chooser-dialog.component.html - 58 + 65 - - More about WISE and Knowledge Integration + + Color: src/assets/wise5/common/node-icon-chooser-dialog/node-icon-chooser-dialog.component.html - 62 + 80 - - Select a KI icon + + Select a color src/assets/wise5/common/node-icon-chooser-dialog/node-icon-chooser-dialog.component.html - 71 + 81 Save src/assets/wise5/common/node-icon-chooser-dialog/node-icon-chooser-dialog.component.html - 91 + 97 src/assets/wise5/components/draw/edit-draw-connected-components/edit-draw-connected-components.component.html From 6d32a437351ae823c096eaa4034813db0d84077a Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Thu, 19 Oct 2023 16:47:41 -0700 Subject: [PATCH 3/7] refactor(AnnotationService): getLatestCommentAnnotation() --- .../wise5/services/annotationService.ts | 105 ++++++------------ src/messages.xlf | 6 +- 2 files changed, 36 insertions(+), 75 deletions(-) diff --git a/src/assets/wise5/services/annotationService.ts b/src/assets/wise5/services/annotationService.ts index d14691f6b0b..7fb687dbfa7 100644 --- a/src/assets/wise5/services/annotationService.ts +++ b/src/assets/wise5/services/annotationService.ts @@ -440,28 +440,15 @@ export class AnnotationService { * @return object containing the component's latest score and comment annotations */ getLatestComponentAnnotations( - nodeId, - componentId, - workgroupId, + nodeId: string, + componentId: string, + workgroupId: number, scoreType: 'score' | 'autoScore' | 'any' = 'any', - commentType = null - ) { - let latestScoreAnnotation = this.getLatestScoreAnnotation( - nodeId, - componentId, - workgroupId, - scoreType - ); - let latestCommentAnnotation = this.getLatestCommentAnnotation( - nodeId, - componentId, - workgroupId, - commentType - ); - + commentType: 'comment' | 'autoComment' | 'any' = 'any' + ): any { return { - score: latestScoreAnnotation, - comment: latestCommentAnnotation + score: this.getLatestScoreAnnotation(nodeId, componentId, workgroupId, scoreType), + comment: this.getLatestCommentAnnotation(nodeId, componentId, workgroupId, commentType) }; } @@ -574,59 +561,33 @@ export class AnnotationService { return false; } - /** - * Get the latest comment annotation - * @param nodeId the node id - * @param componentId the component id - * @param workgroupId the workgroup id - * @param commentType (optional) the type of comment - * e.g. - * 'autoComment' for auto graded comment - * 'comment' for teacher graded comment - * 'any' for auto graded comment or teacher graded comment - * @returns the latest comment annotation - */ - getLatestCommentAnnotation(nodeId, componentId, workgroupId, commentType) { - let annotation = null; - const annotations = this.getAnnotations(); - - if (commentType == null) { - commentType = 'any'; - } - - for (let a = annotations.length - 1; a >= 0; a--) { - const tempAnnotation = annotations[a]; - if (tempAnnotation != null) { - let acceptAnnotation = false; - const tempNodeId = tempAnnotation.nodeId; - const tempComponentId = tempAnnotation.componentId; - const tempToWorkgroupId = tempAnnotation.toWorkgroupId; - const tempAnnotationType = tempAnnotation.type; - - if ( - nodeId == tempNodeId && - componentId == tempComponentId && - workgroupId == tempToWorkgroupId - ) { - if ( - commentType === 'any' && - (tempAnnotationType === 'autoComment' || tempAnnotationType === 'comment') - ) { - acceptAnnotation = true; - } else if (commentType === 'autoComment' && tempAnnotationType === 'autoComment') { - acceptAnnotation = true; - } else if (commentType === 'comment' && tempAnnotationType === 'comment') { - acceptAnnotation = true; - } + getLatestCommentAnnotation( + nodeId: string, + componentId: string, + workgroupId: number, + commentType: 'comment' | 'autoComment' | 'any' = 'any' + ): Annotation { + return ( + this.getAnnotations() + .filter( + (annotation) => + annotation.nodeId == nodeId && + annotation.componentId == componentId && + annotation.toWorkgroupId == workgroupId && + this.matchesCommentType(annotation, commentType) + ) + .at(-1) || null + ); + } - if (acceptAnnotation) { - annotation = tempAnnotation; - break; - } - } - } - } - return annotation; + private matchesCommentType( + annotation: Annotation, + commentType: 'comment' | 'autoComment' | 'any' + ): boolean { + return ( + (commentType === 'any' && ['autoComment', 'comment'].includes(annotation.type)) || + annotation.type === commentType + ); } getScoreValueFromScoreAnnotation(scoreAnnotation: any): number { diff --git a/src/messages.xlf b/src/messages.xlf index 420d13b1fd7..d4e1e3981d6 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -20968,21 +20968,21 @@ If this problem continues, let your teacher know and move on to the next activit Sorry, you cannot view this item yet. src/assets/wise5/services/studentNodeService.ts - 39 + 40 Item Locked src/assets/wise5/services/studentNodeService.ts - 43 + 44 <p>To visit <b></b> you need to:</p><ul> src/assets/wise5/services/studentNodeService.ts - 50 + 51 From eca7ddbc05e22ef17b8ca6be99ab3858d4c209fc Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Fri, 20 Oct 2023 10:12:02 -0700 Subject: [PATCH 4/7] refactor(StudentDataService): Clean up code (#1480) --- src/app/services/studentDataService.spec.ts | 45 -------------- .../wise5/services/studentDataService.ts | 60 ++++--------------- 2 files changed, 13 insertions(+), 92 deletions(-) diff --git a/src/app/services/studentDataService.spec.ts b/src/app/services/studentDataService.spec.ts index 4cad90753b4..fb4534679c0 100644 --- a/src/app/services/studentDataService.spec.ts +++ b/src/app/services/studentDataService.spec.ts @@ -39,11 +39,9 @@ describe('StudentDataService', () => { shouldCheckIsComponentSubmitDirty(); shouldGetLatestComponentStateByNodeIdAndComponentId(); shouldGetLatestSubmitComponentState(); - shouldGetStudentWorkByStudentWorkId(); shouldGetComponentStatesByNodeId(); shouldGetComponentStatesByNodeIdAndComponentId(); shouldGetEventsByNodeId(); - shouldGetEventsByNodeIdAndComponentId(); shouldGetLatestNodeEnteredEventNodeIdWithExistingNode(); shouldCalculateCanVisitNode(); shouldGetNodeStatusByNodeId(); @@ -408,31 +406,6 @@ function shouldGetLatestSubmitComponentState() { }); } -function shouldGetStudentWorkByStudentWorkId() { - it('should get student work by student work id with an id that does not exist', () => { - service.studentData = { - componentStates: [ - createComponentState(1, 'node1', 'component1'), - createComponentState(2, 'node2', 'component2'), - createComponentState(3, 'node3', 'component3') - ] - }; - const componentState = service.getStudentWorkByStudentWorkId(4); - expect(componentState).toEqual(null); - }); - it('should get student work by student work id with an id that does exist', () => { - service.studentData = { - componentStates: [ - createComponentState(1, 'node1', 'component1'), - createComponentState(2, 'node1', 'component1'), - createComponentState(3, 'node1', 'component1') - ] - }; - const componentState = service.getStudentWorkByStudentWorkId(2); - expect(componentState.id).toEqual(2); - }); -} - function shouldGetComponentStatesByNodeId() { it('should get component states by node id', () => { service.studentData = { @@ -489,24 +462,6 @@ function shouldGetEventsByNodeId() { }); } -function shouldGetEventsByNodeIdAndComponentId() { - it('should get events by node id and component id', () => { - service.studentData = { - events: [ - createEvent(1, 'node1', 'component1'), - createEvent(2, 'node1', 'component2'), - createEvent(3, 'node2', 'component3'), - createEvent(4, 'node3', 'component4'), - createEvent(5, 'node1', 'component1') - ] - }; - const events = service.getEventsByNodeIdAndComponentId('node1', 'component1'); - expect(events.length).toEqual(2); - expect(events[0].id).toEqual(1); - expect(events[1].id).toEqual(5); - }); -} - function shouldGetLatestNodeEnteredEventNodeIdWithExistingNode() { it('should get latest node entered event node id with existing node', () => { service.studentData = { diff --git a/src/assets/wise5/services/studentDataService.ts b/src/assets/wise5/services/studentDataService.ts index bdc6ff0711a..981d7e7b5a3 100644 --- a/src/assets/wise5/services/studentDataService.ts +++ b/src/assets/wise5/services/studentDataService.ts @@ -551,63 +551,29 @@ export class StudentDataService extends DataService { return null; } - getStudentWorkByStudentWorkId(studentWorkId) { - for (const componentState of this.studentData.componentStates) { - if (componentState.id === studentWorkId) { - return componentState; - } - } - return null; - } - - getComponentStates() { + getComponentStates(): any[] { return this.studentData.componentStates; } - getComponentStatesByNodeId(nodeId) { - const componentStatesByNodeId = []; - for (const componentState of this.studentData.componentStates) { - if (componentState.nodeId === nodeId) { - componentStatesByNodeId.push(componentState); - } - } - return componentStatesByNodeId; + getComponentStatesByNodeId(nodeId: string): any[] { + return this.studentData.componentStates.filter( + (componentState) => componentState.nodeId === nodeId + ); } - getComponentStatesByNodeIdAndComponentId(nodeId, componentId) { - const componentStatesByNodeIdAndComponentId = []; - for (const componentState of this.studentData.componentStates) { - if (componentState.nodeId === nodeId && componentState.componentId === componentId) { - componentStatesByNodeIdAndComponentId.push(componentState); - } - } - return componentStatesByNodeIdAndComponentId; + getComponentStatesByNodeIdAndComponentId(nodeId: string, componentId: string): any[] { + return this.studentData.componentStates.filter( + (componentState) => + componentState.nodeId === nodeId && componentState.componentId === componentId + ); } - getEvents() { + getEvents(): any[] { return this.studentData.events; } - getEventsByNodeId(nodeId) { - const eventsByNodeId = []; - const events = this.studentData.events; - for (const event of events) { - if (event.nodeId === nodeId) { - eventsByNodeId.push(event); - } - } - return eventsByNodeId; - } - - getEventsByNodeIdAndComponentId(nodeId, componentId) { - const eventsByNodeId = []; - const events = this.studentData.events; - for (const event of events) { - if (event.nodeId === nodeId && event.componentId === componentId) { - eventsByNodeId.push(event); - } - } - return eventsByNodeId; + getEventsByNodeId(nodeId: string): any[] { + return this.studentData.events.filter((event) => event.nodeId === nodeId); } /** From 7f12dc0e5d50fb2953d69099fc8928216f6a372a Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Fri, 20 Oct 2023 15:15:28 -0700 Subject: [PATCH 5/7] feat(Unit Authoring): Move advanced settings button to side menu #1478 (#1479) --- .../advanced-project-authoring.component.html | 12 ---- .../authoringTool/authoring-tool.component.ts | 7 ++ .../project-authoring.component.html | 12 ---- .../project-authoring.component.ts | 4 -- src/messages.xlf | 68 +++++++++---------- 5 files changed, 39 insertions(+), 64 deletions(-) diff --git a/src/assets/wise5/authoringTool/advanced/advanced-project-authoring.component.html b/src/assets/wise5/authoringTool/advanced/advanced-project-authoring.component.html index 82b660bc530..5c685989f35 100644 --- a/src/assets/wise5/authoringTool/advanced/advanced-project-authoring.component.html +++ b/src/assets/wise5/authoringTool/advanced/advanced-project-authoring.component.html @@ -1,16 +1,4 @@
- - -