mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-35843 prepare fox expiry refactoring to core enrol feature
AMOS BEGIN MOV [errorthresholdlow,enrol_manual],[errorthresholdlow,core_enrol] MOV [expirynotify,enrol_manual],[expirynotify,core_enrol] MOV [expirynotify_help,enrol_manual],[expirynotify_help,core_enrol] MOV [expirynotifyall,enrol_manual],[expirynotifyall,core_enrol] MOV [expirynotifyteacher,enrol_manual],[expirynotifyenroller,core_enrol] MOV [notifyhour,enrol_manual],[expirynotifyhour,core_enrol] MOV [expirythreshold,enrol_manual],[expirythreshold,core_enrol] MOV [expirythreshold_help,enrol_manual],[expirythreshold_help,core_enrol] AMOS END
This commit is contained in:
parent
7e8ae12a7a
commit
8e941204b2
@ -63,6 +63,6 @@ $plugin = enrol_get_plugin('manual');
|
||||
|
||||
$result = $plugin->sync(null, $verbose);
|
||||
|
||||
$plugin->send_notifications($verbose);
|
||||
$plugin->send_expiry_notifications($verbose);
|
||||
|
||||
exit($result);
|
||||
|
@ -38,6 +38,14 @@ function xmldb_enrol_manual_upgrade($oldversion) {
|
||||
upgrade_plugin_savepoint(true, 2012100702, 'enrol', 'manual');
|
||||
}
|
||||
|
||||
if ($oldversion < 2012101400) {
|
||||
// Delete obsoleted settings, now using expiry* prefix to make them more consistent.
|
||||
unset_config('notifylast', 'enrol_manual');
|
||||
unset_config('notifyhour', 'enrol_manual');
|
||||
upgrade_plugin_savepoint(true, 2012101400, 'enrol', 'manual');
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -54,12 +54,12 @@ class enrol_manual_edit_form extends moodleform {
|
||||
$mform->setDefault('enrolperiod', $plugin->get_config('enrolperiod'));
|
||||
$mform->addHelpButton('enrolperiod', 'defaultperiod', 'enrol_manual');
|
||||
|
||||
$options = array(0 => get_string('no'), 1 => get_string('expirynotifyteacher', 'enrol_manual'), 2 => get_string('expirynotifyall', 'enrol_manual'));
|
||||
$mform->addElement('select', 'expirynotify', get_string('expirynotify', 'enrol_manual'), $options);
|
||||
$mform->addHelpButton('expirynotify', 'expirynotify', 'enrol_manual');
|
||||
$options = array(0 => get_string('no'), 1 => get_string('expirynotifyenroller', 'core_enrol'), 2 => get_string('expirynotifyall', 'core_enrol'));
|
||||
$mform->addElement('select', 'expirynotify', get_string('expirynotify', 'core_enrol'), $options);
|
||||
$mform->addHelpButton('expirynotify', 'expirynotify', 'core_enrol');
|
||||
|
||||
$mform->addElement('duration', 'expirythreshold', get_string('expirythreshold', 'enrol_manual'), array('optional' => false, 'defaultunit' => 86400));
|
||||
$mform->addHelpButton('expirythreshold', 'expirythreshold', 'enrol_manual');
|
||||
$mform->addElement('duration', 'expirythreshold', get_string('expirythreshold', 'core_enrol'), array('optional' => false, 'defaultunit' => 86400));
|
||||
$mform->addHelpButton('expirythreshold', 'expirythreshold', 'core_enrol');
|
||||
$mform->disabledIf('expirythreshold', 'expirynotify', 'eq', 0);
|
||||
|
||||
$mform->addElement('hidden', 'courseid');
|
||||
@ -75,7 +75,7 @@ class enrol_manual_edit_form extends moodleform {
|
||||
$errors = parent::validation($data, $files);
|
||||
|
||||
if ($data['expirynotify'] > 0 and $data['expirythreshold'] < 86400) {
|
||||
$errors['expirythreshold'] = get_string('errorthresholdlow', 'enrol_manual');
|
||||
$errors['expirythreshold'] = get_string('errorthresholdlow', 'core_enrol');
|
||||
}
|
||||
|
||||
return $errors;
|
||||
|
@ -35,7 +35,6 @@ $string['editenrolment'] = 'Edit enrolment';
|
||||
$string['editselectedusers'] = 'Edit selected user enrolments';
|
||||
$string['enrolledincourserole'] = 'Enrolled in "{$a->course}" as "{$a->role}"';
|
||||
$string['enrolusers'] = 'Enrol users';
|
||||
$string['errorthresholdlow'] = 'Notification threshold must be at least 1 day.';
|
||||
$string['expiredaction'] = 'Enrolment expiration action';
|
||||
$string['expiredaction_help'] = 'Select action to carry out when user enrolment expires. Please note that some user data and settings are purged from course during course unenrolment.';
|
||||
$string['expirymessageenrollersubject'] = 'Enrolment expiry notification';
|
||||
@ -50,20 +49,12 @@ $string['expirymessageenrolledbody'] = 'Dear {$a->user},
|
||||
This is a notification that your enrolment in the course \'{$a->course}\' is due to expire on {$a->timeend}.
|
||||
|
||||
If you need help, please contact {$a->enroller}.';
|
||||
$string['expirynotify'] = 'Notify before enrolment expires';
|
||||
$string['expirynotify_help'] = 'This setting determines whether enrolment expiry notification messages are sent.';
|
||||
$string['expirynotifyall'] = 'Enroller and enrolled user';
|
||||
$string['expirynotifyteacher'] = 'Enroller only';
|
||||
$string['expirythreshold'] = 'Notification threshold';
|
||||
$string['expirythreshold_help'] = 'This setting specifies the number of days before enrolment expiry that a notification message is sent.';
|
||||
$string['expirythreshold_help'] = 'How long before expiration should be users notified?';
|
||||
$string['manual:config'] = 'Configure manual enrol instances';
|
||||
$string['manual:enrol'] = 'Enrol users';
|
||||
$string['manual:manage'] = 'Manage user enrolments';
|
||||
$string['manual:unenrol'] = 'Unenrol users from the course';
|
||||
$string['manual:unenrolself'] = 'Unenrol self from the course';
|
||||
$string['messageprovider:expiry_notification'] = 'Manual enrolment expiry notifications';
|
||||
$string['notifyhour'] = 'Hour to send enrolment expiry notifications';
|
||||
$string['pluginname'] = 'Manual enrolments';
|
||||
$string['pluginname_desc'] = 'The manual enrolments plugin allows users to be enrolled manually via a link in the course administration settings, by a user with appropriate permissions such as a teacher. The plugin should normally be enabled, since certain other enrolment plugins, such as self enrolment, require it.';
|
||||
$string['status'] = 'Enable manual enrolments';
|
||||
|
@ -280,7 +280,7 @@ class enrol_manual_plugin extends enrol_plugin {
|
||||
*/
|
||||
public function cron() {
|
||||
$this->sync(null, true);
|
||||
$this->send_notifications(true);
|
||||
$this->send_expiry_notifications(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -380,7 +380,7 @@ class enrol_manual_plugin extends enrol_plugin {
|
||||
*
|
||||
* @param bool $verbose verbose CLI output
|
||||
*/
|
||||
public function send_notifications($verbose = false) {
|
||||
public function send_expiry_notifications($verbose = false) {
|
||||
global $DB, $CFG;
|
||||
|
||||
// Unfortunately this may take a long time, it should not be interrupted,
|
||||
@ -389,15 +389,15 @@ class enrol_manual_plugin extends enrol_plugin {
|
||||
@set_time_limit(0);
|
||||
raise_memory_limit(MEMORY_HUGE);
|
||||
|
||||
$notifylast = $this->get_config('notifylast', 0);
|
||||
$notifyhour = $this->get_config('notifyhour', 6);
|
||||
$expirynotifylast = $this->get_config('expirynotifylast', 0);
|
||||
$expirynotifyhour = $this->get_config('expirynotifyhour', 6);
|
||||
$timenow = time();
|
||||
|
||||
$notifytime = usergetmidnight($timenow, $CFG->timezone) + ($notifyhour * 3600);
|
||||
$notifytime = usergetmidnight($timenow, $CFG->timezone) + ($expirynotifyhour * 3600);
|
||||
|
||||
if ($notifylast > $notifytime) {
|
||||
if ($expirynotifylast > $notifytime) {
|
||||
if ($verbose) {
|
||||
mtrace('Manual enrolment notifications were already sent today at '.userdate($notifylast, '', $CFG->timezone).'.');
|
||||
mtrace('Manual enrolment notifications were already sent today at '.userdate($expirynotifylast, '', $CFG->timezone).'.');
|
||||
}
|
||||
return;
|
||||
} else if ($timenow < $notifytime) {
|
||||
@ -463,7 +463,7 @@ class enrol_manual_plugin extends enrol_plugin {
|
||||
if ($verbose) {
|
||||
mtrace('...notification processing finished.');
|
||||
}
|
||||
$this->set_config('notifylast', $timenow);
|
||||
$this->set_config('expirynotifylast', $timenow);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,7 +42,7 @@ if ($ADMIN->fulltree) {
|
||||
for ($i=0; $i<24; $i++) {
|
||||
$options[$i] = $i;
|
||||
}
|
||||
$settings->add(new admin_setting_configselect('enrol_manual/notifyhour', get_string('notifyhour', 'enrol_manual'), '', 6, $options));
|
||||
$settings->add(new admin_setting_configselect('enrol_manual/expirynotifyhour', get_string('expirynotifyhour', 'core_enrol'), '', 6, $options));
|
||||
|
||||
|
||||
//--- enrol instance defaults ----------------------------------------------------------------------------
|
||||
@ -68,11 +68,11 @@ if ($ADMIN->fulltree) {
|
||||
$settings->add(new admin_setting_configduration('enrol_manual/enrolperiod',
|
||||
get_string('defaultperiod', 'enrol_manual'), get_string('defaultperiod_desc', 'enrol_manual'), 0));
|
||||
|
||||
$options = array(0 => get_string('no'), 1 => get_string('expirynotifyteacher', 'enrol_manual'), 2 => get_string('expirynotifyall', 'enrol_manual'));
|
||||
$options = array(0 => get_string('no'), 1 => get_string('expirynotifyenroller', 'core_enrol'), 2 => get_string('expirynotifyall', 'core_enrol'));
|
||||
$settings->add(new admin_setting_configselect('enrol_manual/expirynotify',
|
||||
get_string('expirynotify', 'enrol_manual'), get_string('expirynotify_help', 'enrol_manual'), 0, $options));
|
||||
get_string('expirynotify', 'core_enrol'), get_string('expirynotify_help', 'core_enrol'), 0, $options));
|
||||
|
||||
$settings->add(new admin_setting_configduration('enrol_manual/expirythreshold',
|
||||
get_string('expirythreshold', 'enrol_manual'), get_string('expirythreshold_help', 'enrol_manual'), 86400, 86400));
|
||||
get_string('expirythreshold', 'core_enrol'), get_string('expirythreshold_help', 'core_enrol'), 86400, 86400));
|
||||
|
||||
}
|
||||
|
@ -316,8 +316,8 @@ class enrol_manual_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Note: hopefully nobody executes the unit tests the last second before midnight...
|
||||
|
||||
$manualplugin->set_config('notifylast', $now - 60*60*24);
|
||||
$manualplugin->set_config('notifyhour', 0);
|
||||
$manualplugin->set_config('expirynotifylast', $now - 60*60*24);
|
||||
$manualplugin->set_config('expirynotifyhour', 0);
|
||||
|
||||
$studentrole = $DB->get_record('role', array('shortname'=>'student'));
|
||||
$this->assertNotEmpty($studentrole);
|
||||
@ -394,7 +394,7 @@ class enrol_manual_lib_testcase extends advanced_testcase {
|
||||
|
||||
$sink = $this->redirectMessages();
|
||||
|
||||
$manualplugin->send_notifications(false);
|
||||
$manualplugin->send_expiry_notifications(false);
|
||||
|
||||
$messages = $sink->get_messages();
|
||||
|
||||
@ -451,18 +451,18 @@ class enrol_manual_lib_testcase extends advanced_testcase {
|
||||
// Make sure that notifications are not repeated.
|
||||
$sink->clear();
|
||||
|
||||
$manualplugin->send_notifications(false);
|
||||
$manualplugin->send_expiry_notifications(false);
|
||||
$this->assertEquals(0, $sink->count());
|
||||
|
||||
// use invalid notification hour to verify that before the hour the notifications are not sent.
|
||||
$manualplugin->set_config('notifylast', time() - 60*60*24);
|
||||
$manualplugin->set_config('notifyhour', '24');
|
||||
$manualplugin->set_config('expirynotifylast', time() - 60*60*24);
|
||||
$manualplugin->set_config('expirynotifyhour', '24');
|
||||
|
||||
$manualplugin->send_notifications(false);
|
||||
$manualplugin->send_expiry_notifications(false);
|
||||
$this->assertEquals(0, $sink->count());
|
||||
|
||||
$manualplugin->set_config('notifyhour', '0');
|
||||
$manualplugin->send_notifications(false);
|
||||
$manualplugin->set_config('expirynotifyhour', '0');
|
||||
$manualplugin->send_expiry_notifications(false);
|
||||
$this->assertEquals(6, $sink->count());
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2012100705; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2012101400; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2012100500; // Requires this Moodle version
|
||||
$plugin->component = 'enrol_manual'; // Full name of the plugin (used for diagnostics)
|
||||
$plugin->cron = 600;
|
||||
|
@ -66,7 +66,15 @@ $string['errajaxsearch'] = 'Error when searching users';
|
||||
$string['erroreditenrolment'] = 'An error occurred while trying to edit a users enrolment';
|
||||
$string['errorenrolcohort'] = 'Error creating cohort sync enrolment instance in this course.';
|
||||
$string['errorenrolcohortusers'] = 'Error enrolling cohort members in this course.';
|
||||
$string['errorthresholdlow'] = 'Notification threshold must be at least 1 day.';
|
||||
$string['errorwithbulkoperation'] = 'There was an error while processing your bulk enrolment change.';
|
||||
$string['expirynotify'] = 'Notify before enrolment expires';
|
||||
$string['expirynotify_help'] = 'This setting determines whether enrolment expiry notification messages are sent.';
|
||||
$string['expirynotifyall'] = 'Enroller and enrolled user';
|
||||
$string['expirynotifyenroller'] = 'Enroller only';
|
||||
$string['expirynotifyhour'] = 'Hour to send enrolment expiry notifications';
|
||||
$string['expirythreshold'] = 'Notification threshold';
|
||||
$string['expirythreshold_help'] = 'How long before expiration should be users notified?';
|
||||
$string['finishenrollingusers'] = 'Finish enrolling users';
|
||||
$string['invalidenrolinstance'] = 'Invalid enrolment instance';
|
||||
$string['invalidrole'] = 'Invalid role';
|
||||
|
@ -659,26 +659,6 @@ $string['existingcreators'] = 'Existing course creators';
|
||||
$string['existingstudents'] = 'Enrolled students';
|
||||
$string['existingteachers'] = 'Existing teachers';
|
||||
$string['expandall'] = 'Expand all';
|
||||
$string['expirynotify'] = 'Enrolment expiry notification';
|
||||
$string['expirynotifyemail'] = 'The following students in this course are expiring after exactly {$a->threshold} days:
|
||||
|
||||
{$a->current}
|
||||
|
||||
The following students in this course are expiring in less than {$a->threshold} days:
|
||||
|
||||
{$a->past}
|
||||
|
||||
You may go to the following page to extend their enrolment period:
|
||||
{$a->extendurl}';
|
||||
$string['expirynotifystudents'] = 'Notify students';
|
||||
$string['expirynotifystudents_help'] = 'If an enrolment duration has been specified, then this setting determines whether students receive email notification when they are about to be unenrolled from the course.';
|
||||
$string['expirynotifystudentsemail'] = 'Dear {$a->studentstr}:
|
||||
|
||||
This is a notification that your enrolment in the course {$a->course} will expire in {$a->threshold} days.
|
||||
|
||||
Please contact {$a->teacherstr} for any further enquiries.';
|
||||
$string['expirythreshold'] = 'Threshold';
|
||||
$string['expirythreshold_help'] = 'If an enrolment duration has been specified, then this setting determines the number of days notice given before students are unenrolled from the course.';
|
||||
$string['explanation'] = 'Explanation';
|
||||
$string['extendenrol'] = 'Extend enrolment (individual)';
|
||||
$string['extendperiod'] = 'Extended period';
|
||||
|
Loading…
x
Reference in New Issue
Block a user