- Posts: 7
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
assign default value
- jessicapidoux
- Topic Author
- Offline
- New Member
Less
More
5 years 7 months ago - 5 years 7 months ago #171887
by jessicapidoux
assign default value was created by jessicapidoux
Dear all,
First I have to tell you this is my first survey and I don't know anything about coding. Maybe that is the reason why I haven't found a solution that is suitable to my skills.
After looking for an answer in the forums for several hours, I am desperately to find a solution to my problem that is assigning a default value to an array.
I have a group of questions, inside I have a subquestion "hobbies" and the answers are a likert scale from 1 (strongly disagree) to 7 (Strongly agree)
I want to set answer "1" as checked, default value, to my SQ001 of q1
What can I do?
this javascript I have found doesn't work:
<script type="text/javascript">
$(document).ready(function () {
col = 1;
$('input[type=radio][id$=' + col + ']', $('#q1')).each(function () {
$(this).attr('checked', true);
});
});
</script>
Source: uilots-labs.wp.hum.uu.nl/how-to/default-answers-in-limesurvey/
I tried adding it in the source code of the question, the subquestion and the answer but it doesnt work.
I have found this Assignment Operator:
{Q1_SQ1=(is_empty(Q1_SQ1.NAOK),"A99",Q1_SQ1.NAOK)}
and modified it to my survey:
{q1_SQ001=(is_empty(q1_SQ001.NAOK),"1",q1_SQ001.NAOK)}
but don't know where to put that, I tried here: Question validation equation but it doesn't work
Source: manual.limesurvey.org/Expression_Manager..._Assignment_Operator
I also found this script
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var defaultText = 'My default';
$('#question{QID} tr[id^="javatbd"]').each(function(i) {
if($('input[type="text"]:eq(0)', this).val() == '') {
$('input[type="text"]:eq(0)', this).val(defaultText)
}
});
});
</script>
but I don't know how to adapt it to my case and where to add it
Source: www.limesurvey.org/forum/can-i-do-this-w...ion-type-array-texts
Finally, I know a solution would be to create a Question type - Equation but I don't find the documentation to create something like what I need in the link below :
manual.limesurvey.org/Question_type_-_Equation
Thank you very much for your help.
First I have to tell you this is my first survey and I don't know anything about coding. Maybe that is the reason why I haven't found a solution that is suitable to my skills.
After looking for an answer in the forums for several hours, I am desperately to find a solution to my problem that is assigning a default value to an array.
I have a group of questions, inside I have a subquestion "hobbies" and the answers are a likert scale from 1 (strongly disagree) to 7 (Strongly agree)
I want to set answer "1" as checked, default value, to my SQ001 of q1
What can I do?
this javascript I have found doesn't work:
<script type="text/javascript">
$(document).ready(function () {
col = 1;
$('input[type=radio][id$=' + col + ']', $('#q1')).each(function () {
$(this).attr('checked', true);
});
});
</script>
Source: uilots-labs.wp.hum.uu.nl/how-to/default-answers-in-limesurvey/
I tried adding it in the source code of the question, the subquestion and the answer but it doesnt work.
I have found this Assignment Operator:
{Q1_SQ1=(is_empty(Q1_SQ1.NAOK),"A99",Q1_SQ1.NAOK)}
and modified it to my survey:
{q1_SQ001=(is_empty(q1_SQ001.NAOK),"1",q1_SQ001.NAOK)}
but don't know where to put that, I tried here: Question validation equation but it doesn't work
Source: manual.limesurvey.org/Expression_Manager..._Assignment_Operator
I also found this script
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var defaultText = 'My default';
$('#question{QID} tr[id^="javatbd"]').each(function(i) {
if($('input[type="text"]:eq(0)', this).val() == '') {
$('input[type="text"]:eq(0)', this).val(defaultText)
}
});
});
</script>
but I don't know how to adapt it to my case and where to add it
Source: www.limesurvey.org/forum/can-i-do-this-w...ion-type-array-texts
Finally, I know a solution would be to create a Question type - Equation but I don't find the documentation to create something like what I need in the link below :
manual.limesurvey.org/Question_type_-_Equation
Thank you very much for your help.
Attachments:
Last edit: 5 years 7 months ago by jessicapidoux.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12788
- Thank you received: 3940
5 years 7 months ago #171888
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic assign default value
Hi,
Remove the quotes from "1". Quotes mean "This is a string"; but I think you are assigning numerical codes to your scale.
Now at the start of your survey create a question of type "equation" and write this as question text.
{Q1_SQ001=if(is_empty(Q1_SQ001),1,Q1_SQ001)}
{Q1_SQ002=if(is_empty(Q1_SQ002),1,Q1_SQ002)}
{Q1_SQ003=if(is_empty(Q1_SQ003),1,Q1_SQ003)}
{Q1_SQ004=if(is_empty(Q1_SQ004),1,Q1_SQ004)}
You see, for each subquestion one equation.
See here about equations:
manual.limesurvey.org/Question_type_-_Equation
Best regards
Joffm
That's nearly fine.{q1_SQ001=(is_empty(q1_SQ001.NAOK),"1",q1_SQ001.NAOK)}
Remove the quotes from "1". Quotes mean "This is a string"; but I think you are assigning numerical codes to your scale.
Now at the start of your survey create a question of type "equation" and write this as question text.
{Q1_SQ001=if(is_empty(Q1_SQ001),1,Q1_SQ001)}
{Q1_SQ002=if(is_empty(Q1_SQ002),1,Q1_SQ002)}
{Q1_SQ003=if(is_empty(Q1_SQ003),1,Q1_SQ003)}
{Q1_SQ004=if(is_empty(Q1_SQ004),1,Q1_SQ004)}
You see, for each subquestion one equation.
See here about equations:
manual.limesurvey.org/Question_type_-_Equation
Best regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
The following user(s) said Thank You: DenisChenu
The topic has been locked.
- jessicapidoux
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
5 years 7 months ago #171890
by jessicapidoux
Replied by jessicapidoux on topic assign default value
Hi, thanks a lot for your quick answer.
I have tried but it doesn't work in my survey.
Please find attached two print screens with my survey configuration with the equation question and a preview of the question.
Regards,
Jessica
I have tried but it doesn't work in my survey.
Please find attached two print screens with my survey configuration with the equation question and a preview of the question.
Regards,
Jessica
Attachments:
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12788
- Thank you received: 3940
5 years 7 months ago #171891
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic assign default value
And why did you place the equation after the question?
How do you expect this to work, if you set the default value after the question has to be answered.
Best regards
Joffm
How do you expect this to work, if you set the default value after the question has to be answered.
Best regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
The following user(s) said Thank You: DenisChenu
The topic has been locked.
- jessicapidoux
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
5 years 7 months ago - 5 years 7 months ago #171892
by jessicapidoux
Replied by jessicapidoux on topic assign default value
Thanks for the file to see the structure.
I changed the order of the equation as it was not obvious for me as it is for you.
If it's useful for somebody I leave a new comment because I think there is a bug.
I wrote:
{q1_SQ001=if(is_empty(q1_SQ001),1,q1_SQ001)}
{q1_SQ002=if(is_empty(q1_SQ002),1,q1_SQ002)}
{q1_SQ003=if(is_empty(q1_SQ003),1,q1_SQ003)}
And it worked as expected.
But then I added more rows:
{q1_SQ001=if(is_empty(q1_SQ001),1,q1_SQ001)}
{q1_SQ002=if(is_empty(q1_SQ002),1,q1_SQ002)}
{q1_SQ003=if(is_empty(q1_SQ003),1,q1_SQ003)}
{q1_SQ004=if(is_empty(q1_SQ004),1,q1_SQ004)}
{q1_SQ005=if(is_empty(q1_SQ005),1,q1_SQ005)}
{q1_SQ006=if(is_empty(q1_SQ006),1,q1_SQ006)}
{q1_SQ007=if(is_empty(q1_SQ007),1,q1_SQ007)}
When I click "save" and "preview question" I still see only the first three options
Actually, I need to click on the button "save and close" instead of the save button and then "preview question" so it works properly.
Thanks again for your help.
Have a nice day,
Jessica
I changed the order of the equation as it was not obvious for me as it is for you.
If it's useful for somebody I leave a new comment because I think there is a bug.
I wrote:
{q1_SQ001=if(is_empty(q1_SQ001),1,q1_SQ001)}
{q1_SQ002=if(is_empty(q1_SQ002),1,q1_SQ002)}
{q1_SQ003=if(is_empty(q1_SQ003),1,q1_SQ003)}
And it worked as expected.
But then I added more rows:
{q1_SQ001=if(is_empty(q1_SQ001),1,q1_SQ001)}
{q1_SQ002=if(is_empty(q1_SQ002),1,q1_SQ002)}
{q1_SQ003=if(is_empty(q1_SQ003),1,q1_SQ003)}
{q1_SQ004=if(is_empty(q1_SQ004),1,q1_SQ004)}
{q1_SQ005=if(is_empty(q1_SQ005),1,q1_SQ005)}
{q1_SQ006=if(is_empty(q1_SQ006),1,q1_SQ006)}
{q1_SQ007=if(is_empty(q1_SQ007),1,q1_SQ007)}
When I click "save" and "preview question" I still see only the first three options
Actually, I need to click on the button "save and close" instead of the save button and then "preview question" so it works properly.
Thanks again for your help.
Have a nice day,
Jessica
Attachments:
Last edit: 5 years 7 months ago by jessicapidoux.
The topic has been locked.
- jessicapidoux
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
5 years 7 months ago - 5 years 7 months ago #171893
by jessicapidoux
Replied by jessicapidoux on topic assign default value
Hi, I am afraid I need to write you again for further help.
The equation works randomly and it is not because of the save button.
When I click preview question or preview survey, sometimes I see all the first values checked, sometimes, the last two are not checked.
Please find attached my survey structure.
I have changed the equation as follows:
{q2_SQ001=if(is_empty(q2_SQ001),’Strongly disagree’,q2_SQ001)}
because my scale goes from strongly disagree to strongly agree. It is not a numerical scale but the answers' codes go from 1 to 7.
However, I tried doing it with a numerical scale and still get the same error.
Regards,
Jessica
The equation works randomly and it is not because of the save button.
When I click preview question or preview survey, sometimes I see all the first values checked, sometimes, the last two are not checked.
Please find attached my survey structure.
I have changed the equation as follows:
{q2_SQ001=if(is_empty(q2_SQ001),’Strongly disagree’,q2_SQ001)}
because my scale goes from strongly disagree to strongly agree. It is not a numerical scale but the answers' codes go from 1 to 7.
However, I tried doing it with a numerical scale and still get the same error.
Regards,
Jessica
Attachments:
Last edit: 5 years 7 months ago by jessicapidoux.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12788
- Thank you received: 3940
5 years 7 months ago - 5 years 7 months ago #171897
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic assign default value
Hi,
{q1_SQ024=if(is_empty(q1_SQ024),1,q1_SQ024)}
In both equations.
As you see, you have to enter the CODE, not the label in the equation.
Hide both equation questions.
It is not save to preview one of the questions. You cannot be sure that the equation is parsed before.
Better preview the entire survey.
And two other things.
1. Why did you use a question of type multiple in the sex question?
2. In my opinion it will be not easy to analyze the open ended question "country".
You will get different wording (UK, United Kingdom, Scotland, GB, Great Britain) or (Germany, DE, Deutschland, D), different spelling (typo) or whatever. Why not use a precoded list?
Best regards
Joffm
Typo: should be 24.{q1_SQ023=if(is_empty(q1_SQ023),’Strongly disagree’,q1_SQ024)}
{q1_SQ024=if(is_empty(q1_SQ024),1,q1_SQ024)}
In both equations.
As you see, you have to enter the CODE, not the label in the equation.
Hide both equation questions.
It is not save to preview one of the questions. You cannot be sure that the equation is parsed before.
Better preview the entire survey.
And two other things.
1. Why did you use a question of type multiple in the sex question?
2. In my opinion it will be not easy to analyze the open ended question "country".
You will get different wording (UK, United Kingdom, Scotland, GB, Great Britain) or (Germany, DE, Deutschland, D), different spelling (typo) or whatever. Why not use a precoded list?
Best regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 5 years 7 months ago by Joffm.
The topic has been locked.
- jessicapidoux
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
5 years 7 months ago #171908
by jessicapidoux
Replied by jessicapidoux on topic assign default value
Thank you very much, I updated the questions according to your suggestions. It's better now, I just hope the equation will work when I activate my survey because is still doesn't work when I preview the survey.
Have a nice day ,
Jessica
Have a nice day ,
Jessica
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12788
- Thank you received: 3940
5 years 7 months ago - 5 years 7 months ago #171914
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic assign default value
Well, then the only solution is:
send us your survey as *.lss.
I had a look at your equations in source code mode:
Looks like you copied the equations from somewhere else (like Word, o.ä.)
Please make sure that you only have plain text there.
Best regards
Joffm
send us your survey as *.lss.
I had a look at your equations in source code mode:
Looks like you copied the equations from somewhere else (like Word, o.ä.)
Please make sure that you only have plain text there.
Best regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
Last edit: 5 years 7 months ago by Joffm.
The following user(s) said Thank You: jessicapidoux
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
5 years 7 months ago #171920
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 assign default value
Or use the equation adavanced setting : it was done for this manual.limesurvey.org/Question_type_-_Eq...ation_.28equation.29Joffm wrote: …
Looks like you copied the equations from somewhere else (like Word, o.ä.)
Please make sure that you only have plain text there.…
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 following user(s) said Thank You: jessicapidoux
The topic has been locked.