Sometimes you want to show different versions of a question at a Limesurvey survey. To do so, you need to randomly show one of the X question versions to the user so the first step would be to generate a random number between 1-X. For this we can use the powerful Limesurvey Expression Manager which is available since release 1.92.
The new question type “equation” can be used to store the result of the random function. So create an “equation” question with question code “randnumber” and the following content at the question text field, which will generate a random number between 1 and 2:
Note: At older Limesurvey versions like v1.92 the random number gets re-created at every page load. To keep the same number during the whle survey sessions, use this expression at older Limesurvey versions if you are noticing the mentioned behavior:
It basically means that the system should first check if the rand variavble was already populated. If it is still empty, a random number is created. Else, the already created number is kept and no new random number gets created.
If you want to hide the question from the user, set “Always hide this question” to “yes” at the advanced question settings.
Now we have a question that will be filled with either “1″ or “2″, we can use conditions at following questions to show version A or version B of a question. For this you can use the Limesurvey condition manager and set a condition based on a constant value of 1 or 2 for the equation question. Alternatively you can use the “relevance” field to define when a question should be shown. The appropriate relevance reads:
…and for the second question:
Don’t forget to check if you set up everything correctly by having a look at the survey logic file.
…and if this still sounds too tricky, we can set up the survey for you.