Files
moodle/mod/survey/mod_form.php
Andrew Hancox 6398ff5387 MDL-49101 core: Add a global admin setting config->requiremodintro
Removed requiremodintro setting from all core activity plugins and replace
with a single global setting.
Deprecated moodleform_mod::add_intro_editor and replaced with
moodleform_mod::standard_intro_elements
2015-04-07 10:11:53 +01:00

52 lines
1.7 KiB
PHP

<?php
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}
require_once ($CFG->dirroot.'/course/moodleform_mod.php');
class mod_survey_mod_form extends moodleform_mod {
function definition() {
global $CFG, $DB;
$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'));
if (!empty($CFG->formatstringstriptags)) {
$mform->setType('name', PARAM_TEXT);
} else {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
if (!$options = $DB->get_records_menu("survey", array("template"=>0), "name", "id, name")) {
print_error('cannotfindsurveytmpt', 'survey');
}
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');
$mform->addHelpButton('template', 'surveytype', 'survey');
$this->standard_intro_elements(get_string('customintro', 'survey'));
$this->standard_coursemodule_elements();
//-------------------------------------------------------------------------------
// buttons
$this->add_action_buttons();
}
}