assign default value

Plus d'informations
il y a 2 semaines 4 jours - il y a 2 semaines 4 jours #171887 par jessicapidoux
jessicapidoux a créé le sujet : assign default value
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.
Pièces jointes :
Dernière édition: il y a 2 semaines 4 jours par jessicapidoux.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 semaines 4 jours #171888 par Joffm
Joffm a répondu au sujet : assign default value
Hi,

{q1_SQ001=(is_empty(q1_SQ001.NAOK),"1",q1_SQ001.NAOK)}

That's nearly fine.
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:
https://manual.limesurvey.org/Question_type_-_Equation

Best regards
Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Pièces jointes :
Les utilisateur(s) suivant ont remercié: DenisChenu

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 semaines 4 jours #171890 par jessicapidoux
jessicapidoux a répondu au sujet : 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
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 semaines 4 jours #171891 par Joffm
Joffm a répondu au sujet : 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.

Fichier attaché :

Nom du fichier : limesurvey...9665.lss
Taille du ficher :18 ko


Best regards
Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Pièces jointes :
Les utilisateur(s) suivant ont remercié: DenisChenu

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 semaines 4 jours - il y a 2 semaines 4 jours #171892 par jessicapidoux
jessicapidoux a répondu au sujet : 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
Pièces jointes :
Dernière édition: il y a 2 semaines 4 jours par jessicapidoux.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 semaines 4 jours - il y a 2 semaines 4 jours #171893 par jessicapidoux
jessicapidoux a répondu au sujet : 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
Pièces jointes :
Dernière édition: il y a 2 semaines 4 jours par jessicapidoux.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 semaines 4 jours - il y a 2 semaines 4 jours #171897 par Joffm
Joffm a répondu au sujet : assign default value
Hi,

{q1_SQ023=if(is_empty(q1_SQ023),’Strongly disagree’,q1_SQ024)}

Typo: should be 24.
{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
Dernière édition: il y a 2 semaines 4 jours par Joffm.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 semaines 4 jours #171908 par jessicapidoux
jessicapidoux a répondu au sujet : 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

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 semaines 4 jours - il y a 2 semaines 4 jours #171914 par Joffm
Joffm a répondu au sujet : 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


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Pièces jointes :
Dernière édition: il y a 2 semaines 4 jours par Joffm.
Les utilisateur(s) suivant ont remercié: jessicapidoux

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 semaines 3 jours #171920 par DenisChenu
DenisChenu a répondu au sujet : assign default value

Joffm écrit: …
Looks like you copied the equations from somewhere else (like Word, o.ä.)
Please make sure that you only have plain text there.…

Or use the equation adavanced setting : it was done for this :) manual.limesurvey.org/Question_type_-_Eq...ation_.28equation.29

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
Les utilisateur(s) suivant ont remercié: jessicapidoux

Connexion ou Créer un compte pour participer à la conversation.

Commencez dès maintenant !

Créez simplement un compte et commencez à utiliser LimeSurvey dès aujourd'hui.

Inscrivez-vous maintenant

Inscrivez-vous à notre Newsletter!