Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

not counting hidden questions in the progress bar

  • Siem
  • Siem's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 years 9 months ago #155291 by Siem
I added the below code to the source of the questions and I can see it in the page source.
However it doesn't affect the progress bar. Is the code correct, or do I need to make other changes?

Many thanks in advance,
Simon

tpartner wrote: To set the value of the core progress bar, you can do something like this:

Code:
<script type="text/javascript" charset="utf-8">  
 
  $(document).ready(function() {
    // Progress bar value
    $('#progress-wrapper').css('visibility', 'hidden');
    setTimeout(function() {
      $('#progressbar').progressbar('value', 50 );
      $('#progress-wrapper').css('visibility', 'visible');
    }, 250);
    });    
</script>
 

The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 9 months ago #155294 by tpartner
That code is for previous versions of LimeSurvey. For the current version and the upcoming 3.x, use this code which applies to the Bootstrap progress bar.

Code:
<script type="text/javascript" charset="utf-8">     
  $(document).ready(function() {
    var progressValue = 32;
    $('.progress-bar').css({
      'transition': 'width 0s ease 0s',
      'width': progressValue+'%'
    }).attr('aria-valuenow', progressValue).text(progressValue+'%');
  });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • Siem
  • Siem's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 years 9 months ago #155295 by Siem
This works better :)

Would it be possible to get the current question number into the script, so the script calculates the progress-percentage itself, like below:

var progressValue = Math.round( currentQuestionNumber / 226) ; ?

tpartner wrote: That code is for previous versions of LimeSurvey. For the current version and the upcoming 3.x, use this code which applies to the Bootstrap progress bar.

Code:
<script type="text/javascript" charset="utf-8">     
  $(document).ready(function() {
    var progressValue = 32;
    $('.progress-bar').css({
      'transition': 'width 0s ease 0s',
      'width': progressValue+'%'
    }).attr('aria-valuenow', progressValue).text(progressValue+'%');
  });
</script>

The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 9 months ago #155297 by tpartner
But...that's what LimeSurvey does automatically, so why bother with dynamically changing the progress value?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • Siem
  • Siem's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 years 9 months ago #155298 by Siem
That's correct, but the number I want to divide by in the example is 226 - which is the number of real questions, excluding 24 hidden questions (that I need for the score calculation). LimeSurvey would use the value 250 there instead of 226.

The 226 questions are in the group 'data collection' and the 24 hidden questions in a separate group 'score calculation'.

tpartner wrote: But...that's what LimeSurvey does automatically, so why bother with dynamically changing the progress value?

The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 9 months ago #155299 by tpartner
I don't know of an automatic way to detect "currentQuestionNumber" that excludes hidden questions. LimeSurvey will return the question number with the {QUESTION_NUMBER} placeholder but that also includes hidden questions.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: Siem
The topic has been locked.
  • Siem
  • Siem's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 years 9 months ago #155301 by Siem
Actually that is very helpful! The hidden questions are at the end of the survey so this is perfect.
Below is the working code (if anyone else has this problem):
Code:
<script type="text/javascript" charset="utf-8">     
  $(document).ready(function() {
    var QUESTIONS = 226;
    var progressValue = Math.round(({QUESTION_NUMBER}/QUESTIONS)*100);
    $('.progress-bar').css({
      'transition': 'width 0s ease 0s',
      'width': progressValue+'%'
    }).attr('aria-valuenow', progressValue).text(progressValue+'%');
  });
</script>
The topic has been locked.
  • Siem
  • Siem's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 8 months ago #171658 by Siem
Code:
<script type="text/javascript" charset="utf-8">     
  $(document).ready(function() {
    var QUESTIONS = 226;
    var progressValue = Math.round(({QUESTION_NUMBER}/QUESTIONS)*100);
    $('.progress-bar').css({
      'transition': 'width 0s ease 0s',
      'width': progressValue+'%'
    }).attr('aria-valuenow', progressValue).text(progressValue+'%');
  });
</script>

I upgraded from Version 2 and unfortunately the code doesn't change the progress -bar in Version 3(.13.2).

How can fix it? Many thanks in advance.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 8 months ago #171661 by DenisChenu
Replied by DenisChenu on topic not counting hidden questions in the progress bar

tpartner wrote: I don't know of an automatic way to detect "currentQuestionNumber" that excludes hidden questions. LimeSurvey will return the question number with the {QUESTION_NUMBER} placeholder but that also includes hidden questions.

It was fixed before for sure …

Not currently ? If not : someone must report issue .

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • Siem
  • Siem's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 8 months ago #171684 by Siem
The reason I was using this workaround code in version 2.x is because LimeSurvey counts the hidden questions when calculating the progress-bar, so if you have a 10 question survey with 90 hidden questions at the end, the progress-bar will show 9% when you're at question 9.

However when you enable 'Show "There are X questions in this survey"' it does shows the number of questions - excluding the hidden ones. So it would show "There are 10 questions in the survey" - which is correct from the participant perspective. It is inconsequent now.

I tested it and version 3.13.2+180709 counts hidden questions for the progress-bar calculation, and not for "There are X questions in this survey". Do you think the way the progress-bar handles it, is a bug?

Would it possible to change the 2.X progress-bar workaround code so the works with version 3?
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 8 months ago #171687 by DenisChenu
Replied by DenisChenu on topic not counting hidden questions in the progress bar

Siem wrote: I tested it and version 3.13.2+180709 counts hidden questions for the progress-bar calculation, and not for "There are X questions in this survey". Do you think the way the progress-bar handles it, is a bug?

Clearly : take hidden question in progress bar is a bug.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
More
5 years 8 months ago #171713 by jelo

DenisChenu wrote:

Siem wrote: I tested it and version 3.13.2+180709 counts hidden questions for the progress-bar calculation, and not for "There are X questions in this survey". Do you think the way the progress-bar handles it, is a bug?

Clearly : take hidden question in progress bar is a bug.


bugs.limesurvey.org/view.php?id=11361

What was the conclusion: All kind of hidden questions should be not counted? What about hidden by css?

bugs.limesurvey.org/view.php?id=11665

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The following user(s) said Thank You: DenisChenu
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose