[system] / branches / rel-2-3-dev / webwork-modperl / lib / WeBWorK / ContentGenerator / Instructor / SendMail.pm Repository:
ViewVC logotype

Diff of /branches/rel-2-3-dev/webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SendMail.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2202 Revision 2203
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.30 2004/05/11 19:56:27 toenail Exp $ 4# $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SendMail.pm,v 1.31 2004/05/12 14:36:43 toenail 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.
26use strict; 26use strict;
27use warnings; 27use warnings;
28use CGI qw(); 28use CGI qw();
29#use HTML::Entities; 29#use HTML::Entities;
30use Mail::Sender; 30use Mail::Sender;
31use WeBWorK::HTML::ScrollingRecordList qw/scrollingRecordList/;
32
31 33
32my $REFRESH_RESIZE_BUTTON = "Set preview to: "; # handle submit value idiocy 34my $REFRESH_RESIZE_BUTTON = "Set preview to: "; # handle submit value idiocy
33sub initialize { 35sub initialize {
34 my ($self) = @_; 36 my ($self) = @_;
35 my $r = $self->r; 37 my $r = $self->r;
47############################################################################################# 49#############################################################################################
48 my $emailDirectory = $ce->{courseDirs}->{email}; 50 my $emailDirectory = $ce->{courseDirs}->{email};
49 my $scoringDirectory = $ce->{courseDirs}->{scoring}; 51 my $scoringDirectory = $ce->{courseDirs}->{scoring};
50 my $templateDirectory = $ce->{courseDirs}->{templates}; 52 my $templateDirectory = $ce->{courseDirs}->{templates};
51 53
52 my $action = $r->param('action'); 54 my $action = $r->param('action') ;
53 my $openfilename = $r->param('openfilename'); 55 my $openfilename = $r->param('openfilename');
54 my $savefilename = $r->param('savefilename'); 56 my $savefilename = $r->param('savefilename');
55 57
56 58
57 #FIXME get these values from global course environment (see subroutines as well) 59 #FIXME get these values from global course environment (see subroutines as well)
73############################################################################################# 75#############################################################################################
74# gather database data 76# gather database data
75############################################################################################# 77#############################################################################################
76 # FIXME this might be better done in body? We don't always need all of this data. or do we? 78 # FIXME this might be better done in body? We don't always need all of this data. or do we?
77 my @users = $db->listUsers; 79 my @users = $db->listUsers;
80 my @Users = $db->getUsers(@users);
78 my @user_records = (); 81 my @user_records = ();
82
83## Mark's code to prefilter userlist
84
85
86 my (@viewable_sections,@viewable_recitations);
87
88 if (defined @{$ce->{viewable_sections}->{$user}})
89 {@viewable_sections = @{$ce->{viewable_sections}->{$user}};}
90 if (defined @{$ce->{viewable_recitations}->{$user}})
91 {@viewable_recitations = @{$ce->{viewable_recitations}->{$user}};}
92
93 if (@viewable_sections or @viewable_recitations){
94 foreach my $student (@Users){
95 my $keep = 0;
96 foreach my $sec (@viewable_sections){
97 if ($student->section() eq $sec){$keep = 1;}
98 }
99 foreach my $rec (@viewable_recitations){
100 if ($student->recitation() eq $rec){$keep = 1;}
101 }
102 if ($keep) {push @user_records, $student;}
103 }
104 }
105 else {@user_records = @Users;}
106
107## End Mark's code
108
79 foreach my $userName (@users) { 109# foreach my $userName (@users) {
80 my $userRecord = $db->getUser($userName); # checked 110# my $userRecord = $db->getUser($userName); # checked
81 die "record for user $userName not found" unless $userRecord; 111# die "record for user $userName not found" unless $userRecord;
82 push(@user_records, $userRecord); 112# push(@user_records, $userRecord);
83 } 113# }
84 ########################### 114 ###########################
85 # Sort the users for presentation in the select list 115 # Sort the users for presentation in the select list
86 ########################### 116 ###########################
87 if (defined $r->param("sort_by") ) { 117# if (defined $r->param("sort_by") ) {
88 my $sort_method = $r->param("sort_by"); 118# my $sort_method = $r->param("sort_by");
89 if ($sort_method eq 'section') { 119# if ($sort_method eq 'section') {
90 @user_records = sort { (lc($a->section) cmp lc($b->section)) || (lc($a->last_name) cmp lc($b->last_name)) } @user_records; 120# @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') { 121# } 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; 122# @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') { 123# } elsif ($sort_method eq 'alphabetical') {
94 @user_records = sort { (lc($a->last_name) cmp lc($b->last_name)) } @user_records; 124# @user_records = sort { (lc($a->last_name) cmp lc($b->last_name)) } @user_records;
95 } elsif ($sort_method eq 'id' ) { 125# } elsif ($sort_method eq 'id' ) {
96 @user_records = sort { $a->user_id cmp $b->user_id } @user_records; 126# @user_records = sort { $a->user_id cmp $b->user_id } @user_records;
97 } 127# }
98 } else { 128# } else {
99 @user_records = sort { $a->user_id cmp $b->user_id } @user_records; 129# @user_records = sort { $a->user_id cmp $b->user_id } @user_records;
100 } 130# }
101 131
102 132
103 # replace the user names by a sorted version. 133 # replace the user names by a sorted version.
104 @users = map {$_->user_id} @user_records; 134 @users = map {$_->user_id} @user_records;
105 # store data 135 # store data
190 220
191 221
192############################################################################################# 222#############################################################################################
193# Determine input source 223# Determine input source
194############################################################################################# 224#############################################################################################
225 #warn "Action = $action";
226 my $input_source;
227 if ($action){
195 my $input_source = ( defined( $r->param('body') ) and $action ne 'Open' ) ? 'form' : 'file'; 228 $input_source = ( defined( $r->param('body') ) and $action ne 'Open' ) ? 'form' : 'file';}
229 else { $input_source = ( defined($r->param('body')) ) ? 'form' : 'file';}
196 230
197############################################################################################# 231#############################################################################################
198# Get inputs 232# Get inputs
199############################################################################################# 233#############################################################################################
200 my($from, $replyTo, $r_text, $subject); 234 my($from, $replyTo, $r_text, $subject);
458 my %classlistLabels = ();# %$hr_classlistLabels; 492 my %classlistLabels = ();# %$hr_classlistLabels;
459 foreach my $ur (@{ $ra_user_records }) { 493 foreach my $ur (@{ $ra_user_records }) {
460 $classlistLabels{$ur->user_id} = $ur->user_id.': '.$ur->last_name. ', '. $ur->first_name.' -- '.$ur->section." / ".$ur->recitation; 494 $classlistLabels{$ur->user_id} = $ur->user_id.': '.$ur->last_name. ', '. $ur->first_name.' -- '.$ur->section." / ".$ur->recitation;
461 } 495 }
462 496
497## Mark edit define scrolling list
498 my $scrolling_user_list = scrollingRecordList({
499 name => "classList", ## changed from classList to action
500 request => $r,
501 default_sort => "lnfn",
502 default_format => "lnfn_uid",
503 default_filters => ["all"],
504 size => 5,
505 multiple => 1,
506 }, @{$ra_user_records});
463 507
464############################################################################################################## 508##############################################################################################################
465 509
466 510
467 my $from = $self->{from}; 511 my $from = $self->{from};
510 "\n", CGI::br(),'Subject: ', CGI::br(), CGI::textarea(-name=>'subject', -default=>$subject, -rows=>3,-columns=>30, -override=>1), 554 "\n", CGI::br(),'Subject: ', CGI::br(), CGI::textarea(-name=>'subject', -default=>$subject, -rows=>3,-columns=>30, -override=>1),
511 ), 555 ),
512############################################################################################# 556#############################################################################################
513# second column 557# second column
514############################################################################################# 558#############################################################################################
515 CGI::td({-align=>'left',style=>'font-size:smaller'}, 559# CGI::td({-align=>'left',style=>'font-size:smaller'},
516 560#
517 CGI::strong("Send to:"), 561# CGI::strong("Send to:"),
518 CGI::radio_group(-name=>'radio', -values=>['all_students','studentID'], 562# CGI::radio_group(-name=>'radio', -values=>['all_students','studentID'],
519 -labels=>{all_students=>'All',studentID => 'Selected'}, 563# -labels=>{all_students=>'All',studentID => 'Selected'},
520 -default=>'studentID', 564# -default=>'studentID',
521 -linebreak=>0 565# -linebreak=>0
522 ), CGI::br(),CGI::br(), 566# ), CGI::br(),CGI::br(),
523 567## Edit by Mark to insert scrolling list
568 CGI::td({-style=>"width:33%"},CGI::strong("Send to:"),
569 CGI::radio_group(-name=>'radio', -values=>['all_students','studentID'],
570 -labels=>{all_students=>'All',studentID => 'Selected'},
571 -default=>'studentID', -linebreak=>0),
572 CGI::br(),$scrolling_user_list),
573## Edit here to insert filtering
574## be sure to fail GRACEFULLY!
575#
576#
524 CGI::input({type=>'submit',value=>'Sort by',name=>'action'}),, 577# CGI::input({type=>'submit',value=>'Sort by',name=>'action'}),,
525 CGI::radio_group(-name=>'sort_by', -values=>['id','alphabetical','section','recitation'], 578# CGI::radio_group(-name=>'sort_by', -values=>['id','alphabetical','section','recitation'],
526 -labels=>{id=>'Login',alphabetical=>'Alph.',section => 'Sec.',recitation=>'Rec.'}, 579# -labels=>{id=>'Login',alphabetical=>'Alph.',section => 'Sec.',recitation=>'Rec.'},
527 -default=>defined($r->param("sort_by")) ? $r->param("sort_by") : 'id', 580# -default=>defined($r->param("sort_by")) ? $r->param("sort_by") : 'id',
528 -linebreak=>0 581# -linebreak=>0
529 ), 582# ),
530 583#
531 CGI::br(),CGI::br(), 584# CGI::br(),CGI::br(),
532 CGI::popup_menu(-name=>'classList', 585# CGI::popup_menu(-name=>'classList',
533 -values=>\@users, 586# -values=>\@users,
534 -labels=>\%classlistLabels, 587# -labels=>\%classlistLabels,
535 -size => 10, 588# -size => 10,
536 -multiple => 1, 589# -multiple => 1,
537 -default=>$user 590# -default=>$user
538 ), 591# ),
539 ), 592# ),
593
540 594
595
541 596
542############################################################################################# 597#############################################################################################
543# third column 598# third column
544############################################################################################# 599#############################################################################################
545 CGI::td({align=>'left'}, 600 CGI::td({align=>'left'},

Legend:
Removed from v.2202  
changed lines
  Added in v.2203

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9