lundi 23 août 2021

Creating multiple correct answers based on reaction time AND correct response (While loops and if statements)

I'm trying to create an experiment in Gorilla experiment builder that uses specific js Gorilla hooks.

I want 3 types of screens a participant could be redirected to: A "correct fast" screen ( if they answer under 2 seconds), a "correct slow" screen (if they answer over two seconds), and an "incorrect" screen (if they give the wrong response).

Here is the code I have. The first while loop works, but it fails as soon as it tries to redirect participants to something other than the "correct fast" screen.

I'm not an expert with javascript at all, so this might just be the way I've written it but I can't seem to figure it out.

            //If the RT is FAST (less than 2 seconds AND correct, move to a correct fast screen)
         var reactionTime = gorilla.readStopwatch();    
          while  (reactionTime <=2000) {
          if (response == "g") {
                

                        return { new_screenName: 'Correct_fast'};
                
            //If the RT is slow but still correct, move to a correct slow screen.     
            }  while  (reactionTime >2000) {
                if (response == "g") {
            
             return { new_screenName: 'Correct_slow'};
             
            //If the response is incorrect, move to an incorrect screen.  
             
           } else if (response == "h") {
                
                return { new_screenName: 'Incorrect'};
                
         
        
            

        
        
        
    }
        } 
    }
        }
    }

}); '''

Aucun commentaire:

Enregistrer un commentaire