How to prompt all answers but one in a matrix table | XM Community
Skip to main content

Hi Qualtrics community,

I’m designing a matrix table question where I want to prompt participants to answer any unanswered rows, but I want to exclude the last row "Other " from this prompt. 

Here are the specifics of my setup:

  • The matrix is a single-answer per row question.
  • The last row ("Other") includes a text entry box.
  • Participants should:
    1. Be prompted to answer any unanswered rows except for "Other."
    2. Always have the option to proceed even if some rows are unanswered (no forced responses)

Can anyone help with a JS skript oder other solutions? Costum validation seems to work only with forcing answers…

Thank you! (:  

 

Please try this:

Qualtrics.SurveyEngine.addOnReady(function () {
const quest = this;
const qc = quest.getQuestionContainer();

const allRows = Array.from(qc.querySelectorAll("tr.ChoiceRow"));
const optionRows = allRows.filter((row) => !row.querySelector(".InputText"));

const holder = document.querySelector(".Skin");
function rrHandler(mutationsList) {
mutationsList.forEach(() => {
const rr = document.querySelector(".RequestResponse");
if (rr) {
rr.classList.remove("shown");
const allChecked = optionRows.all((row) => !!row.querySelector(".q-checked"));
if (allChecked) {
// Don't show request response options if all rows without without input box have answers
const allButtons = holder.querySelectorAll(".ErrorButtons button");
allButtons[0].click();
} else {
// Show request response options if there are some unanswered rows
rr.classList.add("shown");
}
}
});
}

const observer = new MutationObserver(rrHandler);
observer.observe(holder, { childList: true });

// Hide the request response options initially
document.body.insertAdjacentHTML("beforeend", "<style>.RequestResponse{opacity: 0;}.RequestResponse.shown{opacity: 1;}</style>");
});

 


It works! Thank you so much, this is great! 


I just tried my whole survey. Is it possible that the code messes with other questions? I receive no prompt for other questions any more even though I activated it in the requirements.


Leave a Reply