| 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.16 2004/01/17 19:30:22 gage Exp $ |
4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SendMail.pm,v 1.17 2004/01/21 01:16:15 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. |
| … | |
… | |
| 72 | |
72 | |
| 73 | ############################################################################################# |
73 | ############################################################################################# |
| 74 | # gather database data |
74 | # gather database data |
| 75 | ############################################################################################# |
75 | ############################################################################################# |
| 76 | # FIXME this might be better done in body? We don't always need all of this data. or do we? |
76 | # FIXME this might be better done in body? We don't always need all of this data. or do we? |
| 77 | my @users = sort $db->listUsers; |
77 | my @users = $db->listUsers; |
| 78 | my @user_records = (); |
78 | my @user_records = (); |
| 79 | foreach my $userName (@users) { |
79 | foreach my $userName (@users) { |
| 80 | my $userRecord = $db->getUser($userName); # checked |
80 | my $userRecord = $db->getUser($userName); # checked |
| 81 | die "record for user $userName not found" unless $userRecord; |
81 | die "record for user $userName not found" unless $userRecord; |
| 82 | push(@user_records, $userRecord); |
82 | push(@user_records, $userRecord); |
| … | |
… | |
| 90 | @user_records = sort { (lc($a->section) cmp lc($b->section)) || (lc($a->last_name) cmp lc($b->last_name)) } @user_records; |
90 | @user_records = sort { (lc($a->section) cmp lc($b->section)) || (lc($a->last_name) cmp lc($b->last_name)) } @user_records; |
| 91 | } elsif ($sort_method eq 'recitation') { |
91 | } elsif ($sort_method eq 'recitation') { |
| 92 | @user_records = sort { (lc($a->recitation) cmp lc($b->recitation)) || (lc($a->last_name) cmp lc($b->last_name)) } @user_records; |
92 | @user_records = sort { (lc($a->recitation) cmp lc($b->recitation)) || (lc($a->last_name) cmp lc($b->last_name)) } @user_records; |
| 93 | } elsif ($sort_method eq 'alphabetical') { |
93 | } elsif ($sort_method eq 'alphabetical') { |
| 94 | @user_records = sort { (lc($a->last_name) cmp lc($b->last_name)) } @user_records; |
94 | @user_records = sort { (lc($a->last_name) cmp lc($b->last_name)) } @user_records; |
|
|
95 | } elsif ($sort_method eq 'id' ) { |
|
|
96 | @user_records = sort { $a->user_id cmp $b->user_id } @user_records; |
| 95 | } |
97 | } |
|
|
98 | } else { |
|
|
99 | @user_records = sort { $a->user_id cmp $b->user_id } @user_records; |
| 96 | } |
100 | } |
| 97 | |
101 | |
| 98 | |
102 | |
| 99 | # replace the user names by a sorted version. |
103 | # replace the user names by a sorted version. |
| 100 | @users = map {$_->user_id} @user_records; |
104 | @users = map {$_->user_id} @user_records; |
| … | |
… | |
| 243 | ############################################################################################# |
247 | ############################################################################################# |
| 244 | my $to = $r->param('To'); |
248 | my $to = $r->param('To'); |
| 245 | my $script_action = ''; |
249 | my $script_action = ''; |
| 246 | |
250 | |
| 247 | |
251 | |
| 248 | if(not defined($action) or $action eq 'Open' or $action eq $REFRESH_RESIZE_BUTTON |
252 | if(not defined($action) or $action eq 'Open' or $action eq $REFRESH_RESIZE_BUTTON or $action eq 'Sort by' |
| 249 | or $action eq 'Set merge file to:' ){ |
253 | or $action eq 'Set merge file to:' ){ |
| 250 | # warn "FIXME action is |$action| no further initialization required"; |
254 | # warn "FIXME action is |$action| no further initialization required"; |
| 251 | return ''; |
255 | return ''; |
| 252 | } |
256 | } |
| 253 | |
257 | |
| … | |
… | |
| 500 | "\n", CGI::br(),'Subject: ', CGI::br(), CGI::textarea(-name=>'subject', -default=>$subject, -rows=>3,-columns=>30, -override=>1), |
504 | "\n", CGI::br(),'Subject: ', CGI::br(), CGI::textarea(-name=>'subject', -default=>$subject, -rows=>3,-columns=>30, -override=>1), |
| 501 | ), |
505 | ), |
| 502 | ############################################################################################# |
506 | ############################################################################################# |
| 503 | # second column |
507 | # second column |
| 504 | ############################################################################################# |
508 | ############################################################################################# |
| 505 | CGI::td({-align=>'center'}, |
509 | CGI::td({-align=>'left',style=>'font-size:smaller'}, |
| 506 | CGI::start_table({-border=>'0', -cellpadding=>'1',-width=>"100%"}), |
510 | |
| 507 | CGI::Tr( |
|
|
| 508 | CGI::td({valign => 'top'}, |
|
|
| 509 | CGI::strong("Send to:"),CGI::br(), |
511 | CGI::strong("Send to:"), |
| 510 | CGI::radio_group(-name=>'radio', -values=>['all_students','studentID'], |
512 | CGI::radio_group(-name=>'radio', -values=>['all_students','studentID'], |
| 511 | -labels=>{all_students=>'All',studentID => 'Selected'}, |
513 | -labels=>{all_students=>'All',studentID => 'Selected'}, |
| 512 | -default=>'studentID', |
514 | -default=>'studentID', |
| 513 | -linebreak=>1 |
515 | -linebreak=>0 |
|
|
516 | ), CGI::br(),CGI::br(), |
|
|
517 | |
|
|
518 | CGI::input({type=>'submit',value=>'Sort by',name=>'action'}),, |
|
|
519 | CGI::radio_group(-name=>'sort_by', -values=>['id','alphabetical','section','recitation'], |
|
|
520 | -labels=>{id=>'Login',alphabetical=>'Alph.',section => 'Sec.',recitation=>'Rec.'}, |
|
|
521 | -default=>defined($r->param("sort_by")) ? $r->param("sort_by") : 'id', |
|
|
522 | -linebreak=>0 |
| 514 | ), |
523 | ), |
| 515 | ), |
|
|
| 516 | CGI::td({valign => 'top'}, |
|
|
| 517 | CGI::strong("Sort by:"), |
|
|
| 518 | CGI::radio_group(-name=>'sort_by', -values=>['id','alphabetical','section','recitation'], |
|
|
| 519 | -labels=>{id=>'Id',alphabetical=>'Alph.',section => 'Sec.',recitation=>'Rec.'}, |
|
|
| 520 | -default=>defined($r->param("sort_by")) ? $r->param("sort_by") : 'id', |
|
|
| 521 | -linebreak=>1 |
|
|
| 522 | ), |
|
|
| 523 | |
524 | |
| 524 | ), |
525 | CGI::br(),CGI::br(), |
| 525 | ), |
|
|
| 526 | CGI::end_table(), |
|
|
| 527 | CGI::popup_menu(-name=>'classList', |
526 | CGI::popup_menu(-name=>'classList', |
| 528 | -values=>\@users, |
527 | -values=>\@users, |
| 529 | -labels=>\%classlistLabels, |
528 | -labels=>\%classlistLabels, |
| 530 | -size => 10, |
529 | -size => 10, |
| 531 | -multiple => 1, |
530 | -multiple => 1, |