| … | |
… | |
| 69 | # gather list of recipients |
69 | # gather list of recipients |
| 70 | ############################################################################################# |
70 | ############################################################################################# |
| 71 | my @send_to = (); |
71 | my @send_to = (); |
| 72 | #FIXME this (radio) is a lousy name |
72 | #FIXME this (radio) is a lousy name |
| 73 | my $recipients = $r->param('radio'); |
73 | my $recipients = $r->param('radio'); |
| 74 | if ($recipients eq 'all_students') { #only active students #FIXME status check?? |
74 | if (defined($recipients) and $recipients eq 'all_students') { #only active students #FIXME status check?? |
| 75 | foreach my $ur (@user_records) { |
75 | foreach my $ur (@user_records) { |
| 76 | push(@send_to,$ur->user_id) if $ur->status eq 'C' and not($ur->user_id =~ /practice/); |
76 | push(@send_to,$ur->user_id) if $ur->status eq 'C' and not($ur->user_id =~ /practice/); |
| 77 | } |
77 | } |
| 78 | } elsif ($recipients eq 'studentID' ) { |
78 | } elsif (defined($recipients) and $recipients eq 'studentID' ) { |
| 79 | @send_to = $r->param('classList'); |
79 | @send_to = $r->param('classList'); |
| 80 | } else { |
80 | } else { |
| 81 | warn "Don't understand recipient list |$recipients|"; |
81 | # no recipients have been defined -- probably the first time on the page |
| 82 | } |
82 | } |
| 83 | $self->{ra_send_to} = \@send_to; |
83 | $self->{ra_send_to} = \@send_to; |
| 84 | ################################################################# |
84 | ################################################################# |
| 85 | # Check the validity of the input file name |
85 | # Check the validity of the input file name |
| 86 | ################################################################# |
86 | ################################################################# |
| … | |
… | |
| 207 | my $to = $r->param('To'); |
207 | my $to = $r->param('To'); |
| 208 | my $script_action = ''; |
208 | my $script_action = ''; |
| 209 | |
209 | |
| 210 | |
210 | |
| 211 | if(not defined($action) or $action eq 'Open' or $action eq 'Resize message window' |
211 | if(not defined($action) or $action eq 'Open' or $action eq 'Resize message window' |
| 212 | or $action eq 'Choose merge file' ){ |
212 | or $action eq 'Set merge file to:' ){ |
| 213 | # warn "FIXME action is |$action| no further initialization required"; |
213 | # warn "FIXME action is |$action| no further initialization required"; |
| 214 | return ''; |
214 | return ''; |
| 215 | } |
215 | } |
| 216 | |
216 | |
| 217 | |
217 | |
| … | |
… | |
| 352 | if ($response eq 'preview') { |
352 | if ($response eq 'preview') { |
| 353 | $self->print_preview($setID); |
353 | $self->print_preview($setID); |
| 354 | } elsif (($response eq 'send_email')){ |
354 | } elsif (($response eq 'send_email')){ |
| 355 | $self->{message} .= CGI::h3("Email sent to "). join(" ", @{$self->{ra_send_to}}); |
355 | $self->{message} .= CGI::h3("Email sent to "). join(" ", @{$self->{ra_send_to}}); |
| 356 | $self->print_form($setID); |
356 | $self->print_form($setID); |
|
|
357 | } else { |
|
|
358 | $self->print_form($setID); |
| 357 | } |
359 | } |
| 358 | |
360 | |
| 359 | } |
361 | } |
| 360 | sub print_preview { |
362 | sub print_preview { |
| 361 | my ($self, $setID) = @_; |
363 | my ($self, $setID) = @_; |
| … | |
… | |
| 482 | ############################################################################################# |
484 | ############################################################################################# |
| 483 | # third column |
485 | # third column |
| 484 | ############################################################################################# |
486 | ############################################################################################# |
| 485 | CGI::td({align=>'left'}, |
487 | CGI::td({align=>'left'}, |
| 486 | "Merge file is: $merge_file", CGI::br(), |
488 | "Merge file is: $merge_file", CGI::br(), |
| 487 | CGI::submit(-name=>'action', -value=>'Choose merge file'),CGI::br(), |
489 | CGI::submit(-name=>'action', -value=>'Set merge file to:'),CGI::br(), |
| 488 | CGI::popup_menu(-name=>'merge_file', |
490 | CGI::popup_menu(-name=>'merge_file', |
| 489 | -values=>\@sorted_merge_files, |
491 | -values=>\@sorted_merge_files, |
| 490 | -default=>$merge_file, |
492 | -default=>$merge_file, |
| 491 | ), "\n",CGI::hr(),CGI::br(), |
493 | ), "\n",CGI::hr(),CGI::br(), |
| 492 | CGI::submit(-name=>'action', -value=>'preview',-label=>'Preview')," email to ", |
494 | CGI::submit(-name=>'action', -value=>'preview',-label=>'Preview')," email to ", |
| … | |
… | |
| 666 | my $scoringDirectory= $self->{ce}->{courseDirs}->{scoring}; |
668 | my $scoringDirectory= $self->{ce}->{courseDirs}->{scoring}; |
| 667 | my $filePath = "$scoringDirectory/$fileName"; |
669 | my $filePath = "$scoringDirectory/$fileName"; |
| 668 | # Takes a delimited file as a parameter and returns an |
670 | # Takes a delimited file as a parameter and returns an |
| 669 | # associative array with the first field as the key. |
671 | # associative array with the first field as the key. |
| 670 | # Blank lines are skipped. White space is removed |
672 | # Blank lines are skipped. White space is removed |
| 671 | my(@dbArray,$key,%assocArray,$dbString); |
673 | my(@dbArray,$key,$dbString); |
|
|
674 | my %assocArray = (); |
|
|
675 | return |
| 672 | local(*FILE); |
676 | local(*FILE); |
| 673 | open(FILE, "$filePath") or $self->submission_error("Can't open file $filePath"); |
677 | if ($fileName eq 'None') { |
|
|
678 | # do nothing |
|
|
679 | }elsif ( open(FILE, "$filePath") ) { |
| 674 | my $index=0; |
680 | my $index=0; |
| 675 | while (<FILE>){ |
681 | while (<FILE>){ |
| 676 | unless ($_ =~ /\S/) {next;} ## skip blank lines |
682 | unless ($_ =~ /\S/) {next;} ## skip blank lines |
| 677 | chomp; |
683 | chomp; |
| 678 | @{$dbArray[$index]} =$self->getRecord($_,$delimiter); |
684 | @{$dbArray[$index]} =$self->getRecord($_,$delimiter); |
| 679 | $key =$dbArray[$index][0]; |
685 | $key =$dbArray[$index][0]; |
| 680 | #@dbArray = map {$_ =~s/\s/\./g;$_} map {sprintf('%-8.8s',$_);} @dbArray; |
686 | #@dbArray = map {$_ =~s/\s/\./g;$_} map {sprintf('%-8.8s',$_);} @dbArray; |
| 681 | #$dbString = join(" | ",@dbArray); |
687 | #$dbString = join(" | ",@dbArray); |
| 682 | $assocArray{$key}=$dbArray[$index]; |
688 | $assocArray{$key}=$dbArray[$index]; |
| 683 | $index++; |
689 | $index++; |
| 684 | } |
690 | } |
| 685 | close(FILE); |
691 | close(FILE); |
|
|
692 | } else { |
|
|
693 | warn "Couldn't read file $filePath"; |
|
|
694 | } |
| 686 | return \%assocArray; |
695 | return \%assocArray; |
| 687 | } |
696 | } |
| 688 | sub getRecord { |
697 | sub getRecord { |
| 689 | my $self = shift; |
698 | my $self = shift; |
| 690 | my $line = shift; |
699 | my $line = shift; |
| 691 | my $delimiter = shift; |
700 | my $delimiter = shift; |