mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-12 16:48:12 +00:00
72 lines
2.7 KiB
HTML
72 lines
2.7 KiB
HTML
<!doctype html>
|
|
<html>
|
|
|
|
<head>
|
|
<title>jspsych-survey-likert plugin example</title>
|
|
<!-- jQuery -->
|
|
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
|
<!-- this plugin requires the jQuery UI library and stylesheet -->
|
|
<!-- these can be loaded from google's servers with the following links -->
|
|
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
|
|
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/black-tie/jquery-ui.min.css" rel="stylesheet" type="text/css"></link>
|
|
<!-- jsPsych -->
|
|
<script src="scripts/jspsych.js"></script>
|
|
<script src="scripts/plugins/jspsych-survey-likert.js"></script>
|
|
<!-- style -->
|
|
<style>
|
|
#jspsych_target {
|
|
margin: 50px auto 50px auto;
|
|
width: 600px;
|
|
font-size:18px;
|
|
text-align: center;
|
|
}
|
|
#instructions {
|
|
text-align: left;
|
|
}
|
|
pre {
|
|
text-align: left;
|
|
}
|
|
.likertquestion {
|
|
margin: 100px 0;
|
|
}
|
|
button {
|
|
width: 80px;
|
|
height: 28px;
|
|
font-size:20px;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="jspsych_target"></div>
|
|
</body>
|
|
<script type="text/javascript">
|
|
|
|
// defining groups of questions that will go together.
|
|
var page_1_questions = ["I like vegetables.", "I hate eggs."];
|
|
var page_2_questions = ["I like fruit."];
|
|
|
|
// definiting two different response scales that can be used.
|
|
var scale_1 = ["Strongly Disagree", "Disagree", "Neutral", "Agree", "Strongly Agree"];
|
|
var scale_2 = ["Strongly Disagree", "Disagree", "Somewhat Disagree", "Neural", "Somewhat Agree", "Agree", "Strongly Agree"];
|
|
|
|
var likert_block = {
|
|
type: 'survey-likert',
|
|
questions: [page_1_questions, page_2_questions],
|
|
labels: [[scale_1, scale_2], [scale_1]], // need one scale for every question on a page
|
|
intervals: [[5,7], [9]] // note the the intervals and labels don't necessarily need to match.
|
|
};
|
|
|
|
// launch jspsych experiment
|
|
jsPsych.init({
|
|
display_element: $('#jspsych_target'),
|
|
experiment_structure: [likert_block],
|
|
on_finish: function(data) {
|
|
$('#jspsych_target').append($("<pre>", {
|
|
text: JSON.stringify(data, undefined, 2)
|
|
}));
|
|
}
|
|
});
|
|
</script>
|
|
|
|
</html> |