1

For a questionnaire in LimeSurvey v6 I need to implement a two-part question.

In question 1 the respondent should be able to enter the name of organizations they work with, one per row. Ideally the respondent can add as many rows as needed, dynamically. Each row contains just a text field for the name of the organization.

In question 2 I want to display a matrix where each row corresponds to one organization entered in the previous question. There are three columns representing a Likert-type scale from 1 to 7 to assess different aspects (importance, influence, current collaboration).

I used a "Multiple short text" question type in Question 1 with predefined sub-questions and JavaScript to reveal more fields with a button (up to 10 rows). In Question 2 I created an "Array (Numbers)" question and used {question1_SQ001} to {question1_SQ010} as sub-question texts. I used JavaScript in Question 2 to hide rows where the corresponding input was empty. This approach works for a fixed number of rows, not dynamic row creation.

How can I allow the user to freely enter N rows (organizations) and then automatically populate a matrix question with exactly those N inputs as sub-questions, without needing to predefine or cap the number of entries?

0

1 Answer 1

2

I'm part of the core team in LimeSurvey and I can tell the question is valid, as LimeSurvey, a survey provider product that is based on PHP offers a finite amount of possible questions and none of these types can be dynamically changed by the participant when the survey is being filled.

The problem with this is that LimeSurvey has a separate table for each survey in the database and such dynamic change would alter the fields, in the survey table, which is not allowed.

Hence, the question tries to figure out how this can be achieved after all, what the work-arounds are and this answer provides tips and tricks to achieve this.

tl; dr: One can create a new question type and implemet a plugin to adjust the way this new question is to be handled by the UI, backend and database. Below I will explain the idea in detail.

In the response table you have an id field and lots of response fields of the format of

<sid>X<gid>X<qid><a>

Where

  • sid: survey id
  • gid: question group id
  • qid: question id
  • a: suffix for subquestions

Now, if you would like to create a question with an unknown number of subquestions, then that would mean that the user can create fields into your response table. Which would be unsafe. Imagine a nefarious person who wants to hack you and attempts to create 10 000 subquestions. In several RDBMS you will reach into limitations.

So LimeSurvey does not support in essence this kind of dynamic subquestion creation.

However, LimeSurvey has a PluginManager class and a Plugin class and you can create your own plugin. On Cloud you cannot install your plugin but can ask the support team to install it for you. In the community edition you can install your plugin. You will need a config.xml and files related to it.

See this manual article.

You will essentially need to create a new question type (use a code that was not used up so far), store them separately from the responses table ({{survey_<sid>}}), perhaps in a table like

{{survey_dynamic_questions}}(sid, parent_qid, uid, ...)

and modify the display of the themes of your choice for this as well as the way you store the responses. Basically you will need:

  • the new table
  • frontend support for this kind of new question on the admin panel
  • backend support for storing these (files for your plugin to work)
  • config.xml
  • showing it properly in the questionnaire, editing the appropriate twig, css and js files
  • condensing the responses when they are submitted and storing them in the appropriate response field, possibly in JSON
  • editing the responses grid and statistics to handle this new question type

In short: there is no support for this currently due to valid security and integrity concerns but you can either use one of the question types, or implement a plugin for a new question type.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.