Explore the community Forums Lectora Lectora Questions & Answers How to get the selection value from Likert

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #361327 Score: 0
    Profile photo of cpliu
    cpliu
    Member
    beginner
    intermediate
    contributor
    curious george
    wise owl
    Group Member
    2 pts
    @cpliu

    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,

    #361329 Score: 0
    Profile photo of cpliu
    cpliu
    Member
    beginner
    intermediate
    contributor
    curious george
    wise owl
    Group Member
    2 pts
    @cpliu

    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,

     

     

    #361663 Score: 2
    Profile photo of Tim K
    Tim K
    Member
    contributor
    beginner
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    wise owl
    curious george
    Group Member
    354 pts
    @timk

    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.

    This post has received 2 votes up.
    Attachments:
    1. Title-1-1.zip
    #363314 Score: 0
    Profile photo of cpliu
    cpliu
    Member
    beginner
    intermediate
    contributor
    curious george
    wise owl
    Group Member
    2 pts
    @cpliu

    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.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.