Reply To: Issue Importing Images After Test.Is()

PennController for IBEX Forums Support Issue Importing Images After Test.Is() Reply To: Issue Importing Images After Test.Is()

#5656
Jeremy
Keymaster

We resolved this issue by email

The problem was coming from the assumption that newImage commands embedded in the success would only be evaluated in case of a successful test, but all new* commands are evaluated at the beginning of the experiment, even if they are embedded in a test command that will be evaluated upon runtime. One reason for this behavior is to let PennController preload the resources as soon as possible.

In this case, the solution was to carry out the same tests using javascript’s ternary conditional, which will effectively include the PennController commands in Template only if the test is successful, like this:

Template( "myTable.csv" , row => 
  newTrial( "trial"
    ( row.Image.match(/png$/) ?
      newImage( row.Image ).print()
    :
      newText( row.Text ).print()
    )
    ,
    newButton("Next").print().wait()
  )
)

Jeremy