View Issue Details

This bug affects 1 person(s).
 10
IDProjectCategoryView StatusLast Update
13407Bug reportsPluginspublic2018-06-15 15:43
Reporterorvil Assigned Toollehar  
PrioritynoneSeveritycrash 
Status closedResolutionfixed 
Fixed in Version3.7.x 
Summary13407: plugin events seems not to work
Description

Plugin event beforeQuestionRender shows no reaction.
Tried other settings in this event too, but without positive results

Example code here:

<?php
class HelloWorld extends PluginBase{

    static protected $description = 'Hello World Plugin';
    static protected $name = 'Hello World';

    public function init() {
        $this->subscribe('beforeQuestionRender');
    }

    public function beforeQuestionRender(){
       $this->getEvent()->set('questionhelp', 'Hello World');
    }

}
Steps To Reproduce

place code in a dummy plugin

Additional Information

As DenisChenu once mentioned beside the set a append and prepend would push plugin development

TagsNo tags attached.
Attached Files
Bug heat10
Complete LimeSurvey version number (& build)3.4.0
I will donate to the project if issue is resolvedNo
Browserany
Database type & versionMySql
Server OS (if known)Debian Linux, Raspbian
Webserver software & version (if known)Apache2
PHP Version5.6.30

Users monitoring this issue

DenisChenu

Activities

orvil

orvil

2018-02-22 22:46

reporter   ~46728

traced the calls with $this->log("plugin helloWorld ... ");

  • init() function is called every time a question is shown
  • function beforeQuestionRender() is never called
ollehar

ollehar

2018-02-23 15:34

administrator   ~46741

Can we get a plugin to test with, please?

ollehar

ollehar

2018-02-23 15:35

administrator   ~46742

Sorry, didn't see example in comment. Disregard.

orvil

orvil

2018-02-23 23:02

reporter   ~46744

No problem, here it is. With additional log lines in init() and beforeQuestionRender() - activate them if required, logs to \tmp\runtime\plugin.log

helloWorld.php (495 bytes)   
<?php
class helloWorld extends PluginBase
{

	static protected $name        = 'Hello World Test';
	static protected $description = 'This is a Hello World plugin';

	public function init()
	{
		$this->subscribe('beforeQuestionRender');
		
		// $this->log("plugin helloWorld initiated");
		
	}

	public function beforeQuestionRender()
	{
		// $this->log("plugin helloWorld recieved event beforeQuestionRender");
		
		$this->getEvent()->set('questionhelp', 'Hello World');
	}
}
helloWorld.php (495 bytes)   
ollehar

ollehar

2018-02-26 14:20

administrator   ~46750

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&amp;id=26597

ollehar

ollehar

2018-02-26 14:23

administrator   ~46751

I commit a fix to this issue, but it's not working exactly as before. Please pull and test.

orvil

orvil

2018-02-27 13:43

reporter   ~46784

checked the fix with

public function beforeQuestionRender()
{
$this->getEvent()->set('text', 'Hello World');
}

working now.
Log files shows now that

  • init is called once a question page is shown
  • beforeQuestionRender is called for each question

continue to check with other settings like 'help' ...

ollehar

ollehar

2018-02-27 14:14

administrator   ~46786

Great, I'll put this on feedback until then. Thanks for your help!

orvil

orvil

2018-03-12 17:54

reporter   ~47027

Thanks for your update! I checked out the following outputs according to https://manual.limesurvey.org/BeforeQuestionRender
help : ok
mandatory : ok
answers: ok
man_message: ok

class: not sure, got no change

others: not tested yet.

DenisChenu

DenisChenu

2018-03-12 18:19

developer   ~47028

Last edited: 2018-03-12 18:21

It's the basic one, great thanks to olle and you to report. I had the other on a pull request :).

And update manual about the replacement (it's not {QUESTION_TEXT} in template ;) )

DenisChenu

DenisChenu

2018-05-26 10:59

developer   ~47862

@orvil : i think we have whole now. Please reopen if not

c_schmitz

c_schmitz

2018-06-15 15:43

administrator   ~48177

Version 3.12.1 Build 180616 released

Related Changesets

LimeSurvey: master c381d36b

2018-02-26 14:20:29

ollehar

Details Diff
Fixed issue 13407: Plugin event beforeQuestionRender does not work Affected Issues
13407
mod - application/helpers/SurveyRuntimeHelper.php Diff File

Issue History

Date Modified Username Field Change
2018-02-22 21:46 orvil New Issue
2018-02-22 22:46 orvil Note Added: 46728
2018-02-23 14:32 DenisChenu Issue Monitored: DenisChenu
2018-02-23 15:34 ollehar Note Added: 46741
2018-02-23 15:35 ollehar Note Added: 46742
2018-02-23 23:02 orvil File Added: helloWorld.php
2018-02-23 23:02 orvil Note Added: 46744
2018-02-26 13:47 ollehar Assigned To => ollehar
2018-02-26 13:47 ollehar Status new => assigned
2018-02-26 14:20 ollehar Changeset attached => LimeSurvey master c381d36b
2018-02-26 14:20 ollehar Note Added: 46750
2018-02-26 14:20 ollehar Resolution open => fixed
2018-02-26 14:23 ollehar Note Added: 46751
2018-02-26 14:23 ollehar Status assigned => feedback
2018-02-27 13:43 orvil Note Added: 46784
2018-02-27 13:43 orvil Status feedback => assigned
2018-02-27 14:14 ollehar Note Added: 46786
2018-02-27 14:14 ollehar Status assigned => feedback
2018-03-12 17:54 orvil Note Added: 47027
2018-03-12 17:54 orvil Status feedback => assigned
2018-03-12 18:19 DenisChenu Note Added: 47028
2018-03-12 18:21 DenisChenu Note Edited: 47028
2018-05-26 10:59 DenisChenu Status assigned => resolved
2018-05-26 10:59 DenisChenu Fixed in Version => 3.7.x
2018-05-26 10:59 DenisChenu Note Added: 47862
2018-06-15 15:43 c_schmitz Note Added: 48177
2018-06-15 15:43 c_schmitz Status resolved => closed
2021-08-07 07:55 guest Bug heat 8 => 10