- Posts: 10109
- Thank you received: 3595
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
- Online
- LimeSurvey Community Team
Less
More
7 years 11 months ago - 7 years 11 months ago #136049
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic not counting hidden questions in the progress bar
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
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 55
- Thank you received: 1
6 years 11 months ago #153893
by Siem
Replied by Siem on topic not counting hidden questions in the progress bar
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:
How would I implement it, where would I put this code?
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
- Online
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
6 years 11 months ago #153900
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic not counting hidden questions in the progress bar
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
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 55
- Thank you received: 1
6 years 10 months ago #155291
by Siem
Replied by Siem on topic not counting hidden questions in the progress bar
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
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
- Online
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
6 years 10 months ago #155294
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic not counting hidden questions in the progress bar
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
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 55
- Thank you received: 1
6 years 10 months ago #155295
by Siem
Replied by Siem on topic not counting hidden questions in the progress bar
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) ; ?
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
- Online
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
6 years 10 months ago #155297
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic not counting hidden questions in the progress bar
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
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 55
- Thank you received: 1
6 years 10 months ago #155298
by Siem
Replied by Siem on topic not counting hidden questions in the progress bar
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'.
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
- Online
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
6 years 10 months ago #155299
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic not counting hidden questions in the progress bar
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
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 55
- Thank you received: 1
6 years 10 months ago #155301
by Siem
Replied by Siem on topic not counting hidden questions in the progress bar
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):
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
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 55
- Thank you received: 1
5 years 9 months ago #171658
by Siem
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.
Replied by Siem on topic not counting hidden questions in the progress bar
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13648
- Thank you received: 2491
5 years 9 months ago #171661
by DenisChenu
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.
Replied by DenisChenu on topic not counting hidden questions in the progress bar
It was fixed before for sure …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.
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.