PennController for IBEX › Forums › Support › Block n of n?
- This topic has 1 reply, 2 voices, and was last updated 2 years ago by Jeremy.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
July 4, 2022 at 8:41 am #8254SimoneParticipant
Hi Jeremy,
I’m in the process of creating an experiment in which participants will see many trials divided into 9 blocks separated by a break. To keep them motivated, I’d therefore like to inform them how far along in the experiment they are, e.g., “This is block n of 9.”
Is there any way to do that? For reference, the relevant part of my code looks as follows:
PennController.ResetPrefix(null); // Shorten command names (keep this line here)) function SepWithN(sep, main, n) { this.args = [sep,main]; this.run = function(arrays) { assert(arrays.length == 2, "Wrong number of arguments (or bad argument) to SepWithN"); assert(parseInt(n) > 0, "N must be a positive number"); let sep = arrays[0]; let main = arrays[1]; if (main.length <= 1) return main; else { let newArray = []; while (main.length){ for (let i = 0; i < n && main.length>0; i++) newArray.push(main.shift()); for (let j = 0; j < sep.length; ++j) newArray.push(sep[j]); } return newArray; } }; } function sepWithN(sep, main, n) { return new SepWithN(sep, main, n); } // Start with welcome screen, then present test trials in a random order, // and show the final screen after sending the results Sequence( "welcome" , "instructions", "practice1" , "practice2", "practice3", "practice4", "begin", sepWithN("break", randomize("test"), 108) , "send" , "final" )
July 7, 2022 at 2:06 pm #8263JeremyKeymasterHi Simone,
Your code seems perfectly fine to me (assuming you have 9 blocks of 108 test trials—if you have 9 blocks of 12 trials, you need to write
sepWithN("break", randomize("test"), 12)
). You could write your “break” trial like this, for example:newTrial("break", newVar("block_n", 0).global().set(v=>v+1) , newVar("text").set(getVar("block_n")).set(v=>"You've just finished block "+v+" of 9") , newText("prompt", "").text(getVar("text")).print() , newButton("Next").print().wait() )
Jeremy
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.