Welcome to the LimeSurvey Community Forum

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

Is it possible to add a marker to a slider question that shows previous score?

  • davebostockgmail
  • davebostockgmail's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
2 years 4 days ago #233585 by davebostockgmail
Please help us help you and fill where relevant:
Your LimeSurvey version: [5.4.9+22.11.01]
Own server or LimeSurvey hosting: Own Server (LAMP stack)
Survey theme/template: Fruity - Heavily Modified
==================
I am just wondering if there is a way to add a marker to a slider question that would show the answer to a previous slider question ... for example you have 2 sliders rating experience A and experience B on a scale of 1 to 100 ... Experience A is just a normal slider but then on the Experience B question you would show on the slider where the answer to Experience A sits ... 

We are currently doing this with a text display in the text ... Your previous score was : {QID.shown} but having it shown visually gives a better indicator to the person taking the survey.

Thanks in advance for any thoughts on this

Example of desired outcome attached 

 

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 days ago #233601 by tpartner
If the questions are on different pages, you can add something like this to the source of the second question.

HTML:

Code:
<div class="inserted-tooltip-wrapper">
  <div class="inserted-tooltip tooltip tooltip-main bottom in" style="left: {Q1_SQ001}%;">
    <div class="tooltip-arrow"></div>
    <div class="tooltip-inner">Your previous score:<br />{Q1_SQ001}</div>
  </div>
</div>

JavaScript:

Code:
<script type="text/javascript" data-author="Tony Partner">
 
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Identify this question
    var thisQuestion = $('#question{QID}');
 
    // Move the marker element
    $('.slider-container:first', thisQuestion).append($('.inserted-tooltip-wrapper', thisQuestion));
 
    });
</script>

CSS:

Code:
<style type="text/css" data-author="Tony Partner">
 
  .inserted-tooltip-wrapper {
    position: relative;
    margin-top: 10px;
  }
 
  .inserted-tooltip-wrapper .inserted-tooltip {
    transform: translateX(-50%);
  }
</style>

 

 

Sample survey attached: 

File Attachment:

File Name: limesurvey...4444.lss
File Size:61 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • davebostockgmail
  • davebostockgmail's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
2 years 3 days ago #233602 by davebostockgmail
Amazing as always Tony.

This is exactly what I need.

Thanks so much

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 days ago #233604 by tpartner
One caveat, this is for sliders with scales 0-100. If your min/max are different, you will need to modify the left position rule for the inserted-tooltip tooltip element.

For example with slider scale 0-50, it would be this:

Code:
<div class="inserted-tooltip tooltip tooltip-main bottom in" style="left: {Q1_SQ001*2}%;">

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • davebostockgmail
  • davebostockgmail's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
2 years 3 days ago #233607 by davebostockgmail
I already noted that.

Basically the idea is to let the respondent set their own upper band for the score and then the slider maximum value is that. So I created an equation question that took that value and the answer and moved the tool tip to the appropriate place in the slider bar.

Works perfectly.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose