Example #1
0
 /**
  * Field settings.
  */
 protected function field_definition()
 {
     global $CFG;
     $mform =& $this->_form;
     // Enable editor.
     $mform->addElement('selectyesno', 'param1', get_string('editorenable', 'dataform'));
     // Size units.
     $sizeunits = array('px' => 'px', 'em' => 'em', '%' => '%');
     // Field width.
     $colsunit = array('cols' => get_string('cols', 'editor'));
     $options = array('units' => $colsunit + $sizeunits);
     $this->add_field_size_elements('width', get_string('width', 'editor'), $options);
     // Field height.
     $rowsunit = array('rows' => get_string('rows', 'editor'));
     $options = array('units' => $rowsunit + $sizeunits);
     $this->add_field_size_elements('height', get_string('height', 'editor'), $options);
     // Trust text.
     $mform->addElement('selectyesno', 'param4', get_string('trusttext', 'dataformfield_textarea'));
     // Editor file settings.
     $mform->addElement('header', 'filesettingshdr', get_string('filesettings', 'dataform'));
     // Max bytes.
     $options = get_max_upload_sizes($CFG->maxbytes, $this->_field->df->course->maxbytes);
     $mform->addElement('select', 'param5', get_string('filemaxsize', 'dataform'), $options);
     $mform->disabledIf('param5', 'param1', 'eq', 0);
     // Max files.
     $range = range(1, 100);
     $options = array(-1 => get_string('unlimited')) + array_combine($range, $range);
     $mform->addElement('select', 'param6', get_string('filesmax', 'dataform'), $options);
     $mform->disabledIf('param6', 'param1', 'eq', 0);
 }
Example #2
0
 /**
  * Get the default setting for file submission plugin
  *
  * @param MoodleQuickForm $mform The form to add elements to
  * @return void
  */
 public function get_settings(MoodleQuickForm $mform)
 {
     global $CFG, $COURSE;
     $defaultmaxfilesubmissions = $this->get_config('maxfilesubmissions');
     $defaultmaxsubmissionsizebytes = $this->get_config('maxsubmissionsizebytes');
     $settings = array();
     $options = array();
     for ($i = 1; $i <= ASSIGNSUBMISSION_FILE_MAXFILES; $i++) {
         $options[$i] = $i;
     }
     $mform->addElement('select', 'assignsubmission_file_maxfiles', get_string('maxfilessubmission', 'assignsubmission_file'), $options);
     $mform->addHelpButton('assignsubmission_file_maxfiles', 'maxfilessubmission', 'assignsubmission_file');
     $mform->setDefault('assignsubmission_file_maxfiles', $defaultmaxfilesubmissions);
     $mform->disabledIf('assignsubmission_file_maxfiles', 'assignsubmission_file_enabled', 'eq', 0);
     $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes, get_config('assignsubmission_file', 'maxbytes'));
     // Remove the option for 0 bytes.
     unset($choices[0]);
     if ($COURSE->maxbytes == 0) {
         $choices = array(0 => get_string('siteuploadlimit', 'assignsubmission_file')) + $choices;
     } else {
         $choices = array(0 => get_string('courseuploadlimit') . ' (' . display_size($COURSE->maxbytes) . ')') + $choices;
     }
     $settings[] = array('type' => 'select', 'name' => 'maxsubmissionsizebytes', 'description' => get_string('maximumsubmissionsize', 'assignsubmission_file'), 'options' => $choices, 'default' => $defaultmaxsubmissionsizebytes);
     $mform->addElement('select', 'assignsubmission_file_maxsizebytes', get_string('maximumsubmissionsize', 'assignsubmission_file'), $choices);
     $mform->addHelpButton('assignsubmission_file_maxsizebytes', 'maximumsubmissionsize', 'assignsubmission_file');
     $mform->setDefault('assignsubmission_file_maxsizebytes', $defaultmaxsubmissionsizebytes);
     $mform->disabledIf('assignsubmission_file_maxsizebytes', 'assignsubmission_file_enabled', 'eq', 0);
 }
 /**
  * Add question-type specific form fields.
  *
  * @param MoodleQuickForm $mform the form being built.
  */
 function definition_inner(&$mform)
 {
     global $COURSE, $CFG;
     // don't need these default elements :
     $mform->removeElement('defaultgrade');
     $mform->removeElement('penalty');
     $mform->addElement('html', '<a target="_new" href="' . $CFG->wwwroot . '/files/index.php?id=' . $COURSE->id . '">' . get_string("openinnewwindow", "qtype_imagedit") . '</a>');
     // this element will hold the URL of the HTML's IMG SRC value
     // of the altered image file that was uploaded by the user
     // to the current course's "users" folder
     //$mform->addElement('hidden', 'imgurl', '');
     // add feedback
     $mform->addElement('htmleditor', 'feedback', get_string("feedback", "quiz"));
     $mform->setType('feedback', PARAM_RAW);
     // add default elements
     $mform->addElement('hidden', 'defaultgrade', 0);
     $mform->addElement('hidden', 'fraction', 0);
     // add max upload limit menu
     $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes);
     $choices[0] = get_string('courseuploadlimit') . ' (' . display_size($COURSE->maxbytes) . ')';
     $mform->addElement('select', 'maxbytes', get_string('maximumupload'), $choices);
     $mform->setDefault('maxbytes', $COURSE->maxbytes);
     // add essay area checkbox
     $mform->addElement('advcheckbox', 'essay', get_string('addessay', 'qtype_imagedit'), null, null, array(0, 1));
 }
 function definition()
 {
     global $CFG, $COURSE, $DB;
     $mform = $this->_form;
     $pluginconfig = get_config('dialogue');
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('text', 'name', get_string('dialoguename', 'dialogue'), array('size' => '64'));
     $mform->setType('name', PARAM_TEXT);
     $mform->addRule('name', null, 'required', null, 'client');
     moodleform_mod::standard_intro_elements();
     $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes, $pluginconfig->maxbytes);
     $mform->addElement('select', 'maxbytes', get_string('maxattachmentsize', 'dialogue'), $choices);
     $mform->addHelpButton('maxbytes', 'maxattachmentsize', 'dialogue');
     $mform->setDefault('maxbytes', $pluginconfig->maxbytes);
     $choices = range(0, $pluginconfig->maxattachments);
     $choices[0] = get_string('uploadnotallowed');
     $mform->addElement('select', 'maxattachments', get_string('maxattachments', 'dialogue'), $choices);
     $mform->addHelpButton('maxattachments', 'maxattachments', 'dialogue');
     $mform->setDefault('maxattachments', $pluginconfig->maxattachments);
     $mform->addElement('checkbox', 'usecoursegroups', get_string('usecoursegroups', 'dialogue'));
     $mform->addHelpButton('usecoursegroups', 'usecoursegroups', 'dialogue');
     $mform->setDefault('usecoursegroups', 0);
     $this->standard_grading_coursemodule_elements();
     $this->standard_coursemodule_elements();
     $this->add_action_buttons();
 }
Example #5
0
 /**
  * Defines the teamwork instance configuration form
  *
  * @return void
  */
 public function definition()
 {
     global $CFG;
     $teamworkconfig = get_config('teamwork');
     $mform = $this->_form;
     // General --------------------------------------------------------------------
     $mform->addElement('header', 'general', get_string('general', 'form'));
     // Teamwork name
     $label = get_string('teamworkname', 'teamwork');
     $mform->addElement('text', 'name', $label, 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');
     $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
     // Introduction
     $this->add_intro_editor(false, get_string('introduction', 'teamwork'));
     // Grading settings -----------------------------------------------------------
     $mform->addElement('header', 'gradingsettings', get_string('gradingsettings', 'teamwork'));
     $label = get_string('strategy', 'teamwork');
     $mform->addElement('select', 'strategy', $label, teamwork::available_strategies_list());
     $mform->setDefault('strategy', $teamworkconfig->strategy);
     $mform->addHelpButton('strategy', 'strategy', 'teamwork');
     $options = array();
     for ($i = 5; $i >= 0; $i--) {
         $options[$i] = $i;
     }
     $label = get_string('gradedecimals', 'teamwork');
     $mform->addElement('select', 'gradedecimals', $label, $options);
     $mform->setDefault('gradedecimals', $teamworkconfig->gradedecimals);
     // Submission settings --------------------------------------------------------
     $mform->addElement('header', 'submissionsettings', get_string('submissionsettings', 'teamwork'));
     $options = get_max_upload_sizes($CFG->maxbytes, $this->course->maxbytes, 0, $teamworkconfig->maxbytes);
     $mform->addElement('select', 'maxbytes', get_string('maxbytes', 'teamwork'), $options);
     $mform->setDefault('maxbytes', $teamworkconfig->maxbytes);
     // Participation settings --------------------------------------------------------
     $mform->addElement('header', 'participationsettings', get_string('participationsettings', 'teamwork'));
     $options = array();
     for ($i = 1; $i <= 10; $i++) {
         $options[$i] = $i;
     }
     $mform->addElement('select', 'participationnumlimit', get_string('participationnumlimit', 'teamwork'), $options);
     $mform->addHelpButton('participationnumlimit', 'participationnumlimit', 'teamwork');
     // Date settings---------------------------------------------------------------
     $mform->addElement('header', 'datecontrol', get_string('datesettings', 'teamwork'));
     $label = get_string('applystart', 'teamwork');
     $mform->addElement('date_time_selector', 'applystart', $label, array('optional' => false));
     $label = get_string('applyend', 'teamwork');
     $mform->addElement('date_time_selector', 'applyend', $label, array('optional' => false));
     // Common module settings, Restrict availability, Activity completion etc. ----
     $this->_features = array('groups' => false, 'groupings' => false, 'outcomes' => true, 'gradecat' => false, 'idnumber' => true);
     $this->standard_coursemodule_elements();
     // Standard buttons, common to all modules ------------------------------------
     $this->add_action_buttons();
 }
Example #6
0
 /**
  *
  */
 protected function definition_file_settings()
 {
     global $CFG;
     $mform =& $this->_form;
     // File settings.
     $mform->addElement('header', 'filesettingshdr', get_string('filesettings', 'dataform'));
     // Max bytes (param1).
     $options = get_max_upload_sizes($CFG->maxbytes, $this->_field->df->course->maxbytes);
     $mform->addElement('select', 'param1', get_string('filemaxsize', 'dataform'), $options);
     // Max files (param2).
     $range = range(1, 100);
     $options = array_combine($range, $range);
     $options[-1] = get_string('unlimited');
     $mform->addElement('select', 'param2', get_string('filesmax', 'dataform'), $options);
     $mform->setDefault('param2', -1);
     // Accetped types.
     $this->definition_filetypes();
 }
 /**
  * Add question-type specific form fields.
  *
  * @param MoodleQuickForm $mform the form being built.
  */
 function definition_inner(&$mform)
 {
     global $COURSE, $CFG;
     // don't need these default elements :
     $mform->removeElement('defaultgrade');
     $mform->removeElement('penalty');
     // add feedback
     $mform->addElement('htmleditor', 'feedback', get_string("feedback", "quiz"));
     $mform->setType('feedback', PARAM_RAW);
     // add default elements
     $mform->addElement('hidden', 'defaultgrade', 0);
     $mform->addElement('hidden', 'fraction', 0);
     // add max upload limit menu
     $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes);
     $choices[0] = get_string('courseuploadlimit') . ' (' . display_size($COURSE->maxbytes) . ')';
     $mform->addElement('select', 'maxbytes', get_string('maximumupload'), $choices);
     $mform->setDefault('maxbytes', $COURSE->maxbytes);
     // add essay area checkbox
     $mform->addElement('advcheckbox', 'essay', get_string('addessay', 'qtype_fileresponse'), null, null, array(0, 1));
 }
Example #8
0
 /**
  * Get the default setting for OneNote submission plugin
  *
  * @param MoodleQuickForm $mform The form to add elements to
  * @return void
  */
 public function get_settings(MoodleQuickForm $mform)
 {
     global $CFG, $COURSE;
     $defaultmaxfilesubmissions = $this->get_config('maxfilesubmissions');
     $defaultmaxsubmissionsizebytes = $this->get_config('maxsubmissionsizebytes');
     $settings = array();
     $options = array();
     for ($i = 1; $i <= \local_onenote\api\base::ASSIGNSUBMISSION_ONENOTE_MAXFILES; $i++) {
         $options[$i] = $i;
     }
     $name = get_string('maxfilessubmission', 'assignsubmission_onenote');
     $mform->addElement('select', 'assignsubmission_onenote_maxfiles', $name, $options);
     $mform->addHelpButton('assignsubmission_onenote_maxfiles', 'maxfilessubmission', 'assignsubmission_onenote');
     $mform->setDefault('assignsubmission_onenote_maxfiles', $defaultmaxfilesubmissions);
     $mform->disabledIf('assignsubmission_onenote_maxfiles', 'assignsubmission_onenote_enabled', 'notchecked');
     $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes, get_config('assignsubmission_onenote', 'maxbytes'));
     $settings[] = array('type' => 'select', 'name' => 'maxsubmissionsizebytes', 'description' => get_string('maximumsubmissionsize', 'assignsubmission_onenote'), 'options' => $choices, 'default' => $defaultmaxsubmissionsizebytes);
     $name = get_string('maximumsubmissionsize', 'assignsubmission_onenote');
     $mform->addElement('select', 'assignsubmission_onenote_maxsizebytes', $name, $choices);
     $mform->addHelpButton('assignsubmission_onenote_maxsizebytes', 'maximumsubmissionsize', 'assignsubmission_onenote');
     $mform->setDefault('assignsubmission_onenote_maxsizebytes', $defaultmaxsubmissionsizebytes);
     $mform->disabledIf('assignsubmission_onenote_maxsizebytes', 'assignsubmission_onenote_enabled', 'notchecked');
 }
