Thanks for this great plugin. I appreciate all the hard work done here.

I am wondering... is there a way right now to show responses within Views? I know that the responses are stored as nodes, but I need to be able to display individual answers from those responses within Views.

If this isn't currently available, where would be a good place to start in the code (if you have any suggestions)? I'd like to get that working. How many hours would you suspect it would take an average Drupal developer to get working?

Thanks!

Comments

Hi dustinrwh,

Your are definitvely an advanced user of the LimeSurvey Sync module !
Actually, it is not possible to display individual question of one answer using views. The best you can do is to query the body, printing all answers of one (or more) response(s).

There 2 ways to show individual answers :
- The easier way : (not so easy) : declare to the views module (using hook__views_data()) the LimeSurvey tables, including there relationships.
- An harder and much powerfull way : import Limesurvey individual questions into Fields. The views display will be automatically available. This way may be a big evolution of the LimeSurvey Sync module, making this module the best 'form' module on drupal (and not simply the best 'survey' module on drupal). A good start is to explore the code from a sandbox : the LimeSurvey Importer (but I don't sugguest to use the feeds module). Anyway, for survey containing more than 50 questions, the current LimeSurvey Sync module version will be faster than a new version using Fields.

I'm sorry but I'm not able to estimate how many hours this developpment would take to get working.

Please, share your work if you start to dig on one way or another.

Priority:Major» Minor
Status:Active» Postponed

Hum, There is a third way, developpement would be very easy, it may take less than an hour of developpement !
The point is : this way may suit to you if you have only few questions to display within views for one (or few) survey(s).
I explain here how to do it for one question :

  1. On your answer content type edit page : create a field, it will store the answer for the targeted question.
  2. identify the LimeSurvey fieldname you want to match : look into the LimeSurvey database, into the 'survey_168837' structure, it must be something like '168837X19X606'.
  3. Here is the code : dig on the drupal/sites/all/modules/limesurvey_sync/ls_api/limesurvey_sync_api_answ.inc, looking for the limesurvey_sync_answ_import_answer() function : identify the loop next to the comment line '// Extract datas'; and write :
    if ($cell['fieldname'] == '168837X19X606') {
       // Save the $cell['answers'][0] value into the answer node Field, using the node_save() function.
    }
  4. Thanks to that code, the result of the targeted question will be copy into your Field on each answer node synchronization.
    Note : You may identify the targeted question using its title instead of its fieldname, but it is not as specific, especially if you are using multilingual survey or if the question title is edited from the LimeSurvey software.

  5. Now, you can use views to show the value of this specific question.

You can feed back here, it's an interesting feature

Category:task» feature

A version of LimeSurvey Sync that uses fields would be very nice.
It would provide a lot of much-needed flexibility that simply isn't available at this time.

Yes.
I'm working on that. I pledge the LimeSurvey single questions will be available from views. It will be handled by an custom entity. It is not available yet.

It will be challenging, due to the naming convention of limesurvey's database table columns..

Issue summary:View changes

typo

Hello,
I tried your answer:

Here is the code : dig on the drupal/sites/all/modules/limesurvey_sync/ls_api/limesurvey_sync_api_answ.inc, looking for the limesurvey_sync_answ_import_answer() function : identify the loop next to the comment line '// Extract datas'; and write :
if ($cell['fieldname'] == '168837X19X606') {
// Save the $cell['answers'][0] value into the answer node Field, using the node_save() function.
}

but in my case the survey has expired and I would like to expose the results for each question, into fields so that I can manipulate it easily.
But when I try to synchronize again the survey, the answers to the questions do not get copied to the field where they should be.

Also when one create the field for the answer under the specific survey content type, it has only the choice between 1 to 10 values for this field so it can take into account only 10 answers.

In my case not even one answer fills the field.

I might have done something wrong, what do you think?

thanks

forget the number of values restriction, the unlimited option is before 1.
So my problem is only that the fields are not populated with the answers values.

Thanks

well something is missing between the curly brackets, i just got that your example was not complete.

could you tell me more in details what you mean by

// Save the $cell['answers'][0] value into the answer node Field, using the node_save() function

, and how to do it?

Thank you

The sample code did work for me when I try to copy into a node field , I use the following
$node->field_xyz[$lang][0]['value']= $cell['answers'][0]

node_save was not required as $node was passed by reference and I could copy the survey values into a node this way ... not an expert but this was my experience when I was trying this example code ..

Confirming the sample code worked for me too. Had to replace $lang with 'und' since that what was in my field_data_xyz table in the language column. I.e., used
$node->field_xyz['und'][0]['value']= $cell['answers'][0]

Didn't need node_save()

Just added the sample code (just the if statement with the above $node-> statement inside the if) just inside the foreach()
Way cool!

Thanks