Limesurvey: switching language during survey

Whenever a user switches the language during a survey, (s)he is presented the new language after that. So far, so good.

But.... in the results table of LimeSurvey only the startlanguage is stored, not the language that you change to. We ran into this when someone in the customer organisation sent the link with the dutch startlanguage in it to respondents in the UK. These people happily started filling in the survey, after changing this to English.

But they did not know that the resulting report would be based on... yes, the startlanguage.

To overcome this we (we were helped through IRC by Deusdeorum, one of the dedicated users/developers) inserted a last short free text question called qlang with the following code:

<script type="text/javascript" charset="utf-8">
   $(document).on('ready pjax:complete',function() {
       $('#question{QID} input').val($('html').attr('lang'));
       $('#question{QID}').hide();
   });
</script>

This results in writing the used language on the last page to the results table. When a script produces a report, you can better use the variable qlang than the startlanguage when you need the respondent's language.

tested in: Limesurvey 2.6.7 (also known as 2.06+ LTS) and 3.x

  • tip: Javascript must be switched in in your LimeSurvey installation. To do that, you have to disable the Limesurvey XSS filter at Global settings -> Security -> “Filter HTML for XSS” = “No”.