Matrix drag and drop limits per group? | XM Community
Skip to main content

Hi all,
I am trying to implement a q-sort in Qualtrics and was wondering if anyone had any idea how to limit the number of statements in the matrix drag and drop groups? I tried adapting the code from this pick, group, and rank discussion (https://community.qualtrics.com/XMcommunity/discussion/15683/q-sort-task-in-qualtrics), but I really am not familiar with javascript. Does anyone have any suggestions about what I can do or point me to any resources? Thanks!
Qualtrics.SurveyEngine.addOnload(function()
{   
var $jq = jQuery.noConflict();
$jq('.CS').css('display','none');
setInterval(function(){
/*Group 1*/
if($jq('.ChoiceContainer .Columns').eq(0).find('.Selected').length == 2)
{ $jq('.SumInput').eq(0).val(1); }
else
{ $jq('.SumInput').eq(0).val(0); }

/*Group 2*/
if($jq('.ChoiceContainer .Columns').eq(1).find('.Selected').length == 3)
{ $jq('.SumInput').eq(1).val(1); }
else
{ $jq('.SumInput').eq(1).val(0); }

/*Group 3*/
if($jq('.ChoiceContainer .Columns').eq(2).find('.Selected').length == 4)
{ $jq('.SumInput').eq(2).val(1); }
else
{ $jq('.SumInput').eq(2).val(0); }

/*Group 4*/
if($jq('.ChoiceContainer .Columns').eq(3).find('.Selected').length == 5)
{ $jq('.SumInput').eq(3).val(1); }
else
{ $jq('.SumInput').eq(3).val(0); }

/*Group 5*/
if($jq('.ChoiceContainer .Columns').eq(4).find('.Selected').length == 6)
{ $jq('.SumInput').eq(4).val(1); }
else
{ $jq('.SumInput').eq(4).val(0); }

/*Group 6*/
if($jq('.ChoiceContainer .Columns').eq(5).find('.Selected').length == 6)
{ $jq('.SumInput').eq(5).val(1); }
else
{ $jq('.SumInput').eq(5).val(0); }

/*Group 7*/
if($jq('.ChoiceContainer .Columns').eq(6).find('.Selected').length == 6)
{ $jq('.SumInput').eq(6).val(1); }
else
{ $jq('.SumInput').eq(6).val(0); }

/*Group 8*
if($jq('.ChoiceContainer .Columns').eq(7).find('.Selected').length == 5)
{ $jq('.SumInput').eq(7).val(1); }
else
{ $jq('.SumInput').eq(7).val(0); }

/*Group 9*/
if($jq('.ChoiceContainer .Columns').eq(8).find('.Selected').length == 4)
{ $jq('.SumInput').eq(8).val(1); }
else
{ $jq('.SumInput').eq(8).val(0); }

/*Group 10*/
if($jq('.ChoiceContainer .Columns').eq(8).find('.Selected').length == 3)
{ $jq('.SumInput').eq(9).val(1); }
else
{ $jq('.SumInput').eq(9).val(0); }

/*Group 11*/
if($jq('.ChoiceContainer .Columns').eq(8).find('.Selected').length == 2)
{ $jq('.SumInput').eq(10).val(1); }
else
{ $jq('.SumInput').eq(10).val(0); }

}, 100);
})
jQuery("#"+this.questionId+" .ValidationError").html("Custom Message");
;
function ClearAllIntervals() {
   for (var i = 1; i < 99999; i++)
       window.clearInterval(i);
}

Be the first to reply!

Leave a Reply