Example #9
0
 for ($i = 1; $i <= 52; $i++) {
     $sectionmenu[$i] = "{$i}";
 }
 $temp->add(new admin_setting_configselect('moodlecourse/numsections', get_string('numberweeks'), get_string('coursehelpnumberweeks'), 10, $sectionmenu));
 $choices = array();
 $choices['0'] = get_string('hiddensectionscollapsed');
 $choices['1'] = get_string('hiddensectionsinvisible');
 $temp->add(new admin_setting_configselect('moodlecourse/hiddensections', get_string('hiddensections'), get_string('coursehelphiddensections'), 0, $choices));
 $options = range(0, 10);
 $temp->add(new admin_setting_configselect('moodlecourse/newsitems', get_string('newsitemsnumber'), get_string('coursehelpnewsitemsnumber'), 5, $options));
 $temp->add(new admin_setting_configselect('moodlecourse/showgrades', get_string('showgrades'), get_string('coursehelpshowgrades'), 1, array(0 => get_string('no'), 1 => get_string('yes'))));
 $temp->add(new admin_setting_configselect('moodlecourse/showreports', get_string('showreports'), '', 0, array(0 => get_string('no'), 1 => get_string('yes'))));
 if (isset($CFG->maxbytes)) {
     $choices = get_max_upload_sizes($CFG->maxbytes);
 } else {
     $choices = get_max_upload_sizes();
 }
 $temp->add(new admin_setting_configselect('moodlecourse/maxbytes', get_string('maximumupload'), get_string('coursehelpmaximumupload'), key($choices), $choices));
 $temp->add(new admin_setting_configselect('moodlecourse/metacourse', get_string('metacourse'), get_string('coursehelpmetacourse'), 0, array(0 => get_string('no'), 1 => get_string('yes'))));
 ///enrolement course settings
 $temp->add(new admin_setting_heading('enrolhdr', get_string('enrolments'), ''));
 require_once $CFG->dirroot . '/enrol/enrol.class.php';
 $choices = array();
 $modules = explode(',', $CFG->enrol_plugins_enabled);
 foreach ($modules as $module) {
     $name = get_string('enrolname', "enrol_{$module}");
     $plugin = enrolment_factory::factory($module);
     if (method_exists($plugin, 'print_entry')) {
         $choices[$name] = $module;
     }
 }
 * @copyright 2011 The Open University
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once $CFG->dirroot . '/mod/forumng/mod_forumng.php';
$module = new stdClass();
require $CFG->dirroot . '/mod/forumng/version.php';
$settings->add(new admin_setting_heading('forumng_version', '', get_string('displayversion', 'forumng', $module->displayversion)));
$settings->add(new admin_setting_configcheckbox('forumng_replytouser', get_string('replytouser', 'forumng'), get_string('configreplytouser', 'forumng'), 1));
$settings->add(new admin_setting_configtext('forumng_usebcc', get_string('usebcc', 'forumng'), get_string('configusebcc', 'forumng'), 0, PARAM_INT));
$settings->add(new admin_setting_configtext('forumng_donotmailafter', get_string('donotmailafter', 'forumng'), get_string('configdonotmailafter', 'forumng'), 48, PARAM_INT));
// Number of discussions on a page
$settings->add(new admin_setting_configtext('forumng_discussionsperpage', get_string('discussionsperpage', 'forumng'), get_string('configdiscussionsperpage', 'forumng'), 20, PARAM_INT));
if (isset($CFG->maxbytes)) {
    $sizes = get_max_upload_sizes($CFG->maxbytes);
} else {
    $sizes = get_max_upload_sizes(0);
}
unset($sizes[0]);
$sizes[-1] = get_string('forbidattachments', 'forumng');
$settings->add(new admin_setting_configselect('forumng_attachmentmaxbytes', get_string('attachmentmaxbytes', 'forumng'), get_string('configattachmentmaxbytes', 'forumng'), 512000, $sizes));
// Option about read tracking
$settings->add(new admin_setting_configcheckbox('forumng_trackreadposts', get_string('trackreadposts', 'forumng'), get_string('configtrackreadposts', 'forumng'), 1));
// Number of days that a post is considered old and we don't store unread data
$settings->add(new admin_setting_configtext('forumng_readafterdays', get_string('readafterdays', 'forumng'), get_string('configreadafterdays', 'forumng'), 60, PARAM_INT));
// RSS feeds
if (empty($CFG->enablerssfeeds)) {
    $options = array(0 => get_string('rssglobaldisabled', 'admin'));
    $str = get_string('configenablerssfeeds', 'forumng') . '<br />' . get_string('configenablerssfeedsdisabled2', 'admin');
} else {
    $options = array(0 => get_string('no'), 1 => get_string('yes'));
    $str = get_string('configenablerssfeeds', 'forumng');
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * Configure site-wide settings specific to the Dialogue modue
 *
 * Note: the only setting currently relates to unread-post tracking - this will only be
 * supported in your courses if you have applied the patch in CONTRIB-1134 which modifies
 * course/lib.php to check and display unread post counts in the course/topic area.
 * If you havent applied that patch this setting will still be stored in Moodle but it
 * will have no effect on the display of your courses, ie users will not see an unread
 * posts count
 *
 * @package mod_dialogue
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 */
defined('MOODLE_INTERNAL') || die;
if ($hassiteconfig) {
    require_once $CFG->dirroot . '/mod/dialogue/lib.php';
    // whether to provide unread post count
    $settings->add(new admin_setting_configcheckbox('dialogue/trackunread', new lang_string('configtrackunread', 'dialogue'), '', 1));
    // Default total maxbytes of attached files
    if (isset($CFG->maxbytes)) {
        $settings->add(new admin_setting_configselect('dialogue/maxbytes', new lang_string('maxattachmentsize', 'dialogue'), new lang_string('configmaxbytes', 'dialogue'), 512000, get_max_upload_sizes($CFG->maxbytes)));
    }
    $choices = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20);
    // Default number of attachments allowed per post in all dialogues
    $settings->add(new admin_setting_configselect('dialogue/maxattachments', new lang_string('maxattachments', 'dialogue'), new lang_string('configmaxattachments', 'dialogue'), 5, $choices));
    $settings->add(new admin_setting_configcheckbox('dialogue/viewconversationsbyrole', new lang_string('viewconversationsbyrole', 'dialogue'), new lang_string('configviewconversationsbyrole', 'dialogue'), 0));
}
Example #12
0
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * This file defines the admin settings for this plugin
 *
 * @package   assignsubmission_file
 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
// Note: This is on by default.
$settings->add(new admin_setting_configcheckbox('assignsubmission_file/default', new lang_string('default', 'assignsubmission_file'), new lang_string('default_help', 'assignsubmission_file'), 1));
if (isset($CFG->maxbytes)) {
    $name = new lang_string('maximumsubmissionsize', 'assignsubmission_file');
    $description = new lang_string('configmaxbytes', 'assignsubmission_file');
    $maxbytes = get_config('assignsubmission_file', 'maxbytes');
    $element = new admin_setting_configselect('assignsubmission_file/maxbytes', $name, $description, 1048576, get_max_upload_sizes($CFG->maxbytes, 0, 0, $maxbytes));
    $settings->add($element);
}
Example #13
0
 function definition()
 {
     global $CFG, $FORUM_TYPES, $COURSE;
     $mform =& $this->_form;
     //-------------------------------------------------------------------------------
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('text', 'name', get_string('forumname', 'forum'), array('size' => '64'));
     $mform->setType('name', PARAM_TEXT);
     $mform->addRule('name', null, 'required', null, 'client');
     $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
     asort($FORUM_TYPES);
     $mform->addElement('select', 'type', get_string('forumtype', 'forum'), $FORUM_TYPES);
     $mform->setHelpButton('type', array('forumtype', get_string('forumtype', 'forum'), 'forum'));
     $mform->setDefault('type', 'general');
     $mform->addElement('htmleditor', 'intro', get_string('forumintro', 'forum'));
     $mform->setType('intro', PARAM_RAW);
     $mform->addRule('intro', get_string('required'), 'required', null, 'client');
     $mform->setHelpButton('intro', array('writing', 'questions', 'richtext'), false, 'editorhelpbutton');
     $options = array();
     $options[0] = get_string('no');
     $options[1] = get_string('yesforever', 'forum');
     $options[FORUM_INITIALSUBSCRIBE] = get_string('yesinitially', 'forum');
     $options[FORUM_DISALLOWSUBSCRIBE] = get_string('disallowsubscribe', 'forum');
     $mform->addElement('select', 'forcesubscribe', get_string('forcesubscribeq', 'forum'), $options);
     $mform->setHelpButton('forcesubscribe', array('subscription2', get_string('forcesubscribeq', 'forum'), 'forum'));
     $options = array();
     $options[FORUM_TRACKING_OPTIONAL] = get_string('trackingoptional', 'forum');
     $options[FORUM_TRACKING_OFF] = get_string('trackingoff', 'forum');
     $options[FORUM_TRACKING_ON] = get_string('trackingon', 'forum');
     $mform->addElement('select', 'trackingtype', get_string('trackingtype', 'forum'), $options);
     $mform->setHelpButton('trackingtype', array('trackingtype', get_string('trackingtype', 'forum'), 'forum'));
     $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes);
     $choices[1] = get_string('uploadnotallowed');
     $choices[0] = get_string('courseuploadlimit') . ' (' . display_size($COURSE->maxbytes) . ')';
     $mform->addElement('select', 'maxbytes', get_string('maxattachmentsize', 'forum'), $choices);
     $mform->setHelpButton('maxbytes', array('maxattachmentsize', get_string('maxattachmentsize', 'forum'), 'forum'));
     $mform->setDefault('maxbytes', $CFG->forum_maxbytes);
     if ($CFG->enablerssfeeds && isset($CFG->forum_enablerssfeeds) && $CFG->forum_enablerssfeeds) {
         //-------------------------------------------------------------------------------
         $mform->addElement('header', '', get_string('rss'));
         $choices = array();
         $choices[0] = get_string('none');
         $choices[1] = get_string('discussions', 'forum');
         $choices[2] = get_string('posts', 'forum');
         $mform->addElement('select', 'rsstype', get_string('rsstype'), $choices);
         $mform->setHelpButton('rsstype', array('rsstype', get_string('rsstype'), 'forum'));
         $choices = array();
         $choices[0] = '0';
         $choices[1] = '1';
         $choices[2] = '2';
         $choices[3] = '3';
         $choices[4] = '4';
         $choices[5] = '5';
         $choices[10] = '10';
         $choices[15] = '15';
         $choices[20] = '20';
         $choices[25] = '25';
         $choices[30] = '30';
         $choices[40] = '40';
         $choices[50] = '50';
         $mform->addElement('select', 'rssarticles', get_string('rssarticles'), $choices);
         $mform->setHelpButton('rssarticles', array('rssarticles', get_string('rssarticles'), 'forum'));
     }
     //-------------------------------------------------------------------------------
     $mform->addElement('header', '', get_string('grade'));
     $mform->addElement('checkbox', 'assessed', get_string('allowratings', 'forum'), get_string('ratingsuse', 'forum'));
     $mform->addElement('modgrade', 'scale', get_string('grade'), false);
     $mform->disabledIf('scale', 'assessed');
     $mform->addElement('checkbox', 'ratingtime', get_string('ratingtime', 'forum'));
     $mform->disabledIf('ratingtime', 'assessed');
     $mform->addElement('date_time_selector', 'assesstimestart', get_string('from'));
     $mform->disabledIf('assesstimestart', 'assessed');
     $mform->disabledIf('assesstimestart', 'ratingtime');
     $mform->addElement('date_time_selector', 'assesstimefinish', get_string('to'));
     $mform->disabledIf('assesstimefinish', 'assessed');
     $mform->disabledIf('assesstimefinish', 'ratingtime');
     //-------------------------------------------------------------------------------
     $mform->addElement('header', '', get_string('blockafter', 'forum'));
     $options = array();
     $options[0] = get_string('blockperioddisabled', 'forum');
     $options[60 * 60 * 24] = '1 ' . get_string('day');
     $options[60 * 60 * 24 * 2] = '2 ' . get_string('days');
     $options[60 * 60 * 24 * 3] = '3 ' . get_string('days');
     $options[60 * 60 * 24 * 4] = '4 ' . get_string('days');
     $options[60 * 60 * 24 * 5] = '5 ' . get_string('days');
     $options[60 * 60 * 24 * 6] = '6 ' . get_string('days');
     $options[60 * 60 * 24 * 7] = '1 ' . get_string('week');
     $mform->addElement('select', 'blockperiod', get_string("blockperiod", "forum"), $options);
     $mform->setHelpButton('blockperiod', array('manageposts', get_string('blockperiod', 'forum'), 'forum'));
     $mform->addElement('text', 'blockafter', get_string('blockafter', 'forum'));
     $mform->setType('blockafter', PARAM_INT);
     $mform->setDefault('blockafter', '0');
     $mform->addRule('blockafter', null, 'numeric', null, 'client');
     $mform->setHelpButton('blockafter', array('manageposts', get_string('blockafter', 'forum'), 'forum'));
     $mform->disabledIf('blockafter', 'blockperiod', 'eq', 0);
     $mform->addElement('text', 'warnafter', get_string('warnafter', 'forum'));
     $mform->setType('warnafter', PARAM_INT);
     $mform->setDefault('warnafter', '0');
     $mform->addRule('warnafter', null, 'numeric', null, 'client');
     $mform->setHelpButton('warnafter', array('manageposts', get_string('warnafter', 'forum'), 'forum'));
     $mform->disabledIf('warnafter', 'blockperiod', 'eq', 0);
     //-------------------------------------------------------------------------------
     $this->standard_coursemodule_elements();
     //-------------------------------------------------------------------------------
     // buttons
     $this->add_action_buttons();
 }
 $temp->add(new admin_setting_configiplist('allowedip', new lang_string('allowediplist', 'admin'), new lang_string('ipblockersyntax', 'admin'), ''));
 $temp->add(new admin_setting_configiplist('blockedip', new lang_string('blockediplist', 'admin'), new lang_string('ipblockersyntax', 'admin'), ''));
 $ADMIN->add('security', $temp);
 // "sitepolicies" settingpage
 $temp = new admin_settingpage('sitepolicies', new lang_string('sitepolicies', 'admin'));
 $temp->add(new admin_setting_configcheckbox('protectusernames', new lang_string('protectusernames', 'admin'), new lang_string('configprotectusernames', 'admin'), 1));
 $temp->add(new admin_setting_configcheckbox('forcelogin', new lang_string('forcelogin', 'admin'), new lang_string('configforcelogin', 'admin'), 0));
 $temp->add(new admin_setting_configcheckbox('forceloginforprofiles', new lang_string('forceloginforprofiles', 'admin'), new lang_string('configforceloginforprofiles', 'admin'), 1));
 $temp->add(new admin_setting_configcheckbox('forceloginforprofileimage', new lang_string('forceloginforprofileimage', 'admin'), new lang_string('forceloginforprofileimage_help', 'admin'), 0));
 $temp->add(new admin_setting_configcheckbox('opentogoogle', new lang_string('opentogoogle', 'admin'), new lang_string('configopentogoogle', 'admin'), 0));
 $temp->add(new admin_setting_pickroles('profileroles', new lang_string('profileroles', 'admin'), new lang_string('configprofileroles', 'admin'), array('student', 'teacher', 'editingteacher')));
 $maxbytes = 0;
 if (!empty($CFG->maxbytes)) {
     $maxbytes = $CFG->maxbytes;
 }
 $max_upload_choices = get_max_upload_sizes(0, 0, 0, $maxbytes);
 // maxbytes set to 0 will allow the maximum server limit for uploads
 $temp->add(new admin_setting_configselect('maxbytes', new lang_string('maxbytes', 'admin'), new lang_string('configmaxbytes', 'admin'), 0, $max_upload_choices));
 // 100MB
 $defaultuserquota = 104857600;
 $params = new stdClass();
 $params->bytes = $defaultuserquota;
 $params->displaysize = display_size($defaultuserquota);
 $temp->add(new admin_setting_configtext('userquota', new lang_string('userquota', 'admin'), new lang_string('configuserquota', 'admin', $params), $defaultuserquota));
 $temp->add(new admin_setting_configcheckbox('allowobjectembed', new lang_string('allowobjectembed', 'admin'), new lang_string('configallowobjectembed', 'admin'), 0));
 $temp->add(new admin_setting_configcheckbox('enabletrusttext', new lang_string('enabletrusttext', 'admin'), new lang_string('configenabletrusttext', 'admin'), 0));
 $temp->add(new admin_setting_configselect('maxeditingtime', new lang_string('maxeditingtime', 'admin'), new lang_string('configmaxeditingtime', 'admin'), 1800, array(60 => new lang_string('numminutes', '', 1), 300 => new lang_string('numminutes', '', 5), 900 => new lang_string('numminutes', '', 15), 1800 => new lang_string('numminutes', '', 30), 2700 => new lang_string('numminutes', '', 45), 3600 => new lang_string('numminutes', '', 60))));
 $temp->add(new admin_setting_configcheckbox('extendedusernamechars', new lang_string('extendedusernamechars', 'admin'), new lang_string('configextendedusernamechars', 'admin'), 0));
 $temp->add(new admin_setting_configtext('sitepolicy', new lang_string('sitepolicy', 'admin'), new lang_string('sitepolicy_help', 'admin'), '', PARAM_RAW));
 $temp->add(new admin_setting_configtext('sitepolicyguest', new lang_string('sitepolicyguest', 'admin'), new lang_string('sitepolicyguest_help', 'admin'), isset($CFG->sitepolicy) ? $CFG->sitepolicy : '', PARAM_RAW));
 $temp->add(new admin_setting_configcheckbox('extendedusernamechars', new lang_string('extendedusernamechars', 'admin'), new lang_string('configextendedusernamechars', 'admin'), 0));
