WeBWorK Main Forum

email reminder of due dates

email reminder of due dates

by Nandor Sieben -
Number of replies: 2
I usually send out an email reminder when a new set is assigned or is due tomorrow. This involves a bit of copy paste in the email feature. It would be nice to have a button that does this automatically. Perhaps even a cron job could do this.
In reply to Nandor Sieben

Re: email reminder of due dates

by Jason Aubrey -
Hi Nandor,

That's a good idea. Maybe you could add it as a feature request to bugzilla:


(Or, if you want to work on feature development yourself, we could give you a development branch of the system code to work in, just email me.)

In reply to Jason Aubrey

Re: email reminder of due dates

by Nandor Sieben -
I wrote a rudimentary perl script that does this. It could be greatly
improved with more sophisticated timing of the message. I run this 
as a cron job once a day. It gets the info from the database server. 

# WarnDueDate 
# Sends an email to students with a set due in the next 24 hours.  
# Author: Nandor Sieben  

use Mail::Sender;

sub mysql {
my ($sql) = @_;
# print "$sql\n"; 
qx[mysql -s -u webworkWrite --host=myserver.edu -pmypassword webwork << EOF  

@tables= mysql(q[show tables like '%_set';]);


foreach $table (@tables) {
  chop $table;
  @rows=mysql(qq[select set_id, due_date from $table]);
  foreach $row (@rows) {
     $table =~s /.set\Z//;
     if ( $row =~ /(\S+)\s+(\S+)/) {
       next if ($stamp < $ctime);
       next if ($stamp-24*60*60 > $ctime);
       print "$table \t $lt \t $set \n";
       @emails=mysql(qq[select email\_address from $table\_user]);
       foreach $email (@emails) {
         print $email;
         $sender = new Mail::Sender {
                 smtp => 'mailgate.myschool.edu',
                 from => 'webwork@myschool.edu',
                 on_errors => undef,
         or print "Can't create the Mail::Sender object: $Mail::Sender::Error\n";
                 to => "$email",
                 cc => '',
                 subject => "$set is due soon"
         or print "Can't open the message: $sender->{'error_msg'}\n";
         $sender->SendLineEnc("This is an automatic message generated by the WeBWorK system.\n");
         $sender->SendLineEnc("WeBWorK set $set in class $table");
         $sender->SendLineEnc("is due on $lt.");
         or print "Failed to send the message: $sender->{'error_msg'}\n";