When an admin/teacher assigns a role to a user in course or category context you can send an email to the user which the role has been assigned by modifying the following moodle lib file.
/var/www/html/moodle/admin/roles/assign.php
In the file around the lines 103-111 by adding email_to_user() moodle lib function you can send the email to the user from the moodle support user. Be careful that email_to_user() function accepts from and to users as moodle user objects so you can not write simply emails and send.
foreach ($userstoassign as $adduser) {
$allow = true;
if ($allow) {
role_assign($roleid, $adduser->id, $context->id);
email_to_user($adduser, $supportuser, "Your role has been assigned in Moodle", "You have been assigned as a ".$assignableroles[$roleid]." in the ".$contextname );
}
}
After you add this the user will receive an email with subject "Your role has been assigned in Moodle" and message ie. "You have been assigned as a Course creator in the Category: Mathematics"
moodle administration etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
moodle administration etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
3 Nisan 2017 Pazartesi
30 Ekim 2015 Cuma
Moodle Adding Event Monitor Rules in Bulk to all of the Courses
Event Monitor Rules feature is a new and a missing feature which has arrived to moodle in version 2.8. This feature help students to be informed by email if a course material added updated or deleted etc. So they do not need to login to check whether a content has been added to the course or not. It also informs teachers and admins about a specific event occurred (a course has been added, a content has been viewed etc.).
But if you are administering a moodle with 150+ courses it is real heavy duty task to add rules one by one to every course created in moodle.
So with the following php code you can add a rule to the every course created in moodle.
But if you are administering a moodle with 150+ courses it is real heavy duty task to add rules one by one to every course created in moodle.
So with the following php code you can add a rule to the every course created in moodle.
$link = mysql_connect('moodle_host_name_or_ip', 'database_username', 'database_password');By changing the $type variable you can add any kind of event rules to the moodle.
//if connection is not successful you will see text error
if (!$link) {
die('Could not connect: ' . mysql_error());
}
//if connection is successfuly you will see message bellow
echo 'Connected successfully\n';
$type="\\core\\event\\course_module_created";
$content="Course content has been added.
";
$content2="Link : {rulename}
Description: {description}
Event Name: {eventname}
";
$type=mysql_real_escape_string($type);
$content=mysql_real_escape_string($content);
$content2=mysql_real_escape_string($content2);
mysql_select_db('moodle');
//This query finds the courses in moodle
$query_id= "select id from mdl_course";
$result_id = mysql_query($query_id);
echo $result_id;
while($row = mysql_fetch_row($result_id)) {
echo $row[0];
echo "\n";
//This below query adds the event monitor rules into he courses.
$query="INSERT INTO mdl_tool_monitor_rules (userid,courseid,name,plugin,eventname,description,
descriptionformat,frequency,timewindow,template,templateformat,timecreated,timemodified) VALUES('2','".$row[0]."',
'Course Content has been added','core','".$type."','".$content."','1','1','60','".$content2."','1','1445596840','1445596840')";
mysql_query($query);
}
mysql_close($link);
?>
Etiketler:
bulk,
event monitor,
Moodle,
moodle administration,
rules
Kaydol:
Kayıtlar (Atom)
