How to count the number of characters entered at a Limesurvey text question

Sometimes you want Limesurvey users to enter text of a certain length at your survey. In order to provide them with some feedback about the number of characters added, you can make use of the strlen() function* of the Limesurvey Expression Manager for counting the number of characters.
* Function strlen() returns the number of bytes rather than the number of characters in a string, so special characters like or > could be counted as more than a single character.

So how can we set this up? The first step would be creating a text question at your Limesurvey survey. At most of these questions, you can already limit the number of characters the user can input:

Limit characters at Limesurvey text question

For our test survey, we used the new Limesurvey theme “Backy” which is available at our template shop. At that theme, and most others, it looks pretty well adding the information about the number of characters directly at the help text. Since we limited the number of character to 160 we used this text for showing the number of characters to the user:
You have entered X of 160 characters.

Demo question

If you want to count the number of characters of the current text question you can make use of the self variable. The code for counting the characters looks like this:
{strlen(self.NAOK)}

So for the full help text we used:
You have entered {strlen(self.NAOK)} of 160 characters.

If you want to show the number of characters of a different question e.g. with code textquestion you can use:
{strlen(textquestion.NAOK)}

We are using the above code to show the character count at the second text display question of our Limesurvey demo survey.

If you need any help setting up your own character count features feel free to drop us a note any time.

How to use Bootstrap tooltips at a Limesurvey survey

Introduction

Tooltips are a useful feature if you want to add lengthy explanations to certain keywords or answer options at Limesurvey. Since Limesurvey v3.0 the Bootstrap framework is available for all Limesurvey templates which enables you to easily add tooltips to your survey elements. We will show you how this works.

Adding tooltips to Limesurvey survey elements

Bootstrap tooltips need to be added by using proper HTML elements. You can see these elements by switching to the source code view of the Limesurvey editor. We have highlighted default HTML elements:

Limesurvey editor source code mode
Limesurvey editor source code mode

If we now want to use a tooltip for a certain keyword we need to add an additional HTML element. Placing the keyword within a SPAN element is the recommended approach since it shouldn’t change the formatting of the text.
For highlighting the word Limesurvey and adding explanatory text using a tooltip we can use the following HTML:

<span data-toggle="tooltip" title="Limesurvey is the worldwide leading open source survey software">Limesurvey</span>

This is how it looks like at the source code mode of the Limesurvey editor:

Limesurvey tooltip code
Limesurvey tooltip code

And this is how the tooltip shows up when running the Limesurvey survey:

Limesurvey tooltip example
Limesurvey tooltip example

Tooltip core elements

As you can see from the above screenshot it only takes three core elements:

  1. HTML <span>…</span> element for adding the tooltip
  2. data-toggle=”tooltip” for indicating that the element uses a tooltip
  3. title=”Your tooltip text” for defining the to be shown tooltip text

There are some more details your can add to adjust and improve your tooltips:

  • data-html=”true” allows using HTML within the tooltip itself e.g. to highlight certain words within the tooltip with bold text, example:
    title=”Limesurvey is the worldwide <strong>leading</strong> open source survey software”
  • data-placement=”auto | top | bottom | left | right” where auto is the default value. This setting allows defining how the tooltip will be positioned.

Adjusting the tooltip styles

If you have a look at the screenshot above you will notice that the word Limesurvey is not marked in any way to indicate that it uses a tooltip. So users won’t know that additional information is available. To change this, we can add an additional CSS class mytooltip to the above element and then add styles to the custom.css file of the Limesurvey template used to highlight words with tooltips.
This is the extended HTML code for our tooltip:

<span class="mytooltip" data-toggle="tooltip" title="Limesurvey is the worldwide leading open source survey software">Limesurvey</span>

At the custom.css file we are adding the below lines of code to
a) change the cursor on hover
b) underline the word
c) show the keyword as bold text
d) highlight the tooltip keyword with a different color

.mytooltip
{
    cursor: pointer;
    text-decoration: underline;
    font-weight: bold;
    color: orange;
}

This is what we get:

Highlighted Limesurvey tooltip
Highlighted Limesurvey tooltip

Tooltips for Limesurvey answer options

