Conditional feedback based on DragDrop response

PennController for IBEX Forums Support Conditional feedback based on DragDrop response

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8297
    mawilson
    Participant

    I’m setting up a task where participants drag a word into one of two possible positions left open in a sentence. I want to have a training phase in the experiment where participants are provided different feedback based on whether they chose the correct position for the word or the wrong position.

    This is the DragDrop I have at the moment (here’s a link to the experiment, https://farm.pcibex.net/r/PtpjPM/):

    
    newDragDrop("dd", "bungee")
        .log("all")
        .addDrop(getText(first_arg), getText(second_arg))
        .addDrag(getText("word"))
        .offset('0.5em', '0.1em', getText(first_arg), getText(second_arg))
        .wait()
        .callback(getMouseTracker("mouse").stop())
        .removeDrag(getText("word"))
        .removeDrop(getText(first_arg), getText(second_arg))
    

    first_arg and second_arg are the labels of the boxes where the word can be dropped, and I have a variable target_res that is defined to be equal to one of them (with its value depending on which of a random set of words was chosen for that trial). However, I can’t seem to figure out how to add a condition to the callback function that depends on which box the word was dropped on (i.e., that depends on whether target_res is equal to the label of the box the user dropped the word on).

    If it was dropped on the wrong box, I want to display some error text and (ideally if possible) allow the participant to move the word again until they get it right. If it was dropped on the right box, I want to display a confirmation message before continuing on.

    #8299
    Jeremy
    Keymaster

    Hi,

    EDIT: actually you do need callback if you want to only move on when dropping in the right box:

    newText("yes"),newText("no", "drop in the other box")
    ,
    		
    newDragDrop("dd", "bungee")
    	.log("all")
    	.addDrop(
    		getText(first_arg), 
    		getText(second_arg)
    	)
    	.addDrag(getText("word"))
    	.callback( 
    	    getText("yes").remove(),getText("no").remove()
    	    ,
    	    self.test.dropped( getText(target_res) )
            	.success( getText("yes").print() )
            	.failure( getText("no").print() )
    	)
    	.offset('0.5em', '0.1em', 
    		getText(first_arg), 
    		getText(second_arg)
    	)
    	.wait( self.test.dropped(getText(target_res)) )
    	.removeDrag(getText("word"))
    	.removeDrop(
    		getText(first_arg), 
    		getText(second_arg)
    	)
    ,
    
    getMouseTracker("mouse").stop()
    ,

    End of EDIT

    You don’t need to use callback, just test whether the Text element whose name corresponds to the value of target_res is the one that received the draggable element after wait:

    newDragDrop("dd", "bungee")
    	.log("all")
    	.addDrop(
    		getText(first_arg), 
    		getText(second_arg)
    	)
    	.addDrag(getText("word"))
    	.offset('0.5em', '0.1em', 
    		getText(first_arg), 
    		getText(second_arg)
    	)
    	.wait()
    	.test.dropped( getText(target_res) )
    	.success( newText("yes").print() )
    	.failure( newText("no").print() )
    	.removeDrag( getText("word") )
    	.removeDrop(
    		getText(first_arg), 
    		getText(second_arg)
    	)
    ,
    
    getMouseTracker("mouse").stop()
    ,

    Jeremy

    • This reply was modified 1 year, 8 months ago by Jeremy.
    #8303
    mawilson
    Participant

    Thank you for the help—this is working great now!

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