How to place a certain option at the end of a list with randomized answers at Limesurvey survey

Randomizing answer items is an often used approach at scientific surveys and market research. At Limesurvey this can easily be done. Just go to the advanced question settings of a certain question and then set “Random order” to “Randomize on each page load“.
But often such a list contains an option like “Don’t know” or “None of these” or similar. Such an option may appear in the middle of the list of answers if they are randomized and that looks confusing to the user.

In order to place a certain answer item at the bottom of a randomized list, add the following JavaScript code at your question text, using the source code mode of the editor:

Source code mode:
Source code mode of integrated Limesurvey editor

Code:

<script type='text/javascript'> 
/* Place option 5 at the end of the randomized list */
$(document).ready(function() {
var move_element="5";
/* Please do NOT change the lines below */
var move_element="javatbd{SGQ}"+move_element;
$("#"+move_element).insertAfter("#question{QID} .answers-list .answer-item:last-child");
}); 
</script>

This script snippet will move answer item 5 to the end of the randomized list. “5” is the answer code of the to be moved item.

You want to re-order the “other” option? No problem, we have explained this at How to re-order the “other” option at a Limesurvey survey.

How to remove the “Exit and clear survey” button from a Limesurvey template

While you can easily remove the “Resume later” button from your Limesurvey template by de-activating the “Participant may save and resume later?” feature at “General Settings” -> “Notification & data management” of your survey, removing the “Exit and clear survey” button isn’t possible this way. So what to do?

There are two solutions, both require editing the current template so make sure you have sufficient rights for this. And of course, creating a backup first never hurts 🙂

Using CSS to remove the button

At the Limesurvey template editor select the “template.css” file and at the end add this CSS code to hide the button:

#limesurvey .clearall
{
   display: none;
}

For testing we used the <commercial_mode_on>beautiful Limesurvey template “Janus” which you can download here</commercial_mode_off>. This is how the buttons look like before the above adjustment:

with button

…and with the hidden button the result is:

without button

Removing the button placeholder from template code

The solution we recommend to use is to just remove the button placeholder from the template code. While hiding the button using CSS can cause side-effects and users can still use it when setting the browser to display hidden elements, simply removing the code from the template also does the trick.

To do so go to the Limesurvey template editor and at the “Standard files” section select the “navigator.pstpl” file. That’s where we have placed the related code for all templates from our shop.
You should see the following code at which you can simply remove the {CLEARALL} placeholder:

<div id="navigator" class="clearfix">
   <div id="left">
      {SAVE}
   </div>
   <div id="right">
      {CLEARALL}
   </div>
   <div id="middle">
      {NAVIGATOR}
   </div>
</div>

Alternatively, you can comment out the placeholder so that the related code line reads:

<!-- {CLEARALL} -->

If the above doesn’t work for you and you need further help with adjusting your Limesurvey template just drop us a note.

How to calculate the number of days between a date inputted by the user and the current date

Sometimes you want to find out how many days or years have passed between today’s date and a date inputted by the user at a Limesurvey survey. The process is a little complex but it can be done using the Limesurvey Expression Manager.

Calculating the number of days

Let’s assume there is a question of type “date” at your survey which uses question code “q2”. The user can select any date using the date picker and at the help text you can show a message like “That was X days ago.”.
To calculate the value for X you can use this expression:

{floor((time() - strtotime(q2)) / (60 * 60 * 24))}

This looks a little complex, so let’s have a look at the details:

  • To get the current time stamp we use time().
  • Using the strtotime() Expression Manager function we create a time stamp based on the date inputted by the user at question “q2”: strtotime(q2)
  • That time stamp gets subtracted from the current time: (time() – strtotime(q2))
  • Since we are not interested in the time difference in seconds but want to know about the exact number of days we divide the result by (60 * 60 * 24) because one day has 24 hours with 60 minutes and 60 seconds.
  • Finally, the result is rounded down using the floor() function.

Calculating the number of years

Similar to the above approach you can also calculate the number of years between a certain date inputted by the user and today’s date. The expression for this is:
{floor((time() - strtotime(q2)) / (60 * 60 * 24 * 365))}

Using calculated result within conditions/relevance equations

