Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Restrict allowed choices in touch response

Hi,

I'm trying to set up a Wisconsin Card Sorting Test for OSweb. However, I'm stuck trying to figure out a way to restrict the input of a touch response.

At the moment I have this inline JavaScript set to run:

allowedResponses = [1, 2, 3, 4];

while (!allowedResponses.includes(this.response)) {
  this.exp.items.run("touch_response");
}

But it just loops to infinity after the first user input.

This is the task structure:


Has anyone got this to work?

Comments

  • Hi @SpacePenguins ,

    A bit clunky, but you can place the touch_response inside a loop-sequence structure, and then use a repeat_cycle item to repeat the touch_response until a particular criterion is met. Like so:

    Hope this helps!

    — Sebastiaan

  • Hi @sebastiaan

    Thanks for you solution!

    'response not in [1,2,3,4]'

    did not work, but I changed it to:

    'response == 5 or response == 6 or response == 7 or response == 8'

  • Another way of doing this is to have a inline javascript instead of a repeat cycle block.

    In the prepare part of the javascript you can define what squares are allowed or not allowed to be clicked.

    vars.buttonsGridPos = [15,16,17,18,19,20,21]
    

    And in the run part of the script:

    if (buttonsGridPos.includes(response)) {
        repeat_cycle = 0
    }
    else {
        repeat_cycle = 1
    }
    
    


Sign In or Register to comment.