Proceeding to the next trial based on different conditions

PennController for IBEX Forums Support Proceeding to the next trial based on different conditions

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #7764
    supadhye
    Participant

    Hi Jeremy,

    In the current version of my experiment, I ask participants to type their response into a textbox, which is then checked for validity. If the response is valid, the participant moves on to the next trial. However, if it is invalid, the participant can re-attempt the response as long as they get it right.

    In addition to this, I want to add a ‘skip’ button functionality to prevent participants from staying on the same trial for a long. I tried to implement this using a timer such that the first incorrect response initiates the timer which allows the participant to revise and resubmit before timeout. However, this doesn’t seem to be working as intended since the participant remains on the trial beyond the time limit if their first attempt is incorrect. Below is the code I attempted:

     newKey("Enter")
                // wait for 'Enter' key press
                .wait(
                    // check response
                    getTextInput("response").test.text(new RegExp("^" + "[" + row.target.charAt(0) + "|" + row.distractor.charAt(0) + "]"  + ".+" + "["+row.target.substr(-1) +"|" + row.distractor.substr(-1) + "]" + "$", "i"))
                        .failure(
                            // prompt user
                            newText("ERROR! Please type the name of the object").center().print(),
                            newTimer("timeout",5000).start().wait()))

    I also tried to implement a ‘skip’ button which is enabled when the first attempt at the response is invalid. However, in this case, the participant is unable to move to the next trial when their response is correct and they hit ‘Enter.’

    I’m new to PCIbex, so wanted some advice on how I could allow the participant to either (i) proceed to the next trial if their answer is correct (regardless of the attempt number) or (ii) click a ‘skip’ button which allows them to proceed with an incorrect response but only after their first attempt.

    #7765
    Jeremy
    Keymaster

    Hi,

    You can replace newTimer("timeout",5000).start().wait() with newButton("Skip").callback( end() ).print() to print a Button element which, when clicked, will end the trial immediately

    Your current code (re)starts a new Timer element whenever the participant presses Enter from within the input box, and tell PennController to wait for it to elapse before proceeding, regardless of whether a new, correct response is given before its end

    Jeremy

    #7773
    noedoc1
    Participant

    Hi Jeremy!
    I have a similar problem to supadhye’s.
    I have a completion experiment and I want to impose two limits on the completions:
    – I want participants to complete two or more words, not only one (this I have already done)
    – and I want a time limit. So, for example, if a participant is more than one minute in the experiment, I want it to automatically pass on to the next trial and an error message that says: “Too slow”.

    So far I have this, but it is not working: the timer doesn’t stop the trial and the error message doesn’t appear. Do you have any suggestions?

    
    // Practica 1
    newTrial("p1",
    newText("Complete con lo primero que venga a su mente, recuerde que tiene que ser más de una palabra:</p></p>")
        .center()
        .color("blue")
        .print()
    ,
    newTextInput("rta_p1") 
        .css("font-size", "14px")
        .center()
        .before(newText("La señora empujó al padre del niño que "))
        .log()    
        .lines(0)
        .size(250, 22)
        .print()
    ,
    newTimer("hurry", 1000)
        .start()
    ,
    getTimer("hurry")
        .test.ended()
        .success(newText("lento", "¡Muy lento!").print(), getTextInput("rta_p1"))
    ,
    newButton("prox", "Próxima")
        .css("font-size", "medium")
        .css("margin","1em")
        .color("blue")
        .center()
        .print()
        .wait(getTextInput("rta_p1").test.text(/^\s*\S+(?:\s+\S+)+\s*$/)
        .failure(newText("Es necesario completar el recuadro con más de una palabra para pasar a la próxima oración").center().color("red").print()))
    )
    

    Also here’s the demonstration link: https://farm.pcibex.net/r/ooxFkv/

    Thanks a lot!

    Noelia.

    #7778
    Jeremy
    Keymaster

    Hi Noelia,

    PennController commands are linearly executed in a top-down fashion. In your code, once PennController reaches newTimer("hurry", 1000).start(), it starts a 1s timer and immediately moves on to the next command, which is getTimer("hurry").test.ended().success(newText("lento", "¡Muy lento!").print(), getTextInput("rta_p1")). Because you just started the timer, of course the test will fail, so you will never see the Text element named “lento” printed on the page

    Use a callback command to tell PennController to execute commands not linearly, but instead upon the occurrence of the relevant event associated with the type of element on which you use callback. And if you want the participant to click “Próxima” to move on to the next trial after the timer has elapsed, just add your Timer element’s test as a disjunct (or) in the Button element’s wait:

    newTimer("hurry", 60000)
      .callback(
        clear() // remove all elements from the page
        ,
        newText("lento", "¡Muy lento!").print() // print your message
        ,
        getButton("prox").print() // re-print the button, below the message
      )
      .start()
    ,
    newButton("prox", "Próxima")
        .css({margin: "1em", "font-size": "medium"})
        .color("blue")
        .center()
        .print()
        .wait(
          getTimer("hurry").test.ended().or( // validate click if the timer has elapsed...
            getTextInput("rta_p1")           
              .test.text(/^\s*\S+(?:\s+\S+)+\s*$/)  // ... or if there are at least two words in the box
              .failure(
                newText("Es necesario completar el recuadro con más de una palabra para pasar a la próxima oración")
                  .center()
                  .color("red")
                  .print()
              )
          )
        )
    

    Jeremy

    #7785
    noedoc1
    Participant

    Hi Jeremy!
    Thanks for the explanation and the code. I’ve tried it and it worked perfectly.
    Thanks for all your patience!

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