Hello! I am trying to customize some carry forward statements. I have a constant sum question and I want to carry forward the top 5 statements by inputted numerical value from that into my next question. Does anyone know how to do this?
Page 1 / 1
@RKT If I have a list of 20 statements in a constant sum, is there no way then to have a follow-up question on only the top 5 of those from the values that the user inputs?
@Ansh_Par,
With carryover the closest you an get is to carryover all the statements greater than some fixed number.
To carryover the top 5, you'll need a process (web service or JavaScript) to rank the statements and set embedded data flags for the top 5. Then use those flags in display logic for each statement in the follow-up question.
With carryover the closest you an get is to carryover all the statements greater than some fixed number.
To carryover the top 5, you'll need a process (web service or JavaScript) to rank the statements and set embedded data flags for the top 5. Then use those flags in display logic for each statement in the follow-up question.
@TomG Thank you! I am not super familiar with JavaScript and how to set embedded data flags. Could you potentially give me an example of what that would like like. Here is a simplified version of the question set I am working with: !
Make two arrays one with labels and one with codes for each option. Run a loop and store first 5 maximum values and there labels in embedded data. Than use these 5 in next question.
I am struggling a little with what syntax I would use to do this (have not used JavaScript before). How would I refer to the individual entries and then how do you store something in embedded data?
@Ansh_Par - I sent you a private message.
@tomg
Can you paste syntax here I have similar requirement.
Can you paste syntax here I have similar requirement.
Sorry @Tomg
I saw your message and can't pay for this Java script code.
Anyone who can help in free.
I saw your message and can't pay for this Java script code.
Anyone who can help in free.
@christxy - Why do you expect programmers that have skills and knowledge you don't possess to work for free? Do you expect your Docter, Lawyer, Accountant, Car Mechanic, Plumber, Electrician, Hair Stylist, etc. to work for free too?
Figured it out: Here is the syntax for anyone that needs it:
Qualtrics.SurveyEngine.addOnPageSubmit(function(type) {
var $jq = jQuery.noConflict();
var answers = $jq('.Selection input').map(function(val) {
return $(this).getValue();
});
var questions = $jq('.Selection label span').map(function(val) {
return $(this).innerHTML;
});
zip = []
for(var i = 0; i < answers.length; i++) {
zip.push([parseInt(answers[i]), questions[i]]);
}
zip.sort(function(a, b) {
return b[0] - a[0];
});
top_5 = zip.slice(0, 5).map(function(val) { return val[1]});
console.log(top_5);
Qualtrics.SurveyEngine.setEmbeddedData('top_5_questions', top_5);
Just make sure you create a 'top_5_questions' variable in survey flow in order for this to work with embedded data.
Qualtrics.SurveyEngine.addOnPageSubmit(function(type) {
var $jq = jQuery.noConflict();
var answers = $jq('.Selection input').map(function(val) {
return $(this).getValue();
});
var questions = $jq('.Selection label span').map(function(val) {
return $(this).innerHTML;
});
zip = []
for(var i = 0; i < answers.length; i++) {
zip.push([parseInt(answers[i]), questions[i]]);
}
zip.sort(function(a, b) {
return b[0] - a[0];
});
top_5 = zip.slice(0, 5).map(function(val) { return val[1]});
console.log(top_5);
Qualtrics.SurveyEngine.setEmbeddedData('top_5_questions', top_5);
Just make sure you create a 'top_5_questions' variable in survey flow in order for this to work with embedded data.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.