You can not only use this expression to output the results of the calculation within any (follow up) question but you can also use this code for conditions by entering it at the “relevance equation” field (without “{” and “}”). E.g. you can ask participants for their day of birth and then calculate if they are already 18 years old. If not, you can use conditions to hide certain follow up questions or show them a warning.

Storing calculated result

If you want to store the calculated result all you need to do as adding the expression (with “{” and “}”) at an equation question. You can even hide that question (edit question -> advanced question settings -> “Always hide this question”) and the result will still be stored at the database.

Creating a fully responsive Limesurvey Template

We could probably write 10-12 pages about how to create a fully responsive Limesurvey template but we want to spare you from reading about all the technical details. Instead, we just want to sum up our findings and present you the results.

Several people have spent dozens of hours to create the first fully responsive Limesurvey template. You can test the template at this test survey and buy the “TFR Responsive” Limesurvey template at the Limesurvey Template Shop.

Benefits of using a responsive Limesurvey template

Of course, the biggest benefit of a fully responsive Limesurvey template is easily serving lots of different devices and presenting the survey questions well displayed on each of them. This does not only make your survey look more professional it will also lead to an increased response rate.
Furthermore, a known disadvantage of common Limesurvey templates is the lack of support for touch screen devices such as smartphones and tablets. Using such a device it can be really tricky to click a radio button or tick the small check boxes. Participants being frustrated because of such a badly designed user interface may just close the survey and leave. When using our fully responsive Limesurvey template participants can just click the text of an answer option at single or multiple choice question to mark an item. At array questions we made the whole cell clickable so even on small devices it is really easy to answer the survey questions. In addition to that the display of larger array questions is optimized by using responsive tables which means that a large table gets split up into several smaller ones which display nicely on small screens.

Technical details

The template we created is based on the bootstrap framework which is famous for serving different devices nicely. For supporting high quality images we make use of Retina JS which supports dynamic switching to a high quality version of an image or logo file if a retina display is used by the participant.
A known issue when using small devices is displaying large array questions nicely. We implemented the “No more tables” JavaScript library at our responsive Limesurvey Template which dynamically splits up large Limesurvey array questions into smaller sections which display fine even on very small devices.
Furthermore, we added custom icons and “Open Sans” as a modern font to achieve a pleasant look and feel so that our template doesn’t look as boring as the shipped Limesurvey templates.

Additional information/links

Sounds interesting? -> Check this test survey.

Want to use this fully responsive Limesurvey template? -> Get the “TFR Responsive” Limesurvey template at the Limesurvey Template Shop.

Want to see more high quality screenshots? -> There you go:

Survey design tips & tricks

Designing your own survey is pretty easy when using Limesurvey. Unfortunately, creating a really bad survey is also pretty easy. That’s why we have set up a list of survey design tips & tricks. Based on our experience with more then 100 survey projects per year the following recommendations hopefully help you designing better surveys.

1. Motivate users to raise completion rate

A user being presented with a simple “Please help me by filling out the survey, it will take 10-15 minutes.” will see no benefit in wasting his/her time with this. In such cases an incentive like “All users which fill out the survey completely will be allowed to take part in a lottery and can win one of 5 Amazon vouchers worth 20,00€.” can raise participation and completion rates significantly.

2. Start with simple questions

A survey should never start with complex questions people have problems answering at all. Instead, place very simple questions like demographic questions at the beginning. Everyone can answer those and they present an easy introduction. Once people have started filling in simple data they tend to finishing their work and not closing a survey early.

3. Questions should be clear

This may sound pretty obvious but for every question make sure it is clear and precise, collectively allowing for detailed, unambiguous and meaningful answers.

4. Add screening questions to the start

Nothing is more annoying than having completed several questions asking for complex information and being told later that for certain reasons like your age or gender you were suddenly screened out and are not allowed to complete the survey and maybe receive a certain incentive.

If users need to agree to certain terms and conditions or have to be of a certain age or gender you should always place such screen out questions at the beginning.

5. Add problematic questions to the end

Similar to placing easy questions at the beginning you should place problematic questions (e.g. about illnesses) at the end. People having already completed 80% of your survey will most likely answer such questions as well.

