Actions

Workarounds: Further solutions provided by LimeSurvey users

From LimeSurvey Manual

Here you can find workarounds/solutions provided by LimeSurvey users which do not deal with these workaround sections:

If you are looking for general troubleshooting please check our General FAQ and Installation FAQ. If you can't find a solution for your problem please open a new thread at our forum or ask at our live chat.

Please keep in mind that the workarounds published here are no official LimeSurvey extensions but solutions that other users created for themselves.
Therefore we can't give support for any solution on this page.
Please contact the users that, thankfully, shared their solutions with the community if you have any questions.

How to import survey responses from v1.00 into v1.5x (and later)

Tested with: LS >= 1.50

In LimeSurvey v1.50 it´s possible to import a survey, which is generated (and exported) with v1.00 into v1.5x. The Problem is, on that way only the survey structure gets imported, but no respones to that survey.

If you also need to import the responses, follow the next steps:

  1. Export your survey in v1.00
  2. Do a VV-Export in v1.00 (to save your responses)
  3. Import your survey from v1.00 into v1.5x via "Create or Import a New Survey" in the main Admin Panel
  4. Activate your imported survey
  5. Fill out your survey once, so that at least one response is in your database.
  6. Do a VV-Export in v1.5x
  7. Open both VV-Exports (v1.5x and v1.00); if you use Microsoft Excel do it via "Open New File" and "Import from Text-File" or "Import from external source - textfile" and choose "seperated" and "Unicode (UTF-8)"; choose
  8. Compare the file structure and you´ll see that there are two columns added (submitdate and startlanguage) and that all question codes changed.
  9. Copy all rows (except row 1 and 2, that means you start with the third row) from your VV-Export  v1.00 into your VV-Export v1.5x (also put it at the third row)
  10. Add the columns "submitdate" and "startlanguage" in your VV-Export v1.5x-File, right between "id" and "token"
  11. Save your file (in Microsoft Excel use Textfile - Tabstopp seperated). It´s necessary that your file after saving has the same format as before - Notice: it´s not a normal .csv-File.
  12. Import your file via VV-Import

Translate surveys without admin access

Tested with:

User "CasN" has written a nice extension that allows you to translate surveys without having access to the admin panel. He has added his files in the bug and feature tracker (01735: Remote translating feature) where you can download them. You'll also find a short How-To there.

This is how it works:

Copy the scripts in the root of your survey directory and call starttrans.php like this starttrans.php?survey=12345

It will check the languages connected to the survey and also verify the labelsets used.

You will then get a screen with for each language the required links for translating, aswell for the labels as the survey itself. From the survey, the question and tip fields are presented for translation.

Thanks CasN for sharing your solution with the community!

Create Question Pools

Tested with:

This is a simple solution to create question pools for LimeSurvey. It will require access to the backend database. I'm not going to explain how to do this, as if you don't understand it, then you shouldn't really do it.

Basically 3 tables exist that we care about:

  • lime_surveys - id field = sid
  • lime_groups - id field = gid
  • lime_questions id field = qid

In order to show the questions correctly the id field from the lime_groups table exists in the lime_questions table. This then is used to create the parent/child relationship.

However, if you want to create a pool of questions all you need to do is to amend the gid field in the lime_questions table to a value that doesn't exist in the lime_groups table. I would use 0 or a something silly like 10000. Try this with one question and you will notice it doesnt appear in the question list.

It's a crude workaround, but allows you to create as many questions as you want, without having them visible.

This could also be applied for groups as well just by using the sid field in the lime_groups table.

Re-open a submitted answer

Tested with: 1.71+

As an administrator you can re-open a submitted answer.

  1. Reset tokens invitation to not sent
  2. Reset answers to not completed
    1. release <= 1.72: In LS <= 1.72 you don't have the option to "Reset answers to not completed" that version 1.8 offers, so this would require the following workaround:
      1. export of tokens
      2. vvexport of answers
      3. deactivate/activate survey in order to erase answers
      4. import answers from VVimport but Add the 'import as not finalized answers' option
      5. import tokens
    2. release >= 1.8:
      1. from the answer summary page, a new option can be used to reset all answers to a not submitted state
      2. from the tokens summary page, you can reset all tokens to 'not sent' state

Note that this will work only on non anonymous surveys with "Allow Persistence" option set.

Bypassing email check at registration

When you allow public registration to your survey LimeSurvey developers have opted to put in place a certain level of protection from bots and spammers by placing a captcha and by forcing the users to go and check their emails to find the link associated with their tokens.

Sometimes, however, this is a nuisance that actually force people to wait for the email when they would rather just take the survey and get on with things. Ideally it would be great if a token-based survey present the participant a short-text box (like a security question) asking at random one of the field in the registration form when the token is passed via URL (i will put this as feature request for the next edition!).

In the meantime, there is a very easy workaround. The solution is to edit the register.php and add the following code around line 156 (where the code is rewriting the page with the message that the email has been sent):

<a href='$publicurl/index.php?sid=$surveyid&token;=$newtoken⟨=$baselang'>Whatever you want to say</a>

I placed right on line 156 between the two line breaks. The code is simply creating a link to the survey embedding the token in the URL.

NOTE that this is literally bypassing the safety currently in place, but the advantage is streamlining the steps for taking the survey with registration.

Alternate Bypassing Email Check at Registration

For version 1.87, please add the following code on line 180 above the //PRINT COMPLETED PAGE in register.php.  This will take the user directly to the welcome page without any pauses in between and bypasses the user having to go to the email validation to start the survey.

header("Location: $publicurl/index.php?sid=$surveyid&token;=$newtoken");

- Zad Imam 04/20/2010

Used email and public registration

Tested with v1.8

When you have a closed survey with public registration, currently LimeSurvey is not allowing a user to re-use the same email. This is a problem if the user has deleted the registration email without taking the survey. In the above workaround a user was allowed to take a survey by presenting a link straight after the registration; ideally they should be prompted with an additional security question and/or captcha (see bugtracker). In the meantime, this owrkaround allows you to from a link from the corresponding email and present it to the user.

Make sure you back up your register.php first!

Here the querystring has been modified to pull out the token as well as the email address and the error message has been changed to display the link to the survey for the existing token. Please also note that this forced change will not be reflected in the different languages!

Around line 75 find the corresponding code:

//Check if this email already exists in token database

$query = "SELECT email,token FROM {$dbprefix}tokens_$surveyid\n"

. "WHERE email = ".db_quoteall(sanitize_email[['register_email']]);

$result = $connect->Execute($query) or safe_die ($query."<br />".$connect->ErrorMsg());   //Checked

if [[$result->RecordCount(]] > 0)

{

   //transform in array of values

   $row=$result->FetchRow();

   $register_errormsg=$clang->gT("The email you used has already been registered.")."<br><br>".

   "<a style='color:red;font-weight: bold;' href='$publicurl/index.php?sid=$surveyid&token;

       = ".$row['token']."&lang;=$baselang'>Click this link to take the survey now</a><br><br>";

   include "index.php";

   exit;

}

HTTP-Refferer is not shown after a Redirect

There are different ways to redirect a page, just as HTTP-Redirect 301, meta http-equiv="Refresh", meta http-equiv="Referrer", link rel="canonical" or JavaScript window.location. But all of them don't work correct in all Browsers when it comes up to the HTTP-Referer. The only working solution I found is with a bit strange JavaScript. You see the solution at [1]

Provide a preview-all-questions page for any survey

Sometimes people would like to be able to preview all questions in a survey before actually taking the survey - it gives them a chance to prepare their information in advance. While the LimeSurvey admin tool lets you create a printable version of a survey, this is not really appropriate for end users, as it contains placeholders for token values, etc. So, for our installation I created a separate PHP script, which you can install on your server and provide for users. Further notes are in the body of the script:

<?php

/******

PreviewLimeSurvey.php

Displays an HTML page with a preview of all questions in the specified survey; multiple-choice and array questions are displayed with all possible responses listed out. Mandatory questions are displayed with "(* REQUIRED)" after the question text.

Usage: Pass the 5-digit survey ID, e.g.: http://{some_path}/PreviewLimeSurvey.php?sid=nnnnn

Preparation:

   - In the calls to mysql_connect() and mysql_select_db(), substitute the parameters for your own LimeSurvey server and database

   - In the HTML part, modify styles and page title as desired

   - This code presumes your LimeSurvey database tables use standard nomenclature: lime_questions, lime_answers, etc. If that is NOT the case, you will need to modify table names in the queries.

CAVEATS:

   - This does not handle ALL LimeSurvey question types. The default behavior is to print just the text of each question. It then adds additional info for specific types that include lists of options, array tables, etc., but you may need to modify the code to handle all the types that you use.

   - It does NOT print boilerplate questions (type 'X'), because in our setup these would be irrelevant when someone just wants to preview the survey questions. You can change this by commenting out the clause "if ($row['type'] != 'X')"
*/

