Need Help with a custom solution to be implemented in Qualtrics | XM Community
Skip to main content

Hello Everyone, any guidance here would be appreciated.
We have a survey where participants answer 50 questions and these questions are divided into 8 groups. For each group there is a score associated and that needs to be calculated based on the responses given by the participants for each group. The questions have a likert scale Never to Always. I need to pick up these responses and use a javascript for this calculations and then place these calculation results in a open form questions.
image.pngimage.pngHere is the JavaScript i am using:

 function ScoreCore(){
        // Initialize scoring variables
        var score = 0, questions_answered = 0;
        //Convert all arguments to an array
        var dimension = Array.prototype.slice.call(arguments);
        //QB passes strings. Convert the string array to Number
        dimension = dimension.map(Number);
   
        //Loop through the array confirming that the response is not 0 or -77, which would indicate the respondant did not answer the question
       
        for (i =0; i                 if (dimension i] > 0) {
                    score += dimension i];
                    questions_answered++;
            }
        }
            //Core dimensions are scored on a 0% - 100% scale, so convert with Response-1/.25
            score = ((score/questions_answered)-1)*.25;
            return score;
    }
   
    function ScoreDiff(){
        // Initialize scoring variables
        var score = 0, questions_answered = 0;
        //Convert all arguments to an array
        var dimension = Array.prototype.slice.call(arguments);
        //QB passes strings. Convert the string array to Number
        dimension = dimension.map(Number);
   
        //Loop through the array confirming that the response is not 0 or -77, which would indicate the respondant did not answer the question
        //Calculate the
        for (i =0; i                 if (dimensionti] > 0) {
                    if (dimensionei] >=4) {
                        score++; //if the response is 4 or 5, increment the NPS by 1.
                    };
                    questions_answered++;
            }
           
        }
    score = (score/questions_answered); //Produces the Net-Promoter score
    return score;
    }
    //Scoring calculations here feed data into the form question
    //Score: Courage
    document.getElementById('QR_QID18_1').value = ScoreDiff('#QID1_1|recodeVal','#QID1_2|recodeVal','#QID1_3|recodeVal','#QID1_4|recodeVal');
    //Score: Commitment
    document.getElementById('QR_QID18_2').value = ScoreDiff('#QID2_1|recodeVal','#QID2_2|recodeVal','#QID2_3|recodeVal','#QID2_4|recodeVal');
    //Score: Inclusion
    document.getElementById('QR_QID18_3').value = ScoreDiff('#QID3_1|recodeVal','#QID3_2|recodeVal','#QID3_3|recodeVal','#QID4_4|recodeVal');
    //Score:SharedBeliefs
    document.getElementById('QR_QID18_4').value = ScoreDiff('#QID4_1|recodeVal','#QID4_2|recodeVal','#QID4_3|recodeVal','#QID4_4|recodeVal');

Please let me know if there are any mistakes i am doing or if there is a better way to do this.

I think you could use scoring with eight scoring categories.


Leave a Reply