Likert scale - how can ensure that there is a response before proceeding to the next item? #2718
-
I am creating a likert scale questionnaire. It's possible for the participant to proceed to the next trial (by pressing a button) without making a response. I have scanned the documentation for a way to address this, but cannot seem to find anything relevant. Minimal code below. Thanks. (NB I am also getting "undefined" for the first trial, so would welcome pointers on this too...) <!DOCTYPE html>
<html>
<head>
<title>My experiment</title>
<script src="https://unpkg.com/[email protected]"></script>
<script src="https://unpkg.com/@jspsych/[email protected]"></script>
<script src="https://unpkg.com/@jspsych/[email protected]"></script>
<!-- <script src="comparative_stims.js"></script> -->
<link href="https://unpkg.com/[email protected]/css/jspsych.css" rel="stylesheet" type="text/css" />
</head>
<body></body>
<script>
/* initialize jsPsych */
var jsPsych = initJsPsych({
on_finish: function() {
jsPsych.data.displayData();
}
});
/* create timeline */
var timeline = [];
/* define welcome message trial */
var welcome = {
type: jsPsychHtmlKeyboardResponse,
stimulus: "Welcome to the experiment. Press any key to begin."
};
timeline.push(welcome);
/* define instructions trial */
var instructions = {
type: jsPsychHtmlKeyboardResponse,
stimulus: `
<p>Press any key to begin.</p>
`,
post_trial_gap: 2000
};
timeline.push(instructions);
var likert_scale = [
"Strongly Disagree",
"Disagree",
"Neutral",
"Agree",
"Strongly Agree"
];
var comparative_stims = [
{
"item": 1,
"gradable": 1,
"positive": 0,
"statement_NP2": 1,
"sentence": "The first film is scarier than the second film.",
"statement": "The scond film is scary."
},
{
"item": 2,
"gradable": 0,
"positive": 0,
"statement_NP2": 0,
"sentence": "The first series is more terrifying than the second series.",
"statement": "The first series is terrifying."
},
{
"item": 3,
"gradable": 1,
"positive": 0,
"statement_NP2": 0,
"sentence": "The apartment is dirtier than the town house.",
"statement": "The apartment is dirty."
},
{
"item": 4,
"gradable": 0,
"positive": 0,
"statement_NP2": 1,
"sentence": "The first floor is filthier than the second floor.",
"statement": "The scond floor is filthy."
}
]
var test = {
type: jsPsychSurveyLikert,
questions: [
{prompt: () => String(jsPsych.timelineVariable(`sentence`)) +
`<br>` +
String(jsPsych.timelineVariable(`statement`)), labels: likert_scale},
],
data: {
likert_response: 'response'
},
randomize_question_order: true
};
timeline.push(test);
// `string text ${expression} string text`
var test_procedure = {
timeline: [test],
timeline_variables: comparative_stims,
repetitions: 1,
randomize_order: true
};
timeline.push(test_procedure);
/* start the experiment */
jsPsych.run(timeline);
</script>
</html> |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @nickriches, You can set the questions: [
{
prompt: () => String(jsPsych.timelineVariable(`sentence`)) +
`<br>` +
String(jsPsych.timelineVariable(`statement`)),
labels: likert_scale,
required: true
},
], This is described in the description of the questions parameter in the survey-likert docs, but it is hard to spot. |
Beta Was this translation helpful? Give feedback.
Hi @nickriches,
You can set the
required
parameter of a question in thequestions
array.This is described in the description of the questions parameter in the survey-likert docs, but it is hard to spot.