Make it easy to skip stages/steps based on treatment
Is there a recommended way of doing this in the current version? Thanks!
Right now you may implement a shadow step. Modify the step callback as follows:
cb: function() {
if (node.game.settings.treatmentName === 'X') node.done();
// Step code follows for other treatments.
}
Ah makes sense, thanks for the quick response!
You are welcome!
When skipping stages/steps based on treatment using this approach, is there an elegant way to show the true next step in the VisualRound in the header? With this approach the VisualRound would still show the name of the shadow step as the upcoming step. Thanks!
You are right the VisualRound gets confused. I will push an update to deal with this situation asap. The VisualStage instead can be easily tricked by setting the "name" step property of the shadow step to the desired value.
I have pushed an update on the development branch of nodegame-widget. Until this is taken care of in a more systematic way, the preprocess option will do the trick:
https://github.com/nodeGame/nodegame/wiki/VisualRound-Widget-v6#options-available-in-development-version
To update check this page:
https://github.com/nodeGame/nodegame/wiki/nodeGame-Update-v6
Thanks! I am also experiencing a problem with the shadow step. In extendStep in the frame attribute, I set something like this.skip ? "A.htm" : "B.htm" in the shadow step. However, this results in noticeable flickering in loading A.htm when moving from the shadow step to the actual step. Do you have any ideas how to fix this? Thanks.
this.skip ? "A.htm" : "B.htm"
Might not work as expected, unless you are wrapping it inside a function the "this" reference is not the node.game. It depends where you defined the "skip." You could you the treatmentName variable, or doing
frame: function() { return this.skip ? "A.htm" : "B.htm" };
That said, the flickering might stay. If the flickering is due to loading a different frame, make sure you load the right one. However, if the flickering is due to the waitScreen, you may consider disabling the waitScreen on exit of the step before and re-enabling it in the exit callback of the shadow step.
stager.extendStep('step_before', { // ... exit: function() { W.init({ waitScreen: false; }); // If this fails, try moving it into the cb function instead. }};
stager.extendStep('step_shadow', { // ... exit: function() { W.init({ waitScreen: true; }); }};
Notice that if you have a single-player game, you may set the waitScreen to false in the init function of the game.
Let me know if you manage to solve this issue.
Am Fr., 29. Jan. 2021 um 12:49 Uhr schrieb chengemily < [email protected]>:
Thanks! I am also experiencing a problem with the shadow step. In extendStep in the frame attribute, I set something like this.skip ? "A.htm" : "B.htm" in the shadow step. However, this results in noticeable flickering in loading A.htm when moving from the shadow step to the actual step. Do you have any ideas how to fix this? Thanks.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nodeGame/nodegame/issues/112#issuecomment-769759082, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHJM5F7LXH5PZVGOOPJNSTS4KOF7ANCNFSM4KDXD72A .
Thanks for the suggestions! I've implemented getting the frame in a callback as well as disabling the waitScreen. But the flickering persists as the frame needs to reload every time. Will let you know if I figure it out.
Then you could try this:
frame: { reload: false, uri: 'A.htm' }
Am Fr., 29. Jan. 2021 um 15:39 Uhr schrieb chengemily < [email protected]>:
Thanks for the suggestions! I've implemented getting the frame in a callback as well as disabling the waitScreen. But the flickering persists as the frame needs to reload every time. Will let you know if I figure it out.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nodeGame/nodegame/issues/112#issuecomment-769843370, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHJM5GI2FEBXICYKQVBJZDS4LCBJANCNFSM4KDXD72A .
Great thank you, it works!
v7 available in the @dev install allows the selection of game sequence based on treatment.
E.g.,
module.exports = function(treatmentName, settings, stager, setup, gameRoom) {
stager
.next('instructions')
.next('survey')
.step('demographics')
.step('block1')
.step('block2')
.next('end')
if (treatmentName === 'block1') {
stager.skip('block2');
}
else {
stager.skip('block1');
}
};