How to add a "come back" button to the practice trial

PennController for IBEX Forums Support How to add a "come back" button to the practice trial

This topic contains 12 replies, has 3 voices, and was last updated by Avatar Larissa_Cury 3 hours, 8 minutes ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #7246
    Avatar
    Larissa_Cury
    Participant

    Hello!

    In my experiment, I have the following sequence: (instructions_1, practice trial, instructions_2, effective trial, send)

    I’m wondering if it’s possible to add a “come back” button on the second group of instructions in case my participant wishes to practice one more time before starting the effective trial(which will be a “game”). I’d like to add something as “if you wish to practice one more time, click here” (then it would come back to the practice trial).

    Here is the code for the second instruction page:

    newTrial("instructions_E",
      newText("instructions-2","Are you ready?")
      .cssContainer({
        "border": "5px solid black",
        "background-color": "yellow",
        "color": "black",
        "font-size":"50px"})
        .center()
        .print()
      ,
      newText("instructions-6","<p>Feel free to take a break now</p>")
        .cssContainer({
        "font-size":"22px",
        "text-align": "center"})
        .center()
        .print()
      ,
      newImage("boy-image","boy.png")
        .size(200,200)
        .center()
        .print()
      ,
      newText("instructions-7","<p><center>When you feel <b style=color:red;>READY</b>, click on the button below:</p></center>")
        .cssContainer({
        "font-size":"22px",
        "text-align": "center"})
        .center()
        .print()
      ,
      newButton("wait","START THE GAME")
        .center()
        .print()
        .wait()
    );
    

    thanks in advance!!

    • This topic was modified 1 week, 3 days ago by Avatar Larissa_Cury.
    #7249
    Jeremy
    Jeremy
    Keymaster

    Hello,

    If you don’t mind the progress bar widening as the participant goes back in the sequence, since PennController 2.0 you can do this:

    newButton("come back")
      .callback( jump("practice trial") , end() )
      .print()
    

    (that’s assuming your practice trial is literally labeled practice trial)

    Jeremy

    #7253
    Avatar
    Larissa_Cury
    Participant

    Hi, Jeremy! Thanks for your answer!

    I guess I’m doing something wrong…whenever I put the code on the second instruction page (“E”, after the practice trial), the trial ends after the practice and it doesn’t even show the other instruction (E) set.

    newTrial("instructions_E",
      newText("instructions-1","Are you ready?")
      .cssContainer({
        "border": "5px solid black",
        "background-color": "yellow",
        "color": "black",
        "font-size":"50px"})
        .center()
        .print()
    ,
    newText("instructions-6","<p>Feel free to take a break now</p>")
        .cssContainer({
        "font-size":"22px",
        "text-align": "center"})
        .center()
        .print()
    ,
    newImage("boy-image","boy.png")
    .size(200,200)
    .center()
    .print()
    ,
    newText("instructions-7","<p><center> If you want to practice again, click on the button below")
        .cssContainer({
        "font-size":"22px",
        "text-align": "center"})
        .center()
        .print()
    ,
    newButton("come back","PRACTICE AGAIN")
      .callback(jump ("intructions_D"), end () )
      .center()
      .print()
      .wait()
    ,
    newText("instructions-8","<p><center>When you feel <b style=color:red;>READY</b>, click on the button below:</p></center>")
        .cssContainer({
        "font-size":"22px",
        "text-align": "center"})
        .center()
        .print()
    ,
    newButton("wait","START THE GAME")
    .center()
    .print()
    .wait()
    );

    My practice trial, in fact, is a r(shuffle) of eight trials, that’s why I’m trying to come back to the last instruction page before the practice trial begins, I don’t know if the .callback function would apply to this: (but it would be okay if it came back to instructions_D)

    this is my actual “pratice trial” : rshuffle("p_trial_1_no_cue_UP","p_trial_1_no_cue_DOWN","p_trial_2_center_cue_UP","p_trial_2_center_cue_DOWN","p_trial_3_double_cue_UP","p_trial_3_double_cue_DOWN","p_trial_4_spatial_cue_UP","p_trial_4_spatial_cue_DOWN")

    I tried to write just “.callback(“intructions_D”)”, the instructions_E page appeared, but fun thing the button didn’t return to the instruction_D page, when I clicked on it, it just lauched the “start the game button” . This is my actual sequence sequence, I tried to simply it earlier, but maybe I’ve omitted something important:

    Sequence("instructions_A", "instructions_B", "instructions_C", "instructions_D", rshuffle("p_trial_1_no_cue_UP","p_trial_1_no_cue_DOWN","p_trial_2_center_cue_UP","p_trial_2_center_cue_DOWN","p_trial_3_double_cue_UP","p_trial_3_double_cue_DOWN","p_trial_4_spatial_cue_UP","p_trial_4_spatial_cue_DOWN"),"instructions_E", rshuffle("trial_1_no_cue_UP","trial_1_no_cue_DOWN","trial_2_center_cue_UP","trial_2_center_cue_DOWN","trial_3_double_cue_UP","trial_3_double_cue_DOWN","trial_4_spatial_cue_UP","trial_4_spatial_cue_DOWN"),"send","telaFinal");

    thanks in advance!

    #7255
    Jeremy
    Jeremy
    Keymaster

    Hi,

    You are waiting for a click on the “come back” button, so whatever comes after that wait command won’t be executed until you click the “come back” button, but because the callback commands executed upon click on that button ends the trial immediately, the commands below wait never get to be executed at all. Just remove .wait() and things will work

    You might want to replace jump("instructions_D") with jump(startsWith("p_trial_")) if you don’t want to show the practice instructions again. .callback("intructions_D") won’t work because "instructions_D" is not a command, it’s a plain string

    Jeremy

    #7264
    Avatar
    Larissa_Cury
    Participant

    Hi, Jeremy! Thanks again!!

    I did that, however, the experiment ends after the practice trial, it doens’t even show “instructions_E”

    newTrial("instructions_E",
      newText("instructions-1","Are you ready?")
      .cssContainer({
        "border": "5px solid black",
        "background-color": "yellow",
        "color": "black",
        "font-size":"50px"})
        .center()
        .print()
    ,
    newText("instructions-6","<p>Feel free to take a break now</p>")
        .cssContainer({
        "font-size":"22px",
        "text-align": "center"})
        .center()
        .print()
    ,
    newImage("boy-image","boy.png")
    .size(200,200)
    .center()
    .print()
    ,
    newText("instructions-7","<p><center> If you want to practice again, click on the button below")
        .cssContainer({
        "font-size":"22px",
        "text-align": "center"})
        .center()
        .print()
    ,
    newButton("come back","PRACTICE AGAIN")
      .callback(jump(startsWith("p_trial_1_no_cue_UP"))) -> (I guess I'm making the mistake here, because of the third parenthesis, should I put it somewhere else?)
      .center()
      .print()
    ,
    newText("instructions-8","<p><center>When you feel <b style=color:red;>READY</b>, click on the button below:</p></center>")
        .cssContainer({
        "font-size":"22px",
        "text-align": "center"})
        .center()
        .print()
    ,
    newButton("wait","START THE GAME")
    .center()
    .print()
    .wait()
    );
    #7265
    Jeremy
    Jeremy
    Keymaster

    Hi,

    Here’s a demo of what you need to do: https://farm.pcibex.net/r/OYjfNM/

    In this demo project, all the trials but “instructions_E” are dummy trials for illustration purposes, but that doesn’t matter to the logic applied

    Jeremy

    #7274
    Avatar
    Larissa_Cury
    Participant

    Hi, Jeremy!

    Thank you once more! You’re very kind, thank you.

    However, I’m doing something wrong for sure…I tried to copy and paste your code but the same thing happened, the trial ends after practice without even showing “instructions_E”. This is what I tried to do: https://github.com/LariCury/Come_Back_Code_file.git

    Ps: I didn’t know about this placeholder function! I loved it, since I have a very large code, I guess I can try to learn how to use it to make my editings simplier? (currently, I wait for the whole trial to see my changes)

    • This reply was modified 2 days, 5 hours ago by Avatar Larissa_Cury.
    #7278
    Avatar
    Lorrainy
    Participant

    Hey Jeremy and Larissa!

    I was in need of that action as well and I saw this forum open.
    So, I tried the codes and same thing happened to me. The trial ended without even showing the one with the callback function.

    After many attempts I got this and IT WORKED!! (This is based on my experiment though)

    newButton("botao6", "Voltar")
        .callback(jump("pratica1", end()))
        .center()
        .cssContainer({"margin-bottom":"1em"})
        .print()
        ,
        newButton("botao7", "Seguir")
        .center()
        .cssContainer({"margin-bottom":"1em"})
        .print()
        .wait()
    );

    So, the problem was on the order of the parenthesis at the .callback action.

    HOWEVER, If the participant wants to practice again he has to press the button entitled “Voltar” and after that, also press the one with the name “Seguir”. And if he doesn’t needs another practice he only has to press the “Seguir” one. Did it make sense?

    I’m still trying to make the buttom “”Voltar” work alone, without having to press the other one as well…

    Here’s my link at the moment: https://farm.pcibex.net/r/WzOKfG/

    Thanks Jeremy for the tips, I’m loving it

    #7280
    Jeremy
    Jeremy
    Keymaster

    Hi Larissa,

    You script works fine when I try it myself: https://farm.pcibex.net/r/vjsHXy/
    (I had to make a couple minor adjustments to the images and create a dummy table to make this project run—don’t hesitate to share your own project’s demonstration link in the future so we can see your code in its original environment and test it without making those edits)

    Lorrainy: your callback command should be .callback( jump("pratica1") , end() )—when I apply this edit to (a copy of) your project, it works as expected: the experiment goes back to “pratica1” as soon as I click the “Voltar” button, I don’t need to click the “Seguir” one

    Jeremy

    #7281
    Avatar
    Lorrainy
    Participant

    Tried again like you said and it worked!! (Might have been something else before…)

    Thanks Jeremy

    #7288
    Avatar
    Larissa_Cury
    Participant

    Hi, Jeremy!!

    Now it’s working, thank you very very very much!!! Indeed, a final question: is there a “ctrl+F” function that we could use on a PCIBEX script?

    Glad to hear that your project worked too, Lorrainy!!

    #7290
    Jeremy
    Jeremy
    Keymaster

    Hi,

    Yes, there is a Ctrl+F function, you access it by pressing… Ctrl+F 😉

    (on MacOS, it’s Apple+F, and make sure you have your cursor in the editor—click ‘+’ to open the replace field)

    Jeremy

    #7292
    Avatar
    Larissa_Cury
    Participant

    Hi, Jeremy,

    OMG, I can’t believe It was there all this time, so simple!! Thank you once more, you’re the best!

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.