// Put the page parameters in globals

$mySID = $_GET['sid'];

// Preview questions and possible responses for the specified survey ID

function preview_survey($sid) {

   $dbh = mysql_connect('myHost', 'myLimeSurveyDatabaseUsername', 'myLimeSurveyDatabasePassword');

   mysql_select_db('myLimeSurveyDatabaseName', $dbh);

   // Start by getting survey name from db, to display in title

   $result = mysql_query("SELECT surveyls_title FROM lime_surveys_languagesettings WHERE surveyls_survey_id={$sid}");

   $row = mysql_fetch_assoc($result);

   $output = "<h2>Survey Preview: {$row['surveyls_title']}</h2>";    // Initialize markup with heading showing survey name

   $output .= '<div style="margin:15px 0 15px 1em;width:30em;">Below are questions that will appear on your survey.</div>';

   $result = mysql_query("SELECT lq.qid, lq.sid, lq.gid, lq.lid, lq.type, lq.title, lq.question, lq.mandatory, lg.group_order FROM lime_questions AS lq, lime_groups AS lg WHERE lq.sid='{$sid}' AND lg.sid=lq.sid AND lq.gid=lg.gid ORDER BY lg.group_order ASC, question_order ASC");

   while ($row = mysql_fetch_assoc($result))

       {

       // For all questions *except* Boilerplate (type X), print out the main question text

       if ($row['type'] != 'X') {

           if ($row['mandatory'] == 'Y')

               $isMandatory = ' <span style="color:red;">(* REQUIRED)</span>';

           else

               $isMandatory = '';

           // Grab the question text and put in a <div>, first filtering it thru stripFinalBrk(); this strips out the final break tag that appears

           // in many of the questions, which can mess up our formatting (break tags INSIDE the question text are left alone)

           $output .= '<div class="qText">' . stripFinalBrk($row['question']) . $isMandatory . '</div>';

           // Get array of possible options: This will be empty for some question types

           $qOpts = mysql_query("SELECT answer FROM lime_answers WHERE qid={$row['qid']} ORDER BY code ASC");

           $numOpts = mysql_num_rows($qOpts);

           }

       switch ($row['type']) {        // Process output based on question type

           case 'Q':    // Multiple short text

           case 'P':

           case 'K':

           case 'L':

               $output .= '<ul style="margin:0;">';    // Begin tag for bulleted list of options

               // Populate an array of options listed for this question

               while ($rowOpts = mysql_fetch_assoc($qOpts))

                   $output .= '<li>' . $rowOpts['answer'] . '</li>';

               $output .= '</ul>';

               break;

           case ';':        // Mandatory multi-choice flex labels (tabular display)

               $output .= '<div style="margin-left:2em;"><table border="1" cellpadding="4"><tr>';

               // Get labels for columns and create top table row for output

               $output .= "<th> </th>";    // 1st column where row labels will go

               $qColumns = mysql_query("SELECT title FROM lime_labels WHERE lid={$row['lid']} ORDER BY sortorder ASC");

               $numColumns = mysql_num_rows($qColumns);

               while ($colOpts = mysql_fetch_assoc($qColumns)) {

                   $output .= "<th>{$colOpts['title']}</th>";

                   }

               $output .= "</tr>";

               //  Create one row per option. The row labels will be the $qOpts we already got. Use these for 1st column, fill others with blanks

               while ($rowOpts = mysql_fetch_assoc($qOpts)) {

                   $output .= "<tr><td>{$rowOpts['answer']}</td>";

                   for ($i=0; $i < $numColumns; $i++) {    // Fill in blank columns under the column heads output above

                       $output .= "<td> </td>";

                       }    // end $i

                   $output .= "</tr>";

                   }    // end while ($rowOpts)

               $output .= "</table></div>";

               break;

           case 'Z';    // Flexible drop-down/radio-button - user selections come from lime_labels; here, show all possible options

               $output .= '<ul style="margin:0;">';    // Begin tag for bulleted list of options

               $qLabels = mysql_query("SELECT title FROM lime_labels WHERE lid={$row['lid']}");

               while ($rowOpts = mysql_fetch_assoc($qLabels)) {

                   $output .= '<li>' . $rowOpts['title'] . '</li>';

                   }

               $output .= '</ul>';

               break;

           default:    // For any type not specified above, no further output after displaying the question text

               break;

           }    // END: switch ($row['type'])

       }    // End main loop thru survey questions (while ($row....)

   return ($output);

}

/******

   stripFinalBrk(): Test if string ends with a <br /> tag, and if so remove it; returns modified string.
*/

function stripFinalBrk($myString) {

   $yerString = strrev($myString);    // Reverse input string for testing

   // Check if *reversed* string begins with a <br /> tag (backwards) - if so, strip out starting characters and return the rest

   if (substr($yerString,0,6) == '>/ rb<')

       $yerString = substr($yerString,6);

   return(strrev($yerString));    // Reverse back for result

   }

?>



<html>

<head>

   <title>LimeSurvey Preview Page</title>

   <style>

       body {

           font-family: Helvetica, Verdana, sans-serif;

           padding:1em 0 2em 1em;

           font-size:0.9em;

           }

       td, th {

           font-size:0.8em;

           }

       li {

           font-size:0.9em;

           }

       h2 {

           color:#00A;

           }

       div.qText {

           margin:1em 0 0.5em 0;

           padding:0.5em 0 0.2em 0;

           border-top: solid 1px #00a;

           /* border-bottom: solid 1px #00a; */

           }

   </style>

</head>

<body>

   <?php echo(preview_survey($mySID)); ?>

   <hr style="margin-top:15px;" />

</body>

How to export a clean up-to-date .doc questionnaire directly from LimeSurvey

Once we have programmed a questionnaire we sometimes need to export it back. For example, we have made some changes directly in the interface, and would like to save them in a human-readable way for reference. Or, maybe our client needs to make some changes in the plain old .doc format.

While LS lacks such a function it is still possible to do this with free software and a little effort.

Step 1: go to the printable version of your questionnaire

e7e788d275844deeb207679.png

Step 2: using your browser save the html file of the questionnaire locally.

Step 3: open the file using Libre Office.

Step 4: save/export the document as .doc.

Step 5: beautify the result. In your word processor of choice you may want to align all text to the left and use some automated way to put a border on your tables (use this http://www.thedoctools.com/index.php?show=mt_tableborder if you have MsWord)

That's it. Now you have a file that can be sent to your clients or edited.

Notes

For step 2, you may actually want to consider exporting to PDF by using a PDF printer as Bullzip PDF or CutePDF. Your partners may use one of the many PDF annotation tools to comment. On the plus side, it will look a bit better, keeping checkboxes and stuff.

However, not all people are comfortable using this. Even more importantly, I have found that when it exports questionnaire logic in human-readable form the text becomes hard to follow or even stops making sense.

For step 3 you can, theoretically, use other tools like Word or OpenOffice. However the matrix-intensive survey I used for testing crashed all software except LO. Depending on the questionnaire you may need to take other decisions.

Notepad++ macro to replace . with;

If you try to paste a list like this

1. option1

2. option2

... into the quick add box in LimeSurvey it will likely not wok out nicely because it will keep the numbering in the label of the option. However if you change it to ...

1; option1

2; option2

... it will work just fine, creating both codes and labels. I have created a Notepad++ macro that replaces the . following numbers up to 30 with ; , provided that all numbers are at the beginning of the line.

To install it you must

1. Close Notepad++ and keep it closed (otherwise it will override your work)

2. Search for shortcuts.xml in the program folder

3. Open it with another text editor

4. In the macro section paste the code below.

Note that N++ does not have something like an "echo off" command, so you will get lots of feedback from the program while the macro runs. However, I have created several smaller macros so that you may want to choose based on how wide your numbers range. (It will all come clear once you actually run the macro)

Now the code:

  <Macro name="format.1to5" Ctrl="no" Alt="no" Shift="no" Key="0">

       <Action type="0" message="2316" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n1." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n1;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n2." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n2;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n3." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n3;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n4." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n4;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n5." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n5;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

       </Macro>

       <Macro name="format.1to10" Ctrl="no" Alt="no" Shift="no" Key="0">

           <Action type="0" message="2316" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n1." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n1;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n2." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n2;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n3." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n3;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n4." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n4;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n5." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n5;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n6." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n6;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n7." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n7;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n8." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n8;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n9." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n9;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n10." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n10;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

       </Macro>

       <Macro name="format.11to20" Ctrl="no" Alt="no" Shift="no" Key="0">

           <Action type="0" message="2316" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n11." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n11;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n12." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n12;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n13." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n13;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n14." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n14;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n15." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n15;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n16." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n16;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n17." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n17;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n18." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n18;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n19." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n19;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n20." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n20;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

       </Macro>

       <Macro name="format.21to30" Ctrl="no" Alt="no" Shift="no" Key="0">

           <Action type="0" message="2316" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n21." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n21;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n22." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n22;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n23." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n23;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n24." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n24;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n25." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n25;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n26." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n26;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n27." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n27;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n28." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n28;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n29." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n29;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />

           <Action type="3" message="1601" wParam="0" lParam="0" sParam="\n30." />

           <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />

           <Action type="3" message="1602" wParam="0" lParam="0" sParam="\n30;" />

           <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />

           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />

       </Macro>

       <Macro name="home" Ctrl="no" Alt="no" Shift="no" Key="0">

           <Action type="0" message="2316" wParam="0" lParam="0" sParam="" />

       </Macro>


Procedure to translate all surveys in the desired language quick and easy

Step 1: Setup LimeSurvey

  1. Install all new fonts in the Computer/ Server
  2. Add language folders in ~\htdocs\locale
  3. Go to ~\htdocs\application\helpers and insert commands for the desired languages in SurveyRuntimeHelper.php
  4. Go to ~\ htdocs\third_party\ckeditor\_source\plugins\font and edit Plugin.js file using notepad++. Press ctrl+f and search for ‘verdana’. Add all the fonts that you have installed in step A.
  5. Go to ~\htdocs\third_party\ckeditor and edit ckeditor.js file using notepad++. Press ctrl+f and search for ‘verdana’. Add all the fonts that you have installed in step A.

Note: Step 1 is to be performed only once. You can skip this step for all subsequent projects.

Step 2: Export Survey

  1. Export your Survey in .txt (UTF-8 format).
  2. Open the .txt file in excel.

Step 3: Import Translations

  1. Look for the language code in the .txt file. Copy all ‘en’ entries of the questions (with their respective answer options) on a new excel sheet.
  2. Now open the translated excel sheet shared by the client and perform vlookup. Check for errors and incomplete translations.
  3. Once all translations are done, copy the translated entries and paste them in automated translations.xlsx sheet.
  4. Final step. Now, copy the output generated from the automated translations.xlsx sheet and paste it in the .txt file.

Step 4: Save and Upload

  1. Save the .txt file in the same format i.e. Tab Delimited.
  2. Now open LimeSurvey and Import the survey.

Provide a basic statistic without the need of an user account (for example to provide a stat for your client)

This PHP script shows the number of the participants of surveys and the development of the participations presented with a Google Line Chart. There are three key-features: 1. The necessary survey ID's and the title of the project are provide with GET variables so anyone can set up the statistic without the need to adapt the source code 2. The client can see the development with the help of Google Charts 3. Real time count of the overall number of participants

Further the script can handle also surveys where the dates weren't logged and the surveys can also be mixed.

All you need is to provide a URL following this pattern http://yourdomain/survey_stat.php?survey=1010101,2020202,3030303&title=Client%20Name

survey= Here you provide the survey ID's from one or different surveys (when the client runs more than one survey or you want to compare different surveys) title = Here you provide the title

That's it. It is pretty easy and can be set up from anyone.

Here is the full script ready to go with google JS and HTML code:

 
<?php
 
//Connect to the database you use for limesurvey
try {
    $db = new PDO('mysql:host=yourhost.com;dbname=lime_db', 'user', 'pass');
} catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "<br/>";
    die();
}
 
function participants_pd($sid, $db) {
	//get the number of participants for each day of the survey
	$facts = array();
	$x = 0;
	if(!is_numeric($sid)) {
		echo "Survery ID must be a valid number";
		exit();
	}
	else {
		$survey_tbl = "lime_survey_".$sid;
		$query = "select date(`submitdate`) AS date, count(`id`) AS number from `$survey_tbl` where `submitdate` != 'NULL' group by date(`submitdate`)";
		$stmt = $db->query($query);
		while($r = $stmt->fetch(PDO::FETCH_OBJ)) {
				$facts['date'][$x] = $r->date;
				$facts['count'][$x] = $r->number;
				$x++;
		}
		$db = null;
		return $facts;
	}
}
 
function participants_sum($sid, $db) {
	//get number of participants of the survey
	if(!is_numeric($sid)) {
		echo "Survery ID must be a valid number";
		exit();
	}
	else {
	$survey_tbl = "lime_survey_".$sid;
	$sum = "";
	$survey_tbl = "lime_survey_".$sid;
	$query = "select count(`id`) AS sum from `$survey_tbl` where `submitdate` != 'NULL'";
	$stmt = $db->query($query);
	$r = $stmt->fetch(PDO::FETCH_OBJ);
	$sum = $r->sum;
	return $sum;	
	}
}
 
function titles($sid, $db) {
	//get the titles
	$title = "";
	$query_t = "select `surveyls_title` from `lime_surveys_languagesettings` where `surveyls_survey_id` = :sid";
	$stmt_t = $db->prepare($query_t);
	$stmt_t->bindParam(':sid', $sid);
	$stmt_t->execute();
	$r = $stmt_t->fetch(PDO::FETCH_OBJ);
	$title = $r->surveyls_title;
	return $title;	
}
 
//Getting the ID's of the surveys
if(isset($_GET['survey'])) {
	$titles = array();
	$participants = array();
	$surveys = array();
	//check if there are more then one surveys-ids
	if(preg_match("/,/", $_GET['survey'])) {
		//there are more then one survey 
		$surveys = explode(",", $_GET['survey']);
	}
	else {
		$surveys[] = $_GET['survey'];
	}
	foreach ($surveys as $key => $value) {
		//Get the number of participants for each day of the survey of each survey
		$arrayname = "survey".$value;
		${$arrayname} = participants_pd($value,$db);
 
		//Get number of participants for the whole periode
		$participants[] = participants_sum($value,$db);
 
		//Get the titles of the surveys
		$titles[] = titles($value,$db);
	}
}
 
/**
* generating the data string for the google chart
* Will look something like that:
* ['Day','Title S1','Title S2','Title S3'],
* ['2013-10-08',35,462,101],
* ['2013-10-09',15,101,33],
* ['2013-10-10',7,37,10],
* ['2013-10-11',5,14,1],
* ['2013-10-13',2,10,1]]);
*/
 
//First the column names of the chart (in our case Day and the titles )
$data = "['Day'";
foreach ($titles as $key => $value) {
	$data = $data.",'".$value."'";
}
$data = $data."]";
 
//Check which survey the most days
//The x-axis of the chart will filled with the dates of this survey
$max = 0;
$max_sid = "";
foreach ($surveys as $key => $value) {
	$arrayname = "survey".$value;
	if($max < count(${$arrayname}['date'])){
		$max = count(${$arrayname}['date']);
		$max_sid = $key;
	}
}
 