Example #15
0
    $settings->add(new admin_setting_configselect('workshop/grade', get_string('submissiongrade', 'workshop'),
                        get_string('configgrade', 'workshop'), 80, $grades));

    $settings->add(new admin_setting_configselect('workshop/gradinggrade', get_string('gradinggrade', 'workshop'),
                        get_string('configgradinggrade', 'workshop'), 20, $grades));

    $options = array();
    for ($i = 5; $i >= 0; $i--) {
        $options[$i] = $i;
    }
    $settings->add(new admin_setting_configselect('workshop/gradedecimals', get_string('gradedecimals', 'workshop'),
                        get_string('configgradedecimals', 'workshop'), 0, $options));

    if (isset($CFG->maxbytes)) {
        $options = get_max_upload_sizes($CFG->maxbytes);
        $settings->add(new admin_setting_configselect('workshop/maxbytes', get_string('maxbytes', 'workshop'),
                            get_string('configmaxbytes', 'workshop'), 0, $options));
    }

    $settings->add(new admin_setting_configselect('workshop/strategy', get_string('strategy', 'workshop'),
                        get_string('configstrategy', 'workshop'), 'accumulative', workshop::available_strategies_list()));

    $options = workshop::available_example_modes_list();
    $settings->add(new admin_setting_configselect('workshop/examplesmode', get_string('examplesmode', 'workshop'),
                        get_string('configexamplesmode', 'workshop'), workshop::EXAMPLES_VOLUNTARY, $options));

    // include the settings of allocation subplugins
    $allocators = get_plugin_list('workshopallocation');
    foreach ($allocators as $allocator => $path) {
        if (file_exists($settingsfile = $path . '/settings.php')) {
 function setup_elements(&$mform)
 {
     global $CFG, $COURSE;
     $ynoptions = array(0 => get_string('no'), 1 => get_string('yes'));
     $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes);
     $choices[0] = get_string('courseuploadlimit') . ' (' . display_size($COURSE->maxbytes) . ')';
     $mform->addElement('select', 'maxbytes', get_string('maximumsize', 'assignment'), $choices);
     $mform->setDefault('maxbytes', $CFG->assignment_maxbytes);
     $mform->addElement('select', 'resubmit', get_string("allowdeleting", "assignment"), $ynoptions);
     $mform->setHelpButton('resubmit', array('allowdeleting', get_string('allowdeleting', 'assignment'), 'assignment'));
     $mform->setDefault('resubmit', 1);
     $options = array();
     for ($i = 1; $i <= 20; $i++) {
         $options[$i] = $i;
     }
     $mform->addElement('select', 'var1', get_string("allowmaxfiles", "assignment"), $options);
     $mform->setHelpButton('var1', array('allowmaxfiles', get_string('allowmaxfiles', 'assignment'), 'assignment'));
     $mform->setDefault('var1', 3);
     $mform->addElement('select', 'var2', get_string("allownotes", "assignment"), $ynoptions);
     $mform->setHelpButton('var2', array('allownotes', get_string('allownotes', 'assignment'), 'assignment'));
     $mform->setDefault('var2', 0);
     $mform->addElement('select', 'var3', get_string("hideintro", "assignment"), $ynoptions);
     $mform->setHelpButton('var3', array('hideintro', get_string('hideintro', 'assignment'), 'assignment'));
     $mform->setDefault('var3', 0);
     $mform->addElement('select', 'emailteachers', get_string("emailteachers", "assignment"), $ynoptions);
     $mform->setHelpButton('emailteachers', array('emailteachers', get_string('emailteachers', 'assignment'), 'assignment'));
     $mform->setDefault('emailteachers', 0);
     $mform->addElement('select', 'var4', get_string("trackdrafts", "assignment"), $ynoptions);
     $mform->setHelpButton('var4', array('trackdrafts', get_string('trackdrafts', 'assignment'), 'assignment'));
     $mform->setDefault('var4', 1);
 }
Example #17
0
 /**
  * Defines the workshop instance configuration form
  *
  * @return void
  */
 public function definition()
 {
     global $CFG;
     $workshopconfig = get_config('workshop');
     $mform = $this->_form;
     // General --------------------------------------------------------------------
     $mform->addElement('header', 'general', get_string('general', 'form'));
     // Workshop name
     $label = get_string('workshopname', 'workshop');
     $mform->addElement('text', 'name', $label, 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');
     $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
     // Introduction
     $this->standard_intro_elements(get_string('introduction', 'workshop'));
     // Grading settings -----------------------------------------------------------
     $mform->addElement('header', 'gradingsettings', get_string('gradingsettings', 'workshop'));
     $mform->setExpanded('gradingsettings');
     $label = get_string('strategy', 'workshop');
     $mform->addElement('select', 'strategy', $label, workshop::available_strategies_list());
     $mform->setDefault('strategy', $workshopconfig->strategy);
     $mform->addHelpButton('strategy', 'strategy', 'workshop');
     $grades = workshop::available_maxgrades_list();
     $gradecategories = grade_get_categories_menu($this->course->id);
     $label = get_string('submissiongrade', 'workshop');
     $mform->addGroup(array($mform->createElement('select', 'grade', '', $grades), $mform->createElement('select', 'gradecategory', '', $gradecategories)), 'submissiongradegroup', $label, ' ', false);
     $mform->setDefault('grade', $workshopconfig->grade);
     $mform->addHelpButton('submissiongradegroup', 'submissiongrade', 'workshop');
     $mform->addElement('text', 'submissiongradepass', get_string('gradetopasssubmission', 'workshop'));
     $mform->addHelpButton('submissiongradepass', 'gradepass', 'grades');
     $mform->setDefault('submissiongradepass', '');
     $mform->setType('submissiongradepass', PARAM_RAW);
     $label = get_string('gradinggrade', 'workshop');
     $mform->addGroup(array($mform->createElement('select', 'gradinggrade', '', $grades), $mform->createElement('select', 'gradinggradecategory', '', $gradecategories)), 'gradinggradegroup', $label, ' ', false);
     $mform->setDefault('gradinggrade', $workshopconfig->gradinggrade);
     $mform->addHelpButton('gradinggradegroup', 'gradinggrade', 'workshop');
     $mform->addElement('text', 'gradinggradepass', get_string('gradetopassgrading', 'workshop'));
     $mform->addHelpButton('gradinggradepass', 'gradepass', 'grades');
     $mform->setDefault('gradinggradepass', '');
     $mform->setType('gradinggradepass', PARAM_RAW);
     $options = array();
     for ($i = 5; $i >= 0; $i--) {
         $options[$i] = $i;
     }
     $label = get_string('gradedecimals', 'workshop');
     $mform->addElement('select', 'gradedecimals', $label, $options);
     $mform->setDefault('gradedecimals', $workshopconfig->gradedecimals);
     // Submission settings --------------------------------------------------------
     $mform->addElement('header', 'submissionsettings', get_string('submissionsettings', 'workshop'));
     $label = get_string('instructauthors', 'workshop');
     $mform->addElement('editor', 'instructauthorseditor', $label, null, workshop::instruction_editors_options($this->context));
     $options = array();
     for ($i = 7; $i >= 0; $i--) {
         $options[$i] = $i;
     }
     $label = get_string('nattachments', 'workshop');
     $mform->addElement('select', 'nattachments', $label, $options);
     $mform->setDefault('nattachments', 1);
     $label = get_string('allowedfiletypesforsubmission', 'workshop');
     $mform->addElement('text', 'submissionfiletypes', $label, array('maxlength' => 255, 'size' => 64));
     $mform->addHelpButton('submissionfiletypes', 'allowedfiletypesforsubmission', 'workshop');
     $mform->setType('submissionfiletypes', PARAM_TEXT);
     $mform->addRule('submissionfiletypes', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
     $mform->disabledIf('submissionfiletypes', 'nattachments', 'eq', 0);
     $options = get_max_upload_sizes($CFG->maxbytes, $this->course->maxbytes, 0, $workshopconfig->maxbytes);
     $mform->addElement('select', 'maxbytes', get_string('maxbytes', 'workshop'), $options);
     $mform->setDefault('maxbytes', $workshopconfig->maxbytes);
     $mform->disabledIf('maxbytes', 'nattachments', 'eq', 0);
     $label = get_string('latesubmissions', 'workshop');
     $text = get_string('latesubmissions_desc', 'workshop');
     $mform->addElement('checkbox', 'latesubmissions', $label, $text);
     $mform->addHelpButton('latesubmissions', 'latesubmissions', 'workshop');
     // Assessment settings --------------------------------------------------------
     $mform->addElement('header', 'assessmentsettings', get_string('assessmentsettings', 'workshop'));
     $label = get_string('instructreviewers', 'workshop');
     $mform->addElement('editor', 'instructreviewerseditor', $label, null, workshop::instruction_editors_options($this->context));
     $label = get_string('useselfassessment', 'workshop');
     $text = get_string('useselfassessment_desc', 'workshop');
     $mform->addElement('checkbox', 'useselfassessment', $label, $text);
     $mform->addHelpButton('useselfassessment', 'useselfassessment', 'workshop');
     // Feedback -------------------------------------------------------------------
     $mform->addElement('header', 'feedbacksettings', get_string('feedbacksettings', 'workshop'));
     $mform->addElement('select', 'overallfeedbackmode', get_string('overallfeedbackmode', 'mod_workshop'), array(0 => get_string('overallfeedbackmode_0', 'mod_workshop'), 1 => get_string('overallfeedbackmode_1', 'mod_workshop'), 2 => get_string('overallfeedbackmode_2', 'mod_workshop')));
     $mform->addHelpButton('overallfeedbackmode', 'overallfeedbackmode', 'mod_workshop');
     $mform->setDefault('overallfeedbackmode', 1);
     $options = array();
     for ($i = 7; $i >= 0; $i--) {
         $options[$i] = $i;
     }
     $mform->addElement('select', 'overallfeedbackfiles', get_string('overallfeedbackfiles', 'workshop'), $options);
     $mform->setDefault('overallfeedbackfiles', 0);
     $mform->disabledIf('overallfeedbackfiles', 'overallfeedbackmode', 'eq', 0);
     $label = get_string('allowedfiletypesforoverallfeedback', 'workshop');
     $mform->addElement('text', 'overallfeedbackfiletypes', $label, array('maxlength' => 255, 'size' => 64));
     $mform->addHelpButton('overallfeedbackfiletypes', 'allowedfiletypesforoverallfeedback', 'workshop');
     $mform->setType('overallfeedbackfiletypes', PARAM_TEXT);
     $mform->addRule('overallfeedbackfiletypes', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
     $mform->disabledIf('overallfeedbackfiletypes', 'overallfeedbackfiles', 'eq', 0);
     $options = get_max_upload_sizes($CFG->maxbytes, $this->course->maxbytes);
     $mform->addElement('select', 'overallfeedbackmaxbytes', get_string('overallfeedbackmaxbytes', 'workshop'), $options);
     $mform->setDefault('overallfeedbackmaxbytes', $workshopconfig->maxbytes);
     $mform->disabledIf('overallfeedbackmaxbytes', 'overallfeedbackmode', 'eq', 0);
     $mform->disabledIf('overallfeedbackmaxbytes', 'overallfeedbackfiles', 'eq', 0);
     $label = get_string('conclusion', 'workshop');
     $mform->addElement('editor', 'conclusioneditor', $label, null, workshop::instruction_editors_options($this->context));
     $mform->addHelpButton('conclusioneditor', 'conclusion', 'workshop');
     // Example submissions --------------------------------------------------------
     $mform->addElement('header', 'examplesubmissionssettings', get_string('examplesubmissions', 'workshop'));
     $label = get_string('useexamples', 'workshop');
     $text = get_string('useexamples_desc', 'workshop');
     $mform->addElement('checkbox', 'useexamples', $label, $text);
     $mform->addHelpButton('useexamples', 'useexamples', 'workshop');
     $label = get_string('examplesmode', 'workshop');
     $options = workshop::available_example_modes_list();
     $mform->addElement('select', 'examplesmode', $label, $options);
     $mform->setDefault('examplesmode', $workshopconfig->examplesmode);
     $mform->disabledIf('examplesmode', 'useexamples');
     // Availability ---------------------------------------------------------------
     $mform->addElement('header', 'accesscontrol', get_string('availability', 'core'));
     $label = get_string('submissionstart', 'workshop');
     $mform->addElement('date_time_selector', 'submissionstart', $label, array('optional' => true));
     $label = get_string('submissionend', 'workshop');
     $mform->addElement('date_time_selector', 'submissionend', $label, array('optional' => true));
     $label = get_string('submissionendswitch', 'mod_workshop');
     $mform->addElement('checkbox', 'phaseswitchassessment', $label);
     $mform->disabledIf('phaseswitchassessment', 'submissionend[enabled]');
     $mform->addHelpButton('phaseswitchassessment', 'submissionendswitch', 'mod_workshop');
     $label = get_string('assessmentstart', 'workshop');
     $mform->addElement('date_time_selector', 'assessmentstart', $label, array('optional' => true));
     $label = get_string('assessmentend', 'workshop');
     $mform->addElement('date_time_selector', 'assessmentend', $label, array('optional' => true));
     $coursecontext = context_course::instance($this->course->id);
     plagiarism_get_form_elements_module($mform, $coursecontext, 'mod_workshop');
     // Common module settings, Restrict availability, Activity completion etc. ----
     $features = array('groups' => true, 'groupings' => true, 'outcomes' => true, 'gradecat' => false, 'idnumber' => false);
     $this->standard_coursemodule_elements();
     // Standard buttons, common to all modules ------------------------------------
     $this->add_action_buttons();
 }
Example #18
0
<?php

//$Id$
require_once $CFG->dirroot . '/mod/assignment/lib.php';
$settings->add(new admin_setting_configselect('assignment_maxbytes', get_string('maximumsize', 'assignment'), get_string('configmaxbytes', 'assignment'), 1048576, get_max_upload_sizes($CFG->maxbytes)));
$options = array(ASSIGNMENT_COUNT_WORDS => trim(get_string('numwords', '')), ASSIGNMENT_COUNT_LETTERS => trim(get_string('numletters', '')));
$settings->add(new admin_setting_configselect('assignment_itemstocount', get_string('itemstocount', 'assignment'), get_string('configitemstocount', 'assignment'), ASSIGNMENT_COUNT_WORDS, $options));
$settings->add(new admin_setting_configcheckbox('assignment_showrecentsubmissions', get_string('showrecentsubmissions', 'assignment'), get_string('configshowrecentsubmissions', 'assignment'), 1));
Example #19
0
 function definition()
 {
     global $USER, $CFG, $DB, $PAGE;
     $mform = $this->_form;
     $PAGE->requires->yui_module('moodle-course-formatchooser', 'M.course.init_formatchooser', array(array('formid' => $mform->getAttribute('id'))));
     $course = $this->_customdata['course'];
     // this contains the data of this form
     $category = $this->_customdata['category'];
     $editoroptions = $this->_customdata['editoroptions'];
     $returnto = $this->_customdata['returnto'];
     $systemcontext = context_system::instance();
     $categorycontext = context_coursecat::instance($category->id);
     if (!empty($course->id)) {
         $coursecontext = context_course::instance($course->id);
         $context = $coursecontext;
     } else {
         $coursecontext = null;
         $context = $categorycontext;
     }
     $courseconfig = get_config('moodlecourse');
     $this->course = $course;
     $this->context = $context;
     /// form definition with new course defaults
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('hidden', 'returnto', null);
     $mform->setType('returnto', PARAM_ALPHANUM);
     $mform->setConstant('returnto', $returnto);
     $mform->addElement('text', 'fullname', get_string('fullnamecourse'), 'maxlength="254" size="50"');
     $mform->addHelpButton('fullname', 'fullnamecourse');
     $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client');
     $mform->setType('fullname', PARAM_TEXT);
     if (!empty($course->id) and !has_capability('moodle/course:changefullname', $coursecontext)) {
         $mform->hardFreeze('fullname');
         $mform->setConstant('fullname', $course->fullname);
     }
     $mform->addElement('text', 'shortname', get_string('shortnamecourse'), 'maxlength="100" size="20"');
     $mform->addHelpButton('shortname', 'shortnamecourse');
     $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
     $mform->setType('shortname', PARAM_TEXT);
     if (!empty($course->id) and !has_capability('moodle/course:changeshortname', $coursecontext)) {
         $mform->hardFreeze('shortname');
         $mform->setConstant('shortname', $course->shortname);
     }
     // Verify permissions to change course category or keep current.
     if (empty($course->id)) {
         if (has_capability('moodle/course:create', $categorycontext)) {
             $displaylist = coursecat::make_categories_list('moodle/course:create');
             $mform->addElement('select', 'category', get_string('coursecategory'), $displaylist);
             $mform->addHelpButton('category', 'coursecategory');
             $mform->setDefault('category', $category->id);
         } else {
             $mform->addElement('hidden', 'category', null);
             $mform->setType('category', PARAM_INT);
             $mform->setConstant('category', $category->id);
         }
     } else {
         if (has_capability('moodle/course:changecategory', $coursecontext)) {
             $displaylist = coursecat::make_categories_list('moodle/course:create');
             if (!isset($displaylist[$course->category])) {
                 //always keep current
                 $displaylist[$course->category] = coursecat::get($course->category)->get_formatted_name();
             }
             $mform->addElement('select', 'category', get_string('coursecategory'), $displaylist);
             $mform->addHelpButton('category', 'coursecategory');
         } else {
             //keep current
             $mform->addElement('hidden', 'category', null);
             $mform->setType('category', PARAM_INT);
             $mform->setConstant('category', $course->category);
         }
     }
     $choices = array();
     $choices['0'] = get_string('hide');
     $choices['1'] = get_string('show');
     $mform->addElement('select', 'visible', get_string('visible'), $choices);
     $mform->addHelpButton('visible', 'visible');
     $mform->setDefault('visible', $courseconfig->visible);
     if (!has_capability('moodle/course:visibility', $context)) {
         $mform->hardFreeze('visible');
         if (!empty($course->id)) {
             $mform->setConstant('visible', $course->visible);
         } else {
             $mform->setConstant('visible', $courseconfig->visible);
         }
     }
     $mform->addElement('date_selector', 'startdate', get_string('startdate'));
     $mform->addHelpButton('startdate', 'startdate');
     $mform->setDefault('startdate', time() + 3600 * 24);
     $mform->addElement('text', 'idnumber', get_string('idnumbercourse'), 'maxlength="100"  size="10"');
     $mform->addHelpButton('idnumber', 'idnumbercourse');
     $mform->setType('idnumber', PARAM_RAW);
     if (!empty($course->id) and !has_capability('moodle/course:changeidnumber', $coursecontext)) {
         $mform->hardFreeze('idnumber');
         $mform->setConstants('idnumber', $course->idnumber);
     }
     // Description.
     $mform->addElement('header', 'descriptionhdr', get_string('description'));
     $mform->setExpanded('descriptionhdr');
     $mform->addElement('editor', 'summary_editor', get_string('coursesummary'), null, $editoroptions);
     $mform->addHelpButton('summary_editor', 'coursesummary');
     $mform->setType('summary_editor', PARAM_RAW);
     $summaryfields = 'summary_editor';
     if ($overviewfilesoptions = course_overviewfiles_options($course)) {
         $mform->addElement('filemanager', 'overviewfiles_filemanager', get_string('courseoverviewfiles'), null, $overviewfilesoptions);
         $mform->addHelpButton('overviewfiles_filemanager', 'courseoverviewfiles');
         $summaryfields .= ',overviewfiles_filemanager';
     }
     if (!empty($course->id) and !has_capability('moodle/course:changesummary', $coursecontext)) {
         // Remove the description header it does not contain anything any more.
         $mform->removeElement('descriptionhdr');
         $mform->hardFreeze($summaryfields);
     }
     // Course format.
     $mform->addElement('header', 'courseformathdr', get_string('type_format', 'plugin'));
     $courseformats = get_sorted_course_formats(true);
     $formcourseformats = array();
     foreach ($courseformats as $courseformat) {
         $formcourseformats[$courseformat] = get_string('pluginname', "format_{$courseformat}");
     }
     if (isset($course->format)) {
         $course->format = course_get_format($course)->get_format();
         // replace with default if not found
         if (!in_array($course->format, $courseformats)) {
             // this format is disabled. Still display it in the dropdown
             $formcourseformats[$course->format] = get_string('withdisablednote', 'moodle', get_string('pluginname', 'format_' . $course->format));
         }
     }
     $mform->addElement('select', 'format', get_string('format'), $formcourseformats);
     $mform->addHelpButton('format', 'format');
     $mform->setDefault('format', $courseconfig->format);
     // Button to update format-specific options on format change (will be hidden by JavaScript).
     $mform->registerNoSubmitButton('updatecourseformat');
     $mform->addElement('submit', 'updatecourseformat', get_string('courseformatudpate'));
     // Just a placeholder for the course format options.
     $mform->addElement('hidden', 'addcourseformatoptionshere');
     $mform->setType('addcourseformatoptionshere', PARAM_BOOL);
     // Appearance.
     $mform->addElement('header', 'appearancehdr', get_string('appearance'));
     if (!empty($CFG->allowcoursethemes)) {
         $themeobjects = get_list_of_themes();
         $themes = array();
         $themes[''] = get_string('forceno');
         foreach ($themeobjects as $key => $theme) {
             if (empty($theme->hidefromselector)) {
                 $themes[$key] = get_string('pluginname', 'theme_' . $theme->name);
             }
         }
         $mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
     }
     $languages = array();
     $languages[''] = get_string('forceno');
     $languages += get_string_manager()->get_list_of_translations();
     $mform->addElement('select', 'lang', get_string('forcelanguage'), $languages);
     $mform->setDefault('lang', $courseconfig->lang);
     $options = range(0, 10);
     $mform->addElement('select', 'newsitems', get_string('newsitemsnumber'), $options);
     $mform->addHelpButton('newsitems', 'newsitemsnumber');
     $mform->setDefault('newsitems', $courseconfig->newsitems);
     $mform->addElement('selectyesno', 'showgrades', get_string('showgrades'));
     $mform->addHelpButton('showgrades', 'showgrades');
     $mform->setDefault('showgrades', $courseconfig->showgrades);
     $mform->addElement('selectyesno', 'showreports', get_string('showreports'));
     $mform->addHelpButton('showreports', 'showreports');
     $mform->setDefault('showreports', $courseconfig->showreports);
     // Files and uploads.
     $mform->addElement('header', 'filehdr', get_string('filesanduploads'));
     if (!empty($course->legacyfiles) or !empty($CFG->legacyfilesinnewcourses)) {
         if (empty($course->legacyfiles)) {
             //0 or missing means no legacy files ever used in this course - new course or nobody turned on legacy files yet
             $choices = array('0' => get_string('no'), '2' => get_string('yes'));
         } else {
             $choices = array('1' => get_string('no'), '2' => get_string('yes'));
         }
         $mform->addElement('select', 'legacyfiles', get_string('courselegacyfiles'), $choices);
         $mform->addHelpButton('legacyfiles', 'courselegacyfiles');
         if (!isset($courseconfig->legacyfiles)) {
             // in case this was not initialised properly due to switching of $CFG->legacyfilesinnewcourses
             $courseconfig->legacyfiles = 0;
         }
         $mform->setDefault('legacyfiles', $courseconfig->legacyfiles);
     }
     // Handle non-existing $course->maxbytes on course creation.
     $coursemaxbytes = !isset($course->maxbytes) ? null : $course->maxbytes;
     // Let's prepare the maxbytes popup.
     $choices = get_max_upload_sizes($CFG->maxbytes, 0, 0, $coursemaxbytes);
     $mform->addElement('select', 'maxbytes', get_string('maximumupload'), $choices);
     $mform->addHelpButton('maxbytes', 'maximumupload');
     $mform->setDefault('maxbytes', $courseconfig->maxbytes);
     // Completion tracking.
     if (completion_info::is_enabled_for_site()) {
         $mform->addElement('header', 'completionhdr', get_string('completion', 'completion'));
         $mform->addElement('selectyesno', 'enablecompletion', get_string('enablecompletion', 'completion'));
         $mform->setDefault('enablecompletion', $courseconfig->enablecompletion);
         $mform->addHelpButton('enablecompletion', 'enablecompletion', 'completion');
     } else {
         $mform->addElement('hidden', 'enablecompletion');
         $mform->setType('enablecompletion', PARAM_INT);
         $mform->setDefault('enablecompletion', 0);
     }
     //--------------------------------------------------------------------------------
     enrol_course_edit_form($mform, $course, $context);
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'groups', get_string('groups', 'group'));
     $choices = array();
     $choices[NOGROUPS] = get_string('groupsnone', 'group');
     $choices[SEPARATEGROUPS] = get_string('groupsseparate', 'group');
     $choices[VISIBLEGROUPS] = get_string('groupsvisible', 'group');
     $mform->addElement('select', 'groupmode', get_string('groupmode', 'group'), $choices);
     $mform->addHelpButton('groupmode', 'groupmode', 'group');
     $mform->setDefault('groupmode', $courseconfig->groupmode);
     $mform->addElement('selectyesno', 'groupmodeforce', get_string('groupmodeforce', 'group'));
     $mform->addHelpButton('groupmodeforce', 'groupmodeforce', 'group');
     $mform->setDefault('groupmodeforce', $courseconfig->groupmodeforce);
     //default groupings selector
     $options = array();
     $options[0] = get_string('none');
     $mform->addElement('select', 'defaultgroupingid', get_string('defaultgrouping', 'group'), $options);
     //--------------------------------------------------------------------------------
     /// customizable role names in this course
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'rolerenaming', get_string('rolerenaming'));
     $mform->addHelpButton('rolerenaming', 'rolerenaming');
     if ($roles = get_all_roles()) {
         $roles = role_fix_names($roles, null, ROLENAME_ORIGINAL);
         $assignableroles = get_roles_for_contextlevels(CONTEXT_COURSE);
         foreach ($roles as $role) {
             $mform->addElement('text', 'role_' . $role->id, get_string('yourwordforx', '', $role->localname));
             $mform->setType('role_' . $role->id, PARAM_TEXT);
         }
     }
     //--------------------------------------------------------------------------------
     $this->add_action_buttons();
     //--------------------------------------------------------------------------------
     $mform->addElement('hidden', 'id', null);
     $mform->setType('id', PARAM_INT);
     /// finally set the current form data
     //--------------------------------------------------------------------------------
     $this->set_data($course);
 }
Example #20
0
 public function definition()
 {
     global $COURSE, $CFG;
     $mform = $this->_form;
     $mform->addElement('header', 'general', get_string('general', 'form'));
     // Adding the standard "name" field.
     $mform->addElement('text', 'name', get_string('blogname', 'oublog'), array('size' => '64'));
     $mform->setType('name', PARAM_TEXT);
     $mform->addRule('name', null, 'required', null, 'client');
     if (!defined('OUBLOG_EDIT_INSTANCE')) {
         $this->add_intro_editor(false, get_string('oublogintro', 'oublog'));
         // Adding the "allowcomments" field.
         $options = array(OUBLOG_COMMENTS_ALLOW => get_string('logincomments', 'oublog'), OUBLOG_COMMENTS_ALLOWPUBLIC => get_string('publiccomments', 'oublog'), OUBLOG_COMMENTS_PREVENT => get_string('nocomments', 'oublog'));
         $mform->addElement('select', 'allowcomments', get_string('allowcommentsmax', 'oublog'), $options);
         $mform->setType('allowcomments', PARAM_INT);
         $mform->addHelpButton('allowcomments', 'allowcomments', 'oublog');
         // Adding the "individual" field.
         $options = array(OUBLOG_NO_INDIVIDUAL_BLOGS => get_string('no_blogtogetheroringroups', 'oublog'), OUBLOG_SEPARATE_INDIVIDUAL_BLOGS => get_string('separateindividualblogs', 'oublog'), OUBLOG_VISIBLE_INDIVIDUAL_BLOGS => get_string('visibleindividualblogs', 'oublog'));
         $mform->addElement('select', 'individual', get_string('individualblogs', 'oublog'), $options);
         $mform->setType('individual', PARAM_INT);
         $mform->setDefault('individual', OUBLOG_NO_INDIVIDUAL_BLOGS);
         $mform->addHelpButton('individual', 'individualblogs', 'oublog');
         // Disable "maxvisibility" field when "individual" field is set (not default).
         $mform->disabledIf('maxvisibility', 'individual', OUBLOG_NO_INDIVIDUAL_BLOGS, OUBLOG_NO_INDIVIDUAL_BLOGS);
         // Adding the "maxvisibility" field.
         $options = array(OUBLOG_VISIBILITY_COURSEUSER => get_string('visiblecourseusers', 'oublog'), OUBLOG_VISIBILITY_LOGGEDINUSER => get_string('visibleloggedinusers', 'oublog'), OUBLOG_VISIBILITY_PUBLIC => get_string('visiblepublic', 'oublog'));
         $mform->addElement('select', 'maxvisibility', get_string('maxvisibility', 'oublog'), $options);
         $mform->setType('maxvisibility', PARAM_INT);
         $mform->addHelpButton('maxvisibility', 'maxvisibility', 'oublog');
         // Whether intro text shows on post form pages.
         $mform->addElement('checkbox', 'introonpost', get_string('introonpost', 'oublog'), '', 0);
         // Max size of attachments.
         $modulesettings = get_config('mod_oublog');
         $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes);
         $mform->addElement('select', 'maxbytes', get_string('maxattachmentsize', 'oublog'), $choices);
         $mform->addHelpButton('maxbytes', 'maxattachmentsize', 'oublog');
         $mform->setDefault('maxbytes', $modulesettings->maxbytes);
         // Max number of attachments.
         $choices = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 50, 100);
         $mform->addElement('select', 'maxattachments', get_string('maxattachments', 'oublog'), $choices);
         $mform->addHelpButton('maxattachments', 'maxattachments', 'oublog');
         $mform->setDefault('maxattachments', $modulesettings->maxattachments);
         // Enable the stats block.
         $mform->addElement('checkbox', 'statblockon', get_string('statblockon', 'oublog'), '', 0);
         $mform->addHelpButton('statblockon', 'statblockon', 'oublog');
         // Show OU Alerts reporting link.
         if (oublog_oualerts_enabled()) {
             $mform->addElement('text', 'reportingemail', get_string('reportingemail', 'oublog'), array('size' => '48'));
             $mform->addHelpButton('reportingemail', 'reportingemail', 'oublog');
             $mform->setType('reportingemail', PARAM_NOTAGS);
             $mform->addRule('reportingemail', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
         }
         $mform->addElement('text', 'displayname', get_string('displayname', 'oublog'), array('size' => '48'));
         $mform->addHelpButton('displayname', 'displayname', 'oublog');
         $mform->setType('displayname', PARAM_NOTAGS);
         $mform->addRule('displayname', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
         $mform->addElement('checkbox', 'allowimport', get_string('allowimport', 'oublog'), '', 0);
         $mform->addHelpButton('allowimport', 'allowimport', 'oublog');
         $this->standard_grading_coursemodule_elements();
         $mform->setDefault('grade', 0);
         // Add standard elements, common to all modules.
         $features = new stdClass();
         $features->groupings = true;
         $features->groupmembersonly = true;
         $this->standard_coursemodule_elements($features);
     } else {
         // Adding the "summary" field.
         $mform->addElement('editor', 'summary_editor', get_string('summary', 'oublog'), null, array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes));
         $mform->setType('summary', PARAM_RAW);
         $mform->addElement('hidden', 'instance');
         $mform->setType('instance', PARAM_INT);
     }
     // Add standard buttons, common to all modules.
     $this->add_action_buttons();
 }
Example #21
0
<?php

defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
    require_once $CFG->dirroot . '/mod/videoboard/lib.php';
    if (isset($CFG->maxbytes)) {
        $settings->add(new admin_setting_configselect('videoboard_maxbytes', get_string('maximumsize', 'videoboard'), get_string('settings_descr_videoboard_maxbytes', 'videoboard'), 1048576, get_max_upload_sizes($CFG->maxbytes)));
    }
    $options = array(VIDEOBOARD_COUNT_WORDS => trim(get_string('numwords', '', '?')), VIDEOBOARD_COUNT_LETTERS => trim(get_string('numletters', '', '?')));
    $settings->add(new admin_setting_configselect('videoboard_itemstocount', get_string('itemstocount', 'videoboard'), get_string('settings_descr_videoboard_itemstocount', 'videoboard'), VIDEOBOARD_COUNT_WORDS, $options));
    $settings->add(new admin_setting_configcheckbox('videoboard_showrecentsubmissions', get_string('showrecentsubmissions', 'videoboard'), get_string('configshowrecentsubmissions', 'videoboard'), 1));
    // Converting method
    $options = array();
    $options[1] = get_string('usemediaconvert', 'videoboard');
    //$options[2] = get_string('usethisserver', 'videoboard');
    $options[3] = get_string('useyoutube', 'videoboard');
    $options[4] = get_string('noconversionfiles', 'videoboard');
    $settings->add(new admin_setting_configselect('videoboard_video_convert', get_string('convertmethodvideo', 'videoboard'), get_string('descrforconvertingvideo', 'videoboard'), 1, $options));
    $options = array();
    $options[1] = get_string('usemediaconvert', 'videoboard');
    //$options[2] = get_string('usethisserver', 'videoboard');
    $options[4] = get_string('noconversionfiles', 'videoboard');
    $settings->add(new admin_setting_configselect('videoboard_audio_convert', get_string('convertmethodaudio', 'videoboard'), get_string('descrforconvertingaudio', 'videoboard'), 1, $options));
    // Converting url
    $settings->add(new admin_setting_configtext('videoboard_convert_url', get_string('converturl', 'videoboard'), get_string('descrforconvertingurl', 'videoboard'), '', PARAM_URL));
    // YouTube email
    $settings->add(new admin_setting_configtext('videoboard_youtube_email', get_string('youtube_email', 'videoboard'), get_string('descrforyoutube_email', 'videoboard'), '', PARAM_EMAIL));
    // YouTube password
    $settings->add(new admin_setting_configtext('videoboard_youtube_password', get_string('youtube_password', 'videoboard'), get_string('descrforyoutube_password', 'videoboard'), '', PARAM_TEXT));
    // YouTube ApiKey
    $settings->add(new admin_setting_configtext('videoboard_youtube_apikey', get_string('youtube_apikey', 'videoboard'), get_string('descrforyoutube_apikey', 'videoboard'), '', PARAM_TEXT));
Example #22
0
 function definition()
 {
     global $CFG, $COURSE, $DB;
     $mform =& $this->_form;
     //-------------------------------------------------------------------------------
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('text', 'name', get_string('forumname', 'forum'), 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');
     $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
     $forum_types = forum_get_forum_types();
     asort($forum_types);
     $mform->addElement('select', 'type', get_string('forumtype', 'forum'), $forum_types);
     $mform->addHelpButton('type', 'forumtype', 'forum');
     $mform->setDefault('type', 'general');
     $this->add_intro_editor(true, get_string('forumintro', 'forum'));
     $options = array();
     $options[FORUM_CHOOSESUBSCRIBE] = get_string('subscriptionoptional', 'forum');
     $options[FORUM_FORCESUBSCRIBE] = get_string('subscriptionforced', 'forum');
     $options[FORUM_INITIALSUBSCRIBE] = get_string('subscriptionauto', 'forum');
     $options[FORUM_DISALLOWSUBSCRIBE] = get_string('subscriptiondisabled', 'forum');
     $mform->addElement('select', 'forcesubscribe', get_string('subscriptionmode', 'forum'), $options);
     $mform->addHelpButton('forcesubscribe', 'subscriptionmode', 'forum');
     $options = array();
     $options[FORUM_TRACKING_OPTIONAL] = get_string('trackingoptional', 'forum');
     $options[FORUM_TRACKING_OFF] = get_string('trackingoff', 'forum');
     $options[FORUM_TRACKING_ON] = get_string('trackingon', 'forum');
     $mform->addElement('select', 'trackingtype', get_string('trackingtype', 'forum'), $options);
     $mform->addHelpButton('trackingtype', 'trackingtype', 'forum');
     $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes);
     $choices[1] = get_string('uploadnotallowed');
     $choices[0] = get_string('courseuploadlimit') . ' (' . display_size($COURSE->maxbytes) . ')';
     $mform->addElement('select', 'maxbytes', get_string('maxattachmentsize', 'forum'), $choices);
     $mform->addHelpButton('maxbytes', 'maxattachmentsize', 'forum');
     $mform->setDefault('maxbytes', $CFG->forum_maxbytes);
     $choices = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 50, 100);
     $mform->addElement('select', 'maxattachments', get_string('maxattachments', 'forum'), $choices);
     $mform->addHelpButton('maxattachments', 'maxattachments', 'forum');
     $mform->setDefault('maxattachments', $CFG->forum_maxattachments);
     if ($CFG->enablerssfeeds && isset($CFG->forum_enablerssfeeds) && $CFG->forum_enablerssfeeds) {
         //-------------------------------------------------------------------------------
         $mform->addElement('header', '', get_string('rss'));
         $choices = array();
         $choices[0] = get_string('none');
         $choices[1] = get_string('discussions', 'forum');
         $choices[2] = get_string('posts', 'forum');
         $mform->addElement('select', 'rsstype', get_string('rsstype'), $choices);
         $mform->addHelpButton('rsstype', 'rsstype', 'forum');
         $choices = array();
         $choices[0] = '0';
         $choices[1] = '1';
         $choices[2] = '2';
         $choices[3] = '3';
         $choices[4] = '4';
         $choices[5] = '5';
         $choices[10] = '10';
         $choices[15] = '15';
         $choices[20] = '20';
         $choices[25] = '25';
         $choices[30] = '30';
         $choices[40] = '40';
         $choices[50] = '50';
         $mform->addElement('select', 'rssarticles', get_string('rssarticles'), $choices);
         $mform->addHelpButton('rssarticles', 'rssarticles', 'forum');
     }
     //-------------------------------------------------------------------------------
     $mform->addElement('header', '', get_string('blockafter', 'forum'));
     $options = array();
     $options[0] = get_string('blockperioddisabled', 'forum');
     $options[60 * 60 * 24] = '1 ' . get_string('day');
     $options[60 * 60 * 24 * 2] = '2 ' . get_string('days');
     $options[60 * 60 * 24 * 3] = '3 ' . get_string('days');
     $options[60 * 60 * 24 * 4] = '4 ' . get_string('days');
     $options[60 * 60 * 24 * 5] = '5 ' . get_string('days');
     $options[60 * 60 * 24 * 6] = '6 ' . get_string('days');
     $options[60 * 60 * 24 * 7] = '1 ' . get_string('week');
     $mform->addElement('select', 'blockperiod', get_string('blockperiod', 'forum'), $options);
     $mform->addHelpButton('blockperiod', 'blockperiod', 'forum');
     $mform->addElement('text', 'blockafter', get_string('blockafter', 'forum'));
     $mform->setType('blockafter', PARAM_INT);
     $mform->setDefault('blockafter', '0');
     $mform->addRule('blockafter', null, 'numeric', null, 'client');
     $mform->addHelpButton('blockafter', 'blockafter', 'forum');
     $mform->disabledIf('blockafter', 'blockperiod', 'eq', 0);
     $mform->addElement('text', 'warnafter', get_string('warnafter', 'forum'));
     $mform->setType('warnafter', PARAM_INT);
     $mform->setDefault('warnafter', '0');
     $mform->addRule('warnafter', null, 'numeric', null, 'client');
     $mform->addHelpButton('warnafter', 'warnafter', 'forum');
     $mform->disabledIf('warnafter', 'blockperiod', 'eq', 0);
     //-------------------------------------------------------------------------------
     $this->standard_grading_coursemodule_elements();
     $this->standard_coursemodule_elements();
     //-------------------------------------------------------------------------------
     // buttons
     $this->add_action_buttons();
 }
 /**
  * Define this form - called by the parent constructor
  */
 public function definition()
 {
     global $DB, $CFG, $COURSE, $PAGE, $OUTPUT;
     $jsmodule = array('name' => 'mod_publication', 'fullpath' => '/mod/publication/publication.js', 'requires' => array('node-base', 'node-event-simulate'));
     $PAGE->requires->js_init_call('M.mod_publication.init_mod_form', array(), false, $jsmodule);
     $config = get_config('publication');
     $mform = $this->_form;
     $mform->addElement('header', 'general', get_string('general', 'form'));
     // Name.
     $mform->addElement('text', 'name', get_string('name', 'publication'));
     if (!empty($CFG->formatstringstriptags)) {
         $mform->setType('name', PARAM_TEXT);
     } else {
         $mform->setType('name', PARAM_CLEANHTML);
     }
     $mform->addRule('name', null, 'required', null, 'client');
     $requireintro = isset($config->requiremodintro) && $config->requiremodintro == 1 ? true : false;
     $this->add_intro_editor($requireintro);
     // Publication specific elements.
     $mform->addElement('header', 'publication', get_string('modulename', 'publication'));
     $mform->setExpanded('publication');
     if (isset($this->current->id) && $this->current->id != "") {
         $filecount = $DB->count_records('publication_file', array('publication' => $this->current->id));
     } else {
         $filecount = 0;
     }
     $disabled = array();
     if ($filecount > 0) {
         $disabled['disabled'] = 'disabled';
     }
     $modearray = array();
     $modearray[] =& $mform->createElement('radio', 'mode', '', get_string('modeupload', 'publication'), PUBLICATION_MODE_UPLOAD, $disabled);
     $modearray[] =& $mform->createElement('radio', 'mode', '', get_string('modeimport', 'publication'), PUBLICATION_MODE_IMPORT, $disabled);
     $mform->addGroup($modearray, 'modegrp', get_string('mode', 'publication'), array(' '), false);
     $mform->addHelpButton('modegrp', 'mode', 'publication');
     if (count($filecount) == 0) {
         $mform->addRule('modegrp', null, 'required', null, 'client');
     }
     // Publication mode import specific elements.
     $choices = array();
     $choices[-1] = get_string('choose', 'publication');
     $assigninstances = $DB->get_records('assign', array('course' => $COURSE->id));
     foreach ($assigninstances as $assigninstance) {
         $choices[$assigninstance->id] = $assigninstance->name;
     }
     $mform->addElement('select', 'importfrom', get_string('assignment', 'publication'), $choices, $disabled);
     if (count($disabled) == 0) {
         $mform->disabledif('importfrom', 'mode', 'neq', PUBLICATION_MODE_IMPORT);
     }
     $attributes = array();
     if (isset($this->current->id) && isset($this->current->obtainstudentapproval)) {
         if ($this->current->obtainstudentapproval) {
             $message = get_string('warning_changefromobtainstudentapproval', 'publication');
             $showwhen = "0";
         } else {
             $message = get_string('warning_changetoobtainstudentapproval', 'publication');
             $showwhen = "1";
         }
         $message = trim(preg_replace('/\\s+/', ' ', $message));
         $message = str_replace('\'', '\\\'', $message);
         $attributes['onChange'] = "if (this.value==" . $showwhen . ") {alert('" . $message . "')}";
     }
     $mform->addElement('selectyesno', 'obtainstudentapproval', get_string('obtainstudentapproval', 'publication'), $attributes);
     $mform->setDefault('obtainstudentapproval', get_config('publication', 'obtainstudentapproval'));
     $mform->addHelpButton('obtainstudentapproval', 'obtainstudentapproval', 'publication');
     $mform->disabledIf('obtainstudentapproval', 'mode', 'neq', PUBLICATION_MODE_IMPORT);
     // Publication mode upload specific elements.
     $maxfiles = array();
     for ($i = 1; $i <= 100 || $i <= get_config('publication', 'maxfiles'); $i++) {
         $maxfiles[$i] = $i;
     }
     $mform->addElement('select', 'maxfiles', get_string('maxfiles', 'publication'), $maxfiles);
     $mform->setDefault('maxfiles', get_config('publication', 'maxfiles'));
     $mform->disabledIf('maxfiles', 'mode', 'neq', PUBLICATION_MODE_UPLOAD);
     $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes);
     $choices[0] = get_string('courseuploadlimit', 'publication') . ' (' . display_size($COURSE->maxbytes) . ')';
     $mform->addElement('select', 'maxbytes', get_string('maxbytes', 'publication'), $choices);
     $mform->setDefault('maxbytes', get_config('publication', 'maxbytes'));
     $mform->disabledIf('maxbytes', 'mode', 'neq', PUBLICATION_MODE_UPLOAD);
     $mform->addElement('text', 'allowedfiletypes', get_string('allowedfiletypes', 'publication'), array('size' => '45'));
     $mform->setType('allowedfiletypes', PARAM_RAW);
     $mform->addHelpButton('allowedfiletypes', 'allowedfiletypes', 'publication');
     $mform->addRule('allowedfiletypes', get_string('allowedfiletypes_err', 'publication'), 'regex', '/^([A-Za-z0-9]+([ ]*[,][ ]*[A-Za-z0-9]+)*)$/', 'client', false, false);
     $mform->disabledIf('allowedfiletypes', 'mode', 'neq', PUBLICATION_MODE_UPLOAD);
     $attributes = array();
     if (isset($this->current->id) && isset($this->current->obtainteacherapproval)) {
         if (!$this->current->obtainteacherapproval) {
             $message = get_string('warning_changefromobtainteacherapproval', 'publication');
             $showwhen = "1";
         } else {
             $message = get_string('warning_changetoobtainteacherapproval', 'publication');
             $showwhen = "0";
         }
         $message = trim(preg_replace('/\\s+/', ' ', $message));
         $attributes['onChange'] = "if (this.value==" . $showwhen . ") {alert('" . $message . "')}";
     }
     $mform->addElement('selectyesno', 'obtainteacherapproval', get_string('obtainteacherapproval', 'publication'), $attributes);
     $mform->setDefault('obtainteacherapproval', get_config('publication', 'obtainteacherapproval'));
     $mform->addHelpButton('obtainteacherapproval', 'obtainteacherapproval', 'publication');
     $mform->disabledIf('obtainteacherapproval', 'mode', 'neq', PUBLICATION_MODE_UPLOAD);
     // Availability.
     $mform->addElement('header', 'availability', get_string('availability', 'publication'));
     $mform->setExpanded('availability', true);
     $name = get_string('allowsubmissionsfromdate', 'publication');
     $options = array('optional' => true);
     $mform->addElement('date_time_selector', 'allowsubmissionsfromdate', $name, $options);
     $mform->addHelpButton('allowsubmissionsfromdate', 'allowsubmissionsfromdateh', 'publication');
     $mform->setDefault('allowsubmissionsfromdate', time());
     $name = get_string('duedate', 'publication');
     $mform->addElement('date_time_selector', 'duedate', $name, array('optional' => true));
     $mform->setDefault('duedate', time() + 7 * 24 * 3600);
     $mform->addElement('hidden', 'cutoffdate', false);
     $mform->setType('cutoffdate', PARAM_BOOL);
     $mform->addElement('hidden', 'alwaysshowdescription', true);
     $mform->setType('alwaysshowdescription', PARAM_BOOL);
     // Standard coursemodule elements.
     $this->standard_coursemodule_elements();
     // Buttons.
     $this->add_action_buttons();
 }
 function setup_elements(&$mform)
 {
     global $CFG, $COURSE;
     $ynoptions = array(0 => get_string('no'), 1 => get_string('yes'));
     $mform->addElement('select', 'resubmit', get_string('allowresubmit', 'assignment'), $ynoptions);
     $mform->addHelpButton('resubmit', 'allowresubmit', 'assignment');
     $mform->setDefault('resubmit', 0);
     $mform->addElement('select', 'emailteachers', get_string('emailteachers', 'assignment'), $ynoptions);
     $mform->addHelpButton('emailteachers', 'emailteachers', 'assignment');
     $mform->setDefault('emailteachers', 0);
     $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes);
     $mform->addElement('select', 'maxbytes', get_string('maximumsize', 'assignment'), $choices);
     $mform->setDefault('maxbytes', $CFG->assignment_maxbytes);
     $course_context = context_course::instance($COURSE->id);
     plagiarism_get_form_elements_module($mform, $course_context, 'mod_assignment');
 }
 /**
  * Print the form for this assignment type
  * 
  * @param $mform object Allready existant form
  */
 function setup_elements(&$mform)
 {
     global $CFG, $COURSE;
     $add = optional_param('add', '', PARAM_ALPHA);
     $update = optional_param('update', 0, PARAM_INT);
     // Get course module instance
     $cm = null;
     $onlinejudge = null;
     if (!empty($update)) {
         $cm = get_record('course_modules', 'id', $update);
         $onlinejudge = get_record('assignment_oj', 'assignment', $cm->instance);
     }
     $ynoptions = array(0 => get_string('no'), 1 => get_string('yes'));
     // Programming languages
     $choices = $this->get_languages();
     $mform->addElement('select', 'lang', get_string('assignmentlangs', 'assignment_onlinejudge'), $choices);
     $mform->setDefault('lang', $onlinejudge ? $onlinejudge->language : 'c');
     // Presentation error grade ratio
     unset($choices);
     $choices = get_grade_options()->gradeoptions;
     // Steal from question lib
     $mform->addElement('select', 'ratiope', get_string('ratiope', 'assignment_onlinejudge'), $choices);
     $mform->setHelpButton('ratiope', array('ratiope', get_string('descratiope', 'assignment_onlinejudge'), 'assignment_onlinejudge'));
     $mform->setDefault('ratiope', $onlinejudge ? $onlinejudge->ratiope : 0);
     // Max. CPU time
     unset($choices);
     $choices = $this->get_max_cpu_times($CFG->assignment_oj_max_cpu);
     $mform->addElement('select', 'cpulimit', get_string('cpulimit', 'assignment_onlinejudge'), $choices);
     $mform->setDefault('cpulimit', $onlinejudge ? $onlinejudge->cpulimit : 1);
     // Max. memory usage
     unset($choices);
     $choices = $this->get_max_memory_usages($CFG->assignment_oj_max_mem);
     $mform->addElement('select', 'memlimit', get_string('memlimit', 'assignment_onlinejudge'), $choices);
     $mform->setDefault('memlimit', $onlinejudge ? $onlinejudge->memlimit : $CFG->assignment_oj_max_mem);
     // Allow resubmit
     $mform->addElement('select', 'resubmit', get_string('allowresubmit', 'assignment'), $ynoptions);
     $mform->setHelpButton('resubmit', array('resubmit', get_string('allowresubmit', 'assignment'), 'assignment'));
     $mform->setDefault('resubmit', 1);
     // Compile only?
     $mform->addElement('select', 'compileonly', get_string('compileonly', 'assignment_onlinejudge'), $ynoptions);
     $mform->setHelpButton('compileonly', array('compileonly', get_string('compileonly', 'assignment_onlinejudge'), 'assignment_onlinejudge'));
     $mform->setDefault('compileonly', $onlinejudge ? $onlinejudge->compileonly : 0);
     // Email teachers
     $mform->addElement('select', 'emailteachers', get_string('emailteachers', 'assignment'), $ynoptions);
     $mform->setHelpButton('emailteachers', array('emailteachers', get_string('emailteachers', 'assignment'), 'assignment'));
     $mform->setDefault('emailteachers', 0);
     // Submission max bytes
     $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes);
     $choices[1] = get_string('uploadnotallowed');
     $choices[0] = get_string('courseuploadlimit') . ' (' . display_size($COURSE->maxbytes) . ')';
     $mform->addElement('select', 'maxbytes', get_string('maximumfilesize', 'assignment_onlinejudge'), $choices);
     $mform->setDefault('maxbytes', $CFG->assignment_maxbytes);
 }
