Reply To: Displaying n words on screen

PennController for IBEX Forums Support Displaying n words on screen Reply To: Displaying n words on screen

#10560
Jeremy
Keymaster

Hello,

Template scans the table and produces one output per row. So the idea is, you use Template( row => newTrial to generate one trial per row. Listing one word per row is not the ideal way to go if you want to display several of them at the same time on the page, ie. during the same trial

What you could do is store one list of words per cell, separated with a character of your choice, say .. Here is what it would look like:

Template("items.csv", row =>
  newTrial("listOfWords",
    newMediaRecorder("recorder").log().record()
    ,
    newTimer("recording", 3000).log().start()   // Start the timer now
    ,
    newText("words", row.words1.split('.').join("<br>")) // separate each word with a <br> tag (new line)
        .cssContainer({
          "border-radius": '25px',
          border: '2px solid #73AD21',
          padding: '0.5em'  // add some to not get too close to the border
        })
        .print()
    ,
    newButton("NEXT", "Next words!")
        .callback(  // use a callback to execute this in parallel to waiting for the timer
            getButton("NEXT").remove() // remove the NEXT button
            ,
            getText("words").text( row.words2.split('.').join("<br>") ) // update the displayed list of words
        )
        .print()
        // do not wait for a click, otherwise the timer might elapse before the click
    ,
    getTimer("recording").wait() // wait for the timer to end
    ,
    getMediaRecorder("recorder").stop()
    ,
    getButton("NEXT").remove() // make sure to remove the button, in case the participant didn't get to the second list
    ,
    getText("words").remove()
    ,
    newText('a', "Time is up!").print()
    ,
    newButton('btn--finish--game', 'Finish Game').print().wait()
  )
)

Example items.csv:

words1,words2
hello.world,bye.earth
ibex.is.awesome,pcibex.rocks

Jeremy