| Reference | Downloads | Github

Block break text at the end of the experiment

URL of experiment:

Description of the problem: hello. I have two test blocks in my experiment, where participants take a 60 sec break in between. I show a text which announces the break time (i.e., “break announcement text”). I wrote a code to prevent the break announcement text to show up at the end of the second block, because its basically the end of the experiment. The code reads as follows:

at the very beginning of the js code, i put:
var c;

in the “function experimentInit()”, i put:
c = 0;

then comes the following:

function block_breakRoutineBegin(trials) {
  return function () {
    //------Prepare to start Routine 'block_break'-------
    t = 0;
    block_breakClock.reset(); // clock
    frameN = -1;
    let continueRoutine = true;
    // update component parameters for each repeat

//below is critical
    c += 1;
    if ((c === 2)) {
        continueRoutine = false;
// above is critical
    skipToNewBlock.keys = undefined;
    skipToNewBlock.rt = undefined;
    _skipToNewBlock_allKeys = [];
    // keep track of which components have finished
    block_breakComponents = [];
    for (const thisComponent of block_breakComponents)
      if ('status' in thisComponent)
        thisComponent.status = PsychoJS.Status.NOT_STARTED;
    return Scheduler.Event.NEXT;

I bolded the critical part (c +=1; and if c == 2, skip the routine). In psychopy, I put this code in the “begin routine” tab.

however, although it works perfectly on psychopy builder, it presents the break announcement text right before the “end of experiment” text (or at the end of the second block, lets say) nevertheless.

how can I solve this problem?

thank you so much in advance, tutku

edit: opps, i couldnt bold anything really. but added a comment to emphasize the critical part of the code