Example #26
0
    function setup_elements(&$mform) {
        global $CFG, $COURSE;

        $ynoptions = array( 0 => get_string('no'), 1 => get_string('yes'));

        $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes);
        $choices[0] = get_string('courseuploadlimit') . ' ('.display_size($COURSE->maxbytes).')';
        $mform->addElement('select', 'maxbytes', get_string('maximumsize', 'assignment'), $choices);
        $mform->setDefault('maxbytes', $CFG->assignment_maxbytes);

        $mform->addElement('select', 'resubmit', get_string('allowdeleting', 'assignment'), $ynoptions);
        $mform->addHelpButton('resubmit', 'allowdeleting', 'assignment');
        $mform->setDefault('resubmit', 1);

        $options = array();
        for($i = 1; $i <= 20; $i++) {
            $options[$i] = $i;
        }
        $mform->addElement('select', 'var1', get_string('allowmaxfiles', 'assignment'), $options);
        $mform->addHelpButton('var1', 'allowmaxfiles', 'assignment');
        $mform->setDefault('var1', 3);

        $mform->addElement('select', 'var2', get_string('allownotes', 'assignment'), $ynoptions);
        $mform->addHelpButton('var2', 'allownotes', 'assignment');
        $mform->setDefault('var2', 0);

        $mform->addElement('select', 'var3', get_string('hideintro', 'assignment'), $ynoptions);
        $mform->addHelpButton('var3', 'hideintro', 'assignment');
        $mform->setDefault('var3', 0);

        $mform->addElement('select', 'emailteachers', get_string('emailteachers', 'assignment'), $ynoptions);
        $mform->addHelpButton('emailteachers', 'emailteachers', 'assignment');
        $mform->setDefault('emailteachers', 0);

        $mform->addElement('select', 'var4', get_string('trackdrafts', 'assignment'), $ynoptions);
        $mform->addHelpButton('var4', 'trackdrafts', 'assignment');
        $mform->setDefault('var4', 1);

        $course_context = context_course::instance($COURSE->id);
        plagiarism_get_form_elements_module($mform, $course_context, 'mod_assignment');
    }
 public function test_get_max_upload_sizes()
 {
     // Test with very low limits so we are not affected by php upload limits.
     // Test activity limit smallest.
     $sitebytes = 102400;
     $coursebytes = 51200;
     $modulebytes = 10240;
     $result = get_max_upload_sizes($sitebytes, $coursebytes, $modulebytes);
     $this->assertSame('Activity upload limit (10KB)', $result['0']);
     $this->assertCount(2, $result);
     // Test course limit smallest.
     $sitebytes = 102400;
     $coursebytes = 10240;
     $modulebytes = 51200;
     $result = get_max_upload_sizes($sitebytes, $coursebytes, $modulebytes);
     $this->assertSame('Course upload limit (10KB)', $result['0']);
     $this->assertCount(2, $result);
     // Test site limit smallest.
     $sitebytes = 10240;
     $coursebytes = 102400;
     $modulebytes = 51200;
     $result = get_max_upload_sizes($sitebytes, $coursebytes, $modulebytes);
     $this->assertSame('Site upload limit (10KB)', $result['0']);
     $this->assertCount(2, $result);
     // Test site limit not set.
     $sitebytes = 0;
     $coursebytes = 102400;
     $modulebytes = 51200;
     $result = get_max_upload_sizes($sitebytes, $coursebytes, $modulebytes);
     $this->assertSame('Activity upload limit (50KB)', $result['0']);
     $this->assertCount(3, $result);
     $sitebytes = 0;
     $coursebytes = 51200;
     $modulebytes = 102400;
     $result = get_max_upload_sizes($sitebytes, $coursebytes, $modulebytes);
     $this->assertSame('Course upload limit (50KB)', $result['0']);
     $this->assertCount(3, $result);
     // Test custom bytes in range.
     $sitebytes = 102400;
     $coursebytes = 51200;
     $modulebytes = 51200;
     $custombytes = 10240;
     $result = get_max_upload_sizes($sitebytes, $coursebytes, $modulebytes, $custombytes);
     $this->assertCount(3, $result);
     // Test custom bytes in range but non-standard.
     $sitebytes = 102400;
     $coursebytes = 51200;
     $modulebytes = 51200;
     $custombytes = 25600;
     $result = get_max_upload_sizes($sitebytes, $coursebytes, $modulebytes, $custombytes);
     $this->assertCount(4, $result);
     // Test custom bytes out of range.
     $sitebytes = 102400;
     $coursebytes = 51200;
     $modulebytes = 51200;
     $custombytes = 102400;
     $result = get_max_upload_sizes($sitebytes, $coursebytes, $modulebytes, $custombytes);
     $this->assertCount(3, $result);
     // Test custom bytes out of range and non-standard.
     $sitebytes = 102400;
     $coursebytes = 51200;
     $modulebytes = 51200;
     $custombytes = 256000;
     $result = get_max_upload_sizes($sitebytes, $coursebytes, $modulebytes, $custombytes);
     $this->assertCount(3, $result);
     // Test site limit only.
     $sitebytes = 51200;
     $result = get_max_upload_sizes($sitebytes);
     $this->assertSame('Site upload limit (50KB)', $result['0']);
     $this->assertSame('50KB', $result['51200']);
     $this->assertSame('10KB', $result['10240']);
     $this->assertCount(3, $result);
     // Test no limit.
     $result = get_max_upload_sizes();
     $this->assertArrayHasKey('0', $result);
     $this->assertArrayHasKey(get_max_upload_file_size(), $result);
 }