6. The less questions the better

People tend to ask this and that instead of focusing on the really important questions only. Always make sure a certain question is really important. The less questions the higher the completion rate!

7. Use free text questions to ask for additional information

Open questions may reveal unexpected and very worthy additional information. You should add optional text questions at all important parts of the survey, asking users “Is there anything else you want to tell us about XYZ?”. This may lead to important user feedback you would not have received when using closed questions only.

8. Make sure your questions are non-suggestive

Asking users “What is your opinion about XYZ?” uses neutral speech while a question like “Don’t you agree that LimeSurvey is a really great tool?” is a very suggestive question which will cause users give a more positive feedback.

9. Only make the most important questions mandatory

Having to complete a survey at which each question is mandatory can be really painful, especially when it comes to complex matrix questions.

When designing a survey you always need to ask yourself “Is this question important enough to make it mandatory?”. Only the questions related to data you really need should be mandatory.

10. Keep questions and answers short and easily readable

Nothing to add to this…

 

To be continued…

 

BTW, if you are not very familiar with designing surveys but need to create an important one, we can help with that. Our experience can help you creating a great survey with a high completion rate.
Just drop us a note if we should review your survey or set it up for you.

 

Adding “I agree” button at the beginning of your Limesurvey survey

Sometimes you need participants to agree to certain terms and conditions before starting to take a survey. There is no build-in feature for this at Limesurvey, but we can easily work around this with some lines of JavaScript. Here we go…

Turn of XSS filter at Limesurvey

To be able to add custom JavaScript at a certain survey question or text, we first need to disable the internal Limesurvey XSS filter. So when being logged in at Limesurvey go to Global Settings -> Security -> “Filter HTML for XSS” and set it no “No”.

Limesurvey XSS Filter

Adding your terms and conditions

Once you have turned off the filter you can add your terms and conditions to your survey’s welcome text. Click the edit icon and select “Edit text elements”. Add your text at the “Welcome message” text box.

Adding the “I agree” / “I do NOT agree” buttons

When a user calls your survey, he will at first be presented the welcome text holding the terms and conditions. There will also be a “next” button to start the survey and on option to “Exit and clear survey”. So instead of re-inventing the wheel, we simply rename these buttons for the welcome page only.

For this you need to go to show the welcome message in source code mode. You’ll see the terms and conditions you entered previously. Go to the end of that text and add the following code there to rename the buttons:

<script>
 $(document).ready(function()
 {
    $('#movenextbtn').attr('value','I agree!');
    $('.clearall').attr('value','I do NOT agree!');
 });
</script>

Of course, you can change the “I agree!” / “I do NOT agree!” texts if you wish.

The result:
Custom Limesurvey button labels

 

Limesurvey – Conditions based on token attributes

Sometimes you want to show certain questions of a survey to a specific user group only. With Limesurvey this is no problem. If your survey is set to be non-anonymous and uses tokens, you can use user defined attributes for conditions. Here we describe the necessary steps.

1. Adding additional attributes

Set the survey to be non-anonymous:
Limesurvey survey settings

Enable tokens:
Enable tokens at Limesurvey

Add a certain number of user defined attribute fields:
Add token attributes at Limesurvey

Assign attribute names after having created the new fields:
Label additional attributes

Add some dummy tokens with user defined values

Add dummy tokens

Set conditions for a certain question

Go to the question and call the condition designer:
Limesurvey condition editor

Select the token field on which the condition should be based on (e. g. “Department”) and define the constant which the condition should match (e. g. “Management”):
Condition based on token attribute

Check condition

You can use the group preview for a first check if the condition was stored successfully,
Limesurvey group preview

because in this case the question will not be shown at the group preview (because the conditions isn’t met). The arrow indicates where the question was previously shown before setting the condition:

Test survey at runtime

Once tokens were assigned when adding users or by using the “Generate tokens” feature, the “Display tokens” screen contains an icon to test each token entry:
Limesurvey token overview

Of the above users, only “Jane” belongs to the department “Management”. Let’s check the different survey behavior to check if the condition works as expected:

Survbey at runtime Survey at runtime

More information