Hi,
some special question this time, could not find a pattern in the manual.
Background: plugins can have settings on
- a global level (valid for all surveys),
- on survey level (valid for one survey) and
- on question level (the usual way)
Meanwhile I found examples how to set and read these settings for global and question level and how to set on survey level.
But unfortuantely I cannot find an example working for LS 3.x how to
read the settings for survey level.
Here is an theoretical example - you will find the missing code in function beforeQuestionRender() where $message3 is created.
Code:
<?php
class someTest extends PluginBase {
// some code skipped
// settings on global level
protected $settings = array(
'scriptActivate' => array(
'type' => 'checkbox',
'label' => 'Activate/deactivate script execution for all surveys',
'default' => '1',
)
)
// settings on survey level
public function beforeSurveySettings()
{
$event = $this->event;
$event->set("surveysettings.{$this->id}", array(
'name' => get_class($this),
'settings' => array(
'scriptsActivate'=>array(
'type'=>'boolean',
'label'=>'Activate script execution for this survey',
'help'=>'If this switch is off no script will be executed in this survey.',
'current' => 1,
)
)
));
}
// settings on question level
public function newQuestionAttributes()
{
$event = $this->event;
$questionAttributes = array (
'scriptActivate' => array(
'types' => '15ABCDEFGHIKLMNOPQRSTUWXYZ!:;|*', /* all question types */
'category' => gT('someTest'),
'sortorder' => 1,
'inputtype' => 'switch',
'caption' => 'Activate script execution',
'default' => '0',
)
)
}
// some code skipped
/**
* now use the attributes e.g. in question rendering
*/
public function beforeQuestionRender()
{
// global level
$message1 = "global settings: " . $this->get('scriptActivate',null,null,$this->settings['scriptActivate']['default']) . '<br />';
// question level
$aAttributes=QuestionAttribute::model()->getQuestionAttributes($this->getEvent()->get('qid'));
$message2 = "question settings: " . $aAttributes["scriptActivate"] . '<br />';
// survey level ???
//$message3 = "survey settings: " . // SOME HELP REQUIRED - THANKS!!!
}
}
Any idea how to get the corresponding code for $message3 ?
Thanks in advance