MDL-8781 survey converted to new formslib - empty intro now means use default from...
[moodle.git] / mod / survey / mod_form.php
CommitLineData
4d7a4019 1<?php
2require_once ('moodleform_mod.php');
3
4class mod_survey_mod_form extends moodleform_mod {
5
6 function definition() {
7
8 global $CFG;
9 $mform =& $this->_form;
10
11 $strrequired = get_string('required');
12
13//-------------------------------------------------------------------------------
14 $mform->addElement('header', 'general', get_string('general', 'form'));
15
16 $mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
17 $mform->setType('name', PARAM_TEXT);
18 $mform->addRule('name', null, 'required', null, 'client');
19
20 if (!$options = get_records_menu("survey", "template", 0, "name", "id, name")) {
21 error('No survey templates found!');
22 }
23
24 foreach ($options as $id => $name) {
25 $options[$id] = get_string($name, "survey");
26 }
27 $options = array(''=>get_string('choose').'...') + $options;
28 $mform->addElement('select', 'template', get_string("surveytype", "survey"), $options);
29 $mform->addRule('template', $strrequired, 'required', null, 'client');
30 $mform->setHelpButton('template', array('surveys', get_string('helpsurveys', 'survey')));
31
32
33 $mform->addElement('textarea', 'intro', get_string('customintro', 'survey'), 'wrap="virtual" rows="20" cols="75"');
34 $mform->setType('intro', PARAM_RAW);
35
36 $this->standard_coursemodule_elements();
37
38//-------------------------------------------------------------------------------
39 // buttons
40 $this->add_action_buttons();
41 }
42
43
44}
45?>