- Posts: 4
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
setup Multiple question types in array
- ledermueller
- Topic Author
- Offline
- New Member
Less
More
7 years 1 month ago - 7 years 1 month ago #147879
by ledermueller
setup Multiple question types in array was created by ledermueller
Hi folks!
First: i am a total beginner with JavaScript/Jquery and i have no ides wich version of LimeSurvey i am using (i have to ask our admin on monday)
Here my wish: I want to create a arrax with miltiple answere types. there should be 3 rows (croprot1, croprot2, croprot3) and 4 colums. the first two colums as drop down (crop1, crop2) and the second two colums as multiple choice/checkbox (technic1, technic2).
I setup the servey with a group "Croprotation" and the subquestions "crop1" (as drop down), "crop2" (as drop down). it should look like this in the attached
I found the manual with the code for something like this ( manual.limesurvey.org/Workarounds:_Quest...stion_types_in_array ), the problem is, i have no idea where to maupulate to get it working. At least i could load the file into my survey, i put is into the questiongroup.
It would be sooooo great if anybody could give me a hint how to change the code for my case.
Thanks in advance,
chears,
Sandra
First: i am a total beginner with JavaScript/Jquery and i have no ides wich version of LimeSurvey i am using (i have to ask our admin on monday)
Here my wish: I want to create a arrax with miltiple answere types. there should be 3 rows (croprot1, croprot2, croprot3) and 4 colums. the first two colums as drop down (crop1, crop2) and the second two colums as multiple choice/checkbox (technic1, technic2).
I setup the servey with a group "Croprotation" and the subquestions "crop1" (as drop down), "crop2" (as drop down). it should look like this in the attached
I found the manual with the code for something like this ( manual.limesurvey.org/Workarounds:_Quest...stion_types_in_array ), the problem is, i have no idea where to maupulate to get it working. At least i could load the file into my survey, i put is into the questiongroup.
It would be sooooo great if anybody could give me a hint how to change the code for my case.
Thanks in advance,
chears,
Sandra
Attachments:
Last edit: 7 years 1 month ago by ledermueller.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11746
- Thank you received: 2750
7 years 1 month ago #147883
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 setup Multiple question types in array
The version of your Limesurvey installation can usually be found at the bottom of each admin page and usually says something like Limesurvey 2.xx 170112 or something.
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.
- ledermueller
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
7 years 1 month ago #147889
by ledermueller
Replied by ledermueller on topic setup Multiple question types in array
Hi, found it! it's Version 2.56.1+161118
The topic has been locked.
- ledermueller
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
7 years 1 month ago #147891
by ledermueller
Replied by ledermueller on topic setup Multiple question types in array
to specifie my questions i marked my ideas/suggestions in red:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Call the "sideBySide" function with number of rows, columns and start position
sideBySide(4, 5, 3); --> 3 for rows, 4 for colums, 1 to star with the first question in the group
});
function sideBySide(rows, columns, startQuestion) {
/*********** Display multiple questions side by side ***********/
if ($('div.qRow1').length == 0) {
var rowNum = 0;
var colNum = 1;
var rowList = new Array();
//////// Add question classes for later use ////////
// Loop through all questions and add row and column specific classes
$('div[id^="question"]').each(function(i) { --> question= Croprotatios (like the groupname)
if(i >= (startQuestion-1) && rowNum < rows) { // This IF condition only needed if there are questions before or following the "inline" questions
$(this).addClass('qRow'+rowNum+'').addClass('qCol'+colNum+'').addClass('inlineQuestion'); --> 'qRow'=1, 'qCol'=1 for the first question, what about 'inlineQuestion'?
--> then i do this for all questions (croprot2 and 3. i don't need if clauses
if(rowNum == 0 && colNum > 1) {
$(this).addClass('columnLabel');
}
if(rowNum > 0 && colNum == 1) {
$(this).addClass('rowLabel');
}
else if(rowNum > 0 && colNum > 1) {
$(this).addClass('questionCell');
}
if(colNum == columns) {
rowList.push('qRow'+rowNum+'');
rowNum++;
colNum = 1;
}
else {
colNum++;
}
}
else {
$(this).addClass('normalQuestion');
}
});
//////// Survey layout manipulation ////////
// Fix the width of the survey
$('table.outerframe').css({
'width': '900px'
});
// Wrap each "row" in a wrapper div
$(rowList).each(function(i) {
$('.'+this+'').wrapAll('<div id="inlineWrapper'+i+'" class="inlineRow" />'); -->
});
// Style the wrapper divs
$('.inlineRow').css({
'width': '850px',
'margin': '0 auto 0 auto',
'clear': 'both'
});
$( '.inlineRow:first' ).css({ --> here i put croprot1??? as the first row to appear?
'margin-top': '10px'
});
// Get all the questions to sit politely side by side
$( '.inlineQuestion' ).css({
'float': 'left',
'height':'41px',
'overflow':'hidden',
'margin-bottom': '-8px'
});
$( '.inlineQuestion .questionhelp' ).hide();
$( '.inlineQuestion .survey-question-help' ).parent().hide();
// A little space under the last row
$( '.inlineRow:last .inlineQuestion' ).css({
'margin-bottom': '10px'
});
// Any questions not displayed inline (this is only needed if there are questions following the "inline" questions)
$( '.normalQuestion' ).css({
'clear': 'both'
});
//////// Column manipulation ////////
puh thats a jungle for me, but if you give me a hint i could figuere out the rest by myselve, hopefully
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Call the "sideBySide" function with number of rows, columns and start position
sideBySide(4, 5, 3); --> 3 for rows, 4 for colums, 1 to star with the first question in the group
});
function sideBySide(rows, columns, startQuestion) {
/*********** Display multiple questions side by side ***********/
if ($('div.qRow1').length == 0) {
var rowNum = 0;
var colNum = 1;
var rowList = new Array();
//////// Add question classes for later use ////////
// Loop through all questions and add row and column specific classes
$('div[id^="question"]').each(function(i) { --> question= Croprotatios (like the groupname)
if(i >= (startQuestion-1) && rowNum < rows) { // This IF condition only needed if there are questions before or following the "inline" questions
$(this).addClass('qRow'+rowNum+'').addClass('qCol'+colNum+'').addClass('inlineQuestion'); --> 'qRow'=1, 'qCol'=1 for the first question, what about 'inlineQuestion'?
--> then i do this for all questions (croprot2 and 3. i don't need if clauses
if(rowNum == 0 && colNum > 1) {
$(this).addClass('columnLabel');
}
if(rowNum > 0 && colNum == 1) {
$(this).addClass('rowLabel');
}
else if(rowNum > 0 && colNum > 1) {
$(this).addClass('questionCell');
}
if(colNum == columns) {
rowList.push('qRow'+rowNum+'');
rowNum++;
colNum = 1;
}
else {
colNum++;
}
}
else {
$(this).addClass('normalQuestion');
}
});
//////// Survey layout manipulation ////////
// Fix the width of the survey
$('table.outerframe').css({
'width': '900px'
});
// Wrap each "row" in a wrapper div
$(rowList).each(function(i) {
$('.'+this+'').wrapAll('<div id="inlineWrapper'+i+'" class="inlineRow" />'); -->
});
// Style the wrapper divs
$('.inlineRow').css({
'width': '850px',
'margin': '0 auto 0 auto',
'clear': 'both'
});
$( '.inlineRow:first' ).css({ --> here i put croprot1??? as the first row to appear?
'margin-top': '10px'
});
// Get all the questions to sit politely side by side
$( '.inlineQuestion' ).css({
'float': 'left',
'height':'41px',
'overflow':'hidden',
'margin-bottom': '-8px'
});
$( '.inlineQuestion .questionhelp' ).hide();
$( '.inlineQuestion .survey-question-help' ).parent().hide();
// A little space under the last row
$( '.inlineRow:last .inlineQuestion' ).css({
'margin-bottom': '10px'
});
// Any questions not displayed inline (this is only needed if there are questions following the "inline" questions)
$( '.normalQuestion' ).css({
'clear': 'both'
});
//////// Column manipulation ////////
puh thats a jungle for me, but if you give me a hint i could figuere out the rest by myselve, hopefully
The topic has been locked.
- ledermueller
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
7 years 1 month ago #147915
by ledermueller
Replied by ledermueller on topic setup Multiple question types in array
solved!!! my admin helped me and with the modified script for version 2.5.8 it's working
www.limesurvey.org/forum/can-i-do-this-w...west-template#146638
byebye
www.limesurvey.org/forum/can-i-do-this-w...west-template#146638
byebye
The topic has been locked.
- ledoux
- Offline
- Premium Member
Less
More
- Posts: 159
- Thank you received: 0
6 years 11 months ago #152642
by ledoux
New user of LS but with the will to contribute to this great community !
Replied by ledoux on topic setup Multiple question types in array
I folks
I would like an array (multiple items) and for each item, the respondent can fill multiple answers (in column). This type of question does exist without coding?
thank you !!
I would like an array (multiple items) and for each item, the respondent can fill multiple answers (in column). This type of question does exist without coding?
thank you !!
New user of LS but with the will to contribute to this great community !
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11746
- Thank you received: 2750
6 years 11 months ago #152643
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 setup Multiple question types in array
Something like this?
manual.limesurvey.org/Question_types#Array_.28Numbers.29
The option with check boxes?
manual.limesurvey.org/Question_types#Array_.28Numbers.29
The option with check boxes?
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The following user(s) said Thank You: ledoux
The topic has been locked.
- ledoux
- Offline
- Premium Member
Less
More
- Posts: 159
- Thank you received: 0
6 years 10 months ago #153104
by ledoux
New user of LS but with the will to contribute to this great community !
Replied by ledoux on topic setup Multiple question types in array
Yes exactly Holch !
I read the manual, but I couldn't set up the options to obtain what is displayed as an example. I obtained only one column (I set "0 to 1, step 1", I also tried 0 to 3). I don't know how to create several columns, and assign a label to each column.
could you help me on that ?
thank you very much
I read the manual, but I couldn't set up the options to obtain what is displayed as an example. I obtained only one column (I set "0 to 1, step 1", I also tried 0 to 3). I don't know how to create several columns, and assign a label to each column.
could you help me on that ?
thank you very much
New user of LS but with the will to contribute to this great community !
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11746
- Thank you received: 2750
6 years 10 months ago #153199
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 setup Multiple question types in array
You need to define subquestions (Vertical items to the left) AND answer options / labels (horizontal items on the top).
manual.limesurvey.org/Question_type_-_Array_(Numbers)
If you go there, there is even an example question that you can download.
manual.limesurvey.org/Question_type_-_Array_(Numbers)
If you go there, there is even an example question that you can download.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The following user(s) said Thank You: ledoux
The topic has been locked.
- ledoux
- Offline
- Premium Member
Less
More
- Posts: 159
- Thank you received: 0
6 years 10 months ago #153268
by ledoux
New user of LS but with the will to contribute to this great community !
Replied by ledoux on topic setup Multiple question types in array
Thank you Holch, I've been on this page of the manual, but it doesn't say clearly how to add collumns (labels - horizontal items at the top). Or I haven't understand..
where do I "define subquestions (Vertical items to the left) AND answer options / labels (horizontal items on the top)." ?
thanl you very much...
where do I "define subquestions (Vertical items to the left) AND answer options / labels (horizontal items on the top)." ?
thanl you very much...
New user of LS but with the will to contribute to this great community !
The topic has been locked.
- ledoux
- Offline
- Premium Member
Less
More
- Posts: 159
- Thank you received: 0
6 years 10 months ago #154642
by ledoux
New user of LS but with the will to contribute to this great community !
Replied by ledoux on topic setup Multiple question types in array
Dear Holch
I can add "subquestions" (horizontal) but the option to add "columns" (to be checked) is not proposed (there is only one for the moment, like a classical "array with 1 checkbox".
What is the process to allow me to propose multiple columns ?
In the manual, the question to be download is in format CSV... If I change the extension and put lsq. then when I import it it says "This is not a valid LimeSurvey question structure XML file.".
I'm quite blocked...
thank you !!
I can add "subquestions" (horizontal) but the option to add "columns" (to be checked) is not proposed (there is only one for the moment, like a classical "array with 1 checkbox".
What is the process to allow me to propose multiple columns ?
In the manual, the question to be download is in format CSV... If I change the extension and put lsq. then when I import it it says "This is not a valid LimeSurvey question structure XML file.".
I'm quite blocked...
thank you !!
New user of LS but with the will to contribute to this great community !
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11746
- Thank you received: 2750
6 years 10 months ago #154643
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 setup Multiple question types in array
I am not quite sure where you are stuck at the moment. Because it definitely works the way I am describing it. Can you show a screenshot that shows where the problem is located or where you can't move forward and what question type you are working with?
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The following user(s) said Thank You: ledoux
The topic has been locked.