mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-12 16:48:12 +00:00
66 lines
2.0 KiB
HTML
66 lines
2.0 KiB
HTML
<!doctype html>
|
|
<html>
|
|
|
|
<head>
|
|
<title>jspsych-free-sort plugin example</title>
|
|
<!-- jQuery -->
|
|
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
|
<!-- requires jQuery UI library as well -->
|
|
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
|
|
<!-- jsPsych -->
|
|
<script src="scripts/jspsych.js"></script>
|
|
<script src="scripts/plugins/jspsych-free-sort.js"></script>
|
|
<!-- style -->
|
|
<style>
|
|
#jspsych_target {
|
|
margin: 50px auto 50px auto;
|
|
width: 800px;
|
|
font-size:18px;
|
|
text-align: center;
|
|
}
|
|
#instructions {
|
|
text-align: left;
|
|
}
|
|
pre {
|
|
text-align: left;
|
|
}
|
|
img {
|
|
width: 100px;
|
|
border: 1px solid #ccc;
|
|
}
|
|
#sort_arena {
|
|
border: 1px solid black;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="jspsych_target"></div>
|
|
</body>
|
|
<script type="text/javascript">
|
|
// declare an array to hold the stimuli
|
|
var sorting_stimuli = [];
|
|
for (var i = 1; i <= 12; i++) {
|
|
sorting_stimuli.push("img/cell_img_" + i + ".jpg");
|
|
}
|
|
|
|
// create free-sort block for jspsych
|
|
var sort_block = {
|
|
type: 'free-sort',
|
|
stimuli: [sorting_stimuli],
|
|
prompt: "<p>Click and drag the images below to sort them so that similar items are close together.</p>"
|
|
};
|
|
|
|
// launch jspsych experiment
|
|
jsPsych.init({
|
|
display_element: $('#jspsych_target'),
|
|
experiment_structure: [sort_block],
|
|
on_finish: function(data) {
|
|
$('#jspsych_target').append($("<pre>", {
|
|
html: JSON.stringify(data, undefined, 2)
|
|
}));
|
|
}
|
|
});
|
|
</script>
|
|
|
|
</html> |