|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 if (!defined('MOODLE_INTERNAL')) { 00003 die('Direct access to this script is forbidden.'); 00004 } 00005 00006 require_once ($CFG->dirroot.'/course/moodleform_mod.php'); 00007 00008 class mod_survey_mod_form extends moodleform_mod { 00009 00010 function definition() { 00011 global $CFG, $DB; 00012 00013 $mform =& $this->_form; 00014 00015 $strrequired = get_string('required'); 00016 00017 //------------------------------------------------------------------------------- 00018 $mform->addElement('header', 'general', get_string('general', 'form')); 00019 00020 $mform->addElement('text', 'name', get_string('name'), array('size'=>'64')); 00021 if (!empty($CFG->formatstringstriptags)) { 00022 $mform->setType('name', PARAM_TEXT); 00023 } else { 00024 $mform->setType('name', PARAM_CLEANHTML); 00025 } 00026 $mform->addRule('name', null, 'required', null, 'client'); 00027 00028 if (!$options = $DB->get_records_menu("survey", array("template"=>0), "name", "id, name")) { 00029 print_error('cannotfindsurveytmpt', 'survey'); 00030 } 00031 00032 foreach ($options as $id => $name) { 00033 $options[$id] = get_string($name, "survey"); 00034 } 00035 $options = array(''=>get_string('choose').'...') + $options; 00036 $mform->addElement('select', 'template', get_string("surveytype", "survey"), $options); 00037 $mform->addRule('template', $strrequired, 'required', null, 'client'); 00038 $mform->addHelpButton('template', 'surveytype', 'survey'); 00039 00040 $this->add_intro_editor(false, get_string('customintro', 'survey')); 00041 00042 $this->standard_coursemodule_elements(); 00043 00044 //------------------------------------------------------------------------------- 00045 // buttons 00046 $this->add_action_buttons(); 00047 } 00048 00049 00050 } 00051