- Posts: 62
- Thank you received: 3
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Create Array 5 Point Choice with Random number, category and maximum score
- Maverick87Shaka
- Topic Author
- Offline
- Senior Member
Less
More
4 years 2 months ago #194238
by Maverick87Shaka
Create Array 5 Point Choice with Random number, category and maximum score was created by Maverick87Shaka
Hi,
I'm lost in front a this particular request. I'm pretty sure we can do it inside limesurvey since you can do pretty everything mixing javascript and native function, but I'm little bit lost in front of this needing.
What I have to do is create an unique array style question, for rating from 1 to 5 some statement. The whole "database" is build up from 15 statement for each categories, the total categories are 4. For now it's pretty linear Array 5 point choice question type.
The two main problem are:
1) they don't want to show all the 15 statement, but only 5 for each category, randomly picked from the whole database and also have a randomized order of them.
So it will be a 20 subquestion statment to rate.
2) they want to create a maximum score basket, for example 60 points, so you basically can't answer 5 to all 20 statement. The current total sums of points should be always visible from user while it's filling up ( top of the page or whatever )
Someone have some idea? I'm little bit lost in front of this reqeust hahahah.
p.s. the result expected is to have the value of points for each category, and category should not be "visible" to user while is filling up the questionnaire.
Thanks!
I'm lost in front a this particular request. I'm pretty sure we can do it inside limesurvey since you can do pretty everything mixing javascript and native function, but I'm little bit lost in front of this needing.
What I have to do is create an unique array style question, for rating from 1 to 5 some statement. The whole "database" is build up from 15 statement for each categories, the total categories are 4. For now it's pretty linear Array 5 point choice question type.
The two main problem are:
1) they don't want to show all the 15 statement, but only 5 for each category, randomly picked from the whole database and also have a randomized order of them.
So it will be a 20 subquestion statment to rate.
2) they want to create a maximum score basket, for example 60 points, so you basically can't answer 5 to all 20 statement. The current total sums of points should be always visible from user while it's filling up ( top of the page or whatever )
Someone have some idea? I'm little bit lost in front of this reqeust hahahah.
p.s. the result expected is to have the value of points for each category, and category should not be "visible" to user while is filling up the questionnaire.
Thanks!
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
4 years 2 months ago - 4 years 2 months ago #194259
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Create Array 5 Point Choice with Random number, category and maximum score
Hi,
create a question of type "short text" and insert the following script
As you see we create 4 arrays, shuffle them and take the first 5 elements.
You will get a string like this
,13,01,04,09,03,30,25,29,16,22,33,41,43,31,37,60,54,48,53,51,
The leading and trailing comma are important.
Now you may set the subquestion relevance of each item
strpos(Q1,',01,')>0
strpos(Q1,',02,')>0
strpos(Q1,',03,')>0
...
and randomize the dispolay of the subquestions.
Joffm
And an example:
create a question of type "short text" and insert the following script
Code:
<script type="text/javascript" charset="utf-8"> function shuffle(array) { var currentIndex = array.length, temporaryValue, randomIndex; // While there remain elements to shuffle... while (0 !== currentIndex) { // Pick a remaining element... randomIndex = Math.floor(Math.random() * currentIndex); currentIndex -= 1; // And swap it with the current element. temporaryValue = array[currentIndex]; array[currentIndex] = array[randomIndex]; array[randomIndex] = temporaryValue; } return array; } $(document).on('ready pjax:scriptcomplete',function(){ // Fill the array var arr1 =["01","02","03","04","05","06","07","08","09",10,11,12,13,14,15]; var arr2 =[16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]; var arr3 =[31,32,33,34,35,36,37,38,39,40,41,42,43,44,45]; var arr4 =[46,47,48,49,50,51,52,53,54,55,56,57,58,59,60]; arr1 = shuffle(arr1); arr2 = shuffle(arr2); arr3 = shuffle(arr3); arr4 = shuffle(arr4); anumbers = '#,' + arr1.slice(0,5).join(',')+ ','; anumbers = anumbers + arr2.slice(0,5).join(',')+ ','; anumbers = anumbers + arr3.slice(0,5).join(',')+ ','; anumbers = anumbers + arr4.slice(0,5).join(',')+ ','; $('#question{QID} input[type="text"]').val(anumbers); // $('#question{QID}').hide(); }); </script>
As you see we create 4 arrays, shuffle them and take the first 5 elements.
You will get a string like this
,13,01,04,09,03,30,25,29,16,22,33,41,43,31,37,60,54,48,53,51,
The leading and trailing comma are important.
Now you may set the subquestion relevance of each item
strpos(Q1,',01,')>0
strpos(Q1,',02,')>0
strpos(Q1,',03,')>0
...
and randomize the dispolay of the subquestions.
Joffm
And an example:
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 years 2 months ago by Joffm. Reason: function strpos corrected
The following user(s) said Thank You: tpartner, Maverick87Shaka
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
4 years 2 months ago #194271
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 Create Array 5 Point Choice with Random number, category and maximum score
Nice!
One suggestion that would allow you to place the hidden control question in the same group as the array...
Change this line:
To this:
This will fire Expression Manager after loading the hidden input, triggering relevance.
One suggestion that would allow you to place the hidden control question in the same group as the array...
Change this line:
Code:
$('#question{QID} input[type="text"]').val(anumbers);
To this:
Code:
$('#question{QID} input[type="text"]').val(anumbers).trigger('keyup');
This will fire Expression Manager after loading the hidden input, triggering relevance.
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: Joffm, Maverick87Shaka
The topic has been locked.
- Maverick87Shaka
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 62
- Thank you received: 3
4 years 1 month ago - 4 years 1 month ago #194592
by Maverick87Shaka
Replied by Maverick87Shaka on topic Create Array 5 Point Choice with Random number, category and maximum score
This is absolute an amazing starting point, and works well.
I've just a "problem" using standard array instead 5 point choice with random display option on, all the rating answer option are mixed up, not only the subquestions order. Since it's a really "scale" vote that you have to provide, it's not comfortable for the user.
But your idea works really well also with question type "Array (5 Point choice)", but I've a problem with this question type and my hosted limesurvey, the random and mandatory option are not saved. When I hit save button, the page reload and I found again my question not randomized and not mandatory.
On top of that, I still need to manage the "total score", so I have to sum all the value given in the array somewhere, and warning ( with no option to submit ) if you exceed 60 total point assigned to subquestions.
I've just a "problem" using standard array instead 5 point choice with random display option on, all the rating answer option are mixed up, not only the subquestions order. Since it's a really "scale" vote that you have to provide, it's not comfortable for the user.
But your idea works really well also with question type "Array (5 Point choice)", but I've a problem with this question type and my hosted limesurvey, the random and mandatory option are not saved. When I hit save button, the page reload and I found again my question not randomized and not mandatory.
On top of that, I still need to manage the "total score", so I have to sum all the value given in the array somewhere, and warning ( with no option to submit ) if you exceed 60 total point assigned to subquestions.
Last edit: 4 years 1 month ago by Maverick87Shaka.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
4 years 1 month ago - 4 years 1 month ago #194593
by Joffm
The subquestions? Of course it is.
You said
Then you should consider a different design.
Then {sum(self.NAOK)<61} is sufficient
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Create Array 5 Point Choice with Random number, category and maximum score
What do you talk about?all the rating otopn are mixed up
The subquestions? Of course it is.
You said
Or do you want to have the randomization within the categories.and also have a randomized order of them.
Then you should consider a different design.
Calculate the sum and validate. But in this case you really should use a "normal" array with numeric answer codes.the "total score", so I have to sum all the value given in the array somewhere, and warning ( with no option to submit
Then {sum(self.NAOK)<61} is sufficient
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 years 1 month ago by Joffm.
The topic has been locked.
- Maverick87Shaka
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 62
- Thank you received: 3
4 years 1 month ago - 4 years 1 month ago #194595
by Maverick87Shaka
Joffm[/quote]
Any tip to do it? And also make it visible all the time for the user, like in the help section something like "34 of 60 points assigned"
Replied by Maverick87Shaka on topic Create Array 5 Point Choice with Random number, category and maximum score
I mean that using normal array with randomize option, make also the answer option scale 1,2,3,4,5 mixed up and not only the subquestions.Joffm wrote:
What do you talk about?all the rating otopn are mixed up
The subquestions? Of course it is.
Calculate the sum and validate. But in this case you really should use a "normal" array with numeric answer codes.Joffm wrote: the "total score", so I have to sum all the value given in the array somewhere, and warning ( with no option to submit
Joffm[/quote]
Any tip to do it? And also make it visible all the time for the user, like in the help section something like "34 of 60 points assigned"
Last edit: 4 years 1 month ago by Maverick87Shaka. Reason: image to small
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
4 years 1 month ago #194597
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Create Array 5 Point Choice with Random number, category and maximum score
Hi,
1. the randomization of answer options is reproducable (at least in 4.1.4.)
Seems to be a bug.
2. Something like that?
Here the requirement was: max. 100% - show the remaining %
Open a new topic about that in the German part to avoid the language gap.
Joffm
1. the randomization of answer options is reproducable (at least in 4.1.4.)
Seems to be a bug.
2. Something like that?
Here the requirement was: max. 100% - show the remaining %
Open a new topic about that in the German part to avoid the language gap.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
The topic has been locked.
- Maverick87Shaka
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 62
- Thank you received: 3
4 years 1 month ago #194598
by Maverick87Shaka
btw I don't speak German :whistle:
Replied by Maverick87Shaka on topic Create Array 5 Point Choice with Random number, category and maximum score
lucky me like every-time :dry: what is the best option to report and hope to get an hotfix included in the next release?Joffm wrote: Hi,
1. the randomization of answer options is reproducable (at least in 4.1.4.)
Seems to be a bug.
Definitely something like this, but even "simpler" with just numeric sum without have it expressed in %.Joffm wrote: 2. Something like that?
Here the requirement was: max. 100% - show the remaining %
Open a new topic about that in the German part to avoid the language gap.
Joffm
btw I don't speak German :whistle:
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
4 years 1 month ago #194601
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Create Array 5 Point Choice with Random number, category and maximum score
Hi,
Now I realized that this message depends on the language of the survey, not the language of the GUI.
Okay, it's quite easy.
1. You have numeric codes of your answer options, like "1","2","3",... that represent the points
Then insert into the queston text just
{sum(self.NAOK)}
You will see that this is expanded to {sum(Q2_SQ001.NAOK, Q2_SQ002.NAOK, Q2_SQ003.NAOK, Q2_SQ004.NAOK, Q2_SQ005.NAOK)}
manual.limesurvey.org/Expression_Manager....27that.27_variables
And in your question validation equation accordingly sum(self.NAOK)<61
You may insert a question tip of your choice like "Don't distribute more than 60 points"
2. You may use the assessment values, though I do not see an advantage, except:
You want to keep the answer codes in your database but calculate the points differently.
Then you have to use
{sum(self.valueNAOK)}
In this example I set the assessment values "-5", "-2", "0", "2","5".
3. If the points are calculated differently in each subquestion, you can't use the "self" operator, but have to calculate "one by one", like
{sum(if(Q1_SQ001.NAOK==1,-5, if(Q1_SQ001.NAOK==2,-2, if(Q1_SQ001.NAOK=,0, if(Q1_SQ001.NAOK==4,2,5)))), if(Q1_SQ002.NAOK==1,20, if(Q1_SQ002.NAOK==2,15, if(Q1_SQ002.NAOK=,10, if(Q1_SQ002.NAOK==4,5,0)))),...
This will be really long.
Joffm
Yes, I was a bit confused as I saw the German message in your screenshot.btw I don't speak German
Now I realized that this message depends on the language of the survey, not the language of the GUI.
Okay, it's quite easy.
1. You have numeric codes of your answer options, like "1","2","3",... that represent the points
Then insert into the queston text just
{sum(self.NAOK)}
You will see that this is expanded to {sum(Q2_SQ001.NAOK, Q2_SQ002.NAOK, Q2_SQ003.NAOK, Q2_SQ004.NAOK, Q2_SQ005.NAOK)}
manual.limesurvey.org/Expression_Manager....27that.27_variables
And in your question validation equation accordingly sum(self.NAOK)<61
You may insert a question tip of your choice like "Don't distribute more than 60 points"
2. You may use the assessment values, though I do not see an advantage, except:
You want to keep the answer codes in your database but calculate the points differently.
Then you have to use
{sum(self.valueNAOK)}
In this example I set the assessment values "-5", "-2", "0", "2","5".
3. If the points are calculated differently in each subquestion, you can't use the "self" operator, but have to calculate "one by one", like
{sum(if(Q1_SQ001.NAOK==1,-5, if(Q1_SQ001.NAOK==2,-2, if(Q1_SQ001.NAOK=,0, if(Q1_SQ001.NAOK==4,2,5)))), if(Q1_SQ002.NAOK==1,20, if(Q1_SQ002.NAOK==2,15, if(Q1_SQ002.NAOK=,10, if(Q1_SQ002.NAOK==4,5,0)))),...
This will be really long.
Joffm
Open here "Community / bug tracker", login with your forum account, and select "bug reports" in the upper right corner.what is the best option to report
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
The following user(s) said Thank You: Maverick87Shaka
The topic has been locked.
- Maverick87Shaka
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 62
- Thank you received: 3
4 years 1 month ago - 4 years 1 month ago #194656
by Maverick87Shaka
Replied by Maverick87Shaka on topic Create Array 5 Point Choice with Random number, category and maximum score
Amazing Joffm, All the logics are there, now I'm playing it expanding and putting together but definitely something that I can do with Limesurvey! Thanks so much!
EDIT 2: Ok no lucky with this concept.
Adding around 300 subquestions ( that is the total database for my assesment ) I've horrible performance when reaching array question.
It's don't take so much time to load up all of them, and then clear the one based on the first question string, but it's become terrible trying to assign a value to each subquestion, it's stay really long on each click. Almost unusable experience.
EDIT3: even if it's the solution of the scoring system, adding the {sum(self.NAOK)} in the question text or the sum(self.NAOK)<61 in the validation equation is causing a tremendous lags of the system, making it impossibile to se and fill up from a user.
There could be something different that I can try?
EDIT 2: Ok no lucky with this concept.
Adding around 300 subquestions ( that is the total database for my assesment ) I've horrible performance when reaching array question.
It's don't take so much time to load up all of them, and then clear the one based on the first question string, but it's become terrible trying to assign a value to each subquestion, it's stay really long on each click. Almost unusable experience.
EDIT3: even if it's the solution of the scoring system, adding the {sum(self.NAOK)} in the question text or the sum(self.NAOK)<61 in the validation equation is causing a tremendous lags of the system, making it impossibile to se and fill up from a user.
There could be something different that I can try?
Last edit: 4 years 1 month ago by Maverick87Shaka. Reason: problem still there, low performance
The topic has been locked.
- Maverick87Shaka
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 62
- Thank you received: 3
4 years 1 month ago #194684
by Maverick87Shaka
Replied by Maverick87Shaka on topic Create Array 5 Point Choice with Random number, category and maximum score
Using the whole database of 300 subquestions in the Array 5 point, and selecting 60 of them with the javascript to build a "random "string in the short text question works fine, it's not causing trouble.
The performance impact comes when I try to use {sum(self.NAOK)} in the question text or sum(self.NAOK)<150 in the validation equation.
Any tip or idea on how to avoid this performance problem?
The performance impact comes when I try to use {sum(self.NAOK)} in the question text or sum(self.NAOK)<150 in the validation equation.
Any tip or idea on how to avoid this performance problem?
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12888
- Thank you received: 3965
4 years 1 month ago #194688
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Create Array 5 Point Choice with Random number, category and maximum score
Please attach a lss export with only these questions.
Joffm
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.