Skip to content

Commit

Permalink
Merge pull request #236 from lookit/release/v2.3.2
Browse files Browse the repository at this point in the history
Release/v2.3.2
  • Loading branch information
Kim Scott committed Mar 5, 2021
2 parents cb64112 + f830dfa commit f1e34c1
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 27 deletions.
2 changes: 2 additions & 0 deletions app/components/exp-frame-base/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,8 @@ let ExpFrameBase = Ember.Component.extend(FullScreen, SessionRecord, {
// that the user is likely to have limited ability to FIX a save error, and the
// only thing they'll really be able to do is try again anyway, preventing
// them from continuing is unnecessarily disruptive.
// 3/5/2021: It actually appears to be ok to enter FS from within the .finally() clause of a promise,
// but we still don't want to hold up moving to the next frame for the ~1s until saving succeeds.
this.send('save');

if (this.get('endSessionRecording') && this.get('sessionRecorder')) {
Expand Down
2 changes: 1 addition & 1 deletion app/components/exp-lookit-video/template.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{! template-lint-disable no-invalid-interactive}}
{{! template-lint-disable no-html-comments}}

<div class="input-group exp-lookit-video row {{unless (and autoProceed (not video.controls)) "cursor-display"}}">
<div class="input-group exp-lookit-video row {{if (or (not autoProceed) video.controls) "cursor-display"}}">

<!--RECORDER-->
<div class="row recorder-container video-recorder-hidden">
Expand Down
29 changes: 18 additions & 11 deletions app/components/exp-player/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ let {
* experiment=experiment
* session=session
* pastSessions=pastSessions
* saveHandler=(action 'saveSession')
* frameIndex=0
* fullScreenElementId='expContainer'}}
* ```
Expand All @@ -33,6 +32,10 @@ export default Ember.Component.extend(FullScreen, {
frames: null,
conditions: null,

// Store sequence and expData on the component so we can update them immediately, then transfer to session
_sequence: [],
_expData: {},

frameIndex: 0, // Index of the currently active frame

displayFullscreen: false,
Expand Down Expand Up @@ -207,16 +210,20 @@ export default Ember.Component.extend(FullScreen, {
},

saveFrame(frameId, frameData) {
// Save the data from a completed frame to the session data item
if (this.get('session.sequence') && frameId != this.get('session.sequence')[this.get('session.sequence').length - 1]) {
this.get('session.sequence').push(frameId);
}
this.get('session.expData')[frameId] = frameData;
if (!this.get('session').child.content || this.get('session').child.content.id === 'TEST_CHILD_DISREGARD') {
return Ember.RSVP.Promise.resolve();
} else {
return this.get('session').save();
// Save the data from a completed frame to the session data item. Add to sequence and
if (frameId != this.get('_sequence')[this.get('_sequence').length - 1]) {
this.get('_sequence').push(frameId);
}
this.get('_expData')[frameId] = frameData;
this.get('session').set('sequence', this.get('_sequence'));
this.get('session').set('expData', this.get('_expData'));
// This takes a second or so! If we directly manipulate session.sequence and session.expData, we can
// end up with overlapping calls to save() that lead to data being lost. Because all of the above steps
// can be done immediately, we can keep _sequence and _expData current (and in the correct order) so that
// when we save the session we don't lose any information. (Alternately we can keep track of whether we're
// currently saving, defer the save if so, and use e.g.
// this.get('session').save().finally(() => {_this.set('_saving', false);})
return this.get('session').save();
},

next(nextFrameIndex = -1) {
Expand Down Expand Up @@ -267,7 +274,7 @@ export default Ember.Component.extend(FullScreen, {
exitType: 'manualInterrupt', // User consciously chose to exit, eg by pressing F1 key
lastPageSeen: this.get('frameIndex') + 1
});
this.get('session').save(); // I think this is the response
this.get('session').save();

// Navigate to last page in experiment (assumed to be survey frame)
var max = this.get('frames.length') - 1;
Expand Down
6 changes: 0 additions & 6 deletions app/controllers/participate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,5 @@ export default Ember.Controller.extend({
return response.get('hasDirtyAttributes');
},
actions: {
saveResponse(payload, callback) {
var response = this.get('response');
response.setProperties(payload);
response.save().then(callback);
this.set('response', response);
}
}
});
6 changes: 0 additions & 6 deletions app/controllers/preview-without-saving.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ export default Participate.extend({
toggleData() {
this.toggleProperty('showData');
this.get('_resolve')();
},
saveResponse(payload, callback) {
var response = this.get('response');
response.setProperties(payload);
response.save().then(callback);
this.set('response', response);
}
}
});
1 change: 0 additions & 1 deletion app/templates/participate.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
experiment=study
session=response
pastSessions=pastResponses
saveHandler=(action "saveResponse")
frameIndex=0
fullScreenElementId="expContainer"
}}
Expand Down
1 change: 0 additions & 1 deletion app/templates/preview-without-saving.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
experiment=study
session=response
pastSessions=pastResponses
saveHandler=(action "saveResponse")
frameIndex=0
fullScreenElementId="expContainer"
}}
Expand Down
1 change: 0 additions & 1 deletion app/templates/preview.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
experiment=study
session=response
pastSessions=pastResponses
saveHandler=(action "saveResponse")
frameIndex=0
fullScreenElementId="expContainer"
}}
Expand Down

0 comments on commit f1e34c1

Please sign in to comment.