Loop & Merge with Scoring (text box) | XM Community
Skip to main content
Hi All, I'm trying to create a task of counting objects in randomly presented images. There are 1000+ images in total within a loop & merge block, and respondents will work on the task for 10 minutes. They will automatically advance to the next regular block when time is up, regardless of how many tasks they have done. I enabled the timer feature with Javascript and it works fine. The tricky part comes in when I also want to evaluate whether respondents complete the tasks correctly. Images differ in terms of correct answer. I want to know that within the 10-minute, how many tasks in total a respondent manages to complete correctly. And then I want to provide this information back to the respondent at the end of the loop and merge block.



In the loop & merge block, I have a field with the image urls, and another field with the correct answer corresponding to the image. However, I couldn't figure out how to enable scoring with my question (and was told that this would be impossible when I contacted Qualtrics support). I wonder if there's anyway to code and achieve cumulative scoring with loop and merge block, especially as I don't have a simple multiple choice question.



Below is a snapshot of the task page:

!



Thanks for your help!
Use an addOnPageSubmit JavaScript function to check the value of the text input against the correct value from the loop field, and if it matches increment an embedded data field that contains your "score".
> @TomG said:

> Use an addOnPageSubmit JavaScript function to check the value of the text input against the correct value from the loop field, and if it matches increment an embedded data field that contains your "score".



Unfortunately this method didn't work for the loop and merge block when I tried, likely due to the fact that the embedded data field is set at the end of the block, i.e., after all rounds in the loop and merge block have been gone through.
> @Jiayi said:

> > @TomG said:

> > Use an addOnPageSubmit JavaScript function to check the value of the text input against the correct value from the loop field, and if it matches increment an embedded data field that contains your "score".

>

> Unfortunately this method didn't work for the loop and merge block when I tried, likely due to the fact that the embedded data field is set at the end of the block, i.e., after all rounds in the loop and merge block have been gone through.



The embedded data field updates as soon as the page is submitted. It works when I try it. Post your code.
> @TomG said:

> > @Jiayi said:

> > > @TomG said:

> > > Use an addOnPageSubmit JavaScript function to check the value of the text input against the correct value from the loop field, and if it matches increment an embedded data field that contains your "score".

> >

> > Unfortunately this method didn't work for the loop and merge block when I tried, likely due to the fact that the embedded data field is set at the end of the block, i.e., after all rounds in the loop and merge block have been gone through.

>

> The embedded data field updates as soon as the page is submitted. It works when I try it. Post your code.



Here's the JavaScript method I use (which unfortunately didn't work):



First, create an embedded data field before the loop and merge block called "CorrectNum" and set it to 0. Next, in the JavaScript editor at the task page in the loop and merge block, add code to the Qualtrics.SurveyEngine.addOnload(function(){}) as below:

!



Then use the embedded data field "CorrectNum" in the block after the loop and merge block to show feedback to respondents.



I also tried to define correctNum globally in the Header and then increment the variable within the loop and merge block, which didn't work either. I suspect that variables need to be defined within the question page to be called.



Any clues? Thanks!
The biggest issue is that you are doing an addOnload. That happens when the page loads, so the respondent hasn't done anything yet, and the input is blank. You should be using addOnPageSubmit. BTW, the class name for a text input is InputText.
> @TomG said:

> The biggest issue is that you are doing an addOnload. That happens when the page loads, so the respondent hasn't done anything yet, and the input is blank. You should be using addOnPageSubmit. BTW, the class name for a text input is InputText.



Thanks a lot! It turns out that it is the issue with "addOnload" and I should be using "addOnPageSubmit".

I tried applying these instructions to a similar project, but the scoring feature doesn't work. Any ideas to what I might be missing?
The project involves solving arithmetic problems, receiving feedback, and then showing the total number correct at the end of the loop and merge.

Flashcards.qsf


Hello,

 

How would you implement this with a multiple choice question?

 

Thanks

 


Leave a Reply