Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

292
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda