Answered

@score number resets between answers

  • 5 April 2024
  • 3 replies
  • 20 views

I want to keep track of how many times the respondent has answered "yes" to a yes/no question. So, I created a loop that increments the score every time the respondent presses "yes".

However, the score data resets to zero when the respondent returns to the original point.

Code:

S1: What is the shape of this picture?

  • A: a square
  • B: a circle
  • C: a triangle

The correct answer would be C, leading to S4.

If the respondent chooses A or B, it leads to S2.

In S2, the respondent can choose whether they want help or to try again.

  • yes: I want help
  • no: back to S1

Code in S2:

If: incorrect, need a hint? is Yes Add 1 to @score If: incorrect, need a hint is Yes go to S3

If: incorrect, need a hint is No go to S1

 

Now, coming back from the loop where we added +1 to the score to the original S1, @score is nullified. Why?

icon

Best answer by Liz 9 April 2024, 09:31

View original

3 replies

Userlevel 7
Badge +5

Hi @Jxri Thanks for stopping by the community! I’m afraid we don’t currently support backwards logic jumps and thus, looping logics. In this case, you will need to continue to move the respondent forward in order to prevent the score from resetting. 

Thanks Liz for being so quick! I also tried that. I mirrored S1 to S6, and after using a hint, the respondent would go there, but then TF said that is not possible either. Do you think it is a matter of the looping idea or something else? Can you figure out another solution?

Userlevel 7
Badge +5

Hi @Jxri The short version is that it’s not possible to create a loop at all in Typeform, so you would need to recreate this question as many times as it may possibly be be answered in order for the scoring to be correct. 
Another option might be to try this in Formless. I haven’t tried this advanced of a calculation/loop, but it’s definitely a lot easier to tell the AI how to score in those forms!

Reply