repeating commmands

PennController for IBEX Forums Support repeating commmands

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #6520
    sintdc
    Participant

    I need to put a slide with multiple questions and the user selects one, and the multiple question needs to be randomized between a couple of questions. We cant figure it out, any ideas?

    #6521
    Jeremy
    Keymaster

    Hi,

    I think I would need more detail to help you with your issue. Do you need to display several lines of text (questions) vertically on the page, randomly ordered, and invite your participants to click on one those lines? If so, you could do something like this:

    newTrial(
      newText("q1", "What's up?").print()
      ,
      newText("q2", "How are you doing?").print()
      ,
      newText("q3", "All good?").print()
      ,
      newText("q4", "How's it going?").print()
      ,
      newSelector("choice")
        .add( getText("q1") , getText("q2") , getText("q3") , getText("q4")  )
        .shuffle()
        .wait()
    )

    Jeremy

    #6522
    sintdc
    Participant

    Hi!

    Basically, I would need three sets of questions stores in the data base
    eg.
    1. “are you male or female?” options for multiple choice, male or female and they choose one.
    2. “what is your favorite color?” options for multiple choice, blue or purple and they choose one.
    3. “are you 20 or 25?” options for multiple choice, 20 or 25 and they choose one.

    then at certain points, have the program randomly pick one of them to display and answer, so each time a new participant goes through it, the order is random and different than the last

    Please let me know if this helped, thank you!

    #6523
    Jeremy
    Keymaster

    If you only need to print one question per slide, and want to randomly order your slides, you could do something like this:

    Sequence( randomize("mcq") )
    
    newTrial( "mcq" ,
      newText("Are you male or female?").print()
      ,
      newScale("gender", "male", "female")
        .labelsPosition("right")
        .print()
        .wait()
    )
    newTrial( "mcq" ,
      newText("What is your favorite color?").print()
      ,
      newScale("color", "blue", "purple")
        .labelsPosition("right")
        .print()
        .wait()
    )
    newTrial( "mcq" ,
      newText("Are you 20 or 25?").print()
      ,
      newScale("age", "20", "25")
        .labelsPosition("right")
        .print()
        .wait()
    )

    Now if your trial sequence is more complex and you want to randomly insert one of those trials inside at different points in your sequence, you’ll need something more sophisticated. For example, you could use the function pick from this thread, like this:

    mcqs = randomize("mcq")
    
    Sequence( "intro" , pick(mcqs,1) , randomize("block1") , pick(mcqs,1) , randomize("block2") , pick(mcqs,1) , "end" )

    Let me know if you have questions

    Jeremy

    #6530
    sintdc
    Participant

    ok thank you for your help, im having difficulties putting the questions in the specific place i need them. for example i need one question to go in slide number 13, another question in slide 15, another is 17 etc. below is what i have now but cant seem to figure it out.
    thank you

    PennController.ResetPrefix(null) // Shorten command names (keep this line here)
    // Show the 'welcome' trial first, then all the 'experiment' trial
    // then send the results and finally show the trial labeled 'final'
    Sequence( "welcome", "SampleSlides", randomize("experiment"), "final" )
    InitiateRecorder("https://plinglab.princeton.edu/IBEX/exptA/exptA-up.php").label("welcome")
    
    Header(
        // We will use this global Var element later to store the participant's name
        newVar("ParticipantName")
            .global()
        ,
        // Delay of 250ms before every trial
        newTimer(250)
            .start()
            .wait()
    )
    .log( "Name" , getVar("ParticipantName") )
    // This log command adds a column reporting the participant's name to every line saved to the results
    
    Template("Instructions.csv",
        variable => newTrial( "welcome" ,
        newImage(variable.ImageFile)
            .size(1080, 608)
            .print()
            .center()
        ,
        newButton("Next")
            .css("font-size", "1.5em")
            .print()
            .wait()
        )
    )
    
    Template("SampleSlides.csv",
        variable => newTrial( "SampleSlides" ,
        newImage(variable.ImageFile)
            .size(1368, 462)
            .print()
            .center()
        ,
        newButton("Next")
            .css("font-size", "1.5em")
            .print()
            .wait()
        )
    )
    ///putting in the questions
    Sequence( randomize("questions") )
    
    newTrial( "questions" ,
      newText("What is the sentence in the yellow dialog box doing?").print()
      ,
      newScale("Giving information", "Requesting information", "I can't tell")
        .labelsPosition("right")
        .print()
        .wait()
    )
    newTrial( "questions" ,
      newText("What did the speaker of the speaker of the yellow dialog box think in the previous panel?").print()
      ,
      newScale("The opposite of what's in the yellow box", "What's in the yellow box", "I can't tell")
        .labelsPosition("right")
        .print()
        .wait()
    )
    newTrial( "questions" ,
      newText("Who has more information about what's in the yellow dialog box?").print()
      ,
      newScale("The person saying it", "The person they're talking to", "They both know the same amount", "I can't tell")
        .labelsPosition("right")
        .print()
        .wait()
    )
    //////
    
    // This Template command generates as many trials as there are rows in myTable.csv
    Template( "myTable.csv" ,
        // Row will iteratively point to every row in myTable.csv
        variable => newTrial( "experiment" ,
            // The actual recording trials and comics start here
            newImage(variable.ImageFile)
                .size(1368, 462)
                .print()
                .center()
                .log()
            ,
    
            newMediaRecorder("recording", "audio")
                .css("font-size", "1.5em")
                .print()
                .log()
                .wait()
            ,
            newButton("Next")
                .css("font-size", "1.5em")
                .print()
                .wait()
        )
    )
    
    
    // Spaces and linebreaks don't matter to the script: we've only been using them for the sake of readability
    newTrial( "final" ,
        newText("<p>Thank you for your participation!</p>")
                .css("font-size", "1.5em")
                .print()
        ,
        newImage("Slide26.png")
                .size(1080, 608)
                .print()
                .center()
        ,
        // Uploads the recordings
        UploadRecordings("sendAsync", "noblock")
        ,
        newButton("Finish")
                .css("font-size", "1.5em")
                .print()
                .wait()
            )
    #6532
    Jeremy
    Keymaster

    Hi,

    I’m not entirely sure what “slide 13/15/17” mean in that context, because I don’t know how many trials your different Template commands generate. I don’t know what the “etc.” stands for either, since you only have three trials labeled questions, so I would expect that you only need three insertions.

    Here I will be assuming that you have a total of 26 trials labeled experiment and that you want to randomly insert one of your three trials labeled questions after 12 experiment trials, another one after one other experiment trial and the last one after yet another experiment trial, and finally run the 12 remaining experiment trials. I will be using the pick function as suggested in my message above:

    questions = randomize("questions")
    experiment = randomize("experiment")
    
    Sequence( "welcome", "SampleSlides", 
      pick(experiment,12),
      pick(questions,1), // 13
      pick(experiment,1),
      pick(questions,1), // 15
      pick(experiment,1),
      pick(questions,1), // 17
      pick(experiment,12),
      "final" 
    )

    By the way, you have two Sequence commands in your code: only one (the last one, I think) will be effective when running your experiment, so you better delete the second one (Sequence( randomize("questions") ))

    Jeremy

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.