- Posts: 14
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Is there a "displayed" property for text question?
- Kristoss
- Topic Author
- Offline
- New Member
Less
More
4 years 5 months ago #190424
by Kristoss
Is there a "displayed" property for text question? was created by Kristoss
Hi Guys,
I'm using text question to show some movies to my participants (via iframe). I would like to show 4 movies from pool of 16 however there are some exclusions (i.e. if participant watched movie 1 he cannot watch movies 3,7,9 and 13)
Is LS aware that text question was showed? I can't find any information about this property (is there any?) and i want to use it to have control over the question randomization.
Alternative I tried to construct dummy-hidden question with default answer but I see that it's value is defined after lunching the survey not after displaying question.
I'm using text question to show some movies to my participants (via iframe). I would like to show 4 movies from pool of 16 however there are some exclusions (i.e. if participant watched movie 1 he cannot watch movies 3,7,9 and 13)
Is LS aware that text question was showed? I can't find any information about this property (is there any?) and i want to use it to have control over the question randomization.
Alternative I tried to construct dummy-hidden question with default answer but I see that it's value is defined after lunching the survey not after displaying question.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
4 years 5 months ago #190427
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 Is there a "displayed" property for text question?
Please refer to the manual - Qcode.relevanceStatus -
manual.limesurvey.org/Expression_Manager...#Access_to_variables
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5033
- Thank you received: 1257
4 years 5 months ago #190429
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 Is there a "displayed" property for text question?
Is relevanceStatus really showing if a question "WAS" displayed? I thought that is only on the current page?
If I get the threadstarter right, four unique random numbers between 1-16 upfront would do the trick. LimeSurvey isn't offering dynamic or static lists, where a one line "Pick four out of 16" would do the trick. A pure EM solution with JS seems not possible.
If I get the threadstarter right, four unique random numbers between 1-16 upfront would do the trick. LimeSurvey isn't offering dynamic or static lists, where a one line "Pick four out of 16" would do the trick. A pure EM solution with JS seems not possible.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- Kristoss
- Topic Author
- Offline
- New Member
Less
More
- Posts: 14
- Thank you received: 0
4 years 5 months ago #190432
by Kristoss
Replied by Kristoss on topic Is there a "displayed" property for text question?
Thank you for answer.
I'm thinking about workaround. Is there a way via JS, implemented in the source of text question, to set the answer value of dummy question? Maybe if I could set it's value but AFTER it was displayed i could use it in EM.
I'm thinking about workaround. Is there a way via JS, implemented in the source of text question, to set the answer value of dummy question? Maybe if I could set it's value but AFTER it was displayed i could use it in EM.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
4 years 5 months ago #190474
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 Is there a "displayed" property for text question?
Did you try Qcode.relevanceStatus?
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
The topic has been locked.
- Kristoss
- Topic Author
- Offline
- New Member
Less
More
- Posts: 14
- Thank you received: 0
4 years 5 months ago - 4 years 5 months ago #190514
by Kristoss
Replied by Kristoss on topic Is there a "displayed" property for text question?
Hi,
I tried but i must missing something. I don't understand in what sequence LS is processing relevanceStatus. In my particular case I want to achieve something like this:
a) from pool of 16 groups pick 1 (ie. id=1)
b) (example id) if the id=1 than change relevance of other groups id=3,id=7,id=8, id=13, to 0
c) from reaming group random pick 1 than proceed to "b" until the end of items
Is it possible to achieve this with "relevanceStatus"? I tired to set relevanceStatus within source code of text questions but with no success.
I tried but i must missing something. I don't understand in what sequence LS is processing relevanceStatus. In my particular case I want to achieve something like this:
a) from pool of 16 groups pick 1 (ie. id=1)
b) (example id) if the id=1 than change relevance of other groups id=3,id=7,id=8, id=13, to 0
c) from reaming group random pick 1 than proceed to "b" until the end of items
Is it possible to achieve this with "relevanceStatus"? I tired to set relevanceStatus within source code of text questions but with no success.
Last edit: 4 years 5 months ago by Kristoss.
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5033
- Thank you received: 1257
4 years 5 months ago #190533
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 Is there a "displayed" property for text question?
You should export your survey (reduced version with only the relevant questions) as LSS and attach that file here.Kristoss wrote: I tired to set relevanceStatus within source code of text questions but with no success.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- Kristoss
- Topic Author
- Offline
- New Member
Less
More
- Posts: 14
- Thank you received: 0
4 years 5 months ago - 4 years 5 months ago #190535
by Kristoss
Replied by Kristoss on topic Is there a "displayed" property for text question?
This LS contains 16 text based question. The logic of random selection is presented in my previous post. Thank you all for help!
And this is the list of all exclusions (for each id there are 5 relevant exclusions):
ID EX1 EX2 EX3 EX4 EX5
1 3 5 7 9 13
2 4 6 8 10 14
3 1 5 7 11 15
4 2 6 8 12 16
5 1 3 7 9 13
6 2 4 8 10 14
7 1 3 5 11 15
8 2 4 6 12 16
9 11 13 15 1 5
10 12 14 16 2 6
11 9 13 15 3 7
12 10 14 16 4 8
13 9 11 15 1 5
14 10 12 16 2 6
15 9 11 13 3 7
16 10 12 14 4 8
And this is the list of all exclusions (for each id there are 5 relevant exclusions):
ID EX1 EX2 EX3 EX4 EX5
1 3 5 7 9 13
2 4 6 8 10 14
3 1 5 7 11 15
4 2 6 8 12 16
5 1 3 7 9 13
6 2 4 8 10 14
7 1 3 5 11 15
8 2 4 6 12 16
9 11 13 15 1 5
10 12 14 16 2 6
11 9 13 15 3 7
12 10 14 16 4 8
13 9 11 15 1 5
14 10 12 16 2 6
15 9 11 13 3 7
16 10 12 14 4 8
Attachments:
Last edit: 4 years 5 months ago by Kristoss.
The topic has been locked.
- Joffm
- Away
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
4 years 5 months ago #190554
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Is there a "displayed" property for text question?
Hi, Kristoss,
you can do it like this:
with a small javascript snippet create an array that only contains valid movies according to a random ID.
Shuffle the array and slice it to a length of four and display it as a string.
I used the characters "A", "B", "C",...
So you might get something like "HFBO".
All movie groups have the same randomization group name and the relevance equation "the string contains the character that matches the movie group (A=1, B=2, C=3,...)"
Joffm
you can do it like this:
with a small javascript snippet create an array that only contains valid movies according to a random ID.
Shuffle the array and slice it to a length of four and display it as a string.
I used the characters "A", "B", "C",...
So you might get something like "HFBO".
All movie groups have the same randomization group name and the relevance equation "the string contains the character that matches the movie group (A=1, B=2, C=3,...)"
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- Kristoss
- Topic Author
- Offline
- New Member
Less
More
- Posts: 14
- Thank you received: 0
4 years 5 months ago - 4 years 5 months ago #190555
by Kristoss
Replied by Kristoss on topic Is there a "displayed" property for text question?
Thank you Joffm!
I'm not the programmer so just to clarify: is your code actually pick the value from REMAINING items after each shuffle? The logic should be as fallows:
1. select random item from pool of 16 (ie. id = 1)
2. remove selected id from selection pool and corresponding items (ie. remove selected id =1 and remove corresponding ids = 3 5 7 9 13;)
3. select random item from remaining items (ie. ids = 2,4,6,8,10,11,12,14,15,16;)
4. select random item from remaining pool (ie. current pool size = 10 items)
5. proceed with steps 2 & 3 until selecting 4 items
I'm not the programmer so just to clarify: is your code actually pick the value from REMAINING items after each shuffle? The logic should be as fallows:
1. select random item from pool of 16 (ie. id = 1)
2. remove selected id from selection pool and corresponding items (ie. remove selected id =1 and remove corresponding ids = 3 5 7 9 13;)
3. select random item from remaining items (ie. ids = 2,4,6,8,10,11,12,14,15,16;)
4. select random item from remaining pool (ie. current pool size = 10 items)
5. proceed with steps 2 & 3 until selecting 4 items
Last edit: 4 years 5 months ago by Kristoss.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
4 years 5 months ago #190572
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 Is there a "displayed" property for text question?
My JavaScript solution...
Create a multiple-numeric type question, hide it with a CSS class and place this script in the question source:
This will randomize the pool and sequentially load the inputs of the multiple-numeric with pool values, removing "exclusions" as it does so.
Then you can place relevance on the following questions something like:
Here is a sample survey attached with the multiple-numeric left visible and console log items to indicate the sequential state of the pool array:
Create a multiple-numeric type question, hide it with a CSS class and place this script in the question source:
Code:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Define the pool var pool = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]; // Shuffle the pool shuffleArray(pool); console.log('log - pool: '+ pool); // Define the exclusions var exclusions = { 1: [3,5,7,9,13], 2: [4,6,8,10,14], 3: [1,5,7,11,15], 4: [2,6,8,12,16], 5: [1,3,7,9,13], 6: [2,4,8,10,14], 7: [1,3,5,11,15], 8: [2,4,6,12,16], 9: [11,13,15,1,5], 10: [12,14,16,2,6], 11: [9,13,15,3,7], 12: [10,14,16,4,8], 13: [9,11,15,1,5], 14: [10,12,16,2,6], 15: [9,11,13,3,7], 16: [10,12,14,4,8] } // Loop through the multiple-numeric inputs $('input:text', thisQuestion).each(function(i){ // Load the input with the first element of the pool array var thisNumber = pool[0]; $('input:text:eq('+i+')', thisQuestion).val(thisNumber).trigger('keyup'); // Now, remove the first element of the pool array pool.splice(0, 1); // Remove pool elements per the exclusions var theseExclusions = exclusions[thisNumber]; console.log('log - exclusions: '+ theseExclusions); $.each(theseExclusions, function(i, val) { var index = pool.indexOf(val); if (index > -1) { pool.splice(index, 1); } }); console.log('log - pool: '+ pool); }); }); 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; } </script>
This will randomize the pool and sequentially load the inputs of the multiple-numeric with pool values, removing "exclusions" as it does so.
Then you can place relevance on the following questions something like:
Code:
Q1_SQ001 == '1' OR Q1_SQ002 == '1' OR Q1_SQ003 == '1' OR Q1_SQ004 == '1'
Here is a sample survey attached with the multiple-numeric left visible and console log items to indicate the sequential state of the pool array:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- Joffm
- Away
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
4 years 5 months ago #190577
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Is there a "displayed" property for text question?
Yes, it does.
But tpartner's solution is better.
I was not able to do the exclusion, therefore I did it by inclusion.
Joffm
But tpartner's solution is better.
I was not able to do the exclusion, therefore I did it by inclusion.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.