Welcome, Guest
Username: Password: Remember me

TOPIC: Multiple question types; doable for me?

Multiple question types; doable for me? 4 months 4 days ago #102506

  • Meester
  • Meester's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
I try to understand the topics on this forum on multiple question types in an array, since this is exactly what I would like to do! But I am unexperienced in using scripts. I really have no idea to get it working. Can somebody explain the basic steps to do it?

The following pictures show what I want. I have a question and each item (onderzoek 1, onderzoek 2, onderzoek 3 etc) should be answered 3 items: date, text and number. I have now split it into two questions: one having text (date will be typed as text, so without a calander :-( and the next questions only numbers are allowed. I would like to combine all items in one array question.






imageshack.us/a/img853/3061/1rs8.jpg
img96.imageshack.us/img96/9822/0et7.jpg
Last Edit: 4 months 4 days ago by Meester.
The administrator has disabled public write access.

Multiple question types; doable for me? 4 months 4 days ago #102520

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 328
Given that these are all essentially text inputs, I wouldn't bother with the multiple question types in an array workaround. I would use an array-text question with 3 columns and apply datepickers to the first column and the jQuery numeric plugin to the third column.

What LimeSurvey version are you using and what is the survey base language?
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Multiple question types; doable for me? 4 months 3 days ago #102529

  • Meester
  • Meester's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
I am using Lymesurvey installed on a server that is hosted by my employer. So I don't know the current version. I will consult the administrator to find out what version we have. Maybe the picture below helps you to identify the version we are using?

If I understand correctly there is a way to apply datepickers to one colum of a text array question. I have not seen that option and I guess that needs to be done by using a script?

The administrator has disabled public write access.

Multiple question types; doable for me? 4 months 3 days ago #102531

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 328
Yes, you will have to apply the date-pickers and the numeric-only inputs with JavaScript.

1) Set up your survey to use JavaScript.

2) Download the jQuery Numeric plugin and upload jquery.numeric.js to your template directory.

3) Add the following to startpage.pstpl after the {TEMPLATEJS} tag:
<!-- The following line includes jquery.numeric.js -->
<script type="text/javascript" src="{TEMPLATEURL}jquery.numeric.js"></script>

4) Create your array-text question with 3 columns.

5) Add the following script to the source of the array. The script:
- Automatically detects the array question
- Adds some column-specific classes
- Applies datepickers to the inputs in column 1
- Applies the jQuery Numeric plugin to the inputs in column 3
- Adds a suffix to the inputs in column 3

<script type="text/javascript" charset="utf-8">	
 
	$(document).ready(function(){
 
		// Identify this question
		var thisQuestionID = {QID}; // This question ID
		var thisQuestion = $('#question'+thisQuestionID); // This question
 
		// Add some column-specific classes
		$('thead tr, tr.subquestion-list', thisQuestion).each(function(i){
			$('> *', this).each(function(i){
				$(this).addClass('col-'+i+'');
			});
		});
 
		// Datepickers in column 1
		$('tr.subquestion-list .col-1 input[type="text"]', thisQuestion).datepicker({ 
			dateFormat: "yy-mm-dd",
			monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
			monthNamesShort: ['jan', 'feb', 'maa', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
			dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
			dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
			dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
			weekHeader: 'Wk',
			firstDay: 1
		});
 
		// Numerics and answer suffix in column 3
		$('tr.subquestion-list .col-3 input[type="text"]', thisQuestion).numeric().after('ug');
	});
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Multiple question types; doable for me? 4 months 1 day ago #102625

  • Meester
  • Meester's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
YES! it worked! I had to ask the administrator of the lymesurvey to upload the plugin and he also did put the script-codes into the templates.
Then it was an easy job! It looks great. I will post a screenshot this evening later.

Thanks very much.
The administrator has disabled public write access.

Multiple question types; doable for me? 4 months 19 hours ago #102633

  • Meester
  • Meester's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
here it is!

Do you know a way to visualize the arrows in the calender that you use to jump to another month?

The administrator has disabled public write access.

Multiple question types; doable for me? 4 months 19 hours ago #102635

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 328
Yes, you can use the changeMonth and changeYear options when applying the date-picker - api.jqueryui.com/datepicker/#option-changeMonth

So, change this:
// Datepickers in column 1
$('tr.subquestion-list .col-1 input[type="text"]', thisQuestion).datepicker({ 
	dateFormat: "yy-mm-dd",
	monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
	monthNamesShort: ['jan', 'feb', 'maa', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
	dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
	dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
	dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
	weekHeader: 'Wk',
	firstDay: 1
});


To this:
// Datepickers in column 1
$('tr.subquestion-list .col-1 input[type="text"]', thisQuestion).datepicker({ 
	dateFormat: "yy-mm-dd",
	monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
	monthNamesShort: ['jan', 'feb', 'maa', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
	dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
	dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
	dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
	weekHeader: 'Wk',
	firstDay: 1,
	changeMonth: true, 
	changeYear: true 
});
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Multiple question types; doable for me? 3 months 4 weeks ago #102742

  • Meester
  • Meester's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
Yes! it worked!

There are 2 things I am trying now:

- change the individual column widths (not successfull yet; although I use the scripts that are available on this forum)

and

- extend my equation question with numbers that are answered in an array question. I have succesfully used equations using input from numeric input questions, but I don't know the code for the third question in an array.
For instance:
{Q1_1*Q1_2} would be the equation of 2 answers (numeric) of Q1 (have used that before)
But what would be the code for an arrayquestion in which only the third column-answers are to be used? I guess it is like thi"s: {Q2_1_3*Q2_2_3}. Question 2, row 1, column3 * Question2, row2, column3). I have tried this, but it does not work and I cannot find the code to be used in the EM manual.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.215 seconds
Donation Image