- Posts: 16
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Order a questions
- psoliveira
- Topic Author
- Offline
- New Member
Less
More
7 years 3 months ago #147610
by psoliveira
Order a questions was created by psoliveira
Hi everybody,
I want to order a array based on the current week day.
I know that limesurvey allows to order randomly a question and there are some workarounds for this too. But my order is specify and not random.
If someone answers on a thursday, that should be the first item from the list and go down (wednesday, tuesday, monday...) and this should always change depending on the day of the week the survey is taken.
Thank you for your help.
I want to order a array based on the current week day.
I know that limesurvey allows to order randomly a question and there are some workarounds for this too. But my order is specify and not random.
If someone answers on a thursday, that should be the first item from the list and go down (wednesday, tuesday, monday...) and this should always change depending on the day of the week the survey is taken.
Thank you for your help.
Attachments:
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13637
- Thank you received: 2491
7 years 2 months ago - 7 years 2 months ago #147629
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 Order a questions
Hi,
No way to have a specific order currently : i have a very old fork about this issue.
We a feature request about order of answer/sub-question : bugs.limesurvey.org/view.php?id=11988
No way to have a specific order currently : i have a very old fork about this issue.
We a feature request about order of answer/sub-question : bugs.limesurvey.org/view.php?id=11988
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: 7 years 2 months ago by DenisChenu.
The topic has been locked.
- holch
- Online
- LimeSurvey Community Team
Less
More
- Posts: 11645
- Thank you received: 2739
7 years 2 months ago #147633
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Order a questions
I was thinking about this and while there is no way to order this out of the box, but as a workaround you could create 7 questions for this, with the respective order. Now you would just need to figure out how to find out which day of the week it is to show one of these questions and hide the others. Later you will have join these for analysis. Is probably doable via Javascript.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10104
- Thank you received: 3593
7 years 2 months ago #147647
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 Order a questions
Assuming you set up the array sub-questions ordered Sunday-Saturday, adding this script to the source of the array should do the trick:
Sample survey attached:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); // Identify the day of the week var todayDate = new Date(); var weekDay = todayDate.getDay(); // Move the array rows $('tr.answers-list:lt('+weekDay+')', thisQuestion).appendTo($('table.subquestion-list tbody:eq(0)', thisQuestion)); }); </script>
Sample survey attached:
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.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10104
- Thank you received: 3593
7 years 2 months ago - 7 years 2 months ago #147648
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 Order a questions
Oops, sorry, I mis-read the order that you want. If you order the sub-questions reversed Saturday, Friday...Monday,Sunday, use this script:
Sample survey:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); // Identify the day of the week var todayDate = new Date(); var weekDay = todayDate.getDay(); var reverseWeekDay = 6-weekDay // Move the array rows $('tr.answers-list:lt('+(reverseWeekDay)+')', thisQuestion).appendTo($('table.subquestion-list tbody:eq(0)', thisQuestion)); }); </script>
Sample survey:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last edit: 7 years 2 months ago by tpartner.
The following user(s) said Thank You: psoliveira
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13637
- Thank you received: 2491
7 years 2 months ago - 7 years 2 months ago #147650
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 Order a questions
tpartner solution are better, becaus i have no idea to set the order depend on day of the week in Expression Manager with this new plugin :
framagit.org/SondagePro-LimeSurvey-plugi...Ordering/tree/master
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: 7 years 2 months ago by DenisChenu.
The following user(s) said Thank You: psoliveira
The topic has been locked.
- psoliveira
- Topic Author
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 0
7 years 2 months ago #147704
by psoliveira
Replied by psoliveira on topic Order a questions
This works perfectly.
Thanks tpartner.
Thanks tpartner.
The topic has been locked.
- psoliveira
- Topic Author
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 0
7 years 2 months ago #147709
by psoliveira
Replied by psoliveira on topic Order a questions
I also tried this on a array but doesn't work. Any idea why?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10104
- Thank you received: 3593
7 years 2 months ago #147710
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 Order a questions
I don't understand the question. The attached examples are arrays and they do work.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- psoliveira
- Topic Author
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 0
7 years 2 months ago #147711
by psoliveira
Replied by psoliveira on topic Order a questions
Sorry, i meant a texts array.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10104
- Thank you received: 3593
7 years 2 months ago - 7 years 2 months ago #147743
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 Order a questions
This should work for normal ordering (Sunday,Monday...Friday,Saturday):
And this for reverse ordering (Saturday, Friday...Monday,Sunday):
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); // Identify the day of the week var todayDate = new Date(); var weekDay = todayDate.getDay(); // Move the array rows $('table.subquestion-list tr[id^="javatbd"]:lt('+weekDay+')', thisQuestion).appendTo($('table.subquestion-list tbody:eq(0)', thisQuestion)); }); </script>
And this for reverse ordering (Saturday, Friday...Monday,Sunday):
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); // Identify the day of the week var todayDate = new Date(); var weekDay = todayDate.getDay(); var reverseWeekDay = 6-weekDay // Move the array rows $('table.subquestion-list tr[id^="javatbd"]:lt('+(reverseWeekDay)+')', thisQuestion).appendTo($('table.subquestion-list tbody:eq(0)', thisQuestion)); }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 7 years 2 months ago by tpartner.
The following user(s) said Thank You: psoliveira
The topic has been locked.
- psoliveira
- Topic Author
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 0
7 years 2 months ago #147752
by psoliveira
Replied by psoliveira on topic Order a questions
Thank you again tpartner.
I've also used this on a multiple numerical input.
Here's the code for the reverse ordering:
And the code for normal ordering:
I've also used this on a multiple numerical input.
Here's the code for the reverse ordering:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); // Identify the day of the week var todayDate = new Date(); var weekDay = todayDate.getDay(); var reverseWeekDay = 6-weekDay // Move the array rows $('table.table-multi-num tr[id^="javatbd"]:lt('+(reverseWeekDay)+')', thisQuestion).appendTo($('table.table-multi-num tbody:eq(0)', thisQuestion)); }); </script>
And the code for normal ordering:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); // Identify the day of the week var todayDate = new Date(); var weekDay = todayDate.getDay(); // Move the array rows $('table.table-multi-num tr[id^="javatbd"]:lt('+(weekDay)+')', thisQuestion).appendTo($('table.table-multi-num tbody:eq(0)', thisQuestion)); }); </script>
The topic has been locked.