2007-03-27 22:01:17 +00:00
|
|
|
<?php
|
2010-05-13 02:02:05 +00:00
|
|
|
if (!defined('MOODLE_INTERNAL')) {
|
|
|
|
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
|
|
|
}
|
|
|
|
|
2007-06-10 23:20:45 +00:00
|
|
|
require_once ($CFG->dirroot.'/course/moodleform_mod.php');
|
2007-03-27 22:01:17 +00:00
|
|
|
|
|
|
|
class mod_survey_mod_form extends moodleform_mod {
|
|
|
|
|
|
|
|
function definition() {
|
2008-05-15 21:40:00 +00:00
|
|
|
global $CFG, $DB;
|
2009-04-22 05:10:08 +00:00
|
|
|
|
2007-03-27 22:01:17 +00:00
|
|
|
$mform =& $this->_form;
|
|
|
|
|
|
|
|
$strrequired = get_string('required');
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
$mform->addElement('header', 'general', get_string('general', 'form'));
|
|
|
|
|
|
|
|
$mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
|
2008-07-26 15:15:25 +00:00
|
|
|
if (!empty($CFG->formatstringstriptags)) {
|
|
|
|
$mform->setType('name', PARAM_TEXT);
|
|
|
|
} else {
|
2010-09-02 18:29:39 +00:00
|
|
|
$mform->setType('name', PARAM_CLEANHTML);
|
2008-07-26 15:15:25 +00:00
|
|
|
}
|
2007-03-27 22:01:17 +00:00
|
|
|
$mform->addRule('name', null, 'required', null, 'client');
|
|
|
|
|
2008-05-15 21:40:00 +00:00
|
|
|
if (!$options = $DB->get_records_menu("survey", array("template"=>0), "name", "id, name")) {
|
2008-06-15 09:14:55 +00:00
|
|
|
print_error('cannotfindsurveytmpt', 'survey');
|
2007-03-27 22:01:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($options as $id => $name) {
|
|
|
|
$options[$id] = get_string($name, "survey");
|
|
|
|
}
|
|
|
|
$options = array(''=>get_string('choose').'...') + $options;
|
|
|
|
$mform->addElement('select', 'template', get_string("surveytype", "survey"), $options);
|
|
|
|
$mform->addRule('template', $strrequired, 'required', null, 'client');
|
2010-06-28 17:05:24 +00:00
|
|
|
$mform->addHelpButton('template', 'surveytype', 'survey');
|
2007-03-27 22:01:17 +00:00
|
|
|
|
2009-04-22 05:10:08 +00:00
|
|
|
$this->add_intro_editor(false, get_string('customintro', 'survey'));
|
2007-03-27 22:01:17 +00:00
|
|
|
|
2009-04-21 08:57:20 +00:00
|
|
|
$this->standard_coursemodule_elements();
|
2007-03-27 22:01:17 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
// buttons
|
|
|
|
$this->add_action_buttons();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2009-11-01 15:24:58 +00:00
|
|
|
|