How to add a "___ out of ___" type of question? | XM Community
Skip to main content
Solved

How to add a "___ out of ___" type of question?

  • February 25, 2024
  • 1 reply
  • 49 views

Forum|alt.badge.img

I want to add a math question that requires the subject to answer in proportions, so I want to add something like ___ out of ___ or similar to this, anyone knows how can I do it? 

Best answer by ahmedA

There’s no defined question type for this.

What you can do is to create a form question with two fields which you can then move to the question HTML.

Example:

Question HTML:

<div><span class="dest" id="v1"></span> out of <span class="dest" id="v2"></span></div>

 

Question JS:

Qualtrics.SurveyEngine.addOnReady(function () {
	const quest = this;
	const qc = quest.getQuestionContainer();
	const sources = qc.querySelectorAll(".InputText");
	const destinations = qc.querySelectorAll(".dest");

	destinations.forEach((dest, index) => {
		const src = sources[index];
		dest.insertAdjacentElement("afterbegin", src);
		// To enforce only numbers
		src.type = "number";
	});
});

You can style the text boxes by using the selector .dest .InputText

View original

1 reply

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • 2028 replies
  • Answer
  • February 25, 2024

There’s no defined question type for this.

What you can do is to create a form question with two fields which you can then move to the question HTML.

Example:

Question HTML:

<div><span class="dest" id="v1"></span> out of <span class="dest" id="v2"></span></div>

 

Question JS:

Qualtrics.SurveyEngine.addOnReady(function () {
	const quest = this;
	const qc = quest.getQuestionContainer();
	const sources = qc.querySelectorAll(".InputText");
	const destinations = qc.querySelectorAll(".dest");

	destinations.forEach((dest, index) => {
		const src = sources[index];
		dest.insertAdjacentElement("afterbegin", src);
		// To enforce only numbers
		src.type = "number";
	});
});

You can style the text boxes by using the selector .dest .InputText


Leave a Reply