Reply To: Questionnaire with questions on the same page

PennController for IBEX Forums Support Questionnaire with questions on the same page Reply To: Questionnaire with questions on the same page

#5561
Jeremy
Keymaster

Hi Daniela,

I would need more detail about the whole setup of your experiment, but here is an example that picks names from a table and shows them all in a single trial in a random order:

AddTable("myTable", `name,presented
John,yes
Lucrecia,no
Maggie,yes
Vincent,yes
Robert,no
Shay,yes
George,no
__,void`)

var names = [];
var test;
function handleNames(row){
    if (row.name=="__"){
        names = names.sort(v=>Math.random()>=0.5);
        return newTrial(
            ...names.map( r => {
                test = test || newFunction(v=>true).test.is(true);
                test = test.and( getScale(r.name+'-scale-'+r.presented).test.selected() );
                return newText(r.name+": ")
                    .after(
                        newScale(r.name+'-scale-'+r.presented, 5)
                            .before( newText(" I'm sure I NEVER saw this name ") )
                            .after( newText(" I'm sure I DID see this name") )
                            .log()
                            .print()
                    )
                    .print();
            })
            ,
            newButton("Send")
                .print()
                .wait( test )
        )
    }
    names.push(row);
    return [];
}


Template( "myTable", row => handleNames(row) )

I inserted the value of presented in the name of the Scale so you can retrieve the value from the results file, but I think it would be cleaner to just log the Scale score in the results file and add presented back to it from your input table when you analyze your results (in R, for example). If you have the option of defining an array in a js file rather than looking up a CSV table, as in Andrea’s case, I would do that instead, you wouldn’t need all these tricks like adding a row with __ in name.

I also had to use a trick to make sure “Send” would only proceed if all Scale elements are selected.

Jeremy