Search code examples
autocompletelimesurvey

LimeSurvey auto-complete feature


Imagine the question: "Please write down five titles of TV Series".

We want the answer to be spontaneous thus the users freely recall and write their answers such as "Game of Thrones", "The Big Bang Theory" or "Friends".

Our problem is that some of them will write "big bang theory", others "The Big Bang Show" or even "big ban teory" but we know that these answers are the same.

Therefore, we would like LimeSurvey to dynamically offer an auto-completed answer like "The Big Bang Theory" to all of them so that we minimize the manual work of rewriting and grouping the answers.

Is this feature available? If not, do you have any clue about how to implement it?


Solution

  • LimeSurvey (and don't think any other system) don't have core system to do this. But LimeSurvey include jquery-ui, and jquery-ui have autocomplete.

    Something like this (if you have a csv file).

    1. download jquery.csv-0.71.js at https://code.google.com/p/jquery-csv/ and put it in your template directory.
    2. put your csv file in your template directory (name series.csv : one serie by line)
    3. Update the HTML sourve of your question with:

      <script type="text/javascript" src="{TEMPLATEURL}jquery.csv-0.71.js"></script>
      <script>
      var url = "{TEMPLATEURL}series.csv";
      $(function() {
          var seriesTitle = new Array();
      
          $.get(url,function(data){
              fullArray = $.csv.toArrays(data);
              $(fullArray).each(function(i, item){
                  seriesTitle.push(item[0]);
              });
              $("#question{QID} input[type=text]").autocomplete({
                  source: seriesTitle
              });
          });
      });
      </script>
      

      It work for multi text and short text.

    If needed you can use an API (and if available). Look at autocomplete exemple to see using JSON : http://jqueryui.com/autocomplete/#remote