I've discovered how to send an E-mail notification for David Mudrak's Stamp Collection module for Moodle 2.2. It's really easy. All you need to do is to copy this code:
//E-mail notification!
$user = $DB->get_record('user', array('id' => $data->userto));
$subjectOfMsg = $USER->firstname." ".$USER->lastname."'s just given you a NEW STAMP in".$course->shortname;
$success = email_to_user($user, $USER, $subjectOfMsg, $data->text);
if ($success == "1")
{
echo "E-mail successful sent to ".$user->firstname." ".$user->lastname."!";
} else if ($success === "emailstop") {
echo "E-mail of ".$user->firstname." ".$user->lastname." has been DISABLED!"
.'E-mail NOT sent';
} else if (!$success){
echo "Error: E-mail unsuccessful.";
}
//email end
and paste it into line 67 of the addstamp.php file of the Moodle 2.2 version of the Stamp Collection. Like so:
Next, save the file and then MAKE A BACKUP OF YOUR ORIGINAL addstamp.php!!
Ftp the modified file into the http://YourMoodleSite/mod/stampcoll.
You can click the link below to download my modified addstamp.php file.
Remember! It's for Moodle 2.2.
I can't seem to find a way to NOT send out an E-mail notification IF the student doesn't want to receive any emails. Maybe someone on Moodle.org can help me out here.
ReplyDelete//Suggested by Matteo Scaramuccia on the forum in
ReplyDelete//http://moodle.org/mod/forum/discuss.php?d=198694#p866328
//
// E-mail notification - START
$user = $DB->get_record('user', array('id' => $data->userto));
if (!empty($user->emailstop)) {
echo "E-mail of $user->firstname $user->lastname has been DISABLED! E-mail NOT sent";
} else {
$subjectOfMsg = "$USER->firstname $USER->lastname's just given you a NEW STAMP in $course->shortname";
if (email_to_user($user, $USER, $subjectOfMsg, $data->text)) {
echo "E-mail successful sent to $user->firstname $user->lastname!";
} else {
echo "Error: E-mail unsuccessful.";
}
}
// E-mail notification - END
Thanks Matteo for the code. It works just fine!
ReplyDeleteHi Frankie,
ReplyDeleteIs there any code rattling around your noggin that would award a stamp automatically based on, let's say, the number of forum posts in a course or a minimum grade on a section in the grade
book? How cool would that be?
Best wishes from Montreal,
Nick
Hi Nick. My noggin needs more egg-nog to knog how to build a nugget like that at the moment. The best person to do that is Fantastic Mr. Fox, erm.... I mean, the Brilliant Mr. Lewis Carr of Leeds City College, UK. He's done an XBox-like points scoring system for his institution's Moodle site. If only I could get a glimpse of that code....*sniff*.
ReplyDeleteNick, I think this post is related.
ReplyDeletehttp://moodle.org/mod/forum/discuss.php?d=173567
The link in the above comment by me is complicated. This one below here:
ReplyDeletehttp://moodle.org/mod/forum/discuss.php?d=194408#p873826
is what I'm looking for to automatically award stamps based on the number of forum posts have been done by the user! Keeping my finger on it.
Nick, this post on Moodle.org shows how to add a "Count of Posts of a user" information to the forum. It's a major step to gamification of the Stamp Collection module, or for that matter the gamification of the Gradebook scores.
ReplyDeletehttp://moodle.org/mod/forum/discuss.php?d=116200
I've managed to implement it for my Moodle 1.9.15 forum. However, to gamify the Moodle Stamp Collection (SC) so that the module will award stamps/badges every N number of forum posts, is harder than I thought. For example I might be able to program the SC to award 1 stamp for the 10 forum posts that a user has made. But then how can the SC detect that when the user has made 20 forum posts in total, the module will then award an additional stamp????
Boggles the mind. Mind-numbing to say the least.