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 week 4 days 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
6 days 19 hours 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.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose