Created
May 4, 2017 15:17
-
-
Save dgbrokaw/f00c1bc2943d4ee550a739c411bec118 to your computer and use it in GitHub Desktop.
jsPsych trial shuffle + loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Timeline Demo</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script> | |
<script src="jspsych-master/jspsych.js"></script> | |
<script src="jspsych-master/plugins/jspsych-text.js"></script> | |
<link href="jspsych-master/css/jspsych.css" rel="stylesheet" type="text/css"></link> | |
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/black-tie/jquery-ui.min.css" rel="stylesheet" type="text/css"></link> | |
</head> | |
<body> | |
<div id="jspsych-target"></div> | |
</body> | |
<script> | |
var txt1 = "1"; | |
var txt2 = "2"; | |
var txt3 = "3"; | |
var txt4 = "4"; | |
var txt5 = "5"; | |
var text_t1 = { | |
type: 'text' | |
, text: txt1 | |
} | |
var text_t2 = { | |
type: 'text' | |
, text: txt2 | |
} | |
var text_t3 = { | |
type: 'text' | |
, text: txt3 | |
} | |
var text_t4 = { | |
type: 'text' | |
, text: txt4 | |
} | |
var text_t5 = { | |
type: 'text' | |
, text: txt5 | |
} | |
var text_trials = [text_t1, text_t2, text_t3, text_t4, text_t5]; | |
var text_block = { | |
timeline: jsPsych.randomization.shuffle(text_trials) | |
, choices: [13, 48] | |
, loop_function: function() { | |
return jsPsych.data.getLastTrialData().values()[0].key_press !== 48; | |
} | |
} | |
jsPsych.init({ | |
timeline: [text_block] | |
}); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment