Reply To: difficulties calling getTextInput on elements within the same trial and reg exp

PennController for IBEX Forums Support difficulties calling getTextInput on elements within the same trial and reg exp Reply To: difficulties calling getTextInput on elements within the same trial and reg exp

#8385
Jeremy
Keymaster

Hi Kavita,

I think those errors came from a previous version of the script, maybe the latest changes failed to be saved when you tested the experiment. When I test the experiment at the link you provided, I see no errors, and same thing if I create a new project and paste the code from your message. Everything behaves as expected, namely clicks on the buttons only validate the wait commands if the referenced TextInput element have some text in them

Also, would you recommend putting all GJT items into the experiment trial rather than creating a number of separate GJT items as separate trials?

This is entirely your call, but what I would recommend is try to find some recurring pattern and avoid manually typing repeating commands. For example, if you decide to create separate trials, you could list the details of each trial in a table (say, gjt.csv) and use Template, eg:

Template( "gjt.csv" ,
  newTrial("experiment",
    defaultText.center().print()
    ,
    newText("Instructions", "You will now read a sentence in English and need to judge whether you think the sentence is grammatically correct or not. Here you are not interested in the content or words or punctuation, just the form. After you decide whether the sentence is ungrammatical or not, please indicate for ungrammatical sentences how you would fix them so that they become grammatical.")
    ,
    newText("Example", "For example, if you read the sentence The cat chased mouse, you would click on the Ungrammatical button and then type a correction into the box: the mouse.")
    ,
    newText("D1", row.sentence ).bold() // assuming you list the sentences in a column named 'sentence' in gjt.csv
    ,
    newText("instructions2", "Please type G if you think the above sentence is grammatically correct, U if you think it is not grammatically correct or DK if you don't know:")
    ,
    defaultTextInput.center().lines(0).size(600,50).log().print()
    ,
    newTextInput("d1GJT", "")
    ,
    newText("CorrectionInstruction", "If you think the sentence above is ungrammatical, please fix the grammar mistake by typing the correct form in the box below:")
    ,
    newTextInput("correctionD1","")
    ,
    newText("NextPage", "Once you have answered the above questions please click Next below to go to the next question.")
    ,
    newButton("nextQ", "Next Question")
        .print()
        .wait(getTextInput("d1GJT").test.text(/.+/) )
  )
)

Jeremy