This commit is contained in:
Huong Nguyen
2024-06-25 09:50:53 +07:00
8 changed files with 287 additions and 189 deletions
+4 -1
View File
@@ -38,7 +38,10 @@ if (!$plugin) {
}
require_login($course);
require_capability('enrol/' . $type . ':config', $context);
if (!has_any_capability(['enrol/' . $type . ':config', 'moodle/course:editcoursewelcomemessage'], $context)) {
throw new \moodle_exception('nopermissiontoaccesspage', 'error');
}
$url = new moodle_url('/enrol/editinstance.php', ['courseid' => $course->id, 'id' => $instanceid, 'type' => $type]);
$PAGE->set_url($url);
+94 -73
View File
@@ -114,8 +114,17 @@ class enrol_manual_plugin extends enrol_plugin {
$managelink = new moodle_url("/enrol/manual/manage.php", array('enrolid'=>$instance->id));
$icons[] = $OUTPUT->action_icon($managelink, new pix_icon('t/enrolusers', get_string('enrolusers', 'enrol_manual'), 'core', array('class'=>'iconsmall')));
}
$parenticons = parent::get_action_icons($instance);
$icons = array_merge($icons, $parenticons);
if (has_any_capability(['enrol/manual:config', 'moodle/course:editcoursewelcomemessage'], $context)) {
$linkparams = [
'courseid' => $instance->courseid,
'id' => $instance->id,
'type' => $instance->enrol,
];
$editlink = new moodle_url('/enrol/editinstance.php', $linkparams);
$icon = new pix_icon('t/edit', get_string('edit'), 'core', ['class' => 'iconsmall']);
$icons[] = $OUTPUT->action_icon($editlink, $icon);
}
return $icons;
}
@@ -175,7 +184,11 @@ class enrol_manual_plugin extends enrol_plugin {
}
}
$data->notifyall = $data->expirynotify == 2 ? 1 : 0;
// This method is used when configuring the enrolment method, and when only updating the welcome message.
// The 'expirynotify' property won't be set when updating the welcome message.
if (isset($data->expirynotify)) {
$data->notifyall = $data->expirynotify == 2 ? 1 : 0;
}
return parent::update_instance($instance, $data);
}
@@ -582,86 +595,92 @@ class enrol_manual_plugin extends enrol_plugin {
*/
public function edit_instance_form($instance, MoodleQuickForm $mform, $context) {
$options = $this->get_status_options();
$mform->addElement('select', 'status', get_string('status', 'enrol_manual'), $options);
$mform->addHelpButton('status', 'status', 'enrol_manual');
$mform->setDefault('status', $this->get_config('status'));
// Main fields.
if (has_capability('enrol/manual:config', $context)) {
$options = $this->get_status_options();
$mform->addElement('select', 'status', get_string('status', 'enrol_manual'), $options);
$mform->addHelpButton('status', 'status', 'enrol_manual');
$mform->setDefault('status', $this->get_config('status'));
$roles = $this->get_roleid_options($instance, $context);
$mform->addElement('select', 'roleid', get_string('defaultrole', 'role'), $roles);
$mform->setDefault('roleid', $this->get_config('roleid'));
$roles = $this->get_roleid_options($instance, $context);
$mform->addElement('select', 'roleid', get_string('defaultrole', 'role'), $roles);
$mform->setDefault('roleid', $this->get_config('roleid'));
$options = array('optional' => true, 'defaultunit' => 86400);
$mform->addElement('duration', 'enrolperiod', get_string('defaultperiod', 'enrol_manual'), $options);
$mform->setDefault('enrolperiod', $this->get_config('enrolperiod'));
$mform->addHelpButton('enrolperiod', 'defaultperiod', 'enrol_manual');
$options = ['optional' => true, 'defaultunit' => 86400];
$mform->addElement('duration', 'enrolperiod', get_string('defaultperiod', 'enrol_manual'), $options);
$mform->setDefault('enrolperiod', $this->get_config('enrolperiod'));
$mform->addHelpButton('enrolperiod', 'defaultperiod', 'enrol_manual');
$options = $this->get_expirynotify_options();
$mform->addElement('select', 'expirynotify', get_string('expirynotify', 'core_enrol'), $options);
$mform->addHelpButton('expirynotify', 'expirynotify', 'core_enrol');
$options = $this->get_expirynotify_options();
$mform->addElement('select', 'expirynotify', get_string('expirynotify', 'core_enrol'), $options);
$mform->addHelpButton('expirynotify', 'expirynotify', 'core_enrol');
$options = array('optional' => false, 'defaultunit' => 86400);
$mform->addElement('duration', 'expirythreshold', get_string('expirythreshold', 'core_enrol'), $options);
$mform->addHelpButton('expirythreshold', 'expirythreshold', 'core_enrol');
$mform->disabledIf('expirythreshold', 'expirynotify', 'eq', 0);
$options = ['optional' => false, 'defaultunit' => 86400];
$mform->addElement('duration', 'expirythreshold', get_string('expirythreshold', 'core_enrol'), $options);
$mform->addHelpButton('expirythreshold', 'expirythreshold', 'core_enrol');
$mform->disabledIf('expirythreshold', 'expirynotify', 'eq', 0);
}
// Course welcome message.
$mform->addElement(
'select',
'customint1',
get_string(
if (has_any_capability(['enrol/manual:config', 'moodle/course:editcoursewelcomemessage'], $context)) {
$mform->addElement(
'select',
'customint1',
get_string(
identifier: 'sendcoursewelcomemessage',
component: 'core_enrol',
),
enrol_send_welcome_email_options(),
);
$mform->addHelpButton(
elementname: 'customint1',
identifier: 'sendcoursewelcomemessage',
component: 'core_enrol',
),
enrol_send_welcome_email_options(),
);
$mform->addHelpButton(
elementname: 'customint1',
identifier: 'sendcoursewelcomemessage',
component: 'core_enrol',
);
);
$options = [
'cols' => '60',
'rows' => '8',
];
$mform->addElement(
'textarea',
'customtext1',
get_string(
identifier: 'customwelcomemessage',
component: 'core_enrol',
),
$options,
);
$mform->setDefault('customtext1', get_string('customwelcomemessageplaceholder', 'core_enrol'));
$mform->hideIf(
elementname: 'customtext1',
dependenton: 'customint1',
condition: 'eq',
value: ENROL_DO_NOT_SEND_EMAIL,
);
$options = [
'cols' => '60',
'rows' => '8',
];
$mform->addElement(
'textarea',
'customtext1',
get_string(
identifier: 'customwelcomemessage',
component: 'core_enrol',
),
$options,
);
$mform->setDefault('customtext1', get_string('customwelcomemessageplaceholder', 'core_enrol'));
$mform->hideIf(
elementname: 'customtext1',
dependenton: 'customint1',
condition: 'eq',
value: ENROL_DO_NOT_SEND_EMAIL,
);
// Static form elements cannot be hidden by hideIf() so we need to add a dummy group.
// See: https://tracker.moodle.org/browse/MDL-66251.
$group[] = $mform->createElement(
'static',
'customwelcomemessage_extra_help',
null,
get_string(
identifier: 'customwelcomemessage_help',
component: 'core_enrol',
),
);
$mform->addGroup($group, 'group_customwelcomemessage_extra_help', '', ' ', false);
$mform->hideIf(
elementname: 'group_customwelcomemessage_extra_help',
dependenton: 'customint1',
condition: 'eq',
value: ENROL_DO_NOT_SEND_EMAIL,
);
// Static form elements cannot be hidden by hideIf() so we need to add a dummy group.
// See: https://tracker.moodle.org/browse/MDL-66251.
$group[] = $mform->createElement(
'static',
'customwelcomemessage_extra_help',
null,
get_string(
identifier: 'customwelcomemessage_help',
component: 'core_enrol',
),
);
$mform->addGroup($group, 'group_customwelcomemessage_extra_help', '', ' ', false);
$mform->hideIf(
elementname: 'group_customwelcomemessage_extra_help',
dependenton: 'customint1',
condition: 'eq',
value: ENROL_DO_NOT_SEND_EMAIL,
);
}
if (enrol_accessing_via_instance($instance)) {
// Enrolment changes warning.
if (has_capability('enrol/manual:config', $context) && enrol_accessing_via_instance($instance)) {
$warntext = get_string('instanceeditselfwarningtext', 'core_enrol');
$mform->addElement('static', 'selfwarn', get_string('instanceeditselfwarning', 'core_enrol'), $warntext);
}
@@ -681,7 +700,9 @@ class enrol_manual_plugin extends enrol_plugin {
public function edit_instance_validation($data, $files, $instance, $context) {
$errors = array();
if ($data['expirynotify'] > 0 and $data['expirythreshold'] < 86400) {
// This method is used when configuring the enrolment method, and when only updating the welcome message.
// The 'expirynotify' key won't be set when updating the welcome message.
if (isset($data['expirynotify']) && $data['expirynotify'] > 0 && $data['expirythreshold'] < 86400) {
$errors['expirythreshold'] = get_string('errorthresholdlow', 'core_enrol');
}
@@ -35,6 +35,22 @@ Feature: A course welcome message will be sent to the user when they are enrolle
And I should not see "Custom welcome message"
And I should not see "Accepted formats: Plain text or Moodle-auto format. HTML tags and multi-lang tags are also accepted, as well as the following placeholders:"
@javascript
Scenario: Teacher can edit the course welcome message
Given I am on the "C1" "Enrolled users" page logged in as teacher
And I set the field "Participants tertiary navigation" to "Enrolment methods"
When I click on "Edit" "link" in the "Manual enrolments" "table_row"
Then I should see "Send course welcome message"
And I should not see "Enable manual enrolments"
And I should not see "Default role"
And I should not see "Default enrolment duration"
And I should not see "Notify before enrolment expires"
And I should not see "Notification threshold"
And I set the field "Custom welcome message" to "Hello {$a->fullname}, welcome to the course {$a->coursename}"
And I press "Save changes"
And I click on "Edit" "link" in the "Manual enrolments" "table_row"
And I should see "Hello {$a->fullname}, welcome to the course {$a->coursename}"
@javascript
Scenario: Student should not receive a welcome message if the setting is disabled
Given I am on the "C1" "Enrolled users" page logged in as manager
+150 -114
View File
@@ -133,6 +133,32 @@ class enrol_self_plugin extends enrol_plugin {
return true;
}
/**
* Returns edit icons for the page with list of instances.
*
* @param stdClass $instance
* @return array
*/
public function get_action_icons(stdClass $instance): array {
global $OUTPUT;
$context = context_course::instance($instance->courseid);
$icons = [];
if (has_any_capability(['enrol/self:config', 'moodle/course:editcoursewelcomemessage'], $context)) {
$linkparams = [
'courseid' => $instance->courseid,
'id' => $instance->id,
'type' => $instance->enrol,
];
$editlink = new moodle_url('/enrol/editinstance.php', $linkparams);
$icon = new pix_icon('t/edit', get_string('edit'), 'core', ['class' => 'iconsmall']);
$icons[] = $OUTPUT->action_icon($editlink, $icon);
}
return $icons;
}
/**
* Self enrol user to course
*
@@ -828,139 +854,149 @@ class enrol_self_plugin extends enrol_plugin {
public function edit_instance_form($instance, MoodleQuickForm $mform, $context) {
global $CFG, $DB;
// Merge these two settings to one value for the single selection element.
if ($instance->notifyall and $instance->expirynotify) {
$instance->expirynotify = 2;
}
unset($instance->notifyall);
// Main fields.
if (has_capability('enrol/self:config', $context)) {
// Merge these two settings to one value for the single selection element.
if ($instance->notifyall && $instance->expirynotify) {
$instance->expirynotify = 2;
}
unset($instance->notifyall);
$nameattribs = array('size' => '20', 'maxlength' => '255');
$mform->addElement('text', 'name', get_string('custominstancename', 'enrol'), $nameattribs);
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'server');
$nameattribs = ['size' => '20', 'maxlength' => '255'];
$mform->addElement('text', 'name', get_string('custominstancename', 'enrol'), $nameattribs);
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'server');
$options = $this->get_status_options();
$mform->addElement('select', 'status', get_string('status', 'enrol_self'), $options);
$mform->addHelpButton('status', 'status', 'enrol_self');
$options = $this->get_status_options();
$mform->addElement('select', 'status', get_string('status', 'enrol_self'), $options);
$mform->addHelpButton('status', 'status', 'enrol_self');
$options = $this->get_newenrols_options();
$mform->addElement('select', 'customint6', get_string('newenrols', 'enrol_self'), $options);
$mform->addHelpButton('customint6', 'newenrols', 'enrol_self');
$mform->disabledIf('customint6', 'status', 'eq', ENROL_INSTANCE_DISABLED);
$options = $this->get_newenrols_options();
$mform->addElement('select', 'customint6', get_string('newenrols', 'enrol_self'), $options);
$mform->addHelpButton('customint6', 'newenrols', 'enrol_self');
$mform->disabledIf('customint6', 'status', 'eq', ENROL_INSTANCE_DISABLED);
$passattribs = array('size' => '20', 'maxlength' => '50');
$mform->addElement('passwordunmask', 'password', get_string('password', 'enrol_self'), $passattribs);
$mform->addHelpButton('password', 'password', 'enrol_self');
if (empty($instance->id) and $this->get_config('requirepassword')) {
$mform->addRule('password', get_string('required'), 'required', null, 'client');
}
$mform->addRule('password', get_string('maximumchars', '', 50), 'maxlength', 50, 'server');
$passattribs = ['size' => '20', 'maxlength' => '50'];
$mform->addElement('passwordunmask', 'password', get_string('password', 'enrol_self'), $passattribs);
$mform->addHelpButton('password', 'password', 'enrol_self');
if (empty($instance->id) && $this->get_config('requirepassword')) {
$mform->addRule('password', get_string('required'), 'required', null, 'client');
}
$mform->addRule('password', get_string('maximumchars', '', 50), 'maxlength', 50, 'server');
$options = $this->get_groupkey_options();
$mform->addElement('select', 'customint1', get_string('groupkey', 'enrol_self'), $options);
$mform->addHelpButton('customint1', 'groupkey', 'enrol_self');
$options = $this->get_groupkey_options();
$mform->addElement('select', 'customint1', get_string('groupkey', 'enrol_self'), $options);
$mform->addHelpButton('customint1', 'groupkey', 'enrol_self');
$roles = $this->extend_assignable_roles($context, $instance->roleid);
$mform->addElement('select', 'roleid', get_string('role', 'enrol_self'), $roles);
$roles = $this->extend_assignable_roles($context, $instance->roleid);
$mform->addElement('select', 'roleid', get_string('role', 'enrol_self'), $roles);
$options = array('optional' => true, 'defaultunit' => 86400);
$mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'enrol_self'), $options);
$mform->addHelpButton('enrolperiod', 'enrolperiod', 'enrol_self');
$options = ['optional' => true, 'defaultunit' => 86400];
$mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'enrol_self'), $options);
$mform->addHelpButton('enrolperiod', 'enrolperiod', 'enrol_self');
$options = $this->get_expirynotify_options();
$mform->addElement('select', 'expirynotify', get_string('expirynotify', 'core_enrol'), $options);
$mform->addHelpButton('expirynotify', 'expirynotify', 'core_enrol');
$options = $this->get_expirynotify_options();
$mform->addElement('select', 'expirynotify', get_string('expirynotify', 'core_enrol'), $options);
$mform->addHelpButton('expirynotify', 'expirynotify', 'core_enrol');
$options = array('optional' => false, 'defaultunit' => 86400);
$mform->addElement('duration', 'expirythreshold', get_string('expirythreshold', 'core_enrol'), $options);
$mform->addHelpButton('expirythreshold', 'expirythreshold', 'core_enrol');
$mform->disabledIf('expirythreshold', 'expirynotify', 'eq', 0);
$options = ['optional' => false, 'defaultunit' => 86400];
$mform->addElement('duration', 'expirythreshold', get_string('expirythreshold', 'core_enrol'), $options);
$mform->addHelpButton('expirythreshold', 'expirythreshold', 'core_enrol');
$mform->disabledIf('expirythreshold', 'expirynotify', 'eq', 0);
$options = array('optional' => true);
$mform->addElement('date_time_selector', 'enrolstartdate', get_string('enrolstartdate', 'enrol_self'), $options);
$mform->setDefault('enrolstartdate', 0);
$mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'enrol_self');
$options = ['optional' => true];
$mform->addElement('date_time_selector', 'enrolstartdate', get_string('enrolstartdate', 'enrol_self'), $options);
$mform->setDefault('enrolstartdate', 0);
$mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'enrol_self');
$options = array('optional' => true);
$mform->addElement('date_time_selector', 'enrolenddate', get_string('enrolenddate', 'enrol_self'), $options);
$mform->setDefault('enrolenddate', 0);
$mform->addHelpButton('enrolenddate', 'enrolenddate', 'enrol_self');
$options = ['optional' => true];
$mform->addElement('date_time_selector', 'enrolenddate', get_string('enrolenddate', 'enrol_self'), $options);
$mform->setDefault('enrolenddate', 0);
$mform->addHelpButton('enrolenddate', 'enrolenddate', 'enrol_self');
$options = $this->get_longtimenosee_options();
$mform->addElement('select', 'customint2', get_string('longtimenosee', 'enrol_self'), $options);
$mform->addHelpButton('customint2', 'longtimenosee', 'enrol_self');
$options = $this->get_longtimenosee_options();
$mform->addElement('select', 'customint2', get_string('longtimenosee', 'enrol_self'), $options);
$mform->addHelpButton('customint2', 'longtimenosee', 'enrol_self');
$mform->addElement('text', 'customint3', get_string('maxenrolled', 'enrol_self'));
$mform->addHelpButton('customint3', 'maxenrolled', 'enrol_self');
$mform->setType('customint3', PARAM_INT);
$mform->addElement('text', 'customint3', get_string('maxenrolled', 'enrol_self'));
$mform->addHelpButton('customint3', 'maxenrolled', 'enrol_self');
$mform->setType('customint3', PARAM_INT);
require_once($CFG->dirroot.'/cohort/lib.php');
require_once($CFG->dirroot.'/cohort/lib.php');
$cohorts = array(0 => get_string('no'));
$allcohorts = cohort_get_available_cohorts($context, 0, 0, 0);
if ($instance->customint5 && !isset($allcohorts[$instance->customint5])) {
$c = $DB->get_record('cohort',
array('id' => $instance->customint5),
'id, name, idnumber, contextid, visible',
IGNORE_MISSING);
if ($c) {
// Current cohort was not found because current user can not see it. Still keep it.
$allcohorts[$instance->customint5] = $c;
$cohorts = [0 => get_string('no')];
$allcohorts = cohort_get_available_cohorts($context, 0, 0, 0);
if ($instance->customint5 && !isset($allcohorts[$instance->customint5])) {
$c = $DB->get_record('cohort',
['id' => $instance->customint5],
'id, name, idnumber, contextid, visible',
IGNORE_MISSING);
if ($c) {
// Current cohort was not found because current user can not see it. Still keep it.
$allcohorts[$instance->customint5] = $c;
}
}
foreach ($allcohorts as $c) {
$cohorts[$c->id] = format_string($c->name, true, ['context' => context::instance_by_id($c->contextid)]);
if ($c->idnumber) {
$cohorts[$c->id] .= ' ['.s($c->idnumber).']';
}
}
if ($instance->customint5 && !isset($allcohorts[$instance->customint5])) {
// Somebody deleted a cohort, better keep the wrong value so that random ppl can not enrol.
$cohorts[$instance->customint5] = get_string('unknowncohort', 'cohort', $instance->customint5);
}
if (count($cohorts) > 1) {
$mform->addElement('select', 'customint5', get_string('cohortonly', 'enrol_self'), $cohorts);
$mform->addHelpButton('customint5', 'cohortonly', 'enrol_self');
} else {
$mform->addElement('hidden', 'customint5');
$mform->setType('customint5', PARAM_INT);
$mform->setConstant('customint5', 0);
}
}
foreach ($allcohorts as $c) {
$cohorts[$c->id] = format_string($c->name, true, array('context' => context::instance_by_id($c->contextid)));
if ($c->idnumber) {
$cohorts[$c->id] .= ' ['.s($c->idnumber).']';
}
}
if ($instance->customint5 && !isset($allcohorts[$instance->customint5])) {
// Somebody deleted a cohort, better keep the wrong value so that random ppl can not enrol.
$cohorts[$instance->customint5] = get_string('unknowncohort', 'cohort', $instance->customint5);
}
if (count($cohorts) > 1) {
$mform->addElement('select', 'customint5', get_string('cohortonly', 'enrol_self'), $cohorts);
$mform->addHelpButton('customint5', 'cohortonly', 'enrol_self');
} else {
$mform->addElement('hidden', 'customint5');
$mform->setType('customint5', PARAM_INT);
$mform->setConstant('customint5', 0);
// Course welcome message.
if (has_any_capability(['enrol/self:config', 'moodle/course:editcoursewelcomemessage'], $context)) {
$mform->addElement('select', 'customint4', get_string('sendcoursewelcomemessage', 'enrol_self'),
enrol_send_welcome_email_options());
$mform->addHelpButton('customint4', 'sendcoursewelcomemessage', 'enrol_self');
$options = [
'cols' => '60',
'rows' => '8',
];
$mform->addElement('textarea', 'customtext1', get_string('customwelcomemessage', 'core_enrol'), $options);
$mform->setDefault('customtext1', get_string('customwelcomemessageplaceholder', 'core_enrol'));
$mform->hideIf(
elementname: 'customtext1',
dependenton: 'customint4',
condition: 'eq',
value: ENROL_DO_NOT_SEND_EMAIL,
);
// Static form elements cannot be hidden by hideIf() so we need to add a dummy group.
// See: https://tracker.moodle.org/browse/MDL-66251.
$group[] = $mform->createElement(
'static',
'customwelcomemessage_extra_help',
null,
get_string(
identifier: 'customwelcomemessage_help',
component: 'core_enrol',
),
);
$mform->addGroup($group, 'group_customwelcomemessage_extra_help', '', ' ', false);
$mform->hideIf(
elementname: 'group_customwelcomemessage_extra_help',
dependenton: 'customint4',
condition: 'eq',
value: ENROL_DO_NOT_SEND_EMAIL,
);
}
$mform->addElement('select', 'customint4', get_string('sendcoursewelcomemessage', 'enrol_self'),
enrol_send_welcome_email_options());
$mform->addHelpButton('customint4', 'sendcoursewelcomemessage', 'enrol_self');
$options = array('cols' => '60', 'rows' => '8');
$mform->addElement('textarea', 'customtext1', get_string('customwelcomemessage', 'core_enrol'), $options);
$mform->setDefault('customtext1', get_string('customwelcomemessageplaceholder', 'core_enrol'));
$mform->hideIf(
elementname: 'customtext1',
dependenton: 'customint4',
condition: 'eq',
value: ENROL_DO_NOT_SEND_EMAIL,
);
// Static form elements cannot be hidden by hideIf() so we need to add a dummy group.
// See: https://tracker.moodle.org/browse/MDL-66251.
$group[] = $mform->createElement(
'static',
'customwelcomemessage_extra_help',
null,
get_string(
identifier: 'customwelcomemessage_help',
component: 'core_enrol',
),
);
$mform->addGroup($group, 'group_customwelcomemessage_extra_help', '', ' ', false);
$mform->hideIf(
elementname: 'group_customwelcomemessage_extra_help',
dependenton: 'customint4',
condition: 'eq',
value: ENROL_DO_NOT_SEND_EMAIL,
);
if (enrol_accessing_via_instance($instance)) {
// Enrolment changes warning.
if (has_capability('enrol/self:config', $context) && enrol_accessing_via_instance($instance)) {
$warntext = get_string('instanceeditselfwarningtext', 'core_enrol');
$mform->addElement('static', 'selfwarn', get_string('instanceeditselfwarning', 'core_enrol'), $warntext);
}
@@ -40,6 +40,17 @@ Feature: A course welcome message will be sent to the user when they auto-enrol
And I should not see "Custom welcome message"
And I should not see "Accepted formats: Plain text or Moodle-auto format. HTML tags and multi-lang tags are also accepted, as well as the following placeholders:"
@javascript
Scenario: Teacher can edit the course welcome message
Given I am on the "C1" "Enrolled users" page logged in as teacher
And I set the field "Participants tertiary navigation" to "Enrolment methods"
When I click on "Edit" "link" in the "Self enrolment" "table_row"
Then I should see "Send course welcome message"
And I set the field "Custom welcome message" to "Hello {$a->fullname}, welcome to the course {$a->coursename}"
And I press "Save changes"
And I click on "Edit" "link" in the "Self enrolment" "table_row"
And I should see "Hello {$a->fullname}, welcome to the course {$a->coursename}"
@javascript
Scenario: Student should not receive a welcome message if the setting is disabled
Given I am on the "C1" "Enrolled users" page logged in as manager
+1
View File
@@ -180,6 +180,7 @@ $string['course:changesummary'] = 'Change course summary';
$string['course:configurecustomfields'] = 'Configure course custom fields';
$string['course:configuredownloadcontent'] = 'Configure download course content';
$string['course:downloadcoursecontent'] = 'Download course content';
$string['course:editcoursewelcomemessage'] = 'Edit course welcome message';
$string['course:enrolconfig'] = 'Configure enrol instances in courses';
$string['course:enrolreview'] = 'Review course enrolments';
$string['course:setforcedlanguage'] = 'Force course or activity language';
+10
View File
@@ -2748,4 +2748,14 @@ $capabilities = array(
'manager' => CAP_ALLOW,
]
],
// Allow users to edit course welcome messages.
'moodle/course:editcoursewelcomemessage' => [
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => [
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
],
],
);
+1 -1
View File
@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2024062000.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2024062000.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '4.5dev (Build: 20240620)'; // Human-friendly version name