Straightliners are survey participants who rush through a survey by going down a single column in a Grid question and selecting the same response for every row. Straightlining could indicate poor quality survey responses that need to be removed from your analysis. This script checks for straightliners in Single Choice Grid questions and flags them so you can filter them from reporting later.
Detailed Steps
- In your survey, add a Single Choice Grid question.
This script works with any display option. - On a new page immediately after the Single Choice Grid question, add a hidden Single Choice question.
This question records whether straightlining has occurred. - In the hidden Single Choice question, add one answer option that says "Yes."
- In the Table of Contents, click the Page element that contains the Single Choice Grid question to open it for editing.
- Click the Scripting button.
- Click the On Complete tab.
- Copy and paste the script into the On Complete tab.
- Replace SingleChoiceGrid with the name of your Single Choice Grid question.
- Replace SingleChoice with the name of your Single Choice question.
- Click Save.
-
Optional: Add a test screen to ensure the straightlining is being recorded correctly.
- After the Single Choice question, on a new page, add a Text and Image element.
- Type something in the Instruction text field (for example, "Did you straightline?").
- Pipe in the answer from the Single Choice question.
- Preview your survey.
Test your survey by straightlining and not straightlining. When you straightline and arrive at the Text and Image element, you should see the "Yes" answer piped into the instruction text. - Before you distribute your survey, remove or hide the Text and Image element.
Script
/* Script Name: How do I add a straightliner check for Single Choice Grid questions? (Modern Surveys) To ensure your script works as expected, always copy the original script
from the Script Library found in the Alida Help Center. Failure to use the latest script
from the script library may cause unexpected results. */
const gridItems = response.getDataPoint("SingleChoiceGrid").getItems();
const stflag = response.getDataPoint("SingleChoice");
let isStraightliner = true;
let SelectedIndex = gridItems[0].getSelectedIndex();
var someArr = [];
for (let i = 0; i < gridItems.length; i++) {
someArr.push(gridItems[i].getSelectedIndex())
}
var finalarr = someArr.filter(function(x){ return x > -1 });
if (finalarr.length > 1){
for (let i = 0; i < finalarr.length; i++) {
let item = gridItems[i];
let indexVal = item.getSelectedIndex();
if (indexVal !== SelectedIndex) {
isStraightliner = false;
break;
}
}
if (isStraightliner) {
stflag.set(0);
}
}
Comments
0 comments
Article is closed for comments.