Welcome to the LimeSurvey Community Forum

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

Changing the value/position of a slider using only buttons not clicking/dragging

  • Moathh
  • Moathh's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 month 2 weeks ago #268554 by Moathh
LimeSurvey version: [LimeSurvey Cloud Version 6.10.0]
==================
Hi everyone,

I downloaded tpartner's "Slider Control Buttons for LimeSurvey 6.x" from GitHub, which is a great question theme. However, I am wondering if it is possible to disable moving the slider handle/changing the slider value with clicking/dragging, and only rely on the buttons to change the position and the value of the slider.

Thanks!
Moath

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 month 2 weeks ago #268632 by tpartner
You would need to modify the question theme, adding a new custom option to disable the sliders...

1) In /Slider-With-Controls/survey/questions/answer/multiplenumeric/config.xml, add an attribute like this this:

Code:
<attribute>
    <name>disabled</name>
    <category>Custom options</category>
    <sortorder>6</sortorder>
    <inputtype>buttongroup</inputtype>
    <options>
        <yes>Yes</yes>
        <no>No</no>
    </options>
    <default>no</default>
    <caption>Slider disabled</caption>
    <help>Disable the slider so the control buttons must be used.</help>
</attribute>


2) In /Slider-With-Controls/survey/questions/answer/multiplenumeric/rows/sliders/answer_row.twig, change this:

Code:
{% if slider_orientation is same as('horizontal') %}
    {% include '/survey/questions/answer/multiplenumeric/rows/sliders/horizontal_slider.twig' %}
{% endif %}
{% if slider_orientation is same as('vertical') %}
    {% include '/survey/questions/answer/multiplenumeric/rows/sliders/vertical_slider.twig' %}
{% endif %}

To this:

Code:
{% if slider_orientation is same as('horizontal') %}
    {% include '/survey/questions/answer/multiplenumeric/rows/sliders/horizontal_slider.twig' with {'sliderDisabled': question_template_attribute.disabled} %}
{% endif %}
{% if slider_orientation is same as('vertical') %}
    {% include '/survey/questions/answer/multiplenumeric/rows/sliders/vertical_slider.twig' with {'sliderDisabled': question_template_attribute.disabled} %}
{% endif %}


3) In /Slider-With-Controls/survey/questions/answer/multiplenumeric/rows/sliders/horizontal_slider.twig, change this:

Code:
{{ C.Html.textField( myfname ~ 'slid', dispVal ,{
    'class': 'form-control answer-item numeric-item d-none cs-slider-input',
    'id' : "answer" ~ myfname ~ "slid",
    'data-cs-separator' : sSeparator, 
    'data-cs-step' : slider_step, 
    'data-cs-max' : slider_max, 
    'data-cs-min' : slider_min 
}) }}

To this:

Code:
{{ C.Html.textField( myfname ~ 'slid', dispVal ,{
    'class': 'form-control answer-item numeric-item d-none cs-slider-input',
    'id' : "answer" ~ myfname ~ "slid",
    'data-bs-slider-enabled': sliderDisabled == 'yes' ? 'false' : 'true' ,
    'data-cs-separator' : sSeparator, 
    'data-cs-step' : slider_step, 
    'data-cs-max' : slider_max, 
    'data-cs-min' : slider_min 
}) }}

4) In /Slider-With-Controls/survey/questions/answer/multiplenumeric/rows/sliders/vertical_slider.twig, change this:

Code:
{{ C.Html.textField( myfname ~ 'slid', dispVal ,{
    'class': 'form-control answer-item numeric-item d-none',
    'id' : "answer" ~ myfname ~ "slid",
    'data-cs-separator' : sSeparator, 
    'data-cs-step' : slider_step, 
    'data-cs-max' : slider_max, 
    'data-cs-min' : slider_min 
}) }}

To this:

Code:
{{ C.Html.textField( myfname ~ 'slid', dispVal ,{
    'class': 'form-control answer-item numeric-item d-none cs-slider-input',
    'id' : "answer" ~ myfname ~ "slid",
    'data-bs-slider-enabled': sliderDisabled == 'yes' ? 'false' : 'true' ,
    'data-cs-separator' : sSeparator, 
    'data-cs-step' : slider_step, 
    'data-cs-max' : slider_max, 
    'data-cs-min' : slider_min 
}) }}

5) In Configuration --> Global -- General, clear the assets cache.

6) Set the new "Slider disabled" question setting to "Yes".
 

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: DenisChenu

Please Log in to join the conversation.

  • Moathh
  • Moathh's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 month 3 days ago #268752 by Moathh
Hi Tony,

Thanks for your reply. I do not have rights to perform these changes from within LimeSurvey and I am still waiting for my university to decide if this is possible.

Meanwhile, I implemented the changes on the files themselves and reimported the question theme, but unfortunately, it did not work this way. It does give the option to disable the slider but the slider can still be moved by dragging.

Is there another way the changes can take effect other than making the edits from within LimeSurvey and clear the assets cache?

Thanks again for the support.

Cheers,
Moath

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 month 3 days ago #268774 by tpartner
Can you attach a zipped copy of your question theme?

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.

  • Moathh
  • Moathh's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 month 2 days ago #268777 by Moathh
 

File Attachment:

File Name: Slider-Wit...rols.zip
File Size:66 KB


Here is the file. Thanks again!

Best,
Moath

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 month 1 day ago - 1 month 1 day ago #268798 by tpartner
Try this...

In /Slider-With-Controls/survey/questions/answer/multiplenumeric/rows/sliders/horizontal_slider.twig and /Slider-With-Controls/survey/questions/answer/multiplenumeric/rows/sliders/vertical_slider.twig, change:
Code:
data-bs-slider-enabled
".

To:
Code:
data-slider-enabled
".

Here is a working survey - partnersurveys.com/limesurvey6x/index.php/444536?lang=en

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 1 month 1 day ago by tpartner.
The following user(s) said Thank You: DenisChenu, Moathh

Please Log in to join the conversation.

  • Moathh
  • Moathh's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 month 6 hours ago #268840 by Moathh
It worked like a charm, thanks, Tony! I appreciate it 🙏

Cheers,
Moath

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose