- Posts: 14
- Thank you received: 3
Ask the community, share ideas, and connect with other LimeSurvey users!
<div id='SurveyName' style='display:none' hidden=1>{{ aSurveyInfo.name }}</div> <div id='QuestionNumber' style='display:none' hidden=1>{{ processString('{self.qseq}') }}</div> <div id='NumberOfAllQuestions' style='display:none' hidden=1>{{ processString('{NUMBEROFQUESTIONS}') }}</div> <div id='NumberOfVisibleQuestions' style='display:none' hidden=1>{{ aSurveyInfo.iTotalquestions }}</div>
if ("{SURVEYNAME}" == "Survey 1" ) { // All hidden questions at start AdjustProgressBar(); } if ("{SURVEYNAME}" == "Survey 2" ) { // All hidden questions at end AdjustProgressBar(, false); } if ("{SURVEYNAME}" == "Survey 3" ) { // 5 of X hidden questions at start AdjustProgressBar(5); }
function AdjustProgressBar(NumberOffHiddenQuestions = 0, HiddenQuestionsAtStart = true) { var ToolTipText = ""; var SurveyName = $('#SurveyName').text(); var QuestionNumber = $('#QuestionNumber').text(); var NumberOfAllQuestions = $('#NumberOfAllQuestions').text(); var NumberOfVisibleQuestions = $('#NumberOfVisibleQuestions').text(); // var NumberOffHiddenQuestions = NumberOfAllQuestions - NumberOfVisibleQuestions; if (NumberOffHiddenQuestions == 0) { NumberOffHiddenQuestions = NumberOfAllQuestions - NumberOfVisibleQuestions; } QuestionNumber++; // Adjust QuestionNumber if hidden question are at the beginning of the survey if (HiddenQuestionsAtStart) { QuestionNumber = QuestionNumber - NumberOffHiddenQuestions; if (QuestionNumber < 0) { QuestionNumber = 0; } } var progressValue = Math.round(QuestionNumber / NumberOfVisibleQuestions * 100); $('.progress-bar').css({ 'transition': 'width 0s ease 0s', 'width': progressValue+'%' }); ToolTipText = "You have answered ".concat(progressValue, "% of the questions."); // Replace tooltip-text $('.ls-progress-container').attr('title', ToolTipText).tooltip('dispose').tooltip(); // Replace text of div $('.ls-progress-container .visually-hidden').text(ToolTipText); }
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.