Is that possible to poll responses from direct plugin?

More
10 months 1 week ago #210905 by jerryz
Hi there, 

I am trying to write a plugin to poll Surveys and Responses in a 'direct' event plugin. In it, I have no problem getting Survey and Question Properties. However, when I try to get the Responses, I run into some errors on Session. 

First of all, I added the import for common helper:
Yii::import('application.helpers.common_helper', true);

But still, when I tried to run the command, I got an error with the stack trace as:
CException: Property "ConsoleHttpSession.connectionID" is not defined. in /var/www/html/framework/base/CComponent.php:173
Stack trace:
#0 /var/www/html/framework/YiiBase.php(227): CComponent->__set('connectionID', 'db')
#1 /var/www/html/framework/base/CModule.php(393): YiiBase::createComponent(Array)
#2 /var/www/html/framework/base/CModule.php(118): CModule->getComponent('session')
#3 /var/www/html/application/helpers/common_helper.php(1429): CModule->__isset('session')
#4 /var/www/html/plugins/CDCEvents/CDCEvents.php(488): createFieldMap(Object(Survey), 'full', true, false, 'en')
#5 /var/www/html/plugins/CDCEvents/CDCEvents.php(370): CDCEvents->exportResponses(35523, 1, 'short')
#6 /var/www/html/plugins/CDCEvents/CDCEvents.php(358): CDCEvents->extractQR('35523', '1')
#7 /var/www/html/plugins/CDCEvents/CDCEvents.php(155): CDCEvents->processQR('35523', '1')
#8 /var/www/html/plugins/CDCEvents/CDCEvents.php(124): CDCEvents->processAllResponsesFor('35523', false)
#9 [internal function]: CDCEvents->direct()
#10 /var/www/html/application/libraries/PluginManager/PluginManager.php(185): call_user_func(Array)
#11 /var/www/html/application/commands/PluginCommand.php(45): LimeSurvey\PluginManager\PluginManager->dispatchEvent(Object(PluginEvent))
#12 [internal function]: PluginCommand->actionIndex('CDCEvents', 'responses', '[{"survey": "35...')
#13 /var/www/html/framework/console/CConsoleCommand.php(172): ReflectionMethod->invokeArgs(Object(PluginCommand), Array)
#14 /var/www/html/framework/console/CConsoleCommandRunner.php(71): CConsoleCommand->run(Array)
#15 /var/www/html/framework/console/CConsoleApplication.php(92): CConsoleCommandRunner->run(Array)
#16 /var/www/html/framework/base/CApplication.php(185): CConsoleApplication->processRequest()
#17 /var/www/html/application/commands/console.php(76): CApplication->run()
#18 {main}
It seems that the ConsoleApplication is using "ConsoleHttpSession", but the system is still thinking it is "application.core.web.DbHttpSession" and try to set "connectionID" to 'db'. 

I tried to make some change to ./application/commands/console.php to replace the "ConsoleHttpSession" with "application.core.web.DbHttpSession" using:
$config['components']['session']['class'] = 'application.core.web.DbHttpSession';
$config['components']['session']['connectionID'] = 'db';
$config['components']['session']['sessionTableName'] = '{{sessions}}';

Now I got an errror with the stack trace as:
PHP Error[2]: session_set_cookie_params(): Cannot change session cookie parameters when headers already sent
    in file /var/www/html/framework/web/CHttpSession.php at line 267
#0 /var/www/html/framework/web/CHttpSession.php(267): session_set_cookie_params()
#1 /var/www/html/framework/base/CComponent.php(152): DbHttpSession->setCookieParams()
#2 /var/www/html/framework/YiiBase.php(227): DbHttpSession->__set()
#3 /var/www/html/framework/base/CModule.php(393): createComponent()
#4 /var/www/html/framework/base/CModule.php(118): ConsoleApplication->getComponent()
#5 /var/www/html/application/helpers/common_helper.php(1429): ConsoleApplication->__isset()
#6 /var/www/html/plugins/CDCEvents/CDCEvents.php(488): createFieldMap()
#7 /var/www/html/plugins/CDCEvents/CDCEvents.php(370): CDCEvents->exportResponses()
#8 /var/www/html/plugins/CDCEvents/CDCEvents.php(358): CDCEvents->extractQR()
#9 /var/www/html/plugins/CDCEvents/CDCEvents.php(155): CDCEvents->processQR()
#10 /var/www/html/plugins/CDCEvents/CDCEvents.php(124): CDCEvents->processAllResponsesFor()
#11 unknown(0): CDCEvents->direct()
#12 /var/www/html/application/libraries/PluginManager/PluginManager.php(185): call_user_func()
#13 /var/www/html/application/commands/PluginCommand.php(45): LimeSurvey\PluginManager\PluginManager->dispatchEvent()
#14 unknown(0): PluginCommand->actionIndex()
#15 /var/www/html/framework/console/CConsoleCommand.php(172): ReflectionMethod->invokeArgs()
#16 /var/www/html/framework/console/CConsoleCommandRunner.php(71): PluginCommand->run()
#17 /var/www/html/framework/console/CConsoleApplication.php(92): CConsoleCommandRunner->run()
#18 /var/www/html/framework/base/CApplication.php(185): ConsoleApplication->processRequest()
#19 /var/www/html/application/commands/console.php(76): ConsoleApplication->run()

We are stuck now and would really appreciate any help on the issue.

Please Log in to join the conversation.

More
10 months 1 week ago #210922 by DenisChenu
You use DB session ?

Can you test gitlab.com/SondagesPro/mailing/sendMailCron ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development . I don't answer to private message.

Please Log in to join the conversation.

More
10 months 1 week ago - 10 months 1 week ago #210928 by jerryz
I don't need to use DB session.

But the function createFieldMap() in common_helper is checking the session. Line 1429 of this file (version 3.x): github.com/LimeSurvey/LimeSurvey/blob/3....rs/common_helper.php

Do we have a way to poll all fields of Responses for a specific survey without using the createFieldMap()?
Last edit: 10 months 1 week ago by jerryz.

Please Log in to join the conversation.

More
10 months 1 week ago #210957 by DenisChenu

I don't need to use DB session.

 

I don't say you need … config.php seems to be set to use DB sessin : it's case or not ?

Yes : Expressionmanager and fieldmap use session, but session in console is replaced by : github.com/LimeSurvey/LimeSurvey/blob/ma...nsoleHttpSession.php

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development . I don't answer to private message.

Please Log in to join the conversation.

More
10 months 1 week ago #211017 by jerryz
Yes, the config.php is set to use DB session. But that is for the LimeSurvey itself, correct?

For the direct plugin, do we have another way to change that? I saw the ./application/commands/console.php has the session hard-coded to use "ConsoleHttpSession". And I think that is the reason we got the first stack trace. Basically, the config.php is set to use DB session, but the ConsoleApplication is providing a ConsoleHttpSession.

Please Log in to join the conversation.

More
10 months 1 week ago #211041 by DenisChenu
Yes : there is an issue by LimeSurvey here …

My opinion (unsure it work) : create your own fixLsCommand And report the issue, we really need to have a clean direct/cron plugin system.
Each time i want to have one : i need to track all potential error …
 

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development . I don't answer to private message.

Please Log in to join the conversation.

More
10 months 1 week ago #211057 by jerryz
Thank you very much for the reference. I will definitely try it out and let you know the outcome.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now