DEV Community

Bismark
Bismark

Posted on

4 3

LimeSurvey afterSurveyComplete event

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');
}
Enter fullscreen mode Exit fullscreen mode

A minimal implementation looks like this.

public function afterSurveyComplete()
{
    $event = $this->getEvent();
    $event->getContent($this)->addContent('Hello World');
}
Enter fullscreen mode Exit fullscreen mode

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);
}

Enter fullscreen mode Exit fullscreen mode

That's it.
Bye!

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay