Timers

This topic contains 9 replies, has 2 voices, and was last updated by Jeremy Jeremy 1 week, 1 day ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #7325
    Avatar
    Elias.mohammad2
    Participant

    For my project, I am struggling to set up a timer for two different columns in my Stroop file. My two columns are “word” for the words to be presented and “transition” for the transition between each shown flashcard meaning that that column is empty. The word column is set to 6000ms while I need the transition column to be only 2000 ms. When this is listed, it works

    newTimer(6000).start().wait()
     )
      .log( "word"    , row.Word       ) 
    )
    

    However, when I used the other code for the transition column, it did not work and gave me the error “There must be some items in the running order”.

    newTimer(2000).start().wait()
      )
    .log( "transition"    , row.Transition      ) 
    )
    

    This is the beginning of the script before the timers.

    Template("Word Pair List .csv" , row => 
      newTrial( "experimental-trial" ,
        defaultText.center()           
        ,
        newText("word", row.Word)      
            .css("font-size", "24pt") 
            .log()                     
            .print()
        ,
        newText("transition")       
            .log()                     
            .print()
        ,
    

    Does anyone have any suggestions for this? Thank you in advance!

    #7326
    Jeremy
    Jeremy
    Keymaster

    Hello,

    It would help if you could share the demonstration link to a project that exhibits the problem. When I try to complete the beginning of the script with either pieces of code, things run normally

    This works:

    Template("Word Pair List .csv" , row =>
      newTrial( "experimental-trial" ,
        defaultText.center()           
        ,
        newText("word", row.Word)      
            .css("font-size", "24pt") 
            .log()                     
            .print()
        ,
        newText("transition")       
            .log()                     
            .print()
        ,
        newTimer(2000).start().wait()
      )
      .log( "transition"    , row.Transition      ) 
    )

    and this works too:

    Template("Word Pair List .csv" , row =&g; 
      newTrial( "experimental-trial" ,
        defaultText.center()           
        ,
        newText("word", row.Word)      
            .css("font-size", "24pt") 
            .log()                     
            .print()
        ,
        newText("transition")       
            .log()                     
            .print()
        ,
        newTimer(6000).start().wait()
     )
      .log( "word"    , row.Word       ) 
    )

    Here is my mock Word Pair List .csv table, for reference:

    Word,Transition
    hello,transition1
    world,transition2

    Jeremy

    #7327
    Avatar
    Elias.mohammad2
    Participant

    Hi Jeremy,

    Sorry, I should have clarified. I need both timers because I want the word column to be 6 seconds while the transition to be only 2 seconds.

    Here is the link: https://farm.pcibex.net/r/iAXgPj/

    Elias

    #7329
    Jeremy
    Jeremy
    Keymaster

    You get this error message because you are attempting to close the content of newTrial( twice:

        ,
        // Wait 1s before moving to the next trial
        newTimer(6000).start().wait()
      )
      .log( "word"    , row.Word       ) // Append the value of 'Word' at the end of the results lines
    
        newTimer(2000).start().wait()
      )
      .log( "transition"    , row.Transition      ) // Append the value of 'Word' at the end of the results lines
    )

    The first lone ) in this code matches the ( of the newTrial( above in your code. The next .log line applies to that newTrial(...) object whose content was just closed with the preceding ). However, on the next line, you are trying to add yet another newTimer element, even though that line is no longer placed inside the parentheses of a newTrial: that does not make sense to the script, which for all it knows is inside the parentheses of Template, but is done with the newTrial(...) it has already processed at that point. Because newTrial has already been closed, the next lone ) matches the remaining open (, which is the one from the Template( above in your code. Accordingly, the last .log command applies to that Template(...) object, but there is no log command on such objects, only on newTrial(...) objects (and on trial-internal elements, but they have a different meaning). Finally, the very last lone ) matches nothing, because at that point in your script there’s no open ( left

    You can see short error messages about those issues in the text editor on your project’s page, if you move your cursor over the red X icons that appear to the left of the line numbers

    What you probably want is this:

    Template("Word Pair List .csv" , row =>
      newTrial( "experimental-trial" ,
        defaultText.center()            // Horizontally center all Text elements automatically
        ,
        newText("word", row.Word)       // Show the text from the 'Word' column
            .css("font-size", "24pt")   // Increase the font size
            .log()                      // Reports when the Text is displayed in the results file
            .print()
        ,
        newTimer(6000).start().wait()   // Give 6s to read the word
        ,
        getTex("word").remove()         // Take the word off the page
        ,
        newTimer(2000).start().wait()   // Wait 2s on the empty page
      )
      .log( "word"        , row.Word       ) // Append the value of 'Word' at the end of the results lines
      .log( "transition"  , row.Transition ) // Append the value of 'Transition' at the end of the results lines
    )

    Let me know if you have questions

    Jeremy

    #7338
    Avatar
    Elias.mohammad2
    Participant

    Jeremy,

    Thanks for the help and the advice. It worked great now!

    Another question I have is that for a later phase (phase 3.js) in my project, I am using the same parameters except I am now testing the participants with the second word of the word pair. So on the screen of “word” I would want to have a text box that they would have to fill out the answer to the one word I present in front of them. On top of that, I want it to assess it and give feedback if it is correct or not (Incorrect is also if they run out of time). Is this possible? I will send you my link for you to see what I have tried. Thanks for the help again!

    Link: https://farm.pcibex.net/r/iAXgPj/

    Elias

    #7342
    Jeremy
    Jeremy
    Keymaster

    Hi Elias,

    As you can see in the Errors tab of the Debug window, your column is named CorrectKey and not CorrectKey (note the space character at the beginning)

    You should have a wait command before your test.text, because otherwise the script will rush through the lines even before the participant has had time to type anything in the box, so the test will necessarily fail (because the box is initially empty). Also note that the CorrectKey cells in your CSV table that do have some text in them all start with a space character, and the third one additionally ends with a space characters: those matter, and unless your participant types space characters in the box at the exact same place, the test will fail too; you probably want to remove those space characters from the cells

    Once you fix those issues, you should get something functional and close to what you want

    Jeremy

    #7360
    Avatar
    Elias.mohammad2
    Participant

    Hi Jeremy,

    Thank you for the help! I followed your instructions and it seems to work but the text box isn’t shown as well the timer not being in effect. Do you see where the issue is?

    https://farm.pcibex.net/r/iAXgPj/

    Elias

    #7361
    Jeremy
    Jeremy
    Keymaster

    Hi Elias,

    You never print the TextInput element so it won’t appear on the page. Your script gets stuck on its wait command because, the element not being displayed on the page, you cannot press Enter to validate it.

    I suspect that what you want is:

    newTimer("allotted time", 6000).start()
    ,
    newTextInput("feedback", "Enter your answer")
        .log()
        .lines(0)
        .size(400, 200)
        .print()
        .callback( getTimer("allotted time").stop() )
    ,
    getTimer("allotted time").wait()
    ,
    getText("word").remove()         // Take the word off the page
    ,
    getTextInput("feedback")
        .remove()
        // .wait( getTextInput("feedback").test.text(/^.+[\r\n].+[\r\n].+$/) )
        .test.text( row.CorrectKey )
        .success( newText("Good job!").print() )
        .failure( newText("Wrong anwser!").print() )
    ,
    newTimer(2000).start().wait()   // Wait 2s on the empty page

    Jeremy

    #7369
    Avatar
    Elias.mohammad2
    Participant

    Hi Jeremy,

    That definitely helped so thank you but for some reason, the textbox is still not showing. Not sure if I messed up the code anywhere else but would you mind giving it a look and seeing where the problem might be. Thanks!

    https://farm.pcibex.net/r/iAXgPj/

    Elias

    #7371
    Jeremy
    Jeremy
    Keymaster

    You are not properly closing your newTrial and Template commands: you need to add two closing parentheses after line 56 of your file Phase 3.js, as hinted at by the message that appears when you move your cursor over the red cross signaling an error:

    You can see short error messages about those issues in the text editor on your project’s page, if you move your cursor over the red X icons that appear to the left of the line numbers

    Jeremy

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

You must be logged in to reply to this topic.