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

  • tpartner
  • tpartner's Avatar
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago - 7 years 11 months ago #136049 by tpartner
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>
 

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 7 years 11 months ago by tpartner.
The topic has been locked.
  • Siem
  • Siem's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 years 11 months ago #153893 by Siem
I have a survey with 226 questions / 56 hidden questions (in a different group).


The progress-bar does not indicate the right value because of these hidden questions. I understand that it is difficult to fix this.

In the previous message Tony suggested 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>

How would I implement it, where would I put this code?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 11 months ago #153900 by tpartner
Place the code in the source of any question on the page or in the group description - manual.limesurvey.org/Workarounds:_Manip...tc..29_in_LimeSurvey

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 10 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
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 10 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 10 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
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 10 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 10 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
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 10 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 10 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 9 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 9 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.

Lime-years ahead

Online-surveys for every purse and purpose