I've used the code in this post (How to pipe and rank statements in an earlier question to a new constant sum matrix — Qualtrics Community) to get the top 3 statements.... but I couldn't work out how to modify this to get the top 5 statements. Is it possible or do I need to use a different approach?
Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
const qid = this.questionId;
available_choices = Qualtrics.SurveyEngine.QuestionInfonqid].Choices;
tot_choices = >]
for(keys in available_choices){
tot_choices.push(keys);}
choice_set ={};
i=1;
tot_choices.forEach(item =>{
option_score = document.getElementsByName("QR~"+qid+"~"+item)0].value;
option_name = document.getElementById("header~"+qid+"~"+i).innerText.trim();
choice_setnoption_name] = option_score;
i++;
});
const sorted_choices = Object.fromEntries(
Object.entries(choice_set).sort((;,a],<,b]) => b-a)
);
i = 1;
for(keys in sorted_choices){
Qualtrics.SurveyEngine.setEmbeddedData("top_"+i, keys);
i++;
}
});
Be the first to reply!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.