How to get the selection value from Likert
June 22, 2017 12:00 AM
I use Likert to have the same five choices (e.g. never, seldom, sometimes, often, always) for 20 questions.
There is only 1 variable for all 20 questions. How do I extract the user selection for each question when there is only 1 variable?
Thanks,
Discussion (3)
I found from debugger that the value of the variable is a string like the one below:
1-3\rSometimes,2-4\rOften,3-4\rOften,4-3\rSometimes,5-3\rSometimes,6-3\rSometimes,...
1 is the question number, 3 is the choice which means sometimes.
Is there a Lectora way to extra the number of choice?
I tried the Javascript, but my skill is not good enough to gather the values I need.
var SurveyPart1JS = VarQ1ToQ20.getValue().split(",");//document.write(SurveyPart1JS);
//console.log(SurveyPart1JS);
for (i = 0; i < SurveyPart1JS .length; i++) {
var temp1 = SurveyPart1JS[i];
var temp2 = temp1.split("-");
var temp3 = temp2[2];
var temp4 = temp3.substring(0, 1);
"VarQ"+ i + ".set(temp4);
// trying to assign the value to Q1, Q2, to Q20 var in Lectora
// document.write( "VarQ"+ i + ".set(temp4);");
}
Can someone help?
Thanks,
undefined
Here's a sample how the values after the "-" can be extracted from a variable value like the string you've posted and how to put the values into separate Lectora variables. Mind I've used a user-defined variable to hold the value. You'll have to update the script to .getValue() of your survey variable.
Thank you, Tim. It works.
Strangely though, I have 3 likert questions. I can only get the result from each individual one but can't get all 3 in a long Javascript code. It's copied and pasted and the only difference is the variable names. I changed the names for each temp variables too. It stops after getting the first one out. Nothing from 2nd and the 3rd.
Instead of getting it from user input, if I put the string with data of user input in first, it captures the result perfectly.
Discussions have been disabled for this post