Sometimes you need to explain what a certain answer option means while you try keeping the answer text as short as possible so the answers are still easily readable. Using tooltips you can have short answer options with additional explanations being shown as tooltips. We have created an example for this as well. This is how the answer options are added at a Limesurvey single choice question:

Limesurvey answer options with tooltips
Limesurvey answer options with tooltips

And this is how it looks like at the survey:

Example of answer options with tooltips
Example of answer options with tooltips

You may notice that the tooltip element at the above example is rather small. This is because by default the size is related to the width of the underlying text. In order to increase the tooltip width we can add the following CSS code to our custom.css file:

.tooltipquestion .radio-item label, 
.tooltipquestion .checkbox-item label 
{
    width: 100%;
}
.answer-item .tooltip .tooltip-inner 
{
    max-width: 75%;
    margin: auto;
}

As you can see there is now an additional class tooltipquestion. This is needed because we need to overwrite the default styles for the labels of checkbox and radio items. To not apply this to all questions we add the class manually to all questions using tooltips. This can be set at the Display section when editing any Limesurvey question:

Limesurvey display settings
Limesurvey display settings

Lengthy tooltip are now shown like this:

Lengthy Limesurvey tooltips
Lengthy Limesurvey tooltips

Additional information and downloads

Here are some helpful links for you:

How to randomize items at Limesurvey

Limesurvey provides various randomization features at different levels and you should make use of it for various reasons. Especially at market research surveys randomizing items is a must-have feature in order to collect data properly. Another use case is A/B testing where you randomly show version A or B or a question for comparing the outcome of e.g. different question texts.
There are some more reasons we have outlined below when introducing the different Limesurvey randomization features.

Randomizing the order of answers/items

Research shows that people tend to pick one of the first answer options and often do not even check all available options. This can result in misleading survey results. So what can we do?
Well, that is rather simple: Most Limesurvey question types provide a setting Random order which can be found at the Display section below the General options. Simply turn it on and that’s it:

Limesurvey "Random order" setting
Limesurvey “Random order” setting

Want to check how this looks like at a real survey? Then check out the test survey we created for you.

Randomly show 1 of X questions (can be used for A/B testing)

There already is a special blog post dealing with this topic so we will just link to it: https://survey-consulting.com/how-to-randomly-show-1-of-x-questions-at-a-limesurvey-survey/

You can check this randomization feature at this test survey.

For creating an A/B test the approach is the same as explained at the example linked above. Simply created two copies of the same question and set conditions based on the random number to either show question A or question B.

Randomly show questions on page

Besides randomizing items within a question you can also randomize the questions displayed on a single page or within the whole survey.
For setting this up there is an option Randomization group name at the Logic section when editing a question. Enter the same randomization group name at all questions which should show up in random order:

Adding a randomization group name to a question
Adding a randomization group name to a question

So if you added rand1 as randomization group name to questions Q1, Q2 and Q3 these will show up in random order when loading the survey like Q3, Q2, Q1 or Q2, Q1, Q3.

We have provided a sample survey at this link.

Randomly show question groups or survey pages

The group by group display mode is the survey format used at most surveys. This means that you put questions dealing with the same topic into the same question group like questions asking for demographic details. If your survey deals with e.g. tech companies you could then have another set of questions at the follow up question group dealing with question related to Amazon, then have another question group asking details for tech company 1, another one for tech company 2 and so on…

Since the drop off rate would usually lead to receiving many opinions about Amazon but just some very few responses related to the tech companies listed towards the end of the survey, your data will be less reliable when comparing the response details for different companies.
To work around that you could simply show the survey groups related to the different tech companies in random order. This can be achieved by entering the same Randomization group when editing a question group:

Adding a randomization group title
Adding a randomization group title

By adding randomizecompanies to all your to be rated companies these pages will show up in random order within the survey.

We have set up an example with Amazon, Google and Facebook for you showing the question groups for rating these companies in random order.

Randomly show 1 of X follow up surveys

Sometimes users are redirected to a certain follow up survey once they have completed the main survey. In certain cases there is not just one survey but you may want to pick 1 of X surveys randomly and redirect users to them.
This is doable by following the approach of randomly showing a question. You create a question of type equation with code randnumber and as question text you simply add:

