Timers

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #7325
    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
    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
    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
    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
    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
    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
    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
    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
    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
    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

    #7488
    Elias.mohammad2
    Participant

    Hi Jeremy,

    Thank you for all your help thus far. I have finished phase 1 and phase 3 of my experiment but I am struggling to create phase 2. In phase 2, I will have four separate blocks.

    The first block is the participants restudying 15-word pairs just as we did in phase 1. However, the difference is that I only need 15 of the word pairs out of 60 in that specific block. Is there any way to specify that I want that in the program?

    The second block is where the participants will study the next 15 words (16-30) where one word will be shown and then only the first three letters of the second word will be shown where they then will have to type in the rest.

    Block three and four are replications of one and two respectfulling except i need to have an audio file playing the whole time in the backround.

    So the three things that i need help with is how to specify a range of words out of the total list of 60 words, how to only show the first three letters of a words with the rest to fill in, and how to have music play in the backround for block 3 and 4.

    Best,
    Elias

    #7490
    Jeremy
    Keymaster

    Hi Elias,

    There are several different and somewhat advanced questions in your message, I won’t be able to fully address them at the moment. Maybe other users of the forums might be able to help you with them. In the meantime, let me give you pointers:

    – The command GetTable().filter lets you subset your tables. You could add a column to your table where you number your items from 1 to 60 and use filter in three different Template commands to generate trials with formats specific to each block in phase 2

    – You can use .substring(0,3) on a string to return just the three first characters, e.g. row.Word.substring(0,3). You can use the TextInput element to have people type in text, and the before/after commands to place the Text and TextInput next to each other, or place them on a Canvas element if you need more control on the visual layout

    – The Audio element will let you play audio files (which you’ll need to upload to your project or to a host space first, of course). The tutorial illustrates how to use it

    Jeremy

    #7643
    Elias.mohammad2
    Participant

    Hi Jeremy,

    I was wondering if you could help me out with an issue I have. I was trying to see if I could put specific files in a specific order. I have the files all completed but need to be placed in a specific way. Would you be able to help me with that? The order I would need it to be is consent->instructions-> questionnaire->phase 1, phase 2, and then phase 3. Here is the link also. Thanks!

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

    #7654
    Jeremy
    Keymaster

    Hi Elias,

    Use the command Sequence, as illustrated here, to control the order of presentation of your trials. For example: Sequence("consent", "instructions", "questionnaire", randomize("phase1"), randomize("phase2"), randomize("phase3")) (the details will depend on the specificities of your project, but I cannot see trials labeled “questionnaire” or “phase1/2/3” in the project at the link you shared—all three )

    Jeremy

    #7686
    Elias.mohammad2
    Participant

    Hi Jeremy,

    Is there any way to send you my project code with all the files? As in what I see when I am working on it because I am struggling to sequence it. I read the instructions and followed them but it continues to not sequence correctly.

    Best,
    Elias

Viewing 15 posts - 1 through 15 (of 18 total)
  • You must be logged in to reply to this topic.