- Posts: 111
- Thank you received: 20
Ask the community, share ideas, and connect with other LimeSurvey users!
<?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!!! } }
$this->getEvent()->get('surveyId') is working fine,DenisChenu wrote:
$this->get('scriptActivate','Survey',$this->getEvent()->get('surveyId'),$this->settings);
? This is really strange ????orvil wrote: Hi Denis,
tried this
$this->getEvent()->get('surveyId') is working fine,DenisChenu wrote:
$this->get('scriptActivate','Survey',$this->getEvent()->get('surveyId'),$this->settings);
but as a result I always get the LS global settings, not these from the survey (simpe plugins) itself.