Actions

AfterFindSurvey: Difference between revisions

From LimeSurvey Manual

No edit summary
No edit summary
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{FeatureStarting|2.63.0. build ??????}}  
{{FeatureStarting|2.63.0.}}  


'''When'''
'''When'''


This event is fired after loading a survey to participant to be able to modify/override some display parameters for current display session.
This event is fired after loading a survey to be able to modify/override some display parameters for current display session.


If needed you can check current controller if you need only during survey taking/


'''Input'''
'''Input'''
Line 14: Line 15:
|-
|-
| surveyId || integer || The id of the current survey
| surveyId || integer || The id of the current survey
|}
'''Possible output'''
All [https://github.com/LimeSurvey/LimeSurvey/blob/master/application/models/Survey.php model attributes] {{NewIn|v=3.22.29}} can be updated, no control are done.
Before only following information can be set in the event:
{|
! Name !! Type !! Description
|-
|-
| template || string || The template name to be used for display
| template || string || The template name to be used for display
Line 37: Line 49:
| navigationdelay || integer || Navigation delay (seconds)
| navigationdelay || integer || Navigation delay (seconds)
|}
|}
'''Possible output'''
None




Line 52: Line 60:


     public function processTest(){
     public function processTest(){
         $this->event->set('template','news_paper');
         $controller = App()->getController();
        // Set template only during survey taking
        if(!empty($controller->getId()) && $controller->getId()=="survey") {
            $this->event->set('template','news_paper');
        }
     }
     }
</syntaxhighlight>
</syntaxhighlight>
[[Category:Plugins events]]
[[Category:Plugins events]]

Latest revision as of 14:34, 21 May 2021

 Hint: This features is available starting in version 2.63.0.


When

This event is fired after loading a survey to be able to modify/override some display parameters for current display session.

If needed you can check current controller if you need only during survey taking/

Input

The event receives the following information:

Name Type Description
surveyId integer The id of the current survey


Possible output

All model attributes (New in 3.22.29 ) can be updated, no control are done.

Before only following information can be set in the event:

Name Type Description
template string The template name to be used for display
usecookie string Set cookie to prevent repeated participation: 'Y' or 'N'
allowprev string Allow backward navigation: 'Y' or 'N'
showxquestions string Show "There are X questions in this survey": 'Y' or 'N'
shownoanswer string Show "No answer": 'Y' or 'N'
showprogress string Show progress bar: 'Y' or 'N'
questionindex integer Show question index / allow jumping: (0-1-2)
usecaptcha string Use CAPTCHA for survey access: 'Y' or 'N'
showgroupinfo string Show group name and/or group description: 'B','N','D','X'
showqnumcode string Show question number and/or code: 'B','N','D','X'
navigationdelay integer Navigation delay (seconds)


Examples

    public function __construct(PluginManager $manager, $id) {
        parent::__construct($manager, $id);
        $this->subscribe('afterFindSurvey', 'processTest');
    }

    public function processTest(){
        $controller = App()->getController();
        // Set template only during survey taking
        if(!empty($controller->getId()) && $controller->getId()=="survey") {
            $this->event->set('template','news_paper');
        }
    }