Example #28
0
 $temp->add(new admin_setting_configselect('moodlecourse/format', new lang_string('format'), new lang_string('coursehelpformat'), 'weeks', $formcourseformats));
 $temp->add(new admin_setting_configtext('moodlecourse/maxsections', new lang_string('maxnumberweeks'), new lang_string('maxnumberweeks_desc'), 52));
 $temp->add(new admin_settings_num_course_sections('moodlecourse/numsections', new lang_string('numberweeks'), new lang_string('coursehelpnumberweeks'), 10));
 $choices = array();
 $choices['0'] = new lang_string('hiddensectionscollapsed');
 $choices['1'] = new lang_string('hiddensectionsinvisible');
 $temp->add(new admin_setting_configselect('moodlecourse/hiddensections', new lang_string('hiddensections'), new lang_string('coursehelphiddensections'), 0, $choices));
 $options = range(0, 10);
 $temp->add(new admin_setting_configselect('moodlecourse/newsitems', new lang_string('newsitemsnumber'), new lang_string('coursehelpnewsitemsnumber'), 5, $options));
 $temp->add(new admin_setting_configselect('moodlecourse/showgrades', new lang_string('showgrades'), new lang_string('coursehelpshowgrades'), 1, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
 $temp->add(new admin_setting_configselect('moodlecourse/showreports', new lang_string('showreports'), '', 0, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
 $currentmaxbytes = get_config('moodlecourse', 'maxbytes');
 if (isset($CFG->maxbytes)) {
     $choices = get_max_upload_sizes($CFG->maxbytes, 0, 0, $currentmaxbytes);
 } else {
     $choices = get_max_upload_sizes(0, 0, 0, $currentmaxbytes);
 }
 $temp->add(new admin_setting_configselect('moodlecourse/maxbytes', new lang_string('maximumupload'), new lang_string('coursehelpmaximumupload'), key($choices), $choices));
 if (!empty($CFG->legacyfilesinnewcourses)) {
     $choices = array('0' => new lang_string('no'), '2' => new lang_string('yes'));
     $temp->add(new admin_setting_configselect('moodlecourse/legacyfiles', new lang_string('courselegacyfiles'), new lang_string('courselegacyfiles_help'), key($choices), $choices));
 }
 $choices = array();
 $choices[COURSE_DISPLAY_SINGLEPAGE] = new lang_string('coursedisplay_single');
 $choices[COURSE_DISPLAY_MULTIPAGE] = new lang_string('coursedisplay_multi');
 $temp->add(new admin_setting_configselect('moodlecourse/coursedisplay', new lang_string('coursedisplay'), new lang_string('coursedisplay_help'), COURSE_DISPLAY_SINGLEPAGE, $choices));
 $temp->add(new admin_setting_heading('groups', new lang_string('groups', 'group'), ''));
 $choices = array();
 $choices[NOGROUPS] = new lang_string('groupsnone', 'group');
 $choices[SEPARATEGROUPS] = new lang_string('groupsseparate', 'group');
 $choices[VISIBLEGROUPS] = new lang_string('groupsvisible', 'group');
Example #29
0
 function definition()
 {
     global $USER, $CFG, $DB;
     $courseconfig = get_config('moodlecourse');
     $mform =& $this->_form;
     $course = $this->_customdata['course'];
     $category = $this->_customdata['category'];
     $systemcontext = get_context_instance(CONTEXT_SYSTEM);
     $categorycontext = get_context_instance(CONTEXT_COURSECAT, $category->id);
     $disable_meta = false;
     // basic meta course state protection; server-side security checks not needed
     if (!empty($course)) {
         $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
         $context = $coursecontext;
         if (course_in_meta($course)) {
             $disable_meta = get_string('metaalreadyinmeta');
         } else {
             if ($course->metacourse) {
                 if ($DB->count_records('course_meta', array('parent_course' => $course->id)) > 0) {
                     $disable_meta = get_string('metaalreadyhascourses');
                 }
             } else {
                 // if users already enrolled directly into coures, do not allow switching to meta,
                 // users with metacourse manage permission are exception
                 // please note that we do not need exact results - anything unexpected here prevents metacourse
                 $managers = get_users_by_capability($coursecontext, 'moodle/course:managemetacourse', 'u.id');
                 $enrolroles = get_roles_with_capability('moodle/course:view', CAP_ALLOW, $coursecontext);
                 if ($users = get_role_users(array_keys($enrolroles), $coursecontext, false, 'u.id', 'u.id ASC')) {
                     foreach ($users as $user) {
                         if (!isset($managers[$user->id])) {
                             $disable_meta = get_string('metaalreadyhasenrolments');
                             break;
                         }
                     }
                 }
                 unset($managers);
                 unset($users);
                 unset($enrolroles);
             }
         }
     } else {
         $coursecontext = null;
         $context = $categorycontext;
     }
     /// form definition with new course defaults
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'general', get_string('general', 'form'));
     // Must have create course capability in both categories in order to move course
     if (has_capability('moodle/course:create', $categorycontext)) {
         $displaylist = array();
         $parentlist = array();
         make_categories_list($displaylist, $parentlist, 'moodle/course:create');
         $mform->addElement('select', 'category', get_string('category'), $displaylist);
     } else {
         $mform->addElement('hidden', 'category', null);
     }
     $mform->setHelpButton('category', array('coursecategory', get_string('category')));
     $mform->setDefault('category', $category->id);
     $mform->setType('category', PARAM_INT);
     $fullname = get_string('defaultcoursefullname');
     $shortname = get_string('defaultcourseshortname');
     while ($DB->record_exists('course', array('fullname' => $fullname)) or $DB->record_exists('course', array('fullname' => $fullname))) {
         $fullname++;
         $shortname++;
     }
     $mform->addElement('text', 'fullname', get_string('fullnamecourse'), 'maxlength="254" size="50"');
     $mform->setHelpButton('fullname', array('coursefullname', get_string('fullnamecourse')), true);
     $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client');
     $mform->setType('fullname', PARAM_MULTILANG);
     if ($course and !has_capability('moodle/course:changefullname', $coursecontext)) {
         $mform->hardFreeze('fullname');
         $mform->setConstant('fullname', $course->fullname);
     }
     $mform->setDefault('fullname', $fullname);
     $mform->addElement('text', 'shortname', get_string('shortnamecourse'), 'maxlength="100" size="20"');
     $mform->setHelpButton('shortname', array('courseshortname', get_string('shortnamecourse')), true);
     $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
     $mform->setType('shortname', PARAM_MULTILANG);
     if ($course and !has_capability('moodle/course:changeshortname', $coursecontext)) {
         $mform->hardFreeze('shortname');
         $mform->setConstant('shortname', $course->shortname);
     }
     $mform->setDefault('shortname', $shortname);
     $mform->addElement('text', 'idnumber', get_string('idnumbercourse'), 'maxlength="100"  size="10"');
     $mform->setHelpButton('idnumber', array('courseidnumber', get_string('idnumbercourse')), true);
     $mform->setType('idnumber', PARAM_RAW);
     if ($course and !has_capability('moodle/course:changeidnumber', $coursecontext)) {
         $mform->hardFreeze('idnumber');
         $mform->setConstants('idnumber', $course->idnumber);
     }
     $mform->addElement('htmleditor', 'summary', get_string('summary'), array('rows' => '10', 'cols' => '65'));
     $mform->setHelpButton('summary', array('text2', get_string('helptext')), true);
     $mform->setType('summary', PARAM_RAW);
     $courseformats = get_list_of_plugins('course/format');
     $formcourseformats = array();
     foreach ($courseformats as $courseformat) {
         $formcourseformats["{$courseformat}"] = get_string("format{$courseformat}", "format_{$courseformat}");
         if ($formcourseformats["{$courseformat}"] == "[[format{$courseformat}]]") {
             $formcourseformats["{$courseformat}"] = get_string("format{$courseformat}");
         }
     }
     $mform->addElement('select', 'format', get_string('format'), $formcourseformats);
     $mform->setHelpButton('format', array('courseformats', get_string('courseformats')), true);
     $mform->setDefault('format', $courseconfig->format);
     for ($i = 1; $i <= 52; $i++) {
         $sectionmenu[$i] = "{$i}";
     }
     $mform->addElement('select', 'numsections', get_string('numberweeks'), $sectionmenu);
     $mform->setDefault('numsections', $courseconfig->numsections);
     $mform->addElement('date_selector', 'startdate', get_string('startdate'));
     $mform->setHelpButton('startdate', array('coursestartdate', get_string('startdate')), true);
     $mform->setDefault('startdate', time() + 3600 * 24);
     $choices = array();
     $choices['0'] = get_string('hiddensectionscollapsed');
     $choices['1'] = get_string('hiddensectionsinvisible');
     $mform->addElement('select', 'hiddensections', get_string('hiddensections'), $choices);
     $mform->setHelpButton('hiddensections', array('coursehiddensections', get_string('hiddensections')), true);
     $mform->setDefault('hiddensections', $courseconfig->hiddensections);
     $options = range(0, 10);
     $mform->addElement('select', 'newsitems', get_string('newsitemsnumber'), $options);
     $mform->setHelpButton('newsitems', array('coursenewsitems', get_string('newsitemsnumber')), true);
     $mform->setDefault('newsitems', $courseconfig->newsitems);
     $mform->addElement('selectyesno', 'showgrades', get_string('showgrades'));
     $mform->setHelpButton('showgrades', array('coursegrades', get_string('grades')), true);
     $mform->setDefault('showgrades', $courseconfig->showgrades);
     $mform->addElement('selectyesno', 'showreports', get_string('showreports'));
     $mform->setHelpButton('showreports', array('coursereports', get_string('activityreport')), true);
     $mform->setDefault('showreports', $courseconfig->showreports);
     $choices = get_max_upload_sizes($CFG->maxbytes);
     $mform->addElement('select', 'maxbytes', get_string('maximumupload'), $choices);
     $mform->setHelpButton('maxbytes', array('courseuploadsize', get_string('maximumupload')), true);
     $mform->setDefault('maxbytes', $courseconfig->maxbytes);
     if (!empty($CFG->allowcoursethemes)) {
         $themes = array();
         $themes[''] = get_string('forceno');
         $themes += get_list_of_themes();
         $mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
     }
     $meta = array();
     $meta[0] = get_string('no');
     $meta[1] = get_string('yes');
     if ($disable_meta === false) {
         $mform->addElement('select', 'metacourse', get_string('managemeta'), $meta);
         $mform->setHelpButton('metacourse', array('metacourse', get_string('metacourse')), true);
         $mform->setDefault('metacourse', $courseconfig->metacourse);
     } else {
         // no metacourse element - we do not want to change it anyway!
         $mform->addElement('static', 'nometacourse', get_string('managemeta'), (empty($course->metacourse) ? $meta[0] : $meta[1]) . " - {$disable_meta} ");
         $mform->setHelpButton('nometacourse', array('metacourse', get_string('metacourse')), true);
     }
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'enrolhdr', get_string('enrolments'));
     $choices = array();
     $modules = explode(',', $CFG->enrol_plugins_enabled);
     foreach ($modules as $module) {
         $name = get_string('enrolname', "enrol_{$module}");
         $plugin = enrolment_factory::factory($module);
         if (method_exists($plugin, 'print_entry')) {
             $choices[$name] = $module;
         }
     }
     asort($choices);
     $choices = array_flip($choices);
     $choices = array_merge(array('' => get_string('sitedefault') . ' (' . get_string('enrolname', "enrol_{$CFG->enrol}") . ')'), $choices);
     $mform->addElement('select', 'enrol', get_string('enrolmentplugins'), $choices);
     $mform->setHelpButton('enrol', array('courseenrolmentplugins', get_string('enrolmentplugins')), true);
     $mform->setDefault('enrol', $courseconfig->enrol);
     $roles = get_assignable_roles($context);
     if (!empty($course)) {
         // add current default role, so that it is selectable even when user can not assign it
         if ($current_role = $DB->get_record('role', array('id' => $course->defaultrole))) {
             $roles[$current_role->id] = strip_tags(format_string($current_role->name, true));
         }
     }
     $choices = array();
     if ($sitedefaultrole = $DB->get_record('role', array('id' => $CFG->defaultcourseroleid))) {
         $choices[0] = get_string('sitedefault') . ' (' . $sitedefaultrole->name . ')';
     } else {
         $choices[0] = get_string('sitedefault');
     }
     $choices = $choices + $roles;
     // fix for MDL-9197
     foreach ($choices as $choiceid => $choice) {
         $choices[$choiceid] = format_string($choice);
     }
     $mform->addElement('select', 'defaultrole', get_string('defaultrole', 'role'), $choices);
     $mform->setDefault('defaultrole', 0);
     $radio = array();
     $radio[] =& MoodleQuickForm::createElement('radio', 'enrollable', null, get_string('no'), 0);
     $radio[] =& MoodleQuickForm::createElement('radio', 'enrollable', null, get_string('yes'), 1);
     $radio[] =& MoodleQuickForm::createElement('radio', 'enrollable', null, get_string('enroldate'), 2);
     $mform->addGroup($radio, 'enrollable', get_string('enrollable'), ' ', false);
     $mform->setHelpButton('enrollable', array('courseenrollable2', get_string('enrollable')), true);
     $mform->setDefault('enrollable', $courseconfig->enrollable);
     $mform->addElement('date_selector', 'enrolstartdate', get_string('enrolstartdate'), array('optional' => true));
     $mform->setDefault('enrolstartdate', 0);
     $mform->disabledIf('enrolstartdate', 'enrollable', 'neq', 2);
     $mform->addElement('date_selector', 'enrolenddate', get_string('enrolenddate'), array('optional' => true));
     $mform->setDefault('enrolenddate', 0);
     $mform->disabledIf('enrolenddate', 'enrollable', 'neq', 2);
     $mform->addElement('duration', 'enrolperiod', get_string('enrolperiod'), array('optional' => true, 'defaultunit' => 86400));
     $mform->setDefault('enrolperiod', $courseconfig->enrolperiod);
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'expirynotifyhdr', get_string('expirynotify'));
     $choices = array();
     $choices['0'] = get_string('no');
     $choices['1'] = get_string('yes');
     $mform->addElement('select', 'expirynotify', get_string('notify'), $choices);
     $mform->setHelpButton('expirynotify', array('expirynotify', get_string('expirynotify')), true);
     $mform->setDefault('expirynotify', $courseconfig->expirynotify);
     $mform->addElement('select', 'notifystudents', get_string('expirynotifystudents'), $choices);
     $mform->setHelpButton('notifystudents', array('expirynotifystudents', get_string('expirynotifystudents')), true);
     $mform->setDefault('notifystudents', $courseconfig->notifystudents);
     $thresholdmenu = array();
     for ($i = 1; $i <= 30; $i++) {
         $seconds = $i * 86400;
         $thresholdmenu[$seconds] = get_string('numdays', '', $i);
     }
     $mform->addElement('select', 'expirythreshold', get_string('expirythreshold'), $thresholdmenu);
     $mform->setHelpButton('expirythreshold', array('expirythreshold', get_string('expirythreshold')), true);
     $mform->setDefault('expirythreshold', $courseconfig->expirythreshold);
     //--------------------------------------------------------------------------------
     $mform->addElement('header', '', get_string('groups', 'group'));
     $choices = array();
     $choices[NOGROUPS] = get_string('groupsnone', 'group');
     $choices[SEPARATEGROUPS] = get_string('groupsseparate', 'group');
     $choices[VISIBLEGROUPS] = get_string('groupsvisible', 'group');
     $mform->addElement('select', 'groupmode', get_string('groupmode'), $choices);
     $mform->setHelpButton('groupmode', array('groupmode', get_string('groupmode')), true);
     $mform->setDefault('groupmode', $courseconfig->groupmode);
     $choices = array();
     $choices['0'] = get_string('no');
     $choices['1'] = get_string('yes');
     $mform->addElement('select', 'groupmodeforce', get_string('force'), $choices);
     $mform->setHelpButton('groupmodeforce', array('groupmodeforce', get_string('groupmodeforce')), true);
     $mform->setDefault('groupmodeforce', $courseconfig->groupmodeforce);
     if (!empty($CFG->enablegroupings)) {
         //default groupings selector
         $options = array();
         $options[0] = get_string('none');
         $mform->addElement('select', 'defaultgroupingid', get_string('defaultgrouping', 'group'), $options);
     }
     //--------------------------------------------------------------------------------
     $mform->addElement('header', '', get_string('availability'));
     $choices = array();
     $choices['0'] = get_string('courseavailablenot');
     $choices['1'] = get_string('courseavailable');
     $mform->addElement('select', 'visible', get_string('availability'), $choices);
     $mform->setHelpButton('visible', array('courseavailability', get_string('availability')), true);
     $mform->setDefault('visible', $courseconfig->visible);
     if ($course and !has_capability('moodle/course:visibility', $coursecontext)) {
         $mform->hardFreeze('visible');
         $mform->setConstant('visible', $course->visible);
     }
     $mform->addElement('passwordunmask', 'enrolpassword', get_string('enrolmentkey'), 'size="25"');
     $mform->setHelpButton('enrolpassword', array('enrolmentkey', get_string('enrolmentkey')), true);
     $mform->setDefault('enrolpassword', '');
     $mform->setDefault('enrolpassword', $courseconfig->enrolpassword);
     $mform->setType('enrolpassword', PARAM_RAW);
     if (empty($course) or $course->password !== '' and $course->id != SITEID) {
         // do not require password in existing courses that do not have password yet - backwards compatibility ;-)
         if (!empty($CFG->enrol_manual_requirekey)) {
             $mform->addRule('enrolpassword', get_string('required'), 'required', null, 'client');
         }
     }
     $choices = array();
     $choices['0'] = get_string('guestsno');
     $choices['1'] = get_string('guestsyes');
     $choices['2'] = get_string('guestskey');
     $mform->addElement('select', 'guest', get_string('opentoguests'), $choices);
     $mform->setHelpButton('guest', array('guestaccess', get_string('opentoguests')), true);
     $mform->setDefault('guest', $courseconfig->guest);
     // If we are creating a course, its enrol method isn't yet chosen, BUT the site has a default enrol method which we can use here
     $enrol_object = $CFG;
     if (!empty($course)) {
         $enrol_object = $course;
     }
     // If the print_entry method exists and the course enrol method isn't manual (both set or inherited from site), show cost
     if (method_exists(enrolment_factory::factory($enrol_object->enrol), 'print_entry') && !($enrol_object->enrol == 'manual' || empty($enrol_object->enrol) && $CFG->enrol == 'manual')) {
         $costgroup = array();
         $currencies = get_list_of_currencies();
         $costgroup[] =& MoodleQuickForm::createElement('text', 'cost', '', 'maxlength="6" size="6"');
         $costgroup[] =& MoodleQuickForm::createElement('select', 'currency', '', $currencies);
         $mform->addGroup($costgroup, 'costgrp', get_string('cost'), '&nbsp;', false);
         //defining a rule for a form element within a group :
         $costgrprules = array();
         //set the message to null to tell Moodle to use a default message
         //available for most rules, fetched from language pack (err_{rulename}).
         $costgrprules['cost'][] = array(null, 'numeric', null, 'client');
         $mform->addGroupRule('costgrp', $costgrprules);
         $mform->setHelpButton('costgrp', array('cost', get_string('cost')), true);
         $mform->setDefault('cost', '');
         $mform->setDefault('currency', empty($CFG->enrol_currency) ? 'USD' : $CFG->enrol_currency);
     }
     //--------------------------------------------------------------------------------
     $mform->addElement('header', '', get_string('language'));
     $languages = array();
     $languages[''] = get_string('forceno');
     $languages += get_list_of_languages();
     $mform->addElement('select', 'lang', get_string('forcelanguage'), $languages);
     $mform->setDefault('lang', $courseconfig->lang);
     //--------------------------------------------------------------------------------
     require_once $CFG->libdir . '/completionlib.php';
     if (completion_info::is_enabled_for_site()) {
         $mform->addElement('header', '', get_string('progress', 'completion'));
         $mform->addElement('select', 'enablecompletion', get_string('completion', 'completion'), array(0 => get_string('completiondisabled', 'completion'), 1 => get_string('completionenabled', 'completion')));
         $mform->setDefault('enablecompletion', $courseconfig->enablecompletion);
     } else {
         $mform->addElement('hidden', 'enablecompletion');
         $mform->setDefault('enablecompletion', 0);
     }
     //--------------------------------------------------------------------------------
     if (has_capability('moodle/site:config', $systemcontext) && (!empty($course->requested) && $CFG->restrictmodulesfor == 'requested' || $CFG->restrictmodulesfor == 'all')) {
         $mform->addElement('header', '', get_string('restrictmodules'));
         $options = array();
         $options['0'] = get_string('no');
         $options['1'] = get_string('yes');
         $mform->addElement('select', 'restrictmodules', get_string('restrictmodules'), $options);
         $mods = array(0 => get_string('allownone'));
         $mods += $DB->get_records_menu('modules', array(), 'name', 'id, name');
         $mform->addElement('select', 'allowedmods', get_string('to'), $mods, array('multiple' => 'multiple', 'size' => '10'));
         $mform->disabledIf('allowedmods', 'restrictmodules', 'eq', 0);
     } else {
         $mform->addElement('hidden', 'restrictmodules', null);
     }
     if ($CFG->restrictmodulesfor == 'all') {
         $mform->setDefault('allowedmods', explode(',', $CFG->defaultallowedmodules));
         if (!empty($CFG->restrictbydefault)) {
             $mform->setDefault('restrictmodules', 1);
         }
     }
     $mform->setType('restrictmodules', PARAM_INT);
     /// customizable role names in this course
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'rolerenaming', get_string('rolerenaming'));
     $mform->setHelpButton('rolerenaming', array('rolerenaming', get_string('rolerenaming')), true);
     if ($roles = get_all_roles()) {
         if ($coursecontext) {
             $roles = role_fix_names($roles, $coursecontext, ROLENAME_ALIAS_RAW);
         }
         $assignableroles = get_roles_for_contextlevels(CONTEXT_COURSE);
         foreach ($roles as $role) {
             $mform->addElement('text', 'role_' . $role->id, get_string('yourwordforx', '', $role->name));
             if (isset($role->localname)) {
                 $mform->setDefault('role_' . $role->id, $role->localname);
             }
             $mform->setType('role_' . $role->id, PARAM_TEXT);
             if (!in_array($role->id, $assignableroles)) {
                 $mform->setAdvanced('role_' . $role->id);
             }
         }
     }
     //--------------------------------------------------------------------------------
     $this->add_action_buttons();
     //--------------------------------------------------------------------------------
     $mform->addElement('hidden', 'id', null);
     $mform->setType('id', PARAM_INT);
 }
