Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

294
Vistas
Qualtrics: Using Javascript to Score Questions Inside a Loop/Merge Block

I have a multiple choice question (Yes/No) where Yes correlates to a score of 0 and No correlates to a score of 1. I've used the "Recode Values" feature to set Yes to 0 and No to 1. This is inside a loop/merge block, so I cannot use the Scoring feature or Embedded Data/Branching in Survey Flow.

My code currently looks like this:

Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var answer = jQuery("#"+this.questionId+".q-checked").val();
Qualtrics.SurveyEngine.setEmbeddedData('answer', answer);
if(answer = 0)  Qualtrics.SurveyEngine.setEmbeddedData('mmm', '0');
if(answer = 1)  Qualtrics.SurveyEngine.setEmbeddedData('mmm', '1');
});

I have also tried:

Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var answer = this.questionContainer.querySelector(".q-checked").nextElementSibling.innerText;
Qualtrics.SurveyEngine.setEmbeddedData('answer', answer);
if(answer = 0)  Qualtrics.SurveyEngine.setEmbeddedData('mmm', '0');
if(answer = 1)  Qualtrics.SurveyEngine.setEmbeddedData('mmm', '1');
});

Inside the same block after this question, I have a page break and then two questions with display logic. If they answer Yes/get a score of 0 on the preliminary question, it should display Question A. If they answer No/get a score of 1 on the preliminary question, it should display Question B.

My code seems to set their score to 1 and display Question B no matter if they answer Yes or No to the preliminary question.

Thank you in advance for any help.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

There are three issues with your code. The first is that you are missing a space before .q-checked in your jQuery selector. It should be:

var answer = jQuery("#"+this.questionId+" .q-checked").val();

The second issue is that the value (choiceid) is not the same thing as the recode. You can either use choiceids (probably 1=Yes and 2=No) or use the Qualtrics JS API to get the recode associated with the value.

The third issue is that your comparisons are incorrect. They should look like:

if(answer == "0") 
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda