First of all, thanks for this module - I am a big fan of LimeSurvey, and I think solid Drupal integration is a big win for both projects.

We are working on a site where we don't need the ls_answ functionality. Whilst ls_survey does not explicitly depend on ls_answ, it does implicitly depend on it, as it is impossible to create survey nodes with ls_answ disabled (due to form validation errors).

The attached patch adds module_exists checks around the areas that seemed to be causing the most trouble - there may be a few others I didn't find, of course. I think the best approach would be to add the code that expects or interacts with ls_answ into the ls_answ module itself, as this would be a better abstraction - this might be best as a separate issue though, as it may take quite a bit of refactoring.

Comments

owen barton’s picture

Status: Active » Needs review
StatusFileSize
new6.44 KB
thedut’s picture

Status: Needs work » Needs review

Hi Owen Barton !

Thank you for sharing your experience and custom code on the LimeSurvey Sync module.

I may think on your idea, but, at the first sight, I may not implement such feature.
The point is : when a survey node is created, it creates in the meanwhile the associated answers content type. The answer content types are declared into the ls_answ_info() function. That why the ls_answ module is needed when creating a new survey node. And it would be an error to declare it somewhere else [EDIT : That's not true on Drupal 7, see #4].

If I would implement your idea, I would need to add a checkboxe when the node survey is created asking if the answers content type has to be created or not but it would make no sense : answer content type is needed even if you don't use tokens or if you don't import answers because you need it to provide the limesurvey answer url : node/add/your_answer_content_type.

Furthermore, I don't understand why someone may want to enable the ls_survey module but not the ls_answ module... The ls_answ module can be enabled it won't change anything (even regarding performances). If you want to disallow to import answers you just need to disable the permission to view the correponding survey node.

The abstraction seems quite good to me, at least on that point.

Could you explain the interest to use the LimeSurvey Sync module without the ls_answ module ?

owen barton’s picture

Could you explain the interest to use the LimeSurvey Sync module without the ls_answ module ?

We are working on a separate module (which we will contribute, of course) to sync actual survey response data into tables to allow it to be efficiently analysed and charted with views (it would be possible to write views integration against the LimeSurvey tables directly, but they are structured in a way that would make many queries complex and slow).

We can't use ls_answ because it does not make the actual data columns available, and even if it did, storing it in node fields would get complex and slow very soon with large datasets.

We have no need to ever display single survey responses on the site. I do understand that you can enable ls_answ without actually running any sync - nevertheless it requires creating a new content type (that will never be used) for every survey, and also adds a lot of configuration and user interface clutter, and leads to a much more confusing user experience than necessary.

It is also confusing that ls_sync currently exists in a "semi-required" state. There is already a number of places where ls_survey does "if module_exists('ls_answ')" and ls_answ does not explicitly depend on ls_survey. Yet it is currently impossible to use even basic ls_survey functionality with ls_answ disabled.

From an abstraction point of view - if both modules really need to depend on each other, and ls_survey contains code that is really for ls_answ, then I don't see any purpose in actually making them separate modules at all - the code might as well just live in separate .inc files in a single module. I see no architectural requirement for ls_survey to include any ls_answ code whatsoever - ls_answ can simply implement standard Drupal hooks and add in it's own fields/functionality. If in any case it is unable to do this, then the standard pattern would be for ls_survey to provide it's own hook at the integration point, and have ls_answ implement that. Using "if module_exists" is also a possibility, but is really best kept for exceptional and simple cases.

thedut’s picture

Status: Active » Needs review

Ok, I understand your point of view now.

and also adds a lot of configuration and user interface clutter, and leads to a much more confusing user experience than necessary

Disabling the ls_answ module makes more sense. However, you don't need it because you are developing a separate module replacing it : it is not an usual case.

We are working on a separate module (which we will contribute, of course) to sync actual survey response data into tables to allow it to be efficiently analysed and charted with views

That an interesting feature ! I'm very curious about it.

(it would be possible to write views integration against the LimeSurvey tables directly, but they are structured in a way that would make many queries complex and slow).
We can't use ls_answ because it does not make the actual data columns available, and even if it did, storing it in node fields would get complex and slow very soon with large datasets.

I totally agree.

I do understand that you can enable ls_answ without actually running any sync - nevertheless it requires creating a new content type (that will never be used) for every survey

I said that the answer content type has to be declared into the ls_answ module but I was wrong concerning Drupal 7 : I explain why here :
The LimeSurvey Sync module was designed first for Drupal6. On Drupal 6, the only way to distinguish the Survey content type and the Answers content type was to set them into disctinct modules, using the $type->module value to detect which content type it was. On Drupal 7, thanks to the new 'base' colomn into the {node_type} table, we could declare both content types into the same module, distinguish them using the $type->base value.

From an abstraction point of view - if both modules really need to depend on each other, and ls_survey contains code that is really for ls_answ, then I don't see any purpose in actually making them separate modules at all

The LimeSurvey Sync includes 3 modules :
- limesurvey_sync (handle the synchronization setting page)
- ls_survey (handle survey content types)
- ls_answ (handle answers).
I have created 3 modules in order to make the code more clear (disctinct features into disctinct folders and modules). but I may keep them into distinct folders without creating distinct modules. It would be a better abstraction.
I may succeed in declaring the Answers content type into the Ls_survey module intead of the ls_answ module (only on the Drupal 7 version).

Your thread happens at the right time : I'm working on a new major version of the LimeSurvey Sync module (7.x-2.0).
For your information, this new version will :

  • enhance the synchronization process :
    • more colomns into the {ls_answ} table,
    • giving the ability to simulate an answer import/synchronization without saving it.
  • and redesign the language selection in a smarter way :
    • creating one answer content type per survey, including all limesurvey languages (instead of one answer content type per survey language for a specific survey),
    • and using the 'Translation' core module to handle translations.

I may include the new module hierarchy into this new major version.

I have not decided yet :

  • if I group all 3 modules into 1 module (i will probably choose this way on the Drupal 7 version).
  • or if I keep the ls_answ module into a distinct module, fixing the semi-required dependency (and not fixing it on the Drupal 6 version).
thedut’s picture

Status: Needs review » Needs work
thedut’s picture

Status: Needs review » Active
thedut’s picture

Status: Needs review » Active

The update script from 7.x-1.x to 7.x-2.x will be quite difficult to create, regarding new changes :
- one module instead of 3
- one content type per survey.
I hope I will have time for this on march.

thedut’s picture

Assigned: Unassigned » thedut
thedut’s picture

Issue summary: View changes
Status: Active » Fixed

Hello Owen,

The v7.x-2.0 is available as an alpha.
There is only one module now.
it comes with many improvements.
More informations here.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.