//fill in the numbers of participants 
$x = 0;
while ($x < $max) {
	$data = $data.",['".${"survey".$surveys[$max_sid]}['date'][$x]."'";
	foreach ($surveys as $key => $value) {
		$arrayname = "survey".$value;
		if(!empty(${$arrayname}['count'][$x])) {
		$data = $data.",".${$arrayname}['count'][$x];
		}
		else {
			$data = $data.",0";
		}
	}
	$data = $data."]";
	$x++;
}
//$data contains now a string with the JS Data Array 
//<?=$data has to be placed in the JS containing the google chart function
 
 
//Setting the title of the site (can be the name of the project or of the costumer)
$title = "Development of the numbers of participants ";
if(isset($_GET['title'])) {
	trim($_GET['title']);
	htmlentities($_GET['title']);
	$title = $title.$_GET['title'];
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
 
	<title><?=$title?></title>
 
	<style type="text/css">
	body,html {
		font-family: Droid Sans;
		font-size: 13px;
		margin:0px;
		width: 100%;
		height: 100%;
		background-color: grey;
 
	}
	h1 {
		font-size: 18px;
		background-color: white;
		margin-left: 0px;
		width: 50%;
		padding: 5px;
	}
	h2 {
		font-size: 15px;
 
	}
	.stat {
		width: 50%;
		background-color: white;
		padding: 5px;
	}
	.stat_li {
		width: 25%;
		float: left;
		text-align: right;
	}
	.stat_re {
		width: 45%;
		float: left;
		margin-left: 5%;
		font-weight: bold;
	}
	</style>
 
  <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
 
      //set up the chart
      //check out https://developers.google.com/chart/ for more options
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      <?php
      if(isset($_GET['survey'])) {
      ?>
      function drawChart() {
 
        var data = google.visualization.arrayToDataTable([
          <?=$data?>
        ]);
 
        var options = {
 
        };
 
        var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
        chart.draw(data, options);
      }
      <?php
  		}
      ?>
    </script>
 
</head>
 
<body>
<h1><?=$title?></h1>
<h2>Overall participants</h2>
<div class="stat">
<?php
if(isset($_GET['survey'])) {
	$x = 0;
	foreach ($participants as $key => $value) {
		echo "<div class='stat_li'>".$titles[$x].":</div><div class='stat_re'>".$value." Participants</div><div style='clear:both;'></div>";
		$x++;
	}
}
?>
</div>
<h2>Development of the participation</h2>
<div id="chart_div" style="width: 51%; height: 50%;"></div>
</body>
</html>


Import show data into a Google Drive Spreadsheet

Tested with: LS >= 2.05

You can import any data (e.g. list of surveys or users, selected answers) stored in your limesurvey database using the "IMPORTXML" function.

  1. Create a XML file to structure and print needed data (you should access it at http://mysite.com/myxml.php )
  2. In your spreadsheet use the following format (pasting in a cell):
=IMPORTXML("http://mysite.com/myxml.php?refresh=&GoogleClock()", "//mytaglabel")


To protect your XML file(s) from direct access you can put them in a dedicated folder and use a .htacess file to limit the access exclusively to Google Apps web crawlers filtered by ip ranges

order allow, deny
deny from all
# allow from your_ip
allow from 66.249.80.0/20 # Used by User-Agents 'apps-spreadsheets' & 'Feedfetcher-Google'
allow from 64.233.160.0/19 # Used by  'GoogleApps' UA
# Uncomment if necessary following ther IP ranges commonly used by Google INC.
# allow from 46.108.0.0/18 64.18.0.0/20 66.249.80.0/20 72.14.192.0/18 74.125.0.0/16 173.194.0.0/16 207.126.144.0/20 209.85.128.0/17 216.239.32.0/19


PHP (XML output) file sample.

The following php file will generate an XML view printing ID, STARTDATE and STARTLANGUAGE values of a survey.

<?php

/*
 - This php file will generate an XML file showing ID, STARTDATE and STARTLANGUAGE values of a survey.
 - Please edit variables for db credentials and survey id ($sid)
*/

    header('Content-Type: text/html; charset=iso-8859-1');
    header('Content-type: application/xml');

// Fetch database credentials (much better outside the wwww root directory)
// ************************
    $dblocation =   ' ';
    $dbname =  ' ';
    $dbuser =    '  ';
    $dbpwd =   ' ';
// ************************

// Create db connection
    $conn = new mysqli($dblocation, $dbuser, $dbpwd, $dbname);
// Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    } 


// Start XML output

    echo "<?xml version='1.0' encoding='iso-8859-1'?>"; 
    echo "<answers>";

// Define survey ID
// ************************
    $sid = "1234";
// ************************

    $sql = "SELECT id, startdate, startlanguage FROM lime_survey_".$sid." ORDER BY 'id' LIMIT 100";
//  $sql = "SELECT 1234X56X789, id, startdate, startlanguage FROM lime_survey_".$sid." ORDER BY 'id' LIMIT 100";

$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {

    echo "<item>\n";
    echo "<id>".$row["id"]."</id>\n";  
    echo "<startdate>".$row["startdate"]."</startdate>\n";
    echo "<startlanguage>".$row["startlanguage"]."</startlanguage>\n";
//  echo "<anylabel>".$row["1234X56X789"]."</anylabel>\n";
    echo "</item>\n";
    }
    } else {
        echo "something is happening here but you don't know what it is";
    }

    echo "</answers>";

// Close db connection
    $conn->close();

?>