Example #30
0
    function definition() {
        global $USER, $CFG, $DB;

        $mform    = $this->_form;

        $course        = $this->_customdata['course']; // this contains the data of this form
        $category      = $this->_customdata['category'];
        $editoroptions = $this->_customdata['editoroptions'];
        $returnto = $this->_customdata['returnto'];

        $systemcontext   = get_context_instance(CONTEXT_SYSTEM);
        $categorycontext = get_context_instance(CONTEXT_COURSECAT, $category->id);

        if (!empty($course->id)) {
            $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
            $context = $coursecontext;
        } else {
            $coursecontext = null;
            $context = $categorycontext;
        }

        $courseconfig = get_config('moodlecourse');

        $this->course  = $course;
        $this->context = $context;

/// form definition with new course defaults
//--------------------------------------------------------------------------------
        $mform->addElement('header','general', get_string('general', 'form'));

        $mform->addElement('hidden', 'returnto', null);
        $mform->setType('returnto', PARAM_ALPHANUM);
        $mform->setConstant('returnto', $returnto);

        // verify permissions to change course category or keep current
        if (empty($course->id)) {
            if (has_capability('moodle/course:create', $categorycontext)) {
                $displaylist = array();
                $parentlist = array();
                make_categories_list($displaylist, $parentlist, 'moodle/course:create');
                $mform->addElement('select', 'category', get_string('category'), $displaylist);
                $mform->addHelpButton('category', 'category');
                $mform->setDefault('category', $category->id);
            } else {
                $mform->addElement('hidden', 'category', null);
                $mform->setType('category', PARAM_INT);
                $mform->setConstant('category', $category->id);
            }
        } else {
            if (has_capability('moodle/course:changecategory', $coursecontext)) {
                $displaylist = array();
                $parentlist = array();
                make_categories_list($displaylist, $parentlist, 'moodle/course:create');
                if (!isset($displaylist[$course->category])) {
                    //always keep current
                    $displaylist[$course->category] = format_string($DB->get_field('course_categories', 'name', array('id'=>$course->category)));
                }
                $mform->addElement('select', 'category', get_string('category'), $displaylist);
                $mform->addHelpButton('category', 'category');
            } else {
                //keep current
                $mform->addElement('hidden', 'category', null);
                $mform->setType('category', PARAM_INT);
                $mform->setConstant('category', $course->category);
            }
        }

        $mform->addElement('text','fullname', get_string('fullnamecourse'),'maxlength="254" size="50"');
        $mform->addHelpButton('fullname', 'fullnamecourse');
        $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client');
        $mform->setType('fullname', PARAM_MULTILANG);
        if (!empty($course->id) and !has_capability('moodle/course:changefullname', $coursecontext)) {
            $mform->hardFreeze('fullname');
            $mform->setConstant('fullname', $course->fullname);
        }

        $mform->addElement('text', 'shortname', get_string('shortnamecourse'), 'maxlength="100" size="20"');
        $mform->addHelpButton('shortname', 'shortnamecourse');
        $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
        $mform->setType('shortname', PARAM_MULTILANG);
        if (!empty($course->id) and !has_capability('moodle/course:changeshortname', $coursecontext)) {
            $mform->hardFreeze('shortname');
            $mform->setConstant('shortname', $course->shortname);
        }

        $mform->addElement('text','idnumber', get_string('idnumbercourse'),'maxlength="100"  size="10"');
        $mform->addHelpButton('idnumber', 'idnumbercourse');
        $mform->setType('idnumber', PARAM_RAW);
        if (!empty($course->id) and !has_capability('moodle/course:changeidnumber', $coursecontext)) {
            $mform->hardFreeze('idnumber');
            $mform->setConstants('idnumber', $course->idnumber);
        }


        $mform->addElement('editor','summary_editor', get_string('coursesummary'), null, $editoroptions);
        $mform->addHelpButton('summary_editor', 'coursesummary');
        $mform->setType('summary_editor', PARAM_RAW);

        if (!empty($course->id) and !has_capability('moodle/course:changesummary', $coursecontext)) {
            $mform->hardFreeze('summary_editor');
        }

        $courseformats = get_plugin_list('format');
        $formcourseformats = array();
        foreach ($courseformats as $courseformat => $formatdir) {
            $formcourseformats[$courseformat] = get_string('pluginname', "format_$courseformat");
        }
        $mform->addElement('select', 'format', get_string('format'), $formcourseformats);
        $mform->addHelpButton('format', 'format');
        $mform->setDefault('format', $courseconfig->format);

        for ($i=1; $i<=52; $i++) {
          $sectionmenu[$i] = "$i";
        }
        $mform->addElement('select', 'numsections', get_string('numberweeks'), $sectionmenu);
        $mform->setDefault('numsections', $courseconfig->numsections);

        $mform->addElement('date_selector', 'startdate', get_string('startdate'));
        $mform->addHelpButton('startdate', 'startdate');
        $mform->setDefault('startdate', time() + 3600 * 24);

        $choices = array();
        $choices['0'] = get_string('hiddensectionscollapsed');
        $choices['1'] = get_string('hiddensectionsinvisible');
        $mform->addElement('select', 'hiddensections', get_string('hiddensections'), $choices);
        $mform->addHelpButton('hiddensections', 'hiddensections');
        $mform->setDefault('hiddensections', $courseconfig->hiddensections);

        $options = range(0, 10);
        $mform->addElement('select', 'newsitems', get_string('newsitemsnumber'), $options);
        $mform->addHelpButton('newsitems', 'newsitemsnumber');
        $mform->setDefault('newsitems', $courseconfig->newsitems);

        $mform->addElement('selectyesno', 'showgrades', get_string('showgrades'));
        $mform->addHelpButton('showgrades', 'showgrades');
        $mform->setDefault('showgrades', $courseconfig->showgrades);

        $mform->addElement('selectyesno', 'showreports', get_string('showreports'));
        $mform->addHelpButton('showreports', 'showreports');
        $mform->setDefault('showreports', $courseconfig->showreports);

        $choices = get_max_upload_sizes($CFG->maxbytes);
        $mform->addElement('select', 'maxbytes', get_string('maximumupload'), $choices);
        $mform->addHelpButton('maxbytes', 'maximumupload');
        $mform->setDefault('maxbytes', $courseconfig->maxbytes);

        if (!empty($course->legacyfiles) or !empty($CFG->legacyfilesinnewcourses)) {
            if (empty($course->legacyfiles)) {
                //0 or missing means no legacy files ever used in this course - new course or nobody turned on legacy files yet
                $choices = array('0'=>get_string('no'), '2'=>get_string('yes'));
            } else {
                $choices = array('1'=>get_string('no'), '2'=>get_string('yes'));
            }
            $mform->addElement('select', 'legacyfiles', get_string('courselegacyfiles'), $choices);
            $mform->addHelpButton('legacyfiles', 'courselegacyfiles');
            if (!isset($courseconfig->legacyfiles)) {
                // in case this was not initialised properly due to switching of $CFG->legacyfilesinnewcourses
                $courseconfig->legacyfiles = 0;
            }
            $mform->setDefault('legacyfiles', $courseconfig->legacyfiles);
        }

        if (!empty($CFG->allowcoursethemes)) {
            $themeobjects = get_list_of_themes();
            $themes=array();
            $themes[''] = get_string('forceno');
            foreach ($themeobjects as $key=>$theme) {
                $themes[$key] = $theme->name;
            }
            $mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
        }

//--------------------------------------------------------------------------------
        enrol_course_edit_form($mform, $course, $context);

//--------------------------------------------------------------------------------
        $mform->addElement('header','', get_string('groups', 'group'));

        $choices = array();
        $choices[NOGROUPS] = get_string('groupsnone', 'group');
        $choices[SEPARATEGROUPS] = get_string('groupsseparate', 'group');
        $choices[VISIBLEGROUPS] = get_string('groupsvisible', 'group');
        $mform->addElement('select', 'groupmode', get_string('groupmode', 'group'), $choices);
        $mform->addHelpButton('groupmode', 'groupmode', 'group');
        $mform->setDefault('groupmode', $courseconfig->groupmode);

        $choices = array();
        $choices['0'] = get_string('no');
        $choices['1'] = get_string('yes');
        $mform->addElement('select', 'groupmodeforce', get_string('groupmodeforce', 'group'), $choices);
        $mform->addHelpButton('groupmodeforce', 'groupmodeforce', 'group');
        $mform->setDefault('groupmodeforce', $courseconfig->groupmodeforce);

        //default groupings selector
        $options = array();
        $options[0] = get_string('none');
        $mform->addElement('select', 'defaultgroupingid', get_string('defaultgrouping', 'group'), $options);

//--------------------------------------------------------------------------------
        $mform->addElement('header','', get_string('availability'));

        $choices = array();
        $choices['0'] = get_string('courseavailablenot');
        $choices['1'] = get_string('courseavailable');
        $mform->addElement('select', 'visible', get_string('availability'), $choices);
        $mform->addHelpButton('visible', 'availability');
        $mform->setDefault('visible', $courseconfig->visible);
        if (!has_capability('moodle/course:visibility', $context)) {
            $mform->hardFreeze('visible');
            if (!empty($course->id)) {
                $mform->setConstant('visible', $course->visible);
            } else {
                $mform->setConstant('visible', $category->visible);
            }
        }

//--------------------------------------------------------------------------------
        $mform->addElement('header','', get_string('language'));

        $languages=array();
        $languages[''] = get_string('forceno');
        $languages += get_string_manager()->get_list_of_translations();
        $mform->addElement('select', 'lang', get_string('forcelanguage'), $languages);
        $mform->setDefault('lang', $courseconfig->lang);

//--------------------------------------------------------------------------------
        if (completion_info::is_enabled_for_site()) {
            $mform->addElement('header','', get_string('progress','completion'));
            $mform->addElement('select', 'enablecompletion', get_string('completion','completion'),
                array(0=>get_string('completiondisabled','completion'), 1=>get_string('completionenabled','completion')));
            $mform->setDefault('enablecompletion', $courseconfig->enablecompletion);

            $mform->addElement('checkbox', 'completionstartonenrol', get_string('completionstartonenrol', 'completion'));
            $mform->setDefault('completionstartonenrol', $courseconfig->completionstartonenrol);
            $mform->disabledIf('completionstartonenrol', 'enablecompletion', 'eq', 0);
        } else {
            $mform->addElement('hidden', 'enablecompletion');
            $mform->setType('enablecompletion', PARAM_INT);
            $mform->setDefault('enablecompletion',0);

            $mform->addElement('hidden', 'completionstartonenrol');
            $mform->setType('completionstartonenrol', PARAM_INT);
            $mform->setDefault('completionstartonenrol',0);
        }

//--------------------------------------------------------------------------------
        if (has_capability('moodle/site:config', $systemcontext)) {
            if (((!empty($course->requested) && $CFG->restrictmodulesfor == 'requested') || $CFG->restrictmodulesfor == 'all')) {
                $mform->addElement('header', '', get_string('restrictmodules'));

                $options = array();
                $options['0'] = get_string('no');
                $options['1'] = get_string('yes');
                $mform->addElement('select', 'restrictmodules', get_string('restrictmodules'), $options);
                if (!empty($CFG->restrictbydefault)) {
                    $mform->setDefault('restrictmodules', 1);
                }

                $mods = array(0=>get_string('allownone'));
                $mods += $DB->get_records_menu('modules', array('visible'=>1), 'name', 'id, name');
                $mform->addElement('select', 'allowedmods', get_string('to'), $mods, array('multiple'=>'multiple', 'size'=>'10'));
                $mform->disabledIf('allowedmods', 'restrictmodules', 'eq', 0);
                // defaults are already in $course
            } else {
                // remove any mod restriction
                $mform->addElement('hidden', 'restrictmodules', 0);
                $mform->setType('restrictmodules', PARAM_INT);
            }
        } else {
            $mform->addElement('hidden', 'restrictmodules');
            $mform->setType('restrictmodules', PARAM_INT);
            if (empty($course->id)) {
                $mform->setConstant('restrictmodules', (int)($CFG->restrictmodulesfor == 'all'));
            } else {
                // keep previous
                $mform->setConstant('restrictmodules', $course->restrictmodules);
            }
        }

/// customizable role names in this course
//--------------------------------------------------------------------------------
        $mform->addElement('header','rolerenaming', get_string('rolerenaming'));
        $mform->addHelpButton('rolerenaming', 'rolerenaming');

        if ($roles = get_all_roles()) {
            if ($coursecontext) {
                $roles = role_fix_names($roles, $coursecontext, ROLENAME_ALIAS_RAW);
            }
            $assignableroles = get_roles_for_contextlevels(CONTEXT_COURSE);
            foreach ($roles as $role) {
                $mform->addElement('text', 'role_'.$role->id, get_string('yourwordforx', '', $role->name));
                if (isset($role->localname)) {
                    $mform->setDefault('role_'.$role->id, $role->localname);
                }
                $mform->setType('role_'.$role->id, PARAM_TEXT);
                if (!in_array($role->id, $assignableroles)) {
                    $mform->setAdvanced('role_'.$role->id);
                }
            }
        }

//--------------------------------------------------------------------------------
        $this->add_action_buttons();
//--------------------------------------------------------------------------------
        $mform->addElement('hidden', 'id', null);
        $mform->setType('id', PARAM_INT);

/// finally set the current form data
//--------------------------------------------------------------------------------
        $this->set_data($course);
    }