Issue T8109
Visible to All Users

Ranking question - ranks are set even no changes we performed

created 3 years ago (modified 3 years ago)

[Ticket cloned from T8079: Set score for ranking type of questions]

Hi Andrew,

I discovered a very strange behavior of the survey from the last example you provided. Here is the updated example.

When ranking answers, if you move just 1mm up or down any of the answers and then release, just for them to have a position assigned (not changing their location among answers) at the end of the survey, the questions are repeated again although the answers are ranked.
I created a small video to show this.

Where could the issue be?

Thank you in advance.

Show previous comments (2)

    Hi Dmitry,

    Thank you for your reply.
    The following functions were created with help from Andrew and their scope is to check if there are any left unanswered questions (user clicked next without ranking any answers) and to repeat those unanswered questions once at the end of the survey.

    JavaScript
    function areValuesEquals(choices, value) { if (!Array.isArray(value)) return false; // debugger; for (var i = 0; i < choices.length; i++) { if (choices[i].value !== value[i]) return false; } return true; } var surveyRunCount = 0; function rotate() { surveyRunCount++; if (surveyRunCount <= 1) { const questions = survey.getAllQuestions(); let hasQuestionsToShow = false; for (let i = 0; i < questions.length; i++) { const q = questions[i]; if (survey.firstPageIsStarted && q.page === survey.pages[0]) continue; //isEmpty() - was not touched if (!q.isEmpty() && !areValuesEquals(q.visibleChoices, q.value)) { q.visible = false; } else { hasQuestionsToShow = true; } } if (hasQuestionsToShow) { survey.clear(false, true); survey.start(); return true; } } return false; }

    You're provided workaround is not suitable for my scenario, because:

    1. There might be cases where the user needs to rank the answers in the same default order that was presented to him. With the workaround, the default position of answers can't be used, as the user has to rank differently than default.
    2. The timer keeps running even if the maxTimeToFinishPage was reached. The timer keeps running until the default order is changed.

    Please let me know if you need more info regarding this.

    Thank you in advance,
    Alex.

    DK DK
    Dmitry Kurmanov 3 years ago

      Hey,

      If I understand correctly, you might don't need to run the areValuesEquals function at all. Checking !q.isEmpty () may be sufficient.

      If the user just skips the response, q.isEmpty will return true. But if the user drags the element a little without changing the order, the ranking question will set the state and q.isEmpty will return true.

      In our opinion, this makes sense. In this case, we assume that the user is happy with the default order of items.

      Thanks,
      Dmitriy
      SurveyJS Team

        Hi Dmitriy,

        Thank you very much for your time and effort into this.
        Your proposed solution works great. You rock!

        Best regards,
        Alex.