LimeSurvey afterSurveyComplete event
Bismark
Posted on June 1, 2022
In my first article I created a simple plugin for LimeSurvey.
Now we want to add some text to the last page, when the user executes the survey.
LimeSurvey offers an event afterSurveyComplete
.
All we have to to now is to subscribe to that event and implement an event handler method:
public function init()
{
$this->subscribe('afterSurveyComplete');
}
A minimal implementation looks like this.
public function afterSurveyComplete()
{
$event = $this->getEvent();
$event->getContent($this)->addContent('Hello World');
}
For further processing, the event provides 2 parameters surveyId
and responseId
.
public function afterSurveyComplete()
{
$event = $this->getEvent();
$surveyId = $event->get('surveyId');
$responseId = $event->get('responseId');
$response = $this->pluginManager->getAPI()->getResponse($surveyId, $responseId);
$myContent = var_export($response, true);
$event->getContent($this)->addContent($myContent);
}
That's it.
Bye!
💖 💪 🙅 🚩
Bismark
Posted on June 1, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.