- Posts: 90
- Thank you received: 17
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Equation in multiple numercial inputs
- urbana
- Topic Author
- Offline
- Premium Member
Less
More
7 years 5 months ago #143096
by urbana
Equation in multiple numercial inputs was created by urbana
Hi, I can't solve my problem with a relevance equation.
I have a question that asks for 4 Numbers.
(we ask for prices)
Minimum Price (mp)
Cheap Price (cp)
Expensive Price (ep)
Maximum Price (map)
Therefore I need a equation that checks:
Is mp < cp <ep < map
Is cp > mp <ep <map
Is ep > mp > cp < map
Is map > ep > cp > mp
An that is the tricky part I need to evaluate the single input and not to check for overall errors.
I could do it in JS but I struggle with the equation field and the manual is behind a lot versions.
Thx a lot!
urban-a
I have a question that asks for 4 Numbers.
(we ask for prices)
Minimum Price (mp)
Cheap Price (cp)
Expensive Price (ep)
Maximum Price (map)
Therefore I need a equation that checks:
Is mp < cp <ep < map
Is cp > mp <ep <map
Is ep > mp > cp < map
Is map > ep > cp > mp
An that is the tricky part I need to evaluate the single input and not to check for overall errors.
I could do it in JS but I struggle with the equation field and the manual is behind a lot versions.
Thx a lot!
urban-a
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5070
- Thank you received: 1263
7 years 5 months ago #143113
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Equation in multiple numercial inputs
Use four single questions.
Allows more flexibility for validation. Also allows to display van Westendorp questions step by step or at once.
Allows more flexibility for validation. Also allows to display van Westendorp questions step by step or at once.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- urbana
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 90
- Thank you received: 17
7 years 5 months ago #143114
by urbana
Replied by urbana on topic Equation in multiple numercial inputs
yes, that would make it easier
But due the new responsive designs every question takes a lot of space and I think breaks a lot of the intended design.
But due the new responsive designs every question takes a lot of space and I think breaks a lot of the intended design.
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5070
- Thank you received: 1263
7 years 5 months ago #143115
by jelo
Get's quite messy when you don't want to have many warnings in the van westendorp question set. I normally show all questions on one page, but hide three of four at the start.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Equation in multiple numercial inputs
Haven't used LS 2.5 but the spaced between questions can be changed and the templates/html will need to be optimized in the default templates as well. Multi numerical question type isn't offering enough control via EM or validation messages.urbana wrote: But due the new responsive designs every question takes a lot of space and I think breaks a lot of the intended design.
Get's quite messy when you don't want to have many warnings in the van westendorp question set. I normally show all questions on one page, but hide three of four at the start.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10613
- Thank you received: 3691
7 years 4 months ago #143398
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 Equation in multiple numercial inputs
Here is a workaround for Van Westendorp Pricing Sliders -
manual.limesurvey.org/Workarounds:_Manip...dorp_Pricing_Sliders
The sliders are dynamically controlled so when a slider is manipulated, all of the "higher" sliders are dynamically pushed to higher levels and "lower" sliders are pushed to lower levels. This ensures that the data will always be valid.
The sliders are dynamically controlled so when a slider is manipulated, all of the "higher" sliders are dynamically pushed to higher levels and "lower" sliders are pushed to lower levels. This ensures that the data will always be valid.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: DenisChenu
The topic has been locked.
- Payek
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 1
6 years 6 months ago #158159
by Payek
Replied by Payek on topic Equation in multiple numercial inputs
Hi everyone,
I'm trying to use the "Van Westendorp Pricing (2.5x)" on LimeSurvey version 2.67.3 + 170728. It seems to work, but I have found that data from intact sliders are not saved in DB. Only sliders moved by "hand" has value in DB. Sliders moved by "script" give an empty value, even if there is max/min value and slider is moved from default position by "script". I used sample survey from manual: Van Westendorp Pricing Sliders
Survey test is on my server, there: TEST Van Westendorp Pricing Sliders
Is it intentional behaviour or I made a mistake?
Thanks for any help,
Payek
I'm trying to use the "Van Westendorp Pricing (2.5x)" on LimeSurvey version 2.67.3 + 170728. It seems to work, but I have found that data from intact sliders are not saved in DB. Only sliders moved by "hand" has value in DB. Sliders moved by "script" give an empty value, even if there is max/min value and slider is moved from default position by "script". I used sample survey from manual: Van Westendorp Pricing Sliders
Survey test is on my server, there: TEST Van Westendorp Pricing Sliders
Is it intentional behaviour or I made a mistake?
Thanks for any help,
Payek
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5070
- Thank you received: 1263
6 years 6 months ago #158163
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Equation in multiple numercial inputs
I don't think you made a mistake.
There is a ongoing discussion about Slider touched / untouched with default values.
bugs.limesurvey.org/view.php?id=12264
There are bugs and different expectations.
You might open a bugreport with the workaround issue.
There is a ongoing discussion about Slider touched / untouched with default values.
bugs.limesurvey.org/view.php?id=12264
There are bugs and different expectations.
You might open a bugreport with the workaround issue.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10613
- Thank you received: 3691
6 years 6 months ago #158165
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 Equation in multiple numercial inputs
Bug found and fixed - I have updated the Workarounds section -
manual.limesurvey.org/Workarounds:_Manip...ascript#Version_2.5x
This is the new code for template.js:
This is the new code for template.js:
Code:
function shuffleArray(array) { for (var i = array.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = array[i]; array[i] = array[j]; array[j] = temp; } return array; } /***** A jQuery plugin to facilitate the Van Westendorp pricing research methodology Copyright (C) 2016 - Tony Partner (http://partnersurveys.com) Licensed MIT, GPL Version - 2.0 Create date - 19/10/16 *****/ (function( $ ){ $.fn.vWPricing25 = function(options) { var opts = $.extend( { order: [1, 2, 3, 4], randomOrder: false }, options); return this.each(function() { var thisQuestion = $(this); thisQuestion.addClass('vwp-question'); // Add some attributes and set the slider max/min values var itemsLength = $('.question-item', thisQuestion).length; $('.question-item', thisQuestion).each(function(i) { var thisInput = $('input[type=text]', this); var thisVal = $(thisInput).val(); $(this).attr('data-item', (i+1)); $(thisInput).attr('data-bs-slider-index', (i+1)); // Slider initial settings setTimeout(function() { var thisSliderMin = $(thisInput).bootstrapSlider('getAttribute', 'min'); $(thisInput).bootstrapSlider('setAttribute', 'min', thisSliderMin+(i)); var thisSliderMax = $(thisInput).bootstrapSlider('getAttribute', 'max'); $(thisInput).bootstrapSlider('setAttribute', 'max', thisSliderMax-((itemsLength-1)-i)); if(thisVal == '') { $(thisInput).val(''); } }, 200); }); // Slider order if(opts.randomOrder == true) { shuffleArray(opts.order); } $(opts.order).each(function(i, val) { $('.subquestion-list.questions-list', thisQuestion).append($('.question-item[data-item="'+val+'"]', thisQuestion)); }); // Listeners on the sliders $('input[type=text]', thisQuestion).on('slide', function(event) { handleVwpSliders(this, $(this).bootstrapSlider('getValue')); }); $('input[type=text]', thisQuestion).on('slideStop', function(event) { handleVwpSliders(this, $(this).bootstrapSlider('getValue')); }); // A function to handle the siders function handleVwpSliders(el, sliderVal) { var movedIndexNum = $(el).attr('data-bs-slider-index'); var lowerSliders = $('input[type=text]', thisQuestion).filter(function() { return $(this).attr('data-bs-slider-index') < movedIndexNum; }); var higherSliders = $('input[type=text]', thisQuestion).filter(function() { return $(this).attr('data-bs-slider-index') > movedIndexNum; }); $(lowerSliders).each(function(i) { var thisIndexNum = $(this).attr('data-bs-slider-index'); var newSliderVal = sliderVal-(movedIndexNum-thisIndexNum); if($(this).bootstrapSlider('getValue') > newSliderVal) { var thisRow = $(this).closest('.question-item'); var thisTooltip = $('.tooltip', thisRow); $(this).bootstrapSlider('setValue', newSliderVal); $('.tooltip-inner', thisTooltip).text($('input.text', thisRow).val()); thisTooltip.show().css('margin-left', '-'+(thisTooltip.width()/2)+'px'); var validationInput = $('input.em_sq_validation', thisRow); $(validationInput).val($('input.text', thisRow).val()) fixnum_checkconditions($(validationInput).attr('value'), $(validationInput).attr('name'), $(validationInput).attr('type')); } }); $(higherSliders).each(function(i) { var thisIndexNum = $(this).attr('data-bs-slider-index'); var newSliderVal = sliderVal+(thisIndexNum-movedIndexNum); if($(this).bootstrapSlider('getValue') < newSliderVal) { var thisRow = $(this).closest('.question-item'); var thisTooltip = $('.tooltip', thisRow); $(this).bootstrapSlider('setValue', newSliderVal); $('.tooltip-inner', thisTooltip).text($('input.text', thisRow).val()); thisTooltip.show().css('margin-left', '-'+(thisTooltip.width()/2)+'px'); var validationInput = $('input.em_sq_validation', thisRow); $(validationInput).val($('input.text', thisRow).val()) fixnum_checkconditions($(validationInput).attr('value'), $(validationInput).attr('name'), $(validationInput).attr('type')); } }); } // Listener on resizing (override the bootstrap callout behaviour) $(window).resize(function() { setTimeout(function() { $('input[type=text]', thisQuestion).each(function(i) { if($(this).val() != '') { var thisRow = $(this).closest('.question-item'); var thisTooltip = $('.tooltip', thisRow); $('.tooltip-inner', thisTooltip).text($.trim($(this).val())); thisTooltip.show().css('margin-left', '-'+(thisTooltip.width()/2)+'px'); } }); }, 1); }); }); }; })( jQuery );
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: Payek
The topic has been locked.
- Payek
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 1
6 years 6 months ago #158169
by Payek
Replied by Payek on topic Equation in multiple numercial inputs
Big Thank You jelo and Tony Partner for quick response and help. Now "Van Westendorp Pricing" working perfectly (for me). IMHO this forum&community are the biggest advantages of Lime.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13912
- Thank you received: 2549
6 years 6 months ago #158213
by DenisChenu
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 Equation in multiple numercial inputs
If you think it can be interesting and if you are interested, i'm happy to create a new question advanced settings (QuestionAttribute) in plugin to add this script for slidertpartner wrote: Bug found and fixed - I have updated the Workarounds section - manual.limesurvey.org/Workarounds:_Manip...ascript#Version_2.5x
This is the new code for template.js…
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.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10613
- Thank you received: 3691
6 years 6 months ago #158220
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 Equation in multiple numercial inputs
@DenisChenu, I will be creating and contributing a custom question for this. I think this is a perfect application for the new custom question types in 3.x.
Having said that, if you think it also should be in a plugin, feel free to use the code.
Having said that, if you think it also should be in a plugin, feel free to use the code.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13912
- Thank you received: 2549
6 years 6 months ago - 6 years 6 months ago #158223
by DenisChenu
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 Equation in multiple numercial inputs
My point of view about custom question (QuestionType) and new question settings (QuestionAttribute)
QuestionType are show in the 1st selector : major difference between 2 questionType (in HTML, maybe in column in DB etc …)
QuestionAttribute add a functionnality to a QuestionType (restriction via EM, javascript if available)
For example :
- slider can be a QuestionType
- slider reset : clearly a QuestionAttribute
- this script can be a QuestionAttribute
Another
- Map must be a QuestionType
- min_value or max_caracter must be QuestionAttribute
Another with ranking (just a new idea)
- Ranking Question type produce the actual without the doDragDropRank function
- doDragDropRank is a QuestionAttribute with 4 parameters : 1 for use + the 3 current one; coming from core but can be disabled by another QuestionAttribute by an external dev (why not something looking like select2 tagging for example)
Currently if we add a new QuestionType for each script/extra functionnality : it's make harder for Survey Admin to know the best one for his situation (big list …)
The script are really near slider question type => Use slider QuestionType
I don't think we remove QuestionAttribute system, maybe way to add it in QuestionAttribute from core update but not the settings .
And current system already to add some script with params (see framagit.org/SondagePro-LimeSurvey-plugin/altExcludeMultiple for an example).
QuestionType are show in the 1st selector : major difference between 2 questionType (in HTML, maybe in column in DB etc …)
QuestionAttribute add a functionnality to a QuestionType (restriction via EM, javascript if available)
For example :
- slider can be a QuestionType
- slider reset : clearly a QuestionAttribute
- this script can be a QuestionAttribute
Another
- Map must be a QuestionType
- min_value or max_caracter must be QuestionAttribute
Another with ranking (just a new idea)
- Ranking Question type produce the actual without the doDragDropRank function
- doDragDropRank is a QuestionAttribute with 4 parameters : 1 for use + the 3 current one; coming from core but can be disabled by another QuestionAttribute by an external dev (why not something looking like select2 tagging for example)
Currently if we add a new QuestionType for each script/extra functionnality : it's make harder for Survey Admin to know the best one for his situation (big list …)
The script are really near slider question type => Use slider QuestionType
I don't think we remove QuestionAttribute system, maybe way to add it in QuestionAttribute from core update but not the settings .
And current system already to add some script with params (see framagit.org/SondagePro-LimeSurvey-plugin/altExcludeMultiple for an example).
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.
Last edit: 6 years 6 months ago by DenisChenu. Reason: Add ranking example
The topic has been locked.