diff --git a/src/app/authoring-tool/edit-advanced-component/edit-advanced-component.component.ts b/src/app/authoring-tool/edit-advanced-component/edit-advanced-component.component.ts index c81bf2b2ab3..a658ba9d660 100644 --- a/src/app/authoring-tool/edit-advanced-component/edit-advanced-component.component.ts +++ b/src/app/authoring-tool/edit-advanced-component/edit-advanced-component.component.ts @@ -1,9 +1,9 @@ import { Directive, Input } from '@angular/core'; import { ComponentContent } from '../../../assets/wise5/common/ComponentContent'; import { Component } from '../../../assets/wise5/common/Component'; -import { NodeService } from '../../../assets/wise5/services/nodeService'; import { NotebookService } from '../../../assets/wise5/services/notebookService'; import { TeacherProjectService } from '../../../assets/wise5/services/teacherProjectService'; +import { TeacherNodeService } from '../../../assets/wise5/services/teacherNodeService'; @Directive() export abstract class EditAdvancedComponentComponent { @@ -13,7 +13,7 @@ export abstract class EditAdvancedComponentComponent { @Input() nodeId: string; constructor( - protected nodeService: NodeService, + protected nodeService: TeacherNodeService, protected notebookService: NotebookService, protected teacherProjectService: TeacherProjectService ) {} diff --git a/src/app/authoring-tool/import-step/choose-import-step-location/choose-import-step-location.component.html b/src/app/authoring-tool/import-step/choose-import-step-location/choose-import-step-location.component.html index 3019caf4155..f09f9ae423c 100644 --- a/src/app/authoring-tool/import-step/choose-import-step-location/choose-import-step-location.component.html +++ b/src/app/authoring-tool/import-step/choose-import-step-location/choose-import-step-location.component.html @@ -40,6 +40,6 @@
Choose a location for the imported steps.
diff --git a/src/app/authoring-tool/import-step/choose-import-step-location/choose-import-step-location.component.ts b/src/app/authoring-tool/import-step/choose-import-step-location/choose-import-step-location.component.ts index 480b37882dd..7b413eddd1b 100644 --- a/src/app/authoring-tool/import-step/choose-import-step-location/choose-import-step-location.component.ts +++ b/src/app/authoring-tool/import-step/choose-import-step-location/choose-import-step-location.component.ts @@ -39,14 +39,14 @@ export class ChooseImportStepLocationComponent { this.projectService.refreshProject(); if (nodesWithNewNodeIds.length === 1) { const newNode = nodesWithNewNodeIds[0]; - this.router.navigate(['../../node', newNode.id], { + this.router.navigate(['../../../node', newNode.id], { relativeTo: this.route, state: { newComponents: newNode.components } }); } else { - this.router.navigate(['../..'], { relativeTo: this.route }); + this.router.navigate(['../../..'], { relativeTo: this.route }); } }); }); diff --git a/src/app/authoring-tool/import-step/choose-import-step/choose-import-step.component.html b/src/app/authoring-tool/import-step/choose-import-step/choose-import-step.component.html index dab2916a288..1dcf5932e25 100644 --- a/src/app/authoring-tool/import-step/choose-import-step/choose-import-step.component.html +++ b/src/app/authoring-tool/import-step/choose-import-step/choose-import-step.component.html @@ -55,7 +55,7 @@
Back - +
diff --git a/src/app/authoring-tool/import-step/choose-import-unit/choose-import-unit.component.ts b/src/app/authoring-tool/import-step/choose-import-unit/choose-import-unit.component.ts index 5f4caff14c6..93d071741f6 100644 --- a/src/app/authoring-tool/import-step/choose-import-unit/choose-import-unit.component.ts +++ b/src/app/authoring-tool/import-step/choose-import-unit/choose-import-unit.component.ts @@ -2,6 +2,7 @@ import { Component } from '@angular/core'; import { ConfigService } from '../../../../assets/wise5/services/configService'; import { ProjectLibraryService } from '../../../../assets/wise5/services/projectLibraryService'; import { ActivatedRoute, Router } from '@angular/router'; +import { Subscription } from 'rxjs'; @Component({ selector: 'choose-import-unit', @@ -11,6 +12,7 @@ import { ActivatedRoute, Router } from '@angular/router'; export class ChooseImportUnitComponent { protected libraryProjects: any[]; protected myProjects: any[]; + private subscriptions: Subscription = new Subscription(); constructor( private configService: ConfigService, @@ -21,11 +23,15 @@ export class ChooseImportUnitComponent { ngOnInit(): void { this.myProjects = this.configService.getAuthorableProjects(); - this.projectLibraryService.getLibraryProjects().then((libraryProjects) => { - this.libraryProjects = this.projectLibraryService.sortAndFilterUniqueProjects( - libraryProjects - ); - }); + this.subscriptions.add( + this.projectLibraryService.getLibraryProjects().subscribe((libraryProjects) => { + this.libraryProjects = libraryProjects; + }) + ); + } + + ngOnDestroy(): void { + this.subscriptions.unsubscribe(); } protected chooseProject(project: any): void { diff --git a/src/app/classroom-monitor/component-new-work-badge/component-new-work-badge.component.ts b/src/app/classroom-monitor/component-new-work-badge/component-new-work-badge.component.ts index 9bd709ff3eb..a8ae55e937f 100644 --- a/src/app/classroom-monitor/component-new-work-badge/component-new-work-badge.component.ts +++ b/src/app/classroom-monitor/component-new-work-badge/component-new-work-badge.component.ts @@ -2,6 +2,7 @@ import { Component, Input } from '@angular/core'; import { Subscription } from 'rxjs'; import { AnnotationService } from '../../../assets/wise5/services/annotationService'; import { TeacherDataService } from '../../../assets/wise5/services/teacherDataService'; +import { Annotation } from '../../../assets/wise5/common/Annotation'; @Component({ selector: 'component-new-work-badge', @@ -29,10 +30,8 @@ export class ComponentNewWorkBadgeComponent { ngOnInit() { this.checkHasNewWork(); this.annotationSavedToServerSubscription = this.AnnotationService.annotationSavedToServer$.subscribe( - ({ annotation }) => { - const annotationNodeId = annotation.nodeId; - const annotationComponentId = annotation.componentId; - if (this.nodeId === annotationNodeId && this.componentId === annotationComponentId) { + (annotation: Annotation) => { + if (annotation.nodeId === this.nodeId && annotation.componentId === this.componentId) { this.checkHasNewWork(); } } diff --git a/src/app/classroom-monitor/milestones/milestones.component.ts b/src/app/classroom-monitor/milestones/milestones.component.ts index 7b5ee233a76..30756cf89dd 100644 --- a/src/app/classroom-monitor/milestones/milestones.component.ts +++ b/src/app/classroom-monitor/milestones/milestones.component.ts @@ -7,6 +7,7 @@ import { AnnotationService } from '../../../assets/wise5/services/annotationServ import { MilestoneService } from '../../../assets/wise5/services/milestoneService'; import { TeacherDataService } from '../../../assets/wise5/services/teacherDataService'; import { Milestone } from '../../domain/milestone'; +import { Annotation } from '../../../assets/wise5/common/Annotation'; @Component({ selector: 'milestones', @@ -62,7 +63,7 @@ export class MilestonesComponent { private subscribeToAnnotationChanges(): void { this.subscriptions.add( - this.annotationService.annotationReceived$.subscribe(({ annotation }) => { + this.annotationService.annotationReceived$.subscribe((annotation: Annotation) => { this.milestones .filter( (milestone) => diff --git a/src/app/domain/run.spec.ts b/src/app/domain/run.spec.ts index c42d3761082..7e957cafc54 100644 --- a/src/app/domain/run.spec.ts +++ b/src/app/domain/run.spec.ts @@ -1,14 +1,13 @@ -import { waitForAsync } from '@angular/core/testing'; -import { Run } from './run'; +import { Run, sortByRunStartTimeDesc } from './run'; describe('Run', () => { const run = new Run({ - startTime: new Date('2019-03-21T08:00:00.0').getTime() + startTime: new Date('2019-03-21').getTime() }); - const beforeStartTime = new Date('2019-03-20T08:00:00.0').getTime(); - const betweenStartAndEndTimes = new Date('2019-03-22T08:00:00.0').getTime(); - const endTime = new Date('2019-03-23T08:00:00.0').getTime(); - const afterEndTime = new Date('2019-03-24T08:00:00.0').getTime(); + const beforeStartTime = new Date('2019-03-20').getTime(); + const betweenStartAndEndTimes = new Date('2019-03-22').getTime(); + const endTime = new Date('2019-03-23').getTime(); + const afterEndTime = new Date('2019-03-24').getTime(); function expectRun(func, timeNow, expectedValue) { expect(run[func](timeNow)).toEqual(expectedValue); @@ -35,4 +34,21 @@ describe('Run', () => { expectRun('isScheduled', beforeStartTime, true); expectRun('isScheduled', betweenStartAndEndTimes, false); }); + + describe('sortByStartTimeDesc()', () => { + let runList: Run[]; + const run2 = new Run({ + startTime: endTime + }); + const run3 = new Run({ + startTime: afterEndTime + }); + beforeEach(() => { + runList = [run2, run3, run]; + runList.sort(sortByRunStartTimeDesc); + }); + it('sorts runs by start date', async () => { + expect(runList).toEqual([run3, run2, run]); + }); + }); }); diff --git a/src/app/domain/run.ts b/src/app/domain/run.ts index b521aefa2ba..51960909f40 100644 --- a/src/app/domain/run.ts +++ b/src/app/domain/run.ts @@ -93,3 +93,7 @@ export class Run { return this.endTime != null; } } + +export function sortByRunStartTimeDesc(a: Run, b: Run): number { + return b.startTime - a.startTime; +} diff --git a/src/app/notebook/notebook-report/notebook-report.component.ts b/src/app/notebook/notebook-report/notebook-report.component.ts index e5b80a2159a..0b4c4804257 100644 --- a/src/app/notebook/notebook-report/notebook-report.component.ts +++ b/src/app/notebook/notebook-report/notebook-report.component.ts @@ -10,6 +10,7 @@ import { insertWiseLinks, replaceWiseLinks } from '../../../assets/wise5/common/wise-link/wise-link'; +import { Annotation } from '../../../assets/wise5/common/Annotation'; @Component({ selector: 'notebook-report', @@ -67,7 +68,7 @@ export class NotebookReportComponent extends NotebookParentComponent { this.isAddNoteButtonAvailable = this.isNoteEnabled(); this.subscriptions.add( - this.NotebookService.notebookItemAnnotationReceived$.subscribe(({ annotation }: any) => { + this.NotebookService.notebookItemAnnotationReceived$.subscribe((annotation: Annotation) => { if (annotation.localNotebookItemId === this.reportId) { this.hasNewAnnotation = true; this.latestAnnotations = this.AnnotationService.getLatestNotebookItemAnnotations( diff --git a/src/app/services/projectLibraryService.spec.ts b/src/app/services/projectLibraryService.spec.ts index ef21f6ea39f..3e379634480 100644 --- a/src/app/services/projectLibraryService.spec.ts +++ b/src/app/services/projectLibraryService.spec.ts @@ -6,21 +6,6 @@ import { ProjectLibraryService } from '../../assets/wise5/services/projectLibrar let configService: ConfigService; let http: HttpTestingController; let service: ProjectLibraryService; -const getLibraryProjectsURL = '/api/project/library'; -const libraryProjects = [ - { - children: [ - { id: 3, name: 'three' }, - { id: 1, name: 'one' } - ] - }, - { - children: [ - { id: 2, name: 'two' }, - { id: 1, name: 'one' } - ] - } -]; describe('ProjectLibraryService', () => { beforeEach(() => { @@ -33,56 +18,32 @@ describe('ProjectLibraryService', () => { configService = TestBed.inject(ConfigService); }); getLibraryProjects(); - sortAndFilterUniqueProjects(); - filterUniqueProjects(); }); function getLibraryProjects() { - describe('getLibraryProjects', () => { - it('should get the library projects', () => { - spyOnLibraryProjectsURLFromConfig(); - const result = service.getLibraryProjects(); - http.expectOne(getLibraryProjectsURL).flush(libraryProjects); - result.then((projects) => { - expect(projects).toEqual(libraryProjects); + describe('getLibraryProjects()', () => { + const getLibraryProjectsURL = '/api/project/library'; + const unit1 = { id: 1, name: 'one' }; + const unit2 = { id: 2, name: 'two' }; + const unit3 = { id: 3, name: 'three' }; + const libraryProjects = [ + { + children: [unit3, unit1] + }, + { + children: [unit2, unit1] + } + ]; + beforeEach(() => { + spyOn(configService, 'getConfigParam').and.callFake(() => { + return getLibraryProjectsURL; }); }); - }); -} - -function spyOnLibraryProjectsURLFromConfig() { - spyOn(configService, 'getConfigParam').and.callFake((param) => { - return getLibraryProjectsURL; - }); -} - -function sortAndFilterUniqueProjects() { - describe('sortAndFilterUniqueProjects', () => { - it('should filter and sort unique projects', () => { - const result = service.sortAndFilterUniqueProjects(libraryProjects); - expect(result).toEqual([ - { id: 3, name: 'three' }, - { id: 2, name: 'two' }, - { id: 1, name: 'one' } - ]); - }); - }); -} - -function filterUniqueProjects() { - describe('filterUniqueProjects', () => { - it('should filter unique projects based on id', () => { - const nonUniqueProjects = [ - { id: 3, name: 'three' }, - { id: 1, name: 'one' }, - { id: 2, name: 'two' }, - { id: 1, name: 'one' } - ]; - const uniqueProjects = service.filterUniqueProjects(nonUniqueProjects); - expect(uniqueProjects.length).toEqual(3); - expect(uniqueProjects[0].id).toEqual(3); - expect(uniqueProjects[1].id).toEqual(1); - expect(uniqueProjects[2].id).toEqual(2); + it('gets the library projects, sorted and filtered', () => { + service.getLibraryProjects().subscribe((projects) => { + expect(projects).toEqual([unit3, unit2, unit1]); + }); + http.expectOne(getLibraryProjectsURL).flush(libraryProjects); }); }); } diff --git a/src/app/services/wiseLinkService.ts b/src/app/services/wiseLinkService.ts index b69dc397244..5316f5ca6b3 100644 --- a/src/app/services/wiseLinkService.ts +++ b/src/app/services/wiseLinkService.ts @@ -3,6 +3,7 @@ import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; import { replaceWiseLinks } from '../../assets/wise5/common/wise-link/wise-link'; import { NodeService } from '../../assets/wise5/services/nodeService'; import { StudentDataService } from '../../assets/wise5/services/studentDataService'; +import { scrollToElement, temporarilyHighlightElement } from '../../assets/wise5/common/dom/dom'; @Injectable() export class WiseLinkService { @@ -43,15 +44,26 @@ export class WiseLinkService { private followLink(nodeId: string, componentId: string): void { if (nodeId === this.studentDataService.getCurrentNodeId()) { - this.nodeService.scrollToComponentAndHighlight(componentId); + this.scrollToComponentAndHighlight(componentId); } else { this.goToNode(nodeId, componentId); } } + private scrollToComponentAndHighlight(componentId: string): void { + const elementId = `component_${componentId}`; + scrollToElement(elementId); + temporarilyHighlightElement(elementId); + } + private goToNode(nodeId: string, componentId: string): void { if (componentId !== '') { - this.nodeService.registerScrollToComponent(componentId); + const subscription = this.studentDataService.currentNodeChanged$.subscribe(() => { + setTimeout(() => { + this.scrollToComponentAndHighlight(componentId); + subscription.unsubscribe(); + }, 500); // timeout attempts to ensure that new node has loaded before scroll+highlight + }); } this.nodeService.setCurrentNode(nodeId); } diff --git a/src/app/student/student-run-list/student-run-list.component.html b/src/app/student/student-run-list/student-run-list.component.html index 687f38588fd..16ce2b5d41f 100644 --- a/src/app/student/student-run-list/student-run-list.component.html +++ b/src/app/student/student-run-list/student-run-list.component.html @@ -26,11 +26,11 @@ Units found: {{ filteredRuns.length }} My WISE units: {{ filteredRuns.length }} - ({{ scheduledTotal() }} scheduled, + ({{ getRunTotal('isScheduled') }} scheduled, {{ activeTotal() }} active{{ getRunTotal('isActive') }} active) @@ -49,9 +49,9 @@ id="run{{ run.id }}" > - {{ run.startTime | date : 'mediumDate' }} + {{ run.startTime | date: 'mediumDate' }} - - {{ run.endTime | date : 'mediumDate' }} + - {{ run.endTime | date: 'mediumDate' }} diff --git a/src/app/student/student-run-list/student-run-list.component.ts b/src/app/student/student-run-list/student-run-list.component.ts index 421db1a3062..98426fce447 100644 --- a/src/app/student/student-run-list/student-run-list.component.ts +++ b/src/app/student/student-run-list/student-run-list.component.ts @@ -6,6 +6,7 @@ import { ActivatedRoute } from '@angular/router'; import { MatDialog } from '@angular/material/dialog'; import { AddProjectDialogComponent } from '../add-project-dialog/add-project-dialog.component'; import { runSpansDays } from '../../../assets/wise5/common/datetime/datetime'; +import { sortByRunStartTimeDesc } from '../../domain/run'; @Component({ selector: 'app-student-run-list', @@ -61,16 +62,8 @@ export class StudentRunListComponent implements OnInit { }); } - sortByStartTimeDesc(a, b) { - let aStartTime = a.startTime; - let bStartTime = b.startTime; - if (aStartTime < bStartTime) { - return 1; - } else if (aStartTime > bStartTime) { - return -1; - } else { - return 0; - } + protected sortByStartTimeDesc(a: StudentRun, b: StudentRun): number { + return sortByRunStartTimeDesc(a, b); } getRunIndex(run: StudentRun) { @@ -86,37 +79,9 @@ export class StudentRunListComponent implements OnInit { return runSpansDays(run, this.localeID); } - activeTotal(): number { - let total = 0; + protected getRunTotal(type: 'isActive' | 'isScheduled'): number { const now = this.configService.getCurrentServerTime(); - for (let run of this.filteredRuns) { - if (run.isActive(now)) { - total++; - } - } - return total; - } - - completedTotal(): number { - let total = 0; - const now = this.configService.getCurrentServerTime(); - for (let run of this.filteredRuns) { - if (run.isCompleted(now)) { - total++; - } - } - return total; - } - - scheduledTotal(): number { - let total = 0; - const now = this.configService.getCurrentServerTime(); - for (let run of this.filteredRuns) { - if (run.isScheduled(now)) { - total++; - } - } - return total; + return this.filteredRuns.filter((run) => run[type](now)).length; } searchUpdated(value: string) { diff --git a/src/app/teacher/authoring-routing.module.ts b/src/app/teacher/authoring-routing.module.ts index 7260d1f48d4..e8d84dfec90 100644 --- a/src/app/teacher/authoring-routing.module.ts +++ b/src/app/teacher/authoring-routing.module.ts @@ -36,6 +36,7 @@ import { ChooseMoveNodeLocationComponent } from '../../assets/wise5/authoringToo import { ChooseCopyNodeLocationComponent } from '../../assets/wise5/authoringTool/choose-node-location/choose-copy-node-location/choose-copy-node-location.component'; import { ProjectAuthoringParentComponent } from '../../assets/wise5/authoringTool/project-authoring-parent/project-authoring-parent.component'; import { ChooseImportUnitComponent } from '../authoring-tool/import-step/choose-import-unit/choose-import-unit.component'; +import { NodeAuthoringParentComponent } from '../../assets/wise5/authoringTool/node/node-authoring-parent/node-authoring-parent.component'; const routes: Routes = [ { @@ -90,6 +91,23 @@ const routes: Routes = [ path: 'choose-location', component: ChooseNewNodeLocation }, + { + path: 'import-step', + children: [ + { + path: 'choose-location', + component: ChooseImportStepLocationComponent + }, + { + path: 'choose-step', + component: ChooseImportStepComponent + }, + { + path: 'choose-unit', + component: ChooseImportUnitComponent + } + ] + }, { path: 'simulation', children: [{ path: 'choose-item', component: ChooseSimulationComponent }] @@ -103,29 +121,28 @@ const routes: Routes = [ }, { path: 'choose-copy-location', component: ChooseCopyNodeLocationComponent }, { path: 'choose-move-location', component: ChooseMoveNodeLocationComponent }, + { path: 'info', component: ProjectInfoAuthoringComponent }, + { path: 'milestones', component: MilestonesAuthoringComponent }, { - path: 'import-step', + path: 'node/:nodeId', + component: NodeAuthoringParentComponent, children: [ { - path: 'choose-location', - component: ChooseImportStepLocationComponent + path: '', + component: NodeAuthoringComponent }, { - path: 'choose-step', - component: ChooseImportStepComponent + path: 'advanced', + component: NodeAdvancedAuthoringComponent, + children: [ + { path: 'branch', component: NodeAdvancedBranchAuthoringComponent }, + { path: 'constraint', component: NodeAdvancedConstraintAuthoringComponent }, + { path: 'general', component: NodeAdvancedGeneralAuthoringComponent }, + { path: 'json', component: NodeAdvancedJsonAuthoringComponent }, + { path: 'path', component: NodeAdvancedPathAuthoringComponent }, + { path: 'rubric', component: EditNodeRubricComponent } + ] }, - { - path: 'choose-unit', - component: ChooseImportUnitComponent - } - ] - }, - { path: 'info', component: ProjectInfoAuthoringComponent }, - { path: 'milestones', component: MilestonesAuthoringComponent }, - { - path: 'node/:nodeId', - component: NodeAuthoringComponent, - children: [ { path: 'choose-component-location', component: ChooseComponentLocationComponent @@ -136,19 +153,6 @@ const routes: Routes = [ } ] }, - - { - path: 'node/:nodeId/advanced', - component: NodeAdvancedAuthoringComponent, - children: [ - { path: 'branch', component: NodeAdvancedBranchAuthoringComponent }, - { path: 'constraint', component: NodeAdvancedConstraintAuthoringComponent }, - { path: 'general', component: NodeAdvancedGeneralAuthoringComponent }, - { path: 'json', component: NodeAdvancedJsonAuthoringComponent }, - { path: 'path', component: NodeAdvancedPathAuthoringComponent }, - { path: 'rubric', component: EditNodeRubricComponent } - ] - }, { path: 'notebook', component: NotebookAuthoringComponent }, { path: 'recovery', component: RecoveryAuthoringComponent }, { diff --git a/src/app/teacher/authoring-tool.module.ts b/src/app/teacher/authoring-tool.module.ts index bbdf33f7d3e..0bcbb700b54 100644 --- a/src/app/teacher/authoring-tool.module.ts +++ b/src/app/teacher/authoring-tool.module.ts @@ -50,6 +50,7 @@ import { NodeIconAndTitleComponent } from '../../assets/wise5/authoringTool/choo import { NodeWithMoveAfterButtonComponent } from '../../assets/wise5/authoringTool/choose-node-location/node-with-move-after-button/node-with-move-after-button.component'; import { ProjectAuthoringParentComponent } from '../../assets/wise5/authoringTool/project-authoring-parent/project-authoring-parent.component'; import { ChooseImportUnitComponent } from '../authoring-tool/import-step/choose-import-unit/choose-import-unit.component'; +import { NodeAuthoringParentComponent } from '../../assets/wise5/authoringTool/node/node-authoring-parent/node-authoring-parent.component'; @NgModule({ declarations: [ @@ -78,6 +79,7 @@ import { ChooseImportUnitComponent } from '../authoring-tool/import-step/choose- InsertNodeInsideButtonComponent, MilestonesAuthoringComponent, NodeAuthoringComponent, + NodeAuthoringParentComponent, NodeIconChooserDialog, NodeIconAndTitleComponent, NodeWithMoveAfterButtonComponent, diff --git a/src/app/teacher/teacher-run-list/teacher-run-list.component.spec.ts b/src/app/teacher/teacher-run-list/teacher-run-list.component.spec.ts index c5a8dd0e23a..1a6b6fb7927 100644 --- a/src/app/teacher/teacher-run-list/teacher-run-list.component.spec.ts +++ b/src/app/teacher/teacher-run-list/teacher-run-list.component.spec.ts @@ -132,19 +132,10 @@ describe('TeacherRunListComponent', () => { runSelectedStatusChanged(); selectAllRunsCheckboxClicked(); selectRunsOptionChosen(); - sortByStartTimeDesc(); unarchiveSelectedRuns(); noRuns(); }); -function sortByStartTimeDesc() { - describe('sortByStartTimeDesc()', () => { - it('should sort runs by start date', async () => { - await expectRunTitles([run3Title, run2Title, run1Title]); - }); - }); -} - function archiveSelectedRuns(): void { describe('archiveSelectedRuns()', () => { it('should archive selected runs', async () => { diff --git a/src/app/teacher/teacher-run-list/teacher-run-list.component.ts b/src/app/teacher/teacher-run-list/teacher-run-list.component.ts index 184a83936d6..8f6288a4826 100644 --- a/src/app/teacher/teacher-run-list/teacher-run-list.component.ts +++ b/src/app/teacher/teacher-run-list/teacher-run-list.component.ts @@ -9,6 +9,7 @@ import { mergeMap } from 'rxjs/operators'; import { ArchiveProjectService } from '../../services/archive-project.service'; import { runSpansDays } from '../../../assets/wise5/common/datetime/datetime'; import { SelectRunsOption } from '../select-runs-controls/select-runs-option'; +import { sortByRunStartTimeDesc } from '../../domain/run'; @Component({ selector: 'app-teacher-run-list', @@ -112,7 +113,7 @@ export class TeacherRunListComponent implements OnInit { } protected sortByStartTimeDesc(a: TeacherRun, b: TeacherRun): number { - return b.startTime - a.startTime; + return sortByRunStartTimeDesc(a, b); } protected runSpansDays(run: TeacherRun): boolean { diff --git a/src/assets/wise5/authoringTool/addNode/NewNodeTemplate.ts b/src/assets/wise5/authoringTool/addNode/NewNodeTemplate.ts index 1436835ecf2..a334a6d9dd0 100644 --- a/src/assets/wise5/authoringTool/addNode/NewNodeTemplate.ts +++ b/src/assets/wise5/authoringTool/addNode/NewNodeTemplate.ts @@ -1,6 +1,5 @@ export interface NewNodeTemplate { label: string; - description: string; icon: string; route: string; } diff --git a/src/assets/wise5/authoringTool/addNode/choose-new-node-template/choose-new-node-template.component.html b/src/assets/wise5/authoringTool/addNode/choose-new-node-template/choose-new-node-template.component.html index 3a12f6ec83a..03577ef8500 100644 --- a/src/assets/wise5/authoringTool/addNode/choose-new-node-template/choose-new-node-template.component.html +++ b/src/assets/wise5/authoringTool/addNode/choose-new-node-template/choose-new-node-template.component.html @@ -1,4 +1,4 @@ -
Start from scratch or choose a step template:
+
Start from scratch, import from another unit, or choose a step template:
{ - this.libraryProjectsList = this.projectLibraryService.sortAndFilterUniqueProjects( - libraryProjects - ); - }); + this.subscriptions.add( + this.projectLibraryService.getLibraryProjects().subscribe((libraryProjects) => { + this.libraryProjectsList = libraryProjects; + }) + ); + } + + ngOnDestroy(): void { + this.subscriptions.unsubscribe(); } showMyImportProject(importProjectId: number): void { diff --git a/src/assets/wise5/authoringTool/node/advanced/branch/node-advanced-branch-authoring.component.ts b/src/assets/wise5/authoringTool/node/advanced/branch/node-advanced-branch-authoring.component.ts index 6a2a38c3595..3f714220e23 100644 --- a/src/assets/wise5/authoringTool/node/advanced/branch/node-advanced-branch-authoring.component.ts +++ b/src/assets/wise5/authoringTool/node/advanced/branch/node-advanced-branch-authoring.component.ts @@ -53,7 +53,7 @@ export class NodeAdvancedBranchAuthoringComponent implements OnInit { ) {} ngOnInit() { - this.route.parent.params.subscribe((params) => { + this.route.parent.parent.params.subscribe((params) => { this.nodeId = params.nodeId; this.node = this.projectService.getNodeById(this.nodeId); this.nodeIds = this.projectService.getFlattenedProjectAsNodeIds(true); diff --git a/src/assets/wise5/authoringTool/node/advanced/constraint/node-advanced-constraint-authoring.component.spec.ts b/src/assets/wise5/authoringTool/node/advanced/constraint/node-advanced-constraint-authoring.component.spec.ts index 534c56a6fb2..cf48d212a40 100644 --- a/src/assets/wise5/authoringTool/node/advanced/constraint/node-advanced-constraint-authoring.component.spec.ts +++ b/src/assets/wise5/authoringTool/node/advanced/constraint/node-advanced-constraint-authoring.component.spec.ts @@ -38,7 +38,7 @@ describe('NodeAdvancedConstraintAuthoringComponent', () => { { provide: ActivatedRoute, useValue: { - parent: { params: of({ nodeId: 'node1' }) } + parent: { parent: { params: of({ nodeId: 'node1' }) } } } } ] diff --git a/src/assets/wise5/authoringTool/node/advanced/constraint/node-advanced-constraint-authoring.component.ts b/src/assets/wise5/authoringTool/node/advanced/constraint/node-advanced-constraint-authoring.component.ts index 9cc14a32de7..b037ceff475 100644 --- a/src/assets/wise5/authoringTool/node/advanced/constraint/node-advanced-constraint-authoring.component.ts +++ b/src/assets/wise5/authoringTool/node/advanced/constraint/node-advanced-constraint-authoring.component.ts @@ -16,7 +16,7 @@ export class NodeAdvancedConstraintAuthoringComponent extends ConstraintsAuthori } ngOnInit() { - this.route.parent.params.subscribe((params) => { + this.route.parent.parent.params.subscribe((params) => { const node = this.projectService.getNodeById(params.nodeId); if (node.constraints == null) { node.constraints = []; diff --git a/src/assets/wise5/authoringTool/node/advanced/general/node-advanced-general-authoring.component.ts b/src/assets/wise5/authoringTool/node/advanced/general/node-advanced-general-authoring.component.ts index 73b08771849..2d32eb85907 100644 --- a/src/assets/wise5/authoringTool/node/advanced/general/node-advanced-general-authoring.component.ts +++ b/src/assets/wise5/authoringTool/node/advanced/general/node-advanced-general-authoring.component.ts @@ -12,7 +12,7 @@ export class NodeAdvancedGeneralAuthoringComponent implements OnInit { constructor(private projectService: TeacherProjectService, private route: ActivatedRoute) {} ngOnInit() { - this.route.parent.params.subscribe((params) => { + this.route.parent.parent.params.subscribe((params) => { this.node = this.projectService.getNodeById(params.nodeId); }); } diff --git a/src/assets/wise5/authoringTool/node/advanced/json/node-advanced-json-authoring.component.ts b/src/assets/wise5/authoringTool/node/advanced/json/node-advanced-json-authoring.component.ts index 85c07e7db17..e5ac7652b4a 100644 --- a/src/assets/wise5/authoringTool/node/advanced/json/node-advanced-json-authoring.component.ts +++ b/src/assets/wise5/authoringTool/node/advanced/json/node-advanced-json-authoring.component.ts @@ -23,7 +23,7 @@ export class NodeAdvancedJsonAuthoringComponent implements OnInit { ) {} ngOnInit() { - this.route.parent.params.subscribe((params) => { + this.route.parent.parent.params.subscribe((params) => { this.nodeId = params.nodeId; this.node = this.projectService.getNodeById(this.nodeId); this.nodeContentJSONString = JSON.stringify(this.node, null, 4); diff --git a/src/assets/wise5/authoringTool/node/advanced/node-advanced-authoring/node-advanced-authoring.component.html b/src/assets/wise5/authoringTool/node/advanced/node-advanced-authoring/node-advanced-authoring.component.html index c574e21dfd5..19514995cf2 100644 --- a/src/assets/wise5/authoringTool/node/advanced/node-advanced-authoring/node-advanced-authoring.component.html +++ b/src/assets/wise5/authoringTool/node/advanced/node-advanced-authoring/node-advanced-authoring.component.html @@ -2,7 +2,7 @@ - -
- +
+
+ + + Step Title {{ nodePosition }}: + Activity Title {{ nodePosition }}: + + +
+
- + + +
+ + + +
+
Components
+ +
+ + +
+ +
+ + - +
+
+
+
+ This step does not have any components. Click the + button to add a component. +
+
+
-
Components
- -
- - - -
- -
- - -
-
-
-
- This step does not have any components. Click the + button to add a component. -
-
-
-
-
-
-
- drag_indicator - - {{ i + 1 }}. {{ getComponentTypeLabel(component.type) }} - -
- -
- - - - -
-
-
- expand_more -
-
- expand_less -
-
+
-
- +
+ +
-
-
- + [componentId]="component.id" + > + + + +
+
+ expand_more +
+
+ expand_less +
+
+ +
+
+ +
diff --git a/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.spec.ts b/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.spec.ts index c8fc3e9a2c5..1d7ee1fa57c 100644 --- a/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.spec.ts +++ b/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.spec.ts @@ -22,6 +22,7 @@ import { DragDropModule } from '@angular/cdk/drag-drop'; import { RouterTestingModule } from '@angular/router/testing'; import { ActivatedRoute, Router, convertToParamMap } from '@angular/router'; import { of } from 'rxjs'; +import { TeacherNodeService } from '../../../services/teacherNodeService'; let component: NodeAuthoringComponent; let component1: any; @@ -56,6 +57,7 @@ describe('NodeAuthoringComponent', () => { ClassroomStatusService, ProjectAssetService, TeacherDataService, + TeacherNodeService, TeacherProjectService, TeacherWebSocketService, { diff --git a/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.ts b/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.ts index 6979023abcf..abdadb64818 100644 --- a/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.ts +++ b/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.ts @@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core'; import { Subscription, filter } from 'rxjs'; import { TeacherDataService } from '../../../services/teacherDataService'; import { TeacherProjectService } from '../../../services/teacherProjectService'; -import { NodeService } from '../../../services/nodeService'; import { ComponentTypeService } from '../../../services/componentTypeService'; import { ComponentServiceLookupService } from '../../../services/componentServiceLookupService'; import { Node } from '../../../common/Node'; @@ -14,7 +13,8 @@ import { EditComponentAdvancedComponent } from '../../../../../app/authoring-too import { Component as WiseComponent } from '../../../common/Component'; import { ChooseNewComponent } from '../../../../../app/authoring-tool/add-component/choose-new-component/choose-new-component.component'; import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'; -import { ActivatedRoute, NavigationEnd, Router } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; +import { TeacherNodeService } from '../../../services/teacherNodeService'; @Component({ selector: 'node-authoring', @@ -32,7 +32,6 @@ export class NodeAuthoringComponent implements OnInit { nodeId: string; nodePosition: any; projectId: number; - showNodeView: boolean = true; subscriptions: Subscription = new Subscription(); constructor( @@ -40,19 +39,14 @@ export class NodeAuthoringComponent implements OnInit { private componentServiceLookupService: ComponentServiceLookupService, private componentTypeService: ComponentTypeService, private dialog: MatDialog, - private nodeService: NodeService, + private nodeService: TeacherNodeService, private projectService: TeacherProjectService, private dataService: TeacherDataService, private route: ActivatedRoute, private router: Router - ) { - this.router.events - .pipe(filter((event) => event instanceof NavigationEnd)) - .subscribe(() => this.updateShowNodeView()); - } + ) {} ngOnInit(): void { - this.updateShowNodeView(); this.nodeId = this.route.snapshot.paramMap.get('nodeId'); this.route.parent.params.subscribe((params) => { this.projectId = Number(params.unitId); @@ -82,12 +76,6 @@ export class NodeAuthoringComponent implements OnInit { } } - private updateShowNodeView(): void { - this.showNodeView = /\/teacher\/edit\/unit\/(\d*)\/node\/(node|group)(\d*)$/.test( - this.router.url - ); - } - ngOnDestroy(): void { this.subscriptions.unsubscribe(); } @@ -189,10 +177,6 @@ export class NodeAuthoringComponent implements OnInit { return this.projectService.saveProject(); } - protected showAdvancedView(): void { - this.router.navigate([`/teacher/edit/unit/${this.projectId}/node/${this.nodeId}/advanced`]); - } - protected getSelectedComponents(): ComponentContent[] { return this.components.filter( (component: ComponentContent) => this.componentsToChecked[component.id] diff --git a/src/assets/wise5/authoringTool/project-authoring/project-authoring.component.html b/src/assets/wise5/authoringTool/project-authoring/project-authoring.component.html index 1622181667d..de15efaf2fc 100644 --- a/src/assets/wise5/authoringTool/project-authoring/project-authoring.component.html +++ b/src/assets/wise5/authoringTool/project-authoring/project-authoring.component.html @@ -13,9 +13,9 @@ -