| 1 | ################################################################################ |
1 | ################################################################################ |
| 2 | # WeBWorK Online Homework Delivery System |
2 | # WeBWorK Online Homework Delivery System |
| 3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
| 4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SendMail.pm,v 1.24 2004/04/07 01:17:58 gage Exp $ |
4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SendMail.pm,v 1.25 2004/05/05 01:53:51 gage Exp $ |
| 5 | # |
5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify it under |
6 | # This program is free software; you can redistribute it and/or modify it under |
| 7 | # the terms of either: (a) the GNU General Public License as published by the |
7 | # the terms of either: (a) the GNU General Public License as published by the |
| 8 | # Free Software Foundation; either version 2, or (at your option) any later |
8 | # Free Software Foundation; either version 2, or (at your option) any later |
| 9 | # version, or (b) the "Artistic License" which comes with this package. |
9 | # version, or (b) the "Artistic License" which comes with this package. |
| … | |
… | |
| 310 | |
310 | |
| 311 | } elsif ($action eq 'Send Email') { |
311 | } elsif ($action eq 'Send Email') { |
| 312 | $self->{response} = 'send_email'; |
312 | $self->{response} = 'send_email'; |
| 313 | |
313 | |
| 314 | my @recipients = @{$self->{ra_send_to}}; |
314 | my @recipients = @{$self->{ra_send_to}}; |
|
|
315 | $self->addmessage(CGI::div({class=>'ResultsWithError'}, |
| 315 | warn "No recipients selected " unless @recipients; |
316 | "No recipients selected")) unless @recipients; |
| 316 | # get merge file |
317 | # get merge file |
| 317 | my $merge_file = ( defined($self->{merge_file}) ) ? $self->{merge_file} : 'None'; |
318 | my $merge_file = ( defined($self->{merge_file}) ) ? $self->{merge_file} : 'None'; |
| 318 | my $delimiter = ','; |
319 | my $delimiter = ','; |
| 319 | my $rh_merge_data = $self->read_scoring_file("$merge_file", "$delimiter"); |
320 | my $rh_merge_data = $self->read_scoring_file("$merge_file", "$delimiter"); |
| 320 | unless (ref($rh_merge_data) ) { |
321 | unless (ref($rh_merge_data) ) { |
| … | |
… | |
| 327 | foreach my $recipient (@recipients) { |
328 | foreach my $recipient (@recipients) { |
| 328 | #warn "FIXME sending email to $recipient"; |
329 | #warn "FIXME sending email to $recipient"; |
| 329 | my $ur = $self->{db}->getUser($recipient); #checked |
330 | my $ur = $self->{db}->getUser($recipient); #checked |
| 330 | die "record for user $recipient not found" unless $ur; |
331 | die "record for user $recipient not found" unless $ur; |
| 331 | unless ($ur->email_address) { |
332 | unless ($ur->email_address) { |
|
|
333 | $self->addmessage(CGI::div({class=>'ResultsWithError'}, |
| 332 | warn "user $recipient does not have an email address -- skipping"; |
334 | "user $recipient does not have an email address -- skipping")); |
| 333 | next; |
335 | next; |
| 334 | } |
336 | } |
| 335 | my ($msg, $preview_header); |
337 | my ($msg, $preview_header); |
| 336 | eval{ ($msg,$preview_header) = $self->process_message($ur,$rh_merge_data); }; |
338 | eval{ ($msg,$preview_header) = $self->process_message($ur,$rh_merge_data); }; |
| 337 | warn "There were errors in processing user $ur, merge file $merge_file. $@" if $@; |
339 | warn "There were errors in processing user $ur, merge file $merge_file. $@" if $@; |