Skip to content

Commit

Permalink
Merge branch 'release-5.16.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
hirokiterashima committed Sep 18, 2020
2 parents f366469 + 87d653e commit ab8faa1
Show file tree
Hide file tree
Showing 22 changed files with 299 additions and 204 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wise",
"version": "5.16.2",
"version": "5.16.3",
"description": "Web-based Inquiry Science Environment",
"main": "app.js",
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<artifactId>wise</artifactId>
<packaging>war</packaging>
<name>Web-based Inquiry Science Environment</name>
<version>5.16.2</version>
<version>5.16.3</version>
<url>http://wise5.org</url>
<licenses>
<license>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.16.2
5.16.3
40 changes: 35 additions & 5 deletions src/main/webapp/site/src/app/services/data.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,46 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { UpgradeModule } from '@angular/upgrade/static';
import { ConfigService } from '../../../../wise5/services/configService';
import { ProjectService } from '../../../../wise5/services/projectService';
import { SessionService } from '../../../../wise5/services/sessionService';
import { UtilService } from '../../../../wise5/services/utilService';

import { DataService } from './data.service';

let service: DataService;
let projectService: ProjectService;

describe('DataService', () => {
let service: DataService;

beforeEach(() => {
TestBed.configureTestingModule({});
TestBed.configureTestingModule({
imports: [ HttpClientTestingModule, UpgradeModule ],
providers: [ ConfigService, ProjectService, SessionService, UtilService ]
});
service = TestBed.inject(DataService);
projectService = TestBed.inject(ProjectService);
});

it('should be created', () => {
expect(service).toBeTruthy();
});
setCurrentNode();
});

function setCurrentNode() {
it('should set the new current node when there is no current node', () => {
const node = { id: 'node1' };
expect(service.currentNode).toEqual(null);
service.setCurrentNode(node);
expect(service.currentNode).toEqual(node);
});
it('should set the new current node when there is a current node', () => {
const node1 = { id: 'node1' };
const node2 = { id: 'node2' };
service.setCurrentNode(node1);
expect(service.currentNode).toEqual(node1);
spyOn(projectService, 'isGroupNode').and.callFake(() => { return false });
spyOn(service, 'broadcastCurrentNodeChanged').and.callFake(() => {});
service.setCurrentNode(node2);
expect(service.previousStep).toEqual(node1);
expect(service.currentNode).toEqual(node2);
})
}
40 changes: 39 additions & 1 deletion src/main/webapp/site/src/app/services/data.service.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import { Injectable } from '@angular/core';
import { UpgradeModule } from '@angular/upgrade/static';
import { Subject } from 'rxjs';
import { ProjectService } from '../../../../wise5/services/projectService';

