Pages

Monday, March 19, 2012

Sending an E-mail notification to a student in David Mudrak's Stamp Collection module for Moodle 2.2!


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.

If you like this post or site
a small donation would be nice but would last only a day,
otherwise leaving a comment (or a compliment) below will last me a month!

8 comments:

  1. 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
  2. //Suggested by Matteo Scaramuccia on the forum in
    //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

    ReplyDelete
  3. Thanks Matteo for the code. It works just fine!

    ReplyDelete
  4. Hi Frankie,
    Is 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

    ReplyDelete
  5. 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*.

    ReplyDelete
  6. Nick, I think this post is related.
    http://moodle.org/mod/forum/discuss.php?d=173567

    ReplyDelete
  7. The link in the above comment by me is complicated. This one below here:
    http://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.

    ReplyDelete
  8. 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.

    http://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.

    ReplyDelete

Ratings and Recommendations by outbrain