Reply To: setCounter with more than 1 item per list

PennController for IBEX Forums Support setCounter with more than 1 item per list Reply To: setCounter with more than 1 item per list

#7450
Jeremy
Keymaster

Hi Jones,

I think I understand what you were trying to do: you were repeating the code as many times as you have items in your CSV table. As a result, you did have 8 trials, but each showing 8 of what I called panels.

I invite you to read the page “Creating a trial template” from the tutorial. As you’ll see, the Template command takes each row from the table and essentially duplicates the one newTrial command you pass as many times, replacing the row. bits with cell values

So what you’re after is simply this:


Template(
    GetTable( "test_table" ).setGroupColumn( "Liste" )
    ,
    row => newTrial( "Trial" ,
        defaultImage.css("margin","1em")
        ,
        newImage("Header","Zeitungsheader.png").center().print(),
        newImage("Subheader","Subheader.png").center().print()
        ,
        newCanvas("Überschrift_nebeneinander","auto","auto")
            .add(420,40, newTextInput("Überschrift_Korrektur").size(200,140) )
            .print()
        ,
        newImage("Absatz",row.Absatz).print( getCanvas("Überschrift_nebeneinander") )
        ,
        newButton("Weiter","Weiter zur nächsten Seite").center().print().wait()
    )
    .log( "Group" , row.Liste  )
    .log( "Text"  , row.Absatz )
)

This, however, will only print one image on the page at a time. If you want to print two images on the page at a time, I invite you to restructure your table so you reference the pairs of images that you want to display together on each row. For example (note that I format this table as you would write it directly in a CSV file in your project’s Resources folder, and not using the AddTable command):

Liste,TopImage,BottomImage
Liste1,1Uberschrift.png,1Absatz1.png
Liste2,Uberschrift.png,Absatz1.png
Liste1,1Absatz2.png,1Absatz3.png
Liste2,Absatz2.png,Absatz3.png
Liste1,1Absatz4.png,1Absatz5.png
Liste2,Absatz4.png,Absatz5.png
Liste1,1Absatz6.png,1Absatz7.png
Liste2,Absatz6.png,Absatz7.png

Of course you would then need to include two Canvas pieces in the newTrial and replace row.Absatz with row.TopImage in the first piece, and with row.BottomImage in the second

Jeremy