- Posts: 18
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Save operations into db
- maurikef
- Topic Author
- Offline
- New Member
Less
More
2 years 2 weeks ago #226057
by maurikef
Save operations into db was created by maurikef
Please help us help you and fill where relevant:
Your LimeSurvey version: 5.2.6
Own server or LimeSurvey hosting: Own server
Survey theme/template: Save operations into db
==================
Hi,
I am writing a plugin that allows me to do the following:
- check access to a page (url)
- check if survey expiration date is set
- check transactions made on the responses page
- check transactions made on the participant page (not from central database)
- check operations to modify a theme
- check insertion of the captcha
- partial storage of questionnaire replies
My purpose is to record these operations within a database to keep track of any critical issues.
For some operations I am trying to use present events (e.g. beforeResponseSave, beforeResponseDelete, beforeParticipantSave, beforeParticipantDelete) but they do not work or, as in the case of participants, refer only to those of the central database and not to those that are added from the panel only for that survey.
Finally, I would like to know how to differentiate the successful operations from the unsuccessful ones. I am using the request (attached code) but I do not think it is correct.
Thanks to those who will answer me
Your LimeSurvey version: 5.2.6
Own server or LimeSurvey hosting: Own server
Survey theme/template: Save operations into db
==================
Hi,
I am writing a plugin that allows me to do the following:
- check access to a page (url)
- check if survey expiration date is set
- check transactions made on the responses page
- check transactions made on the participant page (not from central database)
- check operations to modify a theme
- check insertion of the captcha
- partial storage of questionnaire replies
My purpose is to record these operations within a database to keep track of any critical issues.
For some operations I am trying to use present events (e.g. beforeResponseSave, beforeResponseDelete, beforeParticipantSave, beforeParticipantDelete) but they do not work or, as in the case of participants, refer only to those of the central database and not to those that are added from the panel only for that survey.
Finally, I would like to know how to differentiate the successful operations from the unsuccessful ones. I am using the request (attached code) but I do not think it is correct.
Thanks to those who will answer me
Attachments:
Please Log in to join the conversation.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
2 years 2 weeks ago #226109
by DenisChenu
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.
Replied by DenisChenu on topic Save operations into db
For token (participant) of survey : beforeTokenSave, beforeTokenDelete
For Reponse : best is to add your plugin to 2 events :
LogSurveyParticipant/LogSurveyParticipant.php: $this->subscribe('beforeResponseSave', 'beforeResponseSave');
LogSurveyParticipant/LogSurveyParticipant.php: $this->subscribe('beforeSurveyDynamicSave', 'beforeResponseSave');
Same for Token : TokenDynamic must be used too.
For Reponse : best is to add your plugin to 2 events :
LogSurveyParticipant/LogSurveyParticipant.php: $this->subscribe('beforeResponseSave', 'beforeResponseSave');
LogSurveyParticipant/LogSurveyParticipant.php: $this->subscribe('beforeSurveyDynamicSave', 'beforeResponseSave');
Same for Token : TokenDynamic must be used too.
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.
- maurikef
- Topic Author
- Offline
- New Member
Less
More
- Posts: 18
- Thank you received: 0
2 years 2 weeks ago - 2 years 2 weeks ago #226124
by maurikef
Replied by maurikef on topic Save operations into db
Hi,
thanks for the reply.
for the other points in the list instead you can advise me?
to verify if the operation has been successful is it okay to use the request as code?
thanks again
thanks for the reply.
for the other points in the list instead you can advise me?
to verify if the operation has been successful is it okay to use the request as code?
thanks again
Last edit: 2 years 2 weeks ago by maurikef.
Please Log in to join the conversation.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
2 years 2 weeks ago #226126
by DenisChenu
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.
Replied by DenisChenu on topic Save operations into db
No
1. User can be null
2. hostmachine ?
3. for survey id : manual.limesurvey.org/BeforeModelDelete $this->getEvent()->get('surveyId');
Did you try manual.limesurvey.org/AuditLog ? It's done for this ,
Maybe you can test and improve ?
1. User can be null
2. hostmachine ?
3. for survey id : manual.limesurvey.org/BeforeModelDelete $this->getEvent()->get('surveyId');
Did you try manual.limesurvey.org/AuditLog ? It's done for this ,
Maybe you can test and improve ?
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.
- maurikef
- Topic Author
- Offline
- New Member
Less
More
- Posts: 18
- Thank you received: 0
2 years 2 weeks ago - 2 years 2 weeks ago #226133
by maurikef
Replied by maurikef on topic Save operations into db
Unfortunately, events for responses don’t work. I also tried with the events "beforeDataEntryCreate" and "beforeDataEntryDelete" present in the auditlog but even these do not save anything (I enclose the code, I would not want to do anything wrong).
My first question was: within events how do I save success or failure cases related to saving the recalled operation?
Hostmachine is the local machine name that calls the event (es. localhost)
My first question was: within events how do I save success or failure cases related to saving the recalled operation?
Hostmachine is the local machine name that calls the event (es. localhost)
Attachments:
Last edit: 2 years 2 weeks ago by maurikef.
Please Log in to join the conversation.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
2 years 2 weeks ago #226214
by DenisChenu
with
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.
Replied by DenisChenu on topic Save operations into db
false : it workUnfortunately, events for responses don’t work.
Code:
2022/03/12 15:30:45 [trace] [plugin.TestResponseEvent] beforeSurveyDynamicSave for on 713188 2022/03/12 15:30:45 [trace] [plugin.TestResponseEvent] afterSurveyDynamicSave for new on 713188 2022/03/12 15:30:45 [trace] [plugin.TestResponseEvent] beforeResponseSave for new on 713188 2022/03/12 15:30:45 [trace] [plugin.TestResponseEvent] afterResponseSave for new on 713188 2022/03/12 15:30:54 [trace] [plugin.TestResponseEvent] beforeResponseSave for new on 713188 2022/03/12 15:30:54 [trace] [plugin.TestResponseEvent] afterResponseSave for new on 713188
with
Code:
public function init() { $this->subscribe('beforeResponseSave', 'testResponseSave'); $this->subscribe('beforeSurveyDynamicSave', 'testResponseSave'); $this->subscribe('afterResponseSave', 'testResponseSave'); $this->subscribe('afterSurveyDynamicSave', 'testResponseSave'); } public function testResponseSave() { if (Yii::app() instanceof CConsoleApplication) { return; } $eventName = $this->getEvent()->getEventName(); $surveyId = $this->getEvent()->get('surveyId'); $oResponse = $this->getEvent()->get('model'); if(!empty($oResponse->id)) { $srid = "new"; } else { $srid = $oResponse->id; } $this->log("{$eventName} for {$srid} on {$surveyId}"); }
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.
The following user(s) said Thank You: maurikef
Please Log in to join the conversation.
- maurikef
- Topic Author
- Offline
- New Member
Less
More
- Posts: 18
- Thank you received: 0
2 years 2 weeks ago - 2 years 2 weeks ago #226237
by maurikef
Replied by maurikef on topic Save operations into db
thank you so much, I will have made a mistake then to write something.
for participants instead, doesn't work properly delete it.
attached code, can you understand where I’m wrong?
for participants instead, doesn't work properly delete it.
attached code, can you understand where I’m wrong?
Attachments:
Last edit: 2 years 2 weeks ago by maurikef.
Please Log in to join the conversation.