jspsych/plugins/jspsych-rdk.js
//Function that determines if the response is correct

Function that determines if the response is correct
Function that determines if the response is correct
function correctOrNot(){
			if(typeof trial.correct_choice !== 'undefined'){
				if(trial.correct_choice.constructor === Array){ 
					if(typeof trial.correct_choice[0] === 'string' || trial.correct_choice[0] instanceof String){
						trial.correct_choice = trial.correct_choice.map(function(x){return x.toUpperCase();}); 
						return trial.correct_choice.includes(String.fromCharCode(response.key)); 
					}
					else if (typeof trial.correct_choice[0] === 'number'){
						return trial.correct_choice.includes(response.key); 
					}
				}
				else{
					if(typeof trial.correct_choice === 'string' || trial.correct_choice instanceof String){
						return response.key == trial.correct_choice.toUpperCase().charCodeAt(0);
					}
					else if (typeof trial.correct_choice === 'number'){
						console.log(response.key == trial.correct_choice);
						return response.key == trial.correct_choice;
					}
				}
			}
		}
function correctOrNot ( ) { if ( typeof trial . correct_choice !== 'undefined' ) { if ( trial . correct_choice . constructor === Array ) { if ( typeof trial . correct_choice [ 0 ] === 'string' || trial . correct_choice [ 0 ] instanceof String ) { trial . correct_choice = trial . correct_choice . map ( function ( x ) { return x . toUpperCase ( ) ; } ) ; return trial . correct_choice . includes ( String . fromCharCode ( response . key ) ) ; } else if ( typeof trial . correct_choice [ 0 ] === 'number' ) { return trial . correct_choice . includes ( response . key ) ; } } else { if ( typeof trial . correct_choice === 'string' || trial . correct_choice instanceof String ) { return response . key == trial . correct_choice . toUpperCase ( ) . charCodeAt ( 0 ) ; } else if ( typeof trial . correct_choice === 'number' ) { console . log ( response . key == trial . correct_choice ) ; return response . key == trial . correct_choice ; } } } }
Function that determines if the response is correct
Function that determines if the response is correct
//Check that the correct_choice has been defined
 //If the correct_choice variable holds an array
 //If it is an array
 //If the elements are characters
 //Convert all the values to upper case
 //If the response is included in the correct_choice array, return true. Else, return false.
 //Else if the elements are numbers (javascript character codes)
 //If the response is included in the correct_choice array, return true. Else, return false.
 //Else compare the char with the response key
 //If the element is a character
 //Return true if the user's response matches the correct answer. Return false otherwise.
 //Else if the element is a number (javascript character codes)
