From f675f81edf627adeb715f92f866e3328768bd993 Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Mon, 30 Oct 2023 12:34:24 -0700 Subject: [PATCH] refactor(StudentDataService): Move getNotebookItemsByNodeId() (#1499) --- src/app/services/studentDataService.spec.ts | 27 - ...mberOfNotesOnThisStepConstraintStrategy.ts | 6 +- .../wise5/services/studentDataService.ts | 10 - src/messages.xlf | 644 +++++++++--------- 4 files changed, 327 insertions(+), 360 deletions(-) diff --git a/src/app/services/studentDataService.spec.ts b/src/app/services/studentDataService.spec.ts index fb4534679c0..383d34699ec 100644 --- a/src/app/services/studentDataService.spec.ts +++ b/src/app/services/studentDataService.spec.ts @@ -31,7 +31,6 @@ describe('StudentDataService', () => { shouldEvaluateHasWorkCreatedAfterTimestampFalse(); shouldEvaluateHasWorkCreatedAfterTimestampTrue(); shouldGetBranchPathTakenEventsByNodeId(); - shouldGetNotebookItemsByNodeId(); shouldHandleSaveStudentWorkToServerSuccess(); shouldHandleSaveEventsToServerSuccess(); shouldHandleSaveAnnotationsToServerSuccess(); @@ -94,32 +93,6 @@ function shouldGetBranchPathTakenEventsByNodeId() { }); } -function shouldGetNotebookItemsByNodeId() { - it('should get notebook items by node id', () => { - const notebook = { - allItems: [ - { nodeId: 'node1' }, - { nodeId: 'node1' }, - { nodeId: 'node1' }, - { nodeId: 'node1' }, - { nodeId: 'node1' }, - { nodeId: 'node2' }, - { nodeId: 'node2' }, - { nodeId: 'node2' }, - { nodeId: 'node2' }, - { nodeId: 'node2' } - ] - }; - const notebookItems = service.getNotebookItemsByNodeId(notebook, 'node1'); - expect(notebookItems.length).toEqual(5); - expect(notebookItems[0].nodeId).toEqual('node1'); - expect(notebookItems[1].nodeId).toEqual('node1'); - expect(notebookItems[2].nodeId).toEqual('node1'); - expect(notebookItems[3].nodeId).toEqual('node1'); - expect(notebookItems[4].nodeId).toEqual('node1'); - }); -} - function shouldHandleSaveStudentWorkToServerSuccess() { xit('should handle save student work to server success', () => { service.studentData = { diff --git a/src/assets/wise5/common/constraint/strategies/AddXNumberOfNotesOnThisStepConstraintStrategy.ts b/src/assets/wise5/common/constraint/strategies/AddXNumberOfNotesOnThisStepConstraintStrategy.ts index 66bc5e2fb5a..16c30f9344e 100644 --- a/src/assets/wise5/common/constraint/strategies/AddXNumberOfNotesOnThisStepConstraintStrategy.ts +++ b/src/assets/wise5/common/constraint/strategies/AddXNumberOfNotesOnThisStepConstraintStrategy.ts @@ -3,7 +3,7 @@ import { AbstractConstraintStrategy } from './AbstractConstraintStrategy'; export class AddXNumberOfNotesOnThisStepConstraintStrategy extends AbstractConstraintStrategy { evaluate(criteria: any): boolean { try { - const notebookItemsByNodeId = this.dataService.getNotebookItemsByNodeId( + const notebookItemsByNodeId = this.getNotebookItemsByNodeId( this.notebookService.getNotebookByWorkgroup(), criteria.params.nodeId ); @@ -11,4 +11,8 @@ export class AddXNumberOfNotesOnThisStepConstraintStrategy extends AbstractConst } catch (e) {} return false; } + + private getNotebookItemsByNodeId(notebook: any, nodeId: string): any[] { + return notebook.allItems.filter((item) => item.nodeId === nodeId); + } } diff --git a/src/assets/wise5/services/studentDataService.ts b/src/assets/wise5/services/studentDataService.ts index 981d7e7b5a3..45c73c52230 100644 --- a/src/assets/wise5/services/studentDataService.ts +++ b/src/assets/wise5/services/studentDataService.ts @@ -185,16 +185,6 @@ export class StudentDataService extends DataService { ); } - getNotebookItemsByNodeId(notebook, nodeId) { - const notebookItemsByNodeId = []; - for (const notebookItem of notebook.allItems) { - if (notebookItem.nodeId === nodeId) { - notebookItemsByNodeId.push(notebookItem); - } - } - return notebookItemsByNodeId; - } - populateHistories(events) { this.stackHistory = []; for (const event of events) { diff --git a/src/messages.xlf b/src/messages.xlf index 33af4a6d38b..40b14793917 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -3354,138 +3354,405 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.1 - - Student Frequently Asked Questions + + Getting Started - src/app/help/faq/student-faq/student-faq.component.html + src/app/help/faq/getting-started/getting-started.component.html 3 - - - Table of Contents src/app/help/faq/student-faq/student-faq.component.html - 6 + 132 src/app/help/faq/teacher-faq/teacher-faq.component.html + 407 + + + src/app/help/help-home/help-home.component.html + 18 + + + + Creating an Account + + src/app/help/faq/getting-started/getting-started.component.html 6 + + + All users must create their own account. Teachers must create a teacher account and students must create a student account. Users can create an account by going to the WISE Home Page and clicking on the Register link at the upper right of the screen. - src/app/privacy/privacy.component.html - 4 + src/app/help/faq/getting-started/getting-started.component.html + 7,13 - - General Questions + + Here are instructions on how to create a teacher account. - src/app/help/faq/student-faq/student-faq.component.html - 9 + src/app/help/faq/getting-started/getting-started.component.html + 14 + + + Go to the WISE Home Page. - src/app/help/faq/student-faq/student-faq.component.html + src/app/help/faq/getting-started/getting-started.component.html 16 + + + Click the Register link at the upper right of the screen. - src/app/help/faq/teacher-faq/teacher-faq.component.html - 9 + src/app/help/faq/getting-started/getting-started.component.html + 17,20 + + + + Click on Teacher. + + src/app/help/faq/getting-started/getting-started.component.html + 21 + + + + Choose to sign up with your email or with your Google Account. + + src/app/help/faq/getting-started/getting-started.component.html + 22 + + + src/app/help/faq/student-faq/student-faq.component.html + 21 src/app/help/faq/teacher-faq/teacher-faq.component.html - 28 + 33 - - Technical Questions + + Fill out the form and submit it. + + src/app/help/faq/getting-started/getting-started.component.html + 23 + src/app/help/faq/student-faq/student-faq.component.html - 12 + 22 + + + src/app/help/faq/teacher-faq/teacher-faq.component.html + 34 + + + + If you created an account using your email, you will be given a username that you will need to remember. Your username will be your first name and your last name with no space inbetween. There may be a number added at the end of your username if someone has the same name as you. + + src/app/help/faq/getting-started/getting-started.component.html + 24,28 src/app/help/faq/student-faq/student-faq.component.html - 61 + 23,27 src/app/help/faq/teacher-faq/teacher-faq.component.html - 24 + 35,39 + + + + Using a WISE Unit + + src/app/help/faq/getting-started/getting-started.component.html + 31 + + + + To use a WISE unit with your class, you must first choose a unit to use and then set up a "Run" of that unit. + + src/app/help/faq/getting-started/getting-started.component.html + 32,35 + + + + Here are instructions on how to set up a Run. + + src/app/help/faq/getting-started/getting-started.component.html + 36 + + + + Sign in to WISE with your teacher account. + + src/app/help/faq/getting-started/getting-started.component.html + 38 src/app/help/faq/teacher-faq/teacher-faq.component.html - 328 + 43 - - How do I create an account? + + Click the "Unit Library" tab. - src/app/help/faq/student-faq/student-faq.component.html - 17 + src/app/help/faq/getting-started/getting-started.component.html + 39 + + + src/app/help/faq/teacher-faq/teacher-faq.component.html + 44 src/app/help/faq/teacher-faq/teacher-faq.component.html + 201 + + + + Find a project that you would like to use with your class. + + src/app/help/faq/getting-started/getting-started.component.html + 40 + + + src/app/help/faq/teacher-faq/teacher-faq.component.html + 45 + + + + Click on the project to open the information for the project. + + src/app/help/faq/getting-started/getting-started.component.html + 41 + + + src/app/help/faq/teacher-faq/teacher-faq.component.html + 46 + + + + Click the "Use With Class" button. + + src/app/help/faq/getting-started/getting-started.component.html + 42 + + + src/app/help/faq/teacher-faq/teacher-faq.component.html + 47 + + + + Choose the periods you will use the project in. + + src/app/help/faq/getting-started/getting-started.component.html + 43 + + + src/app/help/faq/teacher-faq/teacher-faq.component.html + 48 + + + + Choose the number of students per team. Choosing 1-3 will allow students to work together in a team. + + src/app/help/faq/getting-started/getting-started.component.html + 44,47 + + + src/app/help/faq/teacher-faq/teacher-faq.component.html + 49,52 + + + + Choose the start date. Students will not be able to use the project until this date. + + src/app/help/faq/getting-started/getting-started.component.html + 48,50 + + + src/app/help/faq/teacher-faq/teacher-faq.component.html + 53,55 + + + + Click "Create Run". + + src/app/help/faq/getting-started/getting-started.component.html + 51 + + + src/app/help/faq/teacher-faq/teacher-faq.component.html + 56 + + + + The run will be created and added to your Teacher Home. + + src/app/help/faq/getting-started/getting-started.component.html + 52 + + + src/app/help/faq/teacher-faq/teacher-faq.component.html + 57 + + + + Copy the "Access Code" for the new run and write it down somewhere like on the white board. Students will need to use this access code to work on the run you created. + + src/app/help/faq/getting-started/getting-started.component.html + 53,56 + + + src/app/help/faq/teacher-faq/teacher-faq.component.html + 58,61 + + + + Teacher FAQ + + src/app/help/faq/getting-started/getting-started.component.html + 76 + + + src/app/help/faq/student-faq/student-faq.component.html + 143 + + + src/app/help/help-home/help-home.component.html 29 - - Go to the Register page. + + Questions from teachers. + + src/app/help/faq/getting-started/getting-started.component.html + 78 + src/app/help/faq/student-faq/student-faq.component.html - 19 + 145 - src/app/help/faq/teacher-faq/teacher-faq.component.html + src/app/help/help-home/help-home.component.html 31 - - Click on Student. + + Student FAQ + + src/app/help/faq/getting-started/getting-started.component.html + 87 + + + src/app/help/faq/teacher-faq/teacher-faq.component.html + 418 + + + src/app/help/help-home/help-home.component.html + 40 + + + + Questions from students. + + src/app/help/faq/getting-started/getting-started.component.html + 89 + + + src/app/help/faq/teacher-faq/teacher-faq.component.html + 420 + + + src/app/help/help-home/help-home.component.html + 42 + + + + Student Frequently Asked Questions src/app/help/faq/student-faq/student-faq.component.html - 20 + 3 - - Choose to sign up with your email or with your Google Account. + + Table of Contents src/app/help/faq/student-faq/student-faq.component.html - 21 + 6 src/app/help/faq/teacher-faq/teacher-faq.component.html - 33 + 6 - src/app/help/getting-started/getting-started.component.html - 22 + src/app/privacy/privacy.component.html + 4 - - Fill out the form and submit it. + + General Questions src/app/help/faq/student-faq/student-faq.component.html - 22 + 9 + + + src/app/help/faq/student-faq/student-faq.component.html + 16 src/app/help/faq/teacher-faq/teacher-faq.component.html - 34 + 9 - src/app/help/getting-started/getting-started.component.html - 23 + src/app/help/faq/teacher-faq/teacher-faq.component.html + 28 - - If you created an account using your email, you will be given a username that you will need to remember. Your username will be your first name and your last name with no space inbetween. There may be a number added at the end of your username if someone has the same name as you. + + Technical Questions src/app/help/faq/student-faq/student-faq.component.html - 23,27 + 12 + + + src/app/help/faq/student-faq/student-faq.component.html + 61 + + + src/app/help/faq/teacher-faq/teacher-faq.component.html + 24 + + + src/app/help/faq/teacher-faq/teacher-faq.component.html + 328 + + + + How do I create an account? + + src/app/help/faq/student-faq/student-faq.component.html + 17 + + + src/app/help/faq/teacher-faq/teacher-faq.component.html + 29 + + + + Go to the Register page. + + src/app/help/faq/student-faq/student-faq.component.html + 19 src/app/help/faq/teacher-faq/teacher-faq.component.html - 35,39 + 31 + + + Click on Student. - src/app/help/getting-started/getting-started.component.html - 24,28 + src/app/help/faq/student-faq/student-faq.component.html + 20 @@ -3756,25 +4023,6 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.382,387 - - Getting Started - - src/app/help/faq/student-faq/student-faq.component.html - 132 - - - src/app/help/faq/teacher-faq/teacher-faq.component.html - 407 - - - src/app/help/getting-started/getting-started.component.html - 3 - - - src/app/help/help-home/help-home.component.html - 18 - - Information for new users. @@ -3790,36 +4038,6 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.20 - - Teacher FAQ - - src/app/help/faq/student-faq/student-faq.component.html - 143 - - - src/app/help/getting-started/getting-started.component.html - 76 - - - src/app/help/help-home/help-home.component.html - 29 - - - - Questions from teachers. - - src/app/help/faq/student-faq/student-faq.component.html - 145 - - - src/app/help/getting-started/getting-started.component.html - 78 - - - src/app/help/help-home/help-home.component.html - 31 - - Teacher Frequently Asked Questions @@ -3885,131 +4103,6 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.41 - - Sign in to WISE with your teacher account. - - src/app/help/faq/teacher-faq/teacher-faq.component.html - 43 - - - src/app/help/getting-started/getting-started.component.html - 38 - - - - Click the "Unit Library" tab. - - src/app/help/faq/teacher-faq/teacher-faq.component.html - 44 - - - src/app/help/faq/teacher-faq/teacher-faq.component.html - 201 - - - src/app/help/getting-started/getting-started.component.html - 39 - - - - Find a project that you would like to use with your class. - - src/app/help/faq/teacher-faq/teacher-faq.component.html - 45 - - - src/app/help/getting-started/getting-started.component.html - 40 - - - - Click on the project to open the information for the project. - - src/app/help/faq/teacher-faq/teacher-faq.component.html - 46 - - - src/app/help/getting-started/getting-started.component.html - 41 - - - - Click the "Use With Class" button. - - src/app/help/faq/teacher-faq/teacher-faq.component.html - 47 - - - src/app/help/getting-started/getting-started.component.html - 42 - - - - Choose the periods you will use the project in. - - src/app/help/faq/teacher-faq/teacher-faq.component.html - 48 - - - src/app/help/getting-started/getting-started.component.html - 43 - - - - Choose the number of students per team. Choosing 1-3 will allow students to work together in a team. - - src/app/help/faq/teacher-faq/teacher-faq.component.html - 49,52 - - - src/app/help/getting-started/getting-started.component.html - 44,47 - - - - Choose the start date. Students will not be able to use the project until this date. - - src/app/help/faq/teacher-faq/teacher-faq.component.html - 53,55 - - - src/app/help/getting-started/getting-started.component.html - 48,50 - - - - Click "Create Run". - - src/app/help/faq/teacher-faq/teacher-faq.component.html - 56 - - - src/app/help/getting-started/getting-started.component.html - 51 - - - - The run will be created and added to your Teacher Home. - - src/app/help/faq/teacher-faq/teacher-faq.component.html - 57 - - - src/app/help/getting-started/getting-started.component.html - 52 - - - - Copy the "Access Code" for the new run and write it down somewhere like on the white board. Students will need to use this access code to work on the run you created. - - src/app/help/faq/teacher-faq/teacher-faq.component.html - 58,61 - - - src/app/help/getting-started/getting-started.component.html - 53,56 - - Should I register my students for WISE or have them do it themselves? @@ -4689,99 +4782,6 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.356 - - Student FAQ - - src/app/help/faq/teacher-faq/teacher-faq.component.html - 418 - - - src/app/help/getting-started/getting-started.component.html - 87 - - - src/app/help/help-home/help-home.component.html - 40 - - - - Questions from students. - - src/app/help/faq/teacher-faq/teacher-faq.component.html - 420 - - - src/app/help/getting-started/getting-started.component.html - 89 - - - src/app/help/help-home/help-home.component.html - 42 - - - - Creating an Account - - src/app/help/getting-started/getting-started.component.html - 6 - - - - All users must create their own account. Teachers must create a teacher account and students must create a student account. Users can create an account by going to the WISE Home Page and clicking on the Register link at the upper right of the screen. - - src/app/help/getting-started/getting-started.component.html - 7,13 - - - - Here are instructions on how to create a teacher account. - - src/app/help/getting-started/getting-started.component.html - 14 - - - - Go to the WISE Home Page. - - src/app/help/getting-started/getting-started.component.html - 16 - - - - Click the Register link at the upper right of the screen. - - src/app/help/getting-started/getting-started.component.html - 17,20 - - - - Click on Teacher. - - src/app/help/getting-started/getting-started.component.html - 21 - - - - Using a WISE Unit - - src/app/help/getting-started/getting-started.component.html - 31 - - - - To use a WISE unit with your class, you must first choose a unit to use and then set up a "Run" of that unit. - - src/app/help/getting-started/getting-started.component.html - 32,35 - - - - Here are instructions on how to set up a Run. - - src/app/help/getting-started/getting-started.component.html - 36 - - What's New? @@ -21007,21 +21007,21 @@ If this problem continues, let your teacher know and move on to the next activit StudentDataService.saveComponentEvent: component, category, event args must not be null src/assets/wise5/services/studentDataService.ts - 251 + 241 StudentDataService.saveComponentEvent: nodeId, componentId, componentType must not be null src/assets/wise5/services/studentDataService.ts - 261 + 251 StudentDataService.saveVLEEvent: category and event args must not be null src/assets/wise5/services/studentDataService.ts - 270 + 260