Hi,
I have a pick group and rank question with 5 groups, very unlikely to very likely. I need to randomly select up to two answers from the very unlikely and unlikely groups and pipe those into the text of the follow up question.
The follow up question would read like this
What makes you say you are unlikely to consider mobile ordering and self checkout.
Any help would be appreciated. Thanks,
get them in the next question and then use subset feature of the randomization in single punch question. Then pipe them to whichever question you need to.
What I ended up doing is grabbing the answer codes (choiceid) from the DOM, randomizing and selecting two. Then storing in embedded data.
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
var $this = jQuery(this.questionContainer);
var arr=[];
var $groupUl;
Qualtrics.SurveyEngine.setEmbeddedData("Q28_Selected_Unlikely_Codes", "");
jQuery(".QuestionBody .groupsContainerTd .Group", $this).each(function (i) {
$groupUl = jQuery(this).find("ul.ui-sortable");
jQuery("li", $groupUl).each(function (i) {
var groupText=jQuery(this).closest(":has(h2)").find("h2").text().toUpperCase();
if(groupText.indexOf("UNLIKELY") >= 0 && groupText.indexOf("NOR") == -1) {
arr.push(jQuery(this).data("choiceid"));
}
});
});
const shuffled = [...arr].sort(() => 0.5 - Math.random());
selected=shuffled.slice(0, 2);
Qualtrics.SurveyEngine.setEmbeddedData("Q28_Selected_Unlikely_Codes", selected.join());
});
Then creating a multiple response question and setting the answers and auto submit so I can then use piped text.
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
var val=Qualtrics.SurveyEngine.getEmbeddedData("Q28_Selected_Unlikely_Codes").split(",");
for (var i = 0; i < val.length; i++) {
this.setChoiceValueByRecodeValue(val[i],true);
}
this.clickNextButton();
});
Don't know if this was the best method, but it's working.
Kudos! We could have used qualtrics to pick by default using randomization but this is fine as long as it works!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.