@Injectable({
providedIn: 'root'
})
export class DataService {

currentNode = null;
previousStep = null;
private currentNodeChangedSource: Subject<any> = new Subject<any>();
public currentNodeChanged$ = this.currentNodeChangedSource.asObservable();

constructor() { }
constructor(
protected upgrade: UpgradeModule,
protected ProjectService: ProjectService) { }

isCompleted(nodeId, componentId) {

Expand Down Expand Up @@ -43,4 +51,34 @@ export class DataService {
saveVLEEvent(nodeId, componentId, componentType, category, event, eventData) {

}

setCurrentNodeByNodeId(nodeId) {
this.setCurrentNode(this.ProjectService.getNodeById(nodeId));
}

setCurrentNode(node) {
const previousCurrentNode = this.currentNode;
this.currentNode = node;
if (previousCurrentNode !== node) {
if (previousCurrentNode && !this.ProjectService.isGroupNode(previousCurrentNode.id)) {
this.previousStep = previousCurrentNode;
}
this.broadcastCurrentNodeChanged({
previousNode: previousCurrentNode,
currentNode: this.currentNode
});
}
}

broadcastCurrentNodeChanged(previousAndCurrentNode: any) {
this.currentNodeChangedSource.next(previousAndCurrentNode);
}

endCurrentNode() {
if (this.currentNode != null) {
this.upgrade.$injector.get('$rootScope').$broadcast('exitNode',
{ nodeToExit: this.currentNode });
}
}

}
17 changes: 0 additions & 17 deletions src/main/webapp/wise5/authoringTool/authoringToolController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,23 +252,6 @@ class AuthoringToolController {
this.setGlobalMessage(this.$translate('notAllowedToEditThisProject'), false, null);
});

this.$scope.$on('openWISELinkChooser', (event, params) => {
const stateParams = {
projectId: params.projectId,
nodeId: params.nodeId,
componentId: params.componentId,
target: params.target
};
this.$mdDialog.show({
templateUrl: 'wise5/authoringTool/wiseLink/wiseLinkAuthoring.html',
controller: 'WISELinkAuthoringController',
controllerAs: 'wiseLinkAuthoringController',
$stateParams: stateParams,
clickOutsideToClose: true,
escapeToClose: true
});
});

if (this.$state.current.name === 'root.at.main') {
this.saveEvent('projectListViewed', 'Navigation');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h5>{{ ::'createAWISELink' | translate }}</h5>
<md-input-container>
<label>{{ ::'setLinkText' | translate }}</label>
<input ng-model="wiseLinkAuthoringController.wiseLinkText"
ng-model-options='{ debounce: 1000 }'
ng-model-options='{ debounce: 500 }'
size="50"/>
</md-input-container>
<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ class WISELinkAuthoringController {
}

/**
* Fire an event to create the WISE Link. Listeners will be the ones that
* actually create the WISE Link. The event that is fired will provide
* the parameters for the WISE Link.
* TODO: i18n
*/
createWISELink() {
Expand All @@ -80,12 +77,12 @@ class WISELinkAuthoringController {
wiseLinkText: this.wiseLinkText,
wiseLinkClass: this.wiseLinkClass
};
this.$rootScope.$broadcast('createWISELink', params);
this.$mdDialog.hide(params);
}
}

cancelWISELinkAuthoring() {
this.$mdDialog.hide();
this.$mdDialog.cancel();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class MilestoneDetailsController {
milestone: any;
periodId: number;
requirements: any;
currentPeriodChangedSubscription: any;

static $inject = [
'$filter',
Expand All @@ -24,18 +25,30 @@ class MilestoneDetailsController {
];
constructor(
$filter,
$scope,
private $scope,
private ConfigService: ConfigService,
private NodeService: NodeService,
private ProjectService: TeacherProjectService,
private TeacherDataService: TeacherDataService
) {
this.$translate = $filter('translate');
this.periodId = this.TeacherDataService.getCurrentPeriod().periodId;
$scope.$on('currentPeriodChanged', (event, { currentPeriod }) => {
this.currentPeriodChangedSubscription = this.TeacherDataService.currentPeriodChanged$
.subscribe(({ currentPeriod }) => {
this.periodId = currentPeriod.periodId;
this.saveMilestoneCurrentPeriodSelectedEvent(currentPeriod);
});
this.$scope.$on('$destroy', () => {
this.ngOnDestroy();
});
}

ngOnDestroy() {
this.unsubscribeAll();
}

unsubscribeAll() {
this.currentPeriodChangedSubscription.unsubscribe();
}

$onInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class NodeGradingViewController {
workgroups: any;
workgroupsById: any;
workVisibilityById: any;
currentPeriodChangedSubscription: any;

static $inject = [
'$filter',
Expand Down Expand Up @@ -130,7 +131,8 @@ class NodeGradingViewController {
}
});

this.$scope.$on('currentPeriodChanged', () => {
this.currentPeriodChangedSubscription = this.TeacherDataService.currentPeriodChanged$
.subscribe(() => {
if (!this.milestone) {
this.milestoneReport = this.MilestoneService.getMilestoneReportByNodeId(this.nodeId);
}
Expand All @@ -139,6 +141,18 @@ class NodeGradingViewController {
if (!this.isDisplayInMilestone()) {
this.saveNodeGradingViewDisplayedEvent();
}

this.$scope.$on('$destroy', () => {
this.ngOnDestroy();
});
}

ngOnDestroy() {
this.unsubscribeAll();
}

unsubscribeAll() {
this.currentPeriodChangedSubscription.unsubscribe();
}

saveNodeGradingViewDisplayedEvent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class NavItemController {
rubricIconName: string;
showPosition: any;
workgroupsOnNodeData: any;
currentPeriodChangedSubscription: any;

static $inject = [
'$element',
Expand Down Expand Up @@ -70,7 +71,6 @@ class NavItemController {
) {
this.$element = $element;
this.$rootScope = $rootScope;
this.$scope = $scope;
this.AnnotationService = AnnotationService;
this.ConfigService = ConfigService;
this.NotificationService = NotificationService;
Expand Down Expand Up @@ -191,11 +191,24 @@ class NavItemController {
this.getAlertNotifications();
});

this.$rootScope.$on('currentPeriodChanged', (event, args) => {
this.currentPeriod = args.currentPeriod;
this.currentPeriodChangedSubscription = this.TeacherDataService.currentPeriodChanged$
.subscribe(({ currentPeriod }) => {
this.currentPeriod = currentPeriod;
this.setWorkgroupsOnNodeData();
this.getAlertNotifications();
});

this.$scope.$on('$destroy', () => {
this.ngOnDestroy();
});
}

ngOnDestroy() {
this.unsubscribeAll();
}

unsubscribeAll() {
this.currentPeriodChangedSubscription.unsubscribe();
}

zoomToElement() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class PeriodSelectController {
currentPeriod: any;
periods: any;
rootNodeId: string;
currentPeriodChangedSubscription: any;
static $inject = [
'$filter',
'$scope',
Expand All @@ -19,7 +20,7 @@ class PeriodSelectController {

constructor(
$filter: any,
$scope: any,
private $scope: any,
private ProjectService: TeacherProjectService,
private StudentStatusService: StudentStatusService,
private TeacherDataService: TeacherDataService
Expand All @@ -35,9 +36,21 @@ class PeriodSelectController {
this.currentPeriod = null;
this.periods = [];
this.initializePeriods();
$scope.$on('currentPeriodChanged', (event, args) => {
this.currentPeriod = args.currentPeriod;
this.currentPeriodChangedSubscription = this.TeacherDataService.currentPeriodChanged$
.subscribe(({ currentPeriod }) => {
this.currentPeriod = currentPeriod;
});
this.$scope.$on('$destroy', () => {
this.ngOnDestroy();
});
}

ngOnDestroy() {
this.unsubscribeAll();
}

unsubscribeAll() {
this.currentPeriodChangedSubscription.unsubscribe();
}

initializePeriods() {
Expand Down
Loading

0 comments on commit ab8faa1

Please sign in to comment.