Adding Custom Fields to Survey Admin

Mehr
5 Monate 3 Wochen her #189675 von marcgold
Hi

Wondering if anyone can provide some guidance if this is going to be possible and if so how would I adjust the plugin that is listed below to achieve this.

What I am trying to achieve is the ability to add 3 custom fields to a survey admin the fields are, Client Name, Project Manager and Telephone Number.

Once they are added I need to be able to use this data in two places. 1. Columns on the Survey List Page - After Survey Name and 2. Above the Welcome Text on the Survey Display Page: (they are not publically available just internal).

I would also like the Custom fields to be editable / viewable on either the General Settings or better Still the Text Elements menu item on the left.

With the plugin (Which is based on the exampleSettings plugin by Denis Chenu - ameded to work with LS 3.17) I am able to get the fields to display and are editable on the Simple Plugins tabs - but cannot figure out what needs to change to get it to work the way I want to.

Any help greatly appreciated, Im not a coder but really enjoying learning the plugin system (albeit slowly) so be gentle please.

This is the Plugin Code I have edited to get it to where it is:
class AddAdminFields extends PluginBase {
 
    protected $storage = 'DbStorage';
    static protected $name = 'Add Fields to Admin';
    static protected $description = 'Add Fields to Admin Screens on surveys';
 
    protected $settings = array(
        'ClientName' => array(
            'type' => 'text',
            'content' => 'Add the Client Name',
 
        ),
        'ProjectManager' => array(
            'type' => 'text',
            'content' => 'Add the Project Manager Name',
 
        ),
        'Tel' => array(
            'type' => 'text',
            'content' => 'Add the Managers Tel:',
 
        ),
    );
 
    public function init()        
    	{
    	$this->subscribe('beforeSurveySettings');
        $this->subscribe('newSurveySettings');
    }
 
    /**
     * This event is fired by the administration panel to gather extra settings
     * available for a survey.
     * The plugin should return setting meta data.
     * @param PluginEvent $event
     */
    public function beforeSurveySettings()
    {
        $event = $this->event;
        $event->set("surveysettings.{$this->id}", array(
            'name' => get_class($this),
            'settings' => array(
                    'ClientName'=>array(
                    'type'=>'text',
                    'label'=>'Client Name',
                    'help'=>'Enter the Client Name.',
                    'current' => $this->get('ClientName', 'Survey', $event->get('survey'),$this->get('ClientName',null,null,$this->settings['ClientName']['default'])),
                ),
                'ProjectManager'=>array(
                    'type'=>'text',
                    'label'=>'Project Manager',
                    'help'=>'Project Managers Name',
                    'current' => $this->get('ProjectManger', 'Survey', $event->get('survey'),$this->get('ProjectManager',null,null,$this->settings['ProjectManager']['default'])),
                ),
                'Tel'=>array(
                    'type'=>'text',
                    'label'=>'Telephone',
                    'help'=>'Enter Telephone No..',
                    'current' => $this->get('Tel', 'Survey', $event->get('survey'),$this->get('Tel',null,null,$this->settings['Tel']['default'])),
                )
 
                )
         ));
    }
 
    public function newSurveySettings()
    {
        $event = $this->event;
        foreach ($event->get('settings') as $name => $value)
        {
            /* In order use survey setting, if not set, use global, if not set use default */
            $default=$event->get($name,null,null,isset($this->settings[$name]['default'])?$this->settings[$name]['default']:NULL);
            $this->set($name, $value, 'Survey', $event->get('survey'),$default);
        }
    }
 
	}

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

LimeSurvey Partners
Mehr
5 Monate 3 Wochen her #189707 von DenisChenu
Hi,

1. Columns on the Survey List Page - After Survey Name

I'm not able to offer a good solution …

2. Above the Welcome Text on the Survey Display Page: (they are not publically available just internal).

'm not able to offer a good solution …

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
An error happen ? Before make a new topic : remind the Debug mode .

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten

Abonnieren Sie unseren Newsletter

Abonnieren Sie unseren Newsletter für alle Neuigkeiten rund um LimeSurvey
captcha