nodegame icon indicating copy to clipboard operation
nodegame copied to clipboard

Make it easy to skip stages/steps based on treatment

Open shakty opened this issue 6 years ago • 13 comments

shakty avatar Jan 07 '20 10:01 shakty

Is there a recommended way of doing this in the current version? Thanks!

chasemcd avatar Nov 24 '20 17:11 chasemcd

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.
}

shakty avatar Nov 24 '20 19:11 shakty

Ah makes sense, thanks for the quick response!

chasemcd avatar Nov 24 '20 19:11 chasemcd

You are welcome!

shakty avatar Nov 24 '20 20:11 shakty

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!

chengemily avatar Jan 25 '21 14:01 chengemily

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.

shakty avatar Jan 25 '21 20:01 shakty

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

shakty avatar Jan 27 '21 09:01 shakty

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.

chengemily avatar Jan 29 '21 11:01 chengemily

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 .

shakty avatar Jan 29 '21 12:01 shakty

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.

chengemily avatar Jan 29 '21 14:01 chengemily

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 .

shakty avatar Jan 29 '21 14:01 shakty

Great thank you, it works!

chengemily avatar Feb 04 '21 15:02 chengemily

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');
    }
};

shakty avatar Aug 30 '21 12:08 shakty