Turning on Force Response will ensure that all statements are placed in a group.
@TomG Both Force Response and custom validation (each box can contain a minimum of 0 statements and a maximum of 6 statements) are both turned on, however, when I preview the survey I am allowed to place 1 statement in each box and move on, leaving 14 statements unsorted.
Hi, if you turn off the Validation and just use Force Response, the respondent will need to sort all 18 statements before moving on. To keep the condition that each group must contain between 0 and 6 items, I was able to adapt the code of qualtrics_nerd in this post to add JavaScript to the PGR question that will disable the Next button after 200 milliseconds if any group contains more than 6 items. I added that delay so the next button would enable when removing a 7th item from a group to make it 6 and pass the condition.
So first, enable "Force Response" so that all statements will get placed, disable "Add validation", and then add the below to the OnReady section of the question's JavaScript:
//to access the question body to apply event listener
let ques=document.getElementById("Questions");
//to access the groups in which options are dragged
let quest=document.querySelectorAll("[role=list]");
//to access the next button
let button=document.getElementById('NextButton');
//function to check items in groups
function check() {
setTimeout(function() {
for(let i=1;i<quest.length;i++)
{
//validates the condition
if(quest[i].childElementCount>6)
{
button.disabled=true;
break;
}
else
{
button.disabled=false;
//enables the button and breaks from the loop if condition is not satisfied
}
}
}, 200);
}
//event listener on question body for when mouse is released
ques.addEventListener("mouseup", function(event) {
check();
});
//event listener on question body for when touch is ended
ques.addEventListener("touchend", function(event) {
check();
});