diff --git a/src/app/test-controller/test-controller.component.ts b/src/app/test-controller/test-controller.component.ts index 8a5c5bc6e56c589b8276d881ff0be6d5e6235ebe..14cba0b9836625120a30fb6edd6155be6a879cfb 100644 --- a/src/app/test-controller/test-controller.component.ts +++ b/src/app/test-controller/test-controller.component.ts @@ -323,7 +323,7 @@ export class TestControllerComponent implements OnInit, OnDestroy { this.tcs.testStatus$.next(TestControllerState.ERROR); }); this.testStatusSubscription = this.tcs.testStatus$.subscribe(testControllerState => { - if ([TestControllerState.FINISHED, TestControllerState.INIT, TestControllerState.LOADING].indexOf(testControllerState) === -1) { + if (this.tcs.testMode.saveResponses && [TestControllerState.FINISHED, TestControllerState.INIT, TestControllerState.LOADING].indexOf(testControllerState) === -1) { this.bs.updateTestState(this.tcs.testId, [<StateReportEntry>{ key: TestStateKey.CONTROLLER, timeStamp: Date.now(), content: testControllerState }]); diff --git a/src/app/test-controller/test-controller.service.ts b/src/app/test-controller/test-controller.service.ts index a5b1d05e69990baf0303f2baaa0052ecf9c237a5..cb21e4f27f289b6e833d7ea661e9448db6c47044 100644 --- a/src/app/test-controller/test-controller.service.ts +++ b/src/app/test-controller/test-controller.service.ts @@ -79,6 +79,7 @@ export class TestControllerService { private unitDefinitions: {[sequenceId: number]: string} = {}; private unitStateDataParts: {[sequenceId: number]: string} = {}; private unitPresentationCompleteStates: {[sequenceId: number]: string} = {}; + private unitResponseCompleteStates: {[sequenceId: number]: string} = {}; private unitStateDataToSave$ = new Subject<UnitStateData>(); public windowFocusState$ = new Subject<WindowFocusState>(); @@ -198,19 +199,24 @@ export class TestControllerService { public addClearedCodeTestlet(testletId: string) { if (this.clearCodeTestlets.indexOf(testletId) < 0) { this.clearCodeTestlets.push(testletId); - this.bs.updateTestState(this.testId, [<StateReportEntry>{ - key: TestStateKey.TESTLETS_CLEARED_CODE, timeStamp: Date.now(), content: JSON.stringify(this.clearCodeTestlets) - }]) + if (this.testMode.saveResponses) { + this.bs.updateTestState(this.testId, [<StateReportEntry>{ + key: TestStateKey.TESTLETS_CLEARED_CODE, timeStamp: Date.now(), content: JSON.stringify(this.clearCodeTestlets) + }]) + } } } public updateUnitStatePresentationProgress(unitDbKey: string, unitSequenceId: number, presentationProgress: string) { + let stateChanged = false; if (!this.unitPresentationCompleteStates[unitSequenceId] || this.unitPresentationCompleteStates[unitSequenceId] === 'none') { this.unitPresentationCompleteStates[unitSequenceId] = presentationProgress; + stateChanged = true; } else if (this.unitPresentationCompleteStates[unitSequenceId] === 'some' && presentationProgress === 'complete') { this.unitPresentationCompleteStates[unitSequenceId] = presentationProgress; + stateChanged = true; } - if (this.testMode.saveResponses) { + if (stateChanged && this.testMode.saveResponses) { this.bs.updateUnitState(this.testId, unitDbKey, [<StateReportEntry>{ key: UnitStateKey.PRESENTATION_PROGRESS, timeStamp: Date.now(), content: presentationProgress }]); @@ -219,9 +225,12 @@ export class TestControllerService { public newUnitStateResponseProgress(unitDbKey: string, unitSequenceId: number, responseProgress: string) { if (this.testMode.saveResponses) { - this.bs.updateUnitState(this.testId, unitDbKey, [<StateReportEntry>{ - key: UnitStateKey.RESPONSE_PROGRESS, timeStamp: Date.now(), content: responseProgress - }]); + if (!this.unitResponseCompleteStates[unitSequenceId] || this.unitResponseCompleteStates[unitSequenceId] !== responseProgress) { + this.unitResponseCompleteStates[unitSequenceId] = responseProgress; + this.bs.updateUnitState(this.testId, unitDbKey, [<StateReportEntry>{ + key: UnitStateKey.RESPONSE_PROGRESS, timeStamp: Date.now(), content: responseProgress + }]); + } } } diff --git a/src/app/test-controller/unithost/unithost.component.ts b/src/app/test-controller/unithost/unithost.component.ts index 64dd6a14922ca407ad69dba7fb255f3acfb55bc9..72b3afb06db2ed7f35e9ff77235a095b8b933d9a 100644 --- a/src/app/test-controller/unithost/unithost.component.ts +++ b/src/app/test-controller/unithost/unithost.component.ts @@ -68,10 +68,11 @@ export class UnithostComponent implements OnInit, OnDestroy { pendingUnitDataToRestore['all'] = this.pendingUnitData.unitState; this.pendingUnitData = null; } - this.bs.updateUnitState(this.tcs.testId, this.myUnitDbKey, [<StateReportEntry>{ - key: UnitStateKey.PLAYER, timeStamp: Date.now(), content: UnitPlayerState.RUNNING - }]); - + if (this.tcs.testMode.saveResponses) { + this.bs.updateUnitState(this.tcs.testId, this.myUnitDbKey, [<StateReportEntry>{ + key: UnitStateKey.PLAYER, timeStamp: Date.now(), content: UnitPlayerState.RUNNING + }]) + } this.postMessageTarget = m.source as Window; if (typeof this.postMessageTarget !== 'undefined') { this.postMessageTarget.postMessage({ @@ -167,12 +168,14 @@ export class UnithostComponent implements OnInit, OnDestroy { const currentUnit = this.tcs.rootTestlet.getUnitAt(this.myUnitSequenceId); this.unitTitle = currentUnit.unitDef.title; this.myUnitDbKey = currentUnit.unitDef.alias; - this.bs.updateTestState(this.tcs.testId, [<StateReportEntry>{ - key: TestStateKey.CURRENT_UNIT_ID, timeStamp: Date.now(), content: this.myUnitDbKey - }]); - this.bs.updateUnitState(this.tcs.testId, this.myUnitDbKey, [<StateReportEntry>{ - key: UnitStateKey.PLAYER, timeStamp: Date.now(), content: UnitPlayerState.LOADING - }]); + if (this.tcs.testMode.saveResponses) { + this.bs.updateTestState(this.tcs.testId, [<StateReportEntry>{ + key: TestStateKey.CURRENT_UNIT_ID, timeStamp: Date.now(), content: this.myUnitDbKey + }]); + this.bs.updateUnitState(this.tcs.testId, this.myUnitDbKey, [<StateReportEntry>{ + key: UnitStateKey.PLAYER, timeStamp: Date.now(), content: UnitPlayerState.LOADING + }]) + } this.tcs.currentUnitDbKey = this.myUnitDbKey; this.tcs.currentUnitTitle = this.unitTitle; this.itemplayerSessionId = Math.floor(Math.random() * 20000000 + 10000000).toString();