2009-11-04 06:14:06 +00:00
|
|
|
<?php
|
2006-10-13 09:58:53 +00:00
|
|
|
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
defined('MOODLE_INTERNAL') || die;
|
2010-05-13 02:02:05 +00:00
|
|
|
|
2006-11-09 22:08:30 +00:00
|
|
|
require_once($CFG->libdir.'/formslib.php');
|
2010-11-17 06:23:56 +00:00
|
|
|
require_once($CFG->libdir.'/completionlib.php');
|
2013-02-21 10:37:52 +11:00
|
|
|
require_once($CFG->libdir. '/coursecatlib.php');
|
2006-11-09 22:08:30 +00:00
|
|
|
|
2006-10-13 09:58:53 +00:00
|
|
|
class course_edit_form extends moodleform {
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
protected $course;
|
|
|
|
protected $context;
|
2006-10-13 09:58:53 +00:00
|
|
|
|
|
|
|
function definition() {
|
2012-10-11 13:31:55 +08:00
|
|
|
global $USER, $CFG, $DB, $PAGE;
|
2006-10-13 09:58:53 +00:00
|
|
|
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
$mform = $this->_form;
|
2012-10-11 13:31:55 +08:00
|
|
|
$PAGE->requires->yui_module('moodle-course-formatchooser', 'M.course.init_formatchooser',
|
|
|
|
array(array('formid' => $mform->getAttribute('id'))));
|
2006-10-13 09:58:53 +00:00
|
|
|
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
$course = $this->_customdata['course']; // this contains the data of this form
|
|
|
|
$category = $this->_customdata['category'];
|
2009-11-04 06:14:06 +00:00
|
|
|
$editoroptions = $this->_customdata['editoroptions'];
|
2010-07-16 07:10:49 +00:00
|
|
|
$returnto = $this->_customdata['returnto'];
|
2006-10-13 09:58:53 +00:00
|
|
|
|
2012-07-23 15:59:04 +08:00
|
|
|
$systemcontext = context_system::instance();
|
|
|
|
$categorycontext = context_coursecat::instance($category->id);
|
2006-10-13 09:58:53 +00:00
|
|
|
|
2009-11-04 06:14:06 +00:00
|
|
|
if (!empty($course->id)) {
|
2012-07-23 15:59:04 +08:00
|
|
|
$coursecontext = context_course::instance($course->id);
|
2006-10-13 09:58:53 +00:00
|
|
|
$context = $coursecontext;
|
2006-10-10 07:05:19 +00:00
|
|
|
} else {
|
2006-10-13 09:58:53 +00:00
|
|
|
$coursecontext = null;
|
|
|
|
$context = $categorycontext;
|
|
|
|
}
|
2009-11-04 08:11:02 +00:00
|
|
|
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
$courseconfig = get_config('moodlecourse');
|
|
|
|
|
|
|
|
$this->course = $course;
|
|
|
|
$this->context = $context;
|
|
|
|
|
2006-10-13 09:58:53 +00:00
|
|
|
/// form definition with new course defaults
|
|
|
|
//--------------------------------------------------------------------------------
|
2006-11-07 08:48:18 +00:00
|
|
|
$mform->addElement('header','general', get_string('general', 'form'));
|
2006-10-13 09:58:53 +00:00
|
|
|
|
2010-07-16 07:10:49 +00:00
|
|
|
$mform->addElement('hidden', 'returnto', null);
|
|
|
|
$mform->setType('returnto', PARAM_ALPHANUM);
|
|
|
|
$mform->setConstant('returnto', $returnto);
|
|
|
|
|
2013-04-17 13:12:36 +08:00
|
|
|
$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.
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
if (empty($course->id)) {
|
|
|
|
if (has_capability('moodle/course:create', $categorycontext)) {
|
2013-02-21 10:37:52 +11:00
|
|
|
$displaylist = coursecat::make_categories_list('moodle/course:create');
|
2013-04-17 13:12:36 +08:00
|
|
|
$mform->addElement('select', 'category', get_string('coursecategory'), $displaylist);
|
|
|
|
$mform->addHelpButton('category', 'coursecategory');
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
$mform->setDefault('category', $category->id);
|
|
|
|
} else {
|
|
|
|
$mform->addElement('hidden', 'category', null);
|
|
|
|
$mform->setType('category', PARAM_INT);
|
|
|
|
$mform->setConstant('category', $category->id);
|
|
|
|
}
|
2006-10-13 09:58:53 +00:00
|
|
|
} else {
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
if (has_capability('moodle/course:changecategory', $coursecontext)) {
|
2013-02-21 10:37:52 +11:00
|
|
|
$displaylist = coursecat::make_categories_list('moodle/course:create');
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
if (!isset($displaylist[$course->category])) {
|
|
|
|
//always keep current
|
2013-06-07 13:55:19 +10:00
|
|
|
$displaylist[$course->category] = coursecat::get($course->category, MUST_EXIST, true)->get_formatted_name();
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
}
|
2013-04-17 13:12:36 +08:00
|
|
|
$mform->addElement('select', 'category', get_string('coursecategory'), $displaylist);
|
|
|
|
$mform->addHelpButton('category', 'coursecategory');
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
} else {
|
|
|
|
//keep current
|
|
|
|
$mform->addElement('hidden', 'category', null);
|
|
|
|
$mform->setType('category', PARAM_INT);
|
|
|
|
$mform->setConstant('category', $course->category);
|
|
|
|
}
|
2009-10-02 07:05:02 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 13:12:36 +08:00
|
|
|
$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);
|
|
|
|
}
|
|
|
|
}
|
2009-11-04 08:11:02 +00:00
|
|
|
|
2013-04-17 13:12:36 +08:00
|
|
|
$mform->addElement('date_selector', 'startdate', get_string('startdate'));
|
|
|
|
$mform->addHelpButton('startdate', 'startdate');
|
|
|
|
$mform->setDefault('startdate', time() + 3600 * 24);
|
2013-03-28 12:18:32 +11:00
|
|
|
|
2013-04-17 15:11:58 +08:00
|
|
|
$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);
|
2013-03-28 12:18:32 +11:00
|
|
|
}
|
2006-10-13 09:58:53 +00:00
|
|
|
|
2013-04-17 15:11:58 +08:00
|
|
|
// Description.
|
|
|
|
$mform->addElement('header', 'descriptionhdr', get_string('description'));
|
|
|
|
$mform->setExpanded('descriptionhdr');
|
2013-04-17 13:12:36 +08:00
|
|
|
|
2013-04-17 15:11:58 +08:00
|
|
|
$mform->addElement('editor','summary_editor', get_string('coursesummary'), null, $editoroptions);
|
|
|
|
$mform->addHelpButton('summary_editor', 'coursesummary');
|
|
|
|
$mform->setType('summary_editor', PARAM_RAW);
|
|
|
|
$summaryfields = 'summary_editor';
|
2013-04-17 13:12:36 +08:00
|
|
|
|
2013-04-17 15:11:58 +08:00
|
|
|
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'));
|
2009-10-02 07:05:02 +00:00
|
|
|
|
2012-10-18 16:03:11 +08:00
|
|
|
$courseformats = get_sorted_course_formats(true);
|
2006-10-13 09:58:53 +00:00
|
|
|
$formcourseformats = array();
|
2012-10-18 16:03:11 +08:00
|
|
|
foreach ($courseformats as $courseformat) {
|
MDL-22054 converting course formats to have own lang packs
AMOS START
MOV [formatscorm,core],[pluginname,format_scorm]
MOV [formatsocial,core],[pluginname,format_social]
MOV [formattopics,core],[pluginname,format_topics]
MOV [formatweeks,core],[pluginname,format_weeks]
AMOS END
2010-04-11 12:46:14 +00:00
|
|
|
$formcourseformats[$courseformat] = get_string('pluginname', "format_$courseformat");
|
2006-10-13 09:58:53 +00:00
|
|
|
}
|
2012-10-18 16:03:11 +08:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-13 09:58:53 +00:00
|
|
|
$mform->addElement('select', 'format', get_string('format'), $formcourseformats);
|
MDL-21695 Course settings page help strings
Many of them are missing at the moment, Helen shall fix that soon
AMOS BEGIN
HLP courseavailability.html,[availability_help,core]
HLP coursecategory.html,[category_help,core]
HLP courseenrollable2.html,[enrollable_help,core]
HLP courseenrolmentplugins.html,[enrolmentplugins_help,core]
HLP courseformats.html,[format_help,core]
HLP coursegrades.html,[showgrades_help,core]
HLP coursehiddensections.html,[hiddensections_help,core]
HLP courseidnumber.html,[idnumbercourse_help,core]
HLP coursenewsitems.html,[newsitemsnumber_help,core]
HLP coursereports.html,[showreports_help,core]
HLP courseshortname.html,[shortnamecourse_help,core]
HLP coursestartdate.html,[startdate_help,core]
HLP courseuploadsize.html,[maximumupload_help,core]
HLP expirynotify.html,[expirynotify_help,core]
HLP expirynotifystudents.html,[expirynotifystudents_help,core]
HLP expirythreshold.html,[expirythreshold_help,core]
HLP groupmodeforce.html,[groupmodeforce_help,core]
HLP groupmode.html,[groupmode_help,core]
HLP metacourse.html,[managemeta_help,core]
HLP rolerenaming.html,[rolerenaming_help,core]
AMOS END
2010-05-03 17:07:51 +00:00
|
|
|
$mform->addHelpButton('format', 'format');
|
2008-09-25 07:33:22 +00:00
|
|
|
$mform->setDefault('format', $courseconfig->format);
|
2006-10-13 09:58:53 +00:00
|
|
|
|
2013-04-17 13:12:36 +08:00
|
|
|
// Button to update format-specific options on format change (will be hidden by JavaScript).
|
2012-10-11 13:31:55 +08:00
|
|
|
$mform->registerNoSubmitButton('updatecourseformat');
|
|
|
|
$mform->addElement('submit', 'updatecourseformat', get_string('courseformatudpate'));
|
|
|
|
|
2013-04-17 13:12:36 +08:00
|
|
|
// Just a placeholder for the course format options.
|
|
|
|
$mform->addElement('hidden', 'addcourseformatoptionshere');
|
|
|
|
$mform->setType('addcourseformatoptionshere', PARAM_BOOL);
|
|
|
|
|
2013-04-17 15:11:58 +08:00
|
|
|
// Appearance.
|
|
|
|
$mform->addElement('header', 'appearancehdr', get_string('appearance'));
|
|
|
|
|
2013-04-17 13:12:36 +08:00
|
|
|
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);
|
2006-10-13 09:58:53 +00:00
|
|
|
|
2007-01-21 09:26:33 +00:00
|
|
|
$options = range(0, 10);
|
2006-10-13 09:58:53 +00:00
|
|
|
$mform->addElement('select', 'newsitems', get_string('newsitemsnumber'), $options);
|
MDL-21695 Course settings page help strings
Many of them are missing at the moment, Helen shall fix that soon
AMOS BEGIN
HLP courseavailability.html,[availability_help,core]
HLP coursecategory.html,[category_help,core]
HLP courseenrollable2.html,[enrollable_help,core]
HLP courseenrolmentplugins.html,[enrolmentplugins_help,core]
HLP courseformats.html,[format_help,core]
HLP coursegrades.html,[showgrades_help,core]
HLP coursehiddensections.html,[hiddensections_help,core]
HLP courseidnumber.html,[idnumbercourse_help,core]
HLP coursenewsitems.html,[newsitemsnumber_help,core]
HLP coursereports.html,[showreports_help,core]
HLP courseshortname.html,[shortnamecourse_help,core]
HLP coursestartdate.html,[startdate_help,core]
HLP courseuploadsize.html,[maximumupload_help,core]
HLP expirynotify.html,[expirynotify_help,core]
HLP expirynotifystudents.html,[expirynotifystudents_help,core]
HLP expirythreshold.html,[expirythreshold_help,core]
HLP groupmodeforce.html,[groupmodeforce_help,core]
HLP groupmode.html,[groupmode_help,core]
HLP metacourse.html,[managemeta_help,core]
HLP rolerenaming.html,[rolerenaming_help,core]
AMOS END
2010-05-03 17:07:51 +00:00
|
|
|
$mform->addHelpButton('newsitems', 'newsitemsnumber');
|
2008-09-25 07:33:22 +00:00
|
|
|
$mform->setDefault('newsitems', $courseconfig->newsitems);
|
2006-10-13 09:58:53 +00:00
|
|
|
|
2007-01-21 09:26:33 +00:00
|
|
|
$mform->addElement('selectyesno', 'showgrades', get_string('showgrades'));
|
MDL-21695 Course settings page help strings
Many of them are missing at the moment, Helen shall fix that soon
AMOS BEGIN
HLP courseavailability.html,[availability_help,core]
HLP coursecategory.html,[category_help,core]
HLP courseenrollable2.html,[enrollable_help,core]
HLP courseenrolmentplugins.html,[enrolmentplugins_help,core]
HLP courseformats.html,[format_help,core]
HLP coursegrades.html,[showgrades_help,core]
HLP coursehiddensections.html,[hiddensections_help,core]
HLP courseidnumber.html,[idnumbercourse_help,core]
HLP coursenewsitems.html,[newsitemsnumber_help,core]
HLP coursereports.html,[showreports_help,core]
HLP courseshortname.html,[shortnamecourse_help,core]
HLP coursestartdate.html,[startdate_help,core]
HLP courseuploadsize.html,[maximumupload_help,core]
HLP expirynotify.html,[expirynotify_help,core]
HLP expirynotifystudents.html,[expirynotifystudents_help,core]
HLP expirythreshold.html,[expirythreshold_help,core]
HLP groupmodeforce.html,[groupmodeforce_help,core]
HLP groupmode.html,[groupmode_help,core]
HLP metacourse.html,[managemeta_help,core]
HLP rolerenaming.html,[rolerenaming_help,core]
AMOS END
2010-05-03 17:07:51 +00:00
|
|
|
$mform->addHelpButton('showgrades', 'showgrades');
|
2008-09-25 07:33:22 +00:00
|
|
|
$mform->setDefault('showgrades', $courseconfig->showgrades);
|
2006-10-13 09:58:53 +00:00
|
|
|
|
2007-01-21 09:26:33 +00:00
|
|
|
$mform->addElement('selectyesno', 'showreports', get_string('showreports'));
|
MDL-21695 Course settings page help strings
Many of them are missing at the moment, Helen shall fix that soon
AMOS BEGIN
HLP courseavailability.html,[availability_help,core]
HLP coursecategory.html,[category_help,core]
HLP courseenrollable2.html,[enrollable_help,core]
HLP courseenrolmentplugins.html,[enrolmentplugins_help,core]
HLP courseformats.html,[format_help,core]
HLP coursegrades.html,[showgrades_help,core]
HLP coursehiddensections.html,[hiddensections_help,core]
HLP courseidnumber.html,[idnumbercourse_help,core]
HLP coursenewsitems.html,[newsitemsnumber_help,core]
HLP coursereports.html,[showreports_help,core]
HLP courseshortname.html,[shortnamecourse_help,core]
HLP coursestartdate.html,[startdate_help,core]
HLP courseuploadsize.html,[maximumupload_help,core]
HLP expirynotify.html,[expirynotify_help,core]
HLP expirynotifystudents.html,[expirynotifystudents_help,core]
HLP expirythreshold.html,[expirythreshold_help,core]
HLP groupmodeforce.html,[groupmodeforce_help,core]
HLP groupmode.html,[groupmode_help,core]
HLP metacourse.html,[managemeta_help,core]
HLP rolerenaming.html,[rolerenaming_help,core]
AMOS END
2010-05-03 17:07:51 +00:00
|
|
|
$mform->addHelpButton('showreports', 'showreports');
|
2008-09-25 07:33:22 +00:00
|
|
|
$mform->setDefault('showreports', $courseconfig->showreports);
|
2006-10-13 09:58:53 +00:00
|
|
|
|
2013-04-17 15:11:58 +08:00
|
|
|
// Files and uploads.
|
|
|
|
$mform->addElement('header', 'filehdr', get_string('filesanduploads'));
|
|
|
|
|
2010-09-03 12:00:59 +00:00
|
|
|
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'));
|
|
|
|
}
|
2010-05-22 13:10:05 +00:00
|
|
|
$mform->addElement('select', 'legacyfiles', get_string('courselegacyfiles'), $choices);
|
|
|
|
$mform->addHelpButton('legacyfiles', 'courselegacyfiles');
|
2010-09-22 08:18:18 +00:00
|
|
|
if (!isset($courseconfig->legacyfiles)) {
|
|
|
|
// in case this was not initialised properly due to switching of $CFG->legacyfilesinnewcourses
|
|
|
|
$courseconfig->legacyfiles = 0;
|
|
|
|
}
|
2010-09-10 03:58:54 +00:00
|
|
|
$mform->setDefault('legacyfiles', $courseconfig->legacyfiles);
|
2010-05-22 13:10:05 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 15:11:58 +08:00
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
2007-07-18 08:57:28 +00:00
|
|
|
//--------------------------------------------------------------------------------
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
enrol_course_edit_form($mform, $course, $context);
|
2006-10-13 09:58:53 +00:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------
|
2013-03-28 11:44:32 +08:00
|
|
|
$mform->addElement('header','groups', get_string('groupsettingsheader', 'group'));
|
2006-10-13 09:58:53 +00:00
|
|
|
|
|
|
|
$choices = array();
|
2007-10-29 09:47:13 +00:00
|
|
|
$choices[NOGROUPS] = get_string('groupsnone', 'group');
|
|
|
|
$choices[SEPARATEGROUPS] = get_string('groupsseparate', 'group');
|
|
|
|
$choices[VISIBLEGROUPS] = get_string('groupsvisible', 'group');
|
2010-05-04 10:07:47 +00:00
|
|
|
$mform->addElement('select', 'groupmode', get_string('groupmode', 'group'), $choices);
|
|
|
|
$mform->addHelpButton('groupmode', 'groupmode', 'group');
|
2008-09-25 07:33:22 +00:00
|
|
|
$mform->setDefault('groupmode', $courseconfig->groupmode);
|
2006-10-13 09:58:53 +00:00
|
|
|
|
2013-04-17 13:12:36 +08:00
|
|
|
$mform->addElement('selectyesno', 'groupmodeforce', get_string('groupmodeforce', 'group'));
|
2010-05-04 10:07:47 +00:00
|
|
|
$mform->addHelpButton('groupmodeforce', 'groupmodeforce', 'group');
|
2008-09-25 07:33:22 +00:00
|
|
|
$mform->setDefault('groupmodeforce', $courseconfig->groupmodeforce);
|
2006-10-13 09:58:53 +00:00
|
|
|
|
2010-04-07 07:37:12 +00:00
|
|
|
//default groupings selector
|
|
|
|
$options = array();
|
|
|
|
$options[0] = get_string('none');
|
|
|
|
$mform->addElement('select', 'defaultgroupingid', get_string('defaultgrouping', 'group'), $options);
|
2007-08-17 08:05:04 +00:00
|
|
|
|
2006-10-13 09:58:53 +00:00
|
|
|
//--------------------------------------------------------------------------------
|
2008-07-28 12:31:29 +00:00
|
|
|
|
2007-03-22 08:11:30 +00:00
|
|
|
/// customizable role names in this course
|
|
|
|
//--------------------------------------------------------------------------------
|
2008-05-13 06:16:51 +00:00
|
|
|
$mform->addElement('header','rolerenaming', get_string('rolerenaming'));
|
MDL-21695 Course settings page help strings
Many of them are missing at the moment, Helen shall fix that soon
AMOS BEGIN
HLP courseavailability.html,[availability_help,core]
HLP coursecategory.html,[category_help,core]
HLP courseenrollable2.html,[enrollable_help,core]
HLP courseenrolmentplugins.html,[enrolmentplugins_help,core]
HLP courseformats.html,[format_help,core]
HLP coursegrades.html,[showgrades_help,core]
HLP coursehiddensections.html,[hiddensections_help,core]
HLP courseidnumber.html,[idnumbercourse_help,core]
HLP coursenewsitems.html,[newsitemsnumber_help,core]
HLP coursereports.html,[showreports_help,core]
HLP courseshortname.html,[shortnamecourse_help,core]
HLP coursestartdate.html,[startdate_help,core]
HLP courseuploadsize.html,[maximumupload_help,core]
HLP expirynotify.html,[expirynotify_help,core]
HLP expirynotifystudents.html,[expirynotifystudents_help,core]
HLP expirythreshold.html,[expirythreshold_help,core]
HLP groupmodeforce.html,[groupmodeforce_help,core]
HLP groupmode.html,[groupmode_help,core]
HLP metacourse.html,[managemeta_help,core]
HLP rolerenaming.html,[rolerenaming_help,core]
AMOS END
2010-05-03 17:07:51 +00:00
|
|
|
$mform->addHelpButton('rolerenaming', 'rolerenaming');
|
2007-03-22 08:11:30 +00:00
|
|
|
|
2008-11-13 08:11:10 +00:00
|
|
|
if ($roles = get_all_roles()) {
|
2012-05-18 11:40:35 +02:00
|
|
|
$roles = role_fix_names($roles, null, ROLENAME_ORIGINAL);
|
2008-11-13 08:11:10 +00:00
|
|
|
$assignableroles = get_roles_for_contextlevels(CONTEXT_COURSE);
|
2007-03-22 08:11:30 +00:00
|
|
|
foreach ($roles as $role) {
|
2012-05-18 11:40:35 +02:00
|
|
|
$mform->addElement('text', 'role_'.$role->id, get_string('yourwordforx', '', $role->localname));
|
2008-11-13 08:11:10 +00:00
|
|
|
$mform->setType('role_'.$role->id, PARAM_TEXT);
|
2007-03-22 08:11:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-13 09:58:53 +00:00
|
|
|
//--------------------------------------------------------------------------------
|
2006-12-19 07:03:08 +00:00
|
|
|
$this->add_action_buttons();
|
2006-10-13 09:58:53 +00:00
|
|
|
//--------------------------------------------------------------------------------
|
|
|
|
$mform->addElement('hidden', 'id', null);
|
|
|
|
$mform->setType('id', PARAM_INT);
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
|
|
|
|
/// finally set the current form data
|
|
|
|
//--------------------------------------------------------------------------------
|
|
|
|
$this->set_data($course);
|
2006-10-16 12:07:44 +00:00
|
|
|
}
|
2006-11-28 08:04:00 +00:00
|
|
|
|
2007-08-17 08:05:04 +00:00
|
|
|
function definition_after_data() {
|
2008-05-30 16:47:21 +00:00
|
|
|
global $DB;
|
2007-08-17 08:05:04 +00:00
|
|
|
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
$mform = $this->_form;
|
2007-08-17 08:05:04 +00:00
|
|
|
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
// add available groupings
|
2007-08-17 08:05:04 +00:00
|
|
|
if ($courseid = $mform->getElementValue('id') and $mform->elementExists('defaultgroupingid')) {
|
|
|
|
$options = array();
|
2008-05-30 16:47:21 +00:00
|
|
|
if ($groupings = $DB->get_records('groupings', array('courseid'=>$courseid))) {
|
2007-08-17 08:05:04 +00:00
|
|
|
foreach ($groupings as $grouping) {
|
|
|
|
$options[$grouping->id] = format_string($grouping->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$gr_el =& $mform->getElement('defaultgroupingid');
|
|
|
|
$gr_el->load($options);
|
|
|
|
}
|
2008-10-08 13:23:35 +00:00
|
|
|
|
2012-10-11 13:31:55 +08:00
|
|
|
// add course format options
|
|
|
|
$formatvalue = $mform->getElementValue('format');
|
|
|
|
if (is_array($formatvalue) && !empty($formatvalue)) {
|
|
|
|
$courseformat = course_get_format((object)array('format' => $formatvalue[0]));
|
|
|
|
|
|
|
|
$elements = $courseformat->create_edit_form_elements($mform);
|
|
|
|
for ($i = 0; $i < count($elements); $i++) {
|
|
|
|
$mform->insertElementBefore($mform->removeElement($elements[$i]->getName(), false),
|
|
|
|
'addcourseformatoptionshere');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-10-13 09:58:53 +00:00
|
|
|
|
|
|
|
/// perform some extra moodle validation
|
2007-11-23 22:15:07 +00:00
|
|
|
function validation($data, $files) {
|
2008-12-06 21:20:42 +00:00
|
|
|
global $DB, $CFG;
|
2008-05-30 16:47:21 +00:00
|
|
|
|
2007-11-23 22:15:07 +00:00
|
|
|
$errors = parent::validation($data, $files);
|
2008-05-30 16:47:21 +00:00
|
|
|
if ($foundcourses = $DB->get_records('course', array('shortname'=>$data['shortname']))) {
|
2006-10-13 09:58:53 +00:00
|
|
|
if (!empty($data['id'])) {
|
|
|
|
unset($foundcourses[$data['id']]);
|
2006-09-24 17:14:44 +00:00
|
|
|
}
|
|
|
|
if (!empty($foundcourses)) {
|
|
|
|
foreach ($foundcourses as $foundcourse) {
|
|
|
|
$foundcoursenames[] = $foundcourse->fullname;
|
|
|
|
}
|
2006-10-13 09:58:53 +00:00
|
|
|
$foundcoursenamestring = implode(',', $foundcoursenames);
|
|
|
|
$errors['shortname']= get_string('shortnametaken', '', $foundcoursenamestring);
|
2006-09-24 17:14:44 +00:00
|
|
|
}
|
|
|
|
}
|
2006-10-13 09:58:53 +00:00
|
|
|
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
$errors = array_merge($errors, enrol_course_edit_validation($data, $this->context));
|
2008-12-06 21:20:42 +00:00
|
|
|
|
2012-10-11 13:31:55 +08:00
|
|
|
$courseformat = course_get_format((object)array('format' => $data['format']));
|
|
|
|
$formaterrors = $courseformat->edit_form_validation($data, $files, $errors);
|
|
|
|
if (!empty($formaterrors) && is_array($formaterrors)) {
|
|
|
|
$errors = array_merge($errors, $formaterrors);
|
|
|
|
}
|
|
|
|
|
2007-11-23 22:15:07 +00:00
|
|
|
return $errors;
|
2006-09-24 17:14:44 +00:00
|
|
|
}
|
2006-10-13 09:58:53 +00:00
|
|
|
}
|
2009-11-04 08:11:02 +00:00
|
|
|
|