{if(is_empty(randnumber.NAOK), rand(1,3), randnumber.NAOK)}

This will create a random number between 1 and 3 if there was no such random number created so far. The newly created number can then be used for defining which URL to call.
You can have another question of type equation using question code redirecturl and based on the random number you can define URLs for 3 different surveys.

{if(randnumber.NAOK == 1, "https://survey.mydomain.com/index.php/111111", 
if(randnumber.NAOK == 2, "https://survey.mydomain.com/index.php/222222", 
https://survey.mydomain.com/index.php/333333"))}

At the survey settings you can optionally enable Automatically call end URL and at the End URL text field of the setting just add {redirecturl.NAOK}. Depending on the randomly created number and the end URL set for it Limesurvey will call one of the 3 surveys randomly.

We added the random redirect to the sample survey created for the Randomly redirect or show 1 of X questionsuse case. Click here to start that survey and you should then see different end URLs at the final “Thank you” page pointing to different surveys.

Sample survey showing all randomization features

All the different features outlined above can be tested at this Limesurvey randomization sample survey.

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 disable the Limesurvey “ComfortUpdate” updating feature

Especially after a new version was released, there can be lots of new bug fix releases within a short time for a new Limesurvey version. These “New release available” messages always pop up after having logged in at the admin interface and it can get a little annoying to get rid of them by clicking [x] at the pop-up message all the time.

If you want to globally turn off the ComfortUpdate feature so there are no more update checks and messages popping up, you can edit the config.php file at /limesurvey/application/config. Don’t forget to create a backup first!

At the end of the file you should find the following settings:

Limesurvey config file

 

To disable the update feature we have to set the “updatable” setting to false. To do so, add a comma after the ‘debugsql’=>0 setting and add another line:

'updatable' => false

The full last block of the config.php file should then look like this:

// Use the following config variable to set modified optional settings copied from config-defaults.php
 'config'=>array(
 // debug: Set this to 1 if you are looking for errors. If you still get no errors after enabling this
 // then please check your error-logs - either in your hosting provider admin panel or in some /logs directory
 // on your webspace.
 // LimeSurvey developers: Set this to 2 to additionally display STRICT PHP error messages and get full access to standard templates
 'debug'=>0,
 'debugsql'=>0, // Set this to 1 to enanble sql logging, only active when debug = 2
 'updatable' => false
 )

You can check if the updater was disabled by:

  • Limesurvey 2.50 and later: Calling the ComfortUpdate feature from the Configuration menu.
  • Limesurvey < 2.50: Going to Global Settings -> ComfortUpdate where you should get the following message: “…comfortUpdate is disabled in your LimeSurvey configuration.”

Introducing “OfflineSurveys” – The Limesurvey Android app

We have often been asked if there is or will be a Limesurvey app and we always had to answer “no”. Up to now the best approach for running Limesurvey on a mobile device was to design your survey properly and use a mobile optimized Limesurvey template so it scales nicely on smaller screens. Since an Internet connection may not be available all the time in certain areas, this could lead to serious problems with surveys being only partially answered or data being lost on submit.

The solution to this is “OfflineSurveys“, an Android app that let’s you take any Limesurvey survey using your Android device even if no Internet connection is available. Thus, it can easily be used for collecting data on location (e.g. mystery shopping) or interviewing people who used a certain service/visited a certain store, …
It is also a perfect solution for kiosk surveys to collect feedback at restaurants, service centers or exhibitions because the app allows to lock the device and sync data later.

The app caches a LimeSurvey online survey and creates on offline version which stores responses on the local device. Data collected offline can later be emailed or exported to your PC. The PRO version supports automatic response synchronization.

OfflineSurveys supports all LimeSurvey question types, Expression Manager features and conditions, placeholders, … and most other LimeSurvey features. It even offers several additional Android multimedia question types to e. g. take a picture, record a voice note or store the current GPS location.

The free version already supports all these additional question types. It can be downloaded at the Google Play Store. For professionals a customized PRO version can be created.

Feel free to check the website at http://www.offlinesurveys.com/ for more details like features or FAQs.

Here are some screenshots of how surveys look like at the app and which additional Android questions the app offer:

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: