--- loncom/interface/Attic/londropadd.pm 2002/10/16 15:02:28 1.58 +++ loncom/interface/Attic/londropadd.pm 2002/11/08 20:51:48 1.60 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to drop and add students in courses # -# $Id: londropadd.pm,v 1.58 2002/10/16 15:02:28 matthew Exp $ +# $Id: londropadd.pm,v 1.60 2002/11/08 20:51:48 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -41,6 +41,7 @@ use Apache::lonnet(); use Apache::loncommon(); use Apache::lonhtmlcommon(); use Apache::Constants qw(:common :http REDIRECT); +use Spreadsheet::WriteExcel; ############################################################### ############################################################### @@ -755,8 +756,7 @@ sub print_html_classlist { if (! exists($ENV{'form.sortby'})) { $ENV{'form.sortby'} = 'username'; } - if (! exists($ENV{'form.Status'}) || - $ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) { + if ($ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) { $ENV{'form.Status'} = 'Active'; } my $status_select = &Apache::lonhtmlcommon::StatusOptions @@ -767,13 +767,17 @@ sub print_html_classlist {
Current Classlist
+END
+ if ($ENV{'form.action'} ne 'modifystudent') {
+ $r->print(<
@@ -848,6 +858,22 @@ END $r->print('"'.join('","',("username","domain","ID","student name", "section")).'"'."\n"); } + } elsif ($mode eq 'excel') { + # Create the excel spreadsheet + $excel_filename = '/prtspool/'. + $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'. + time.'_'.rand(1000000000).'.xls'; + $excel_workbook = Spreadsheet::WriteExcel->new('/home/httpd'. + $excel_filename); + $excel_workbook->set_tempdir('/home/httpd/perl/tmp'); + $excel_sheet = $excel_workbook->addworksheet('classlist'); + # + my $description = 'Classlist for '. + $ENV{'course.'.$ENV{'request.course.id'}.'.description'}; + $excel_sheet->write($row++,0,$description); + # + $excel_sheet->write($row++,0,["username","domain","ID", + "student name","section","status"]); } # # Sort the students @@ -883,9 +909,12 @@ END $username, $domain)); } elsif ($linkto eq 'modify') { - $r->print(''. + $r->print(''. $username."\n"); } $r->print(<<"END"); @@ -909,9 +938,18 @@ END $" = '","'; $r->print("\"@line\"\n"); $" = $tmp; + } elsif ($mode eq 'excel') { + $excel_sheet->write($row++,0,[$username,$domain,$id, + $name,$section,$status]); } } - $r->print(' |
---|
'. + 'Your Excel spreadsheet is ready for download.
'."\n"); + } } @@ -921,7 +959,7 @@ END sub print_modify_student_form { my $r = shift(); &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['sdom','sname','sortby']); + ['sdom','sname']); my $sname = $ENV{'form.sname'}; my $sdom = $ENV{'form.sdom'}; my $sortby = $ENV{'form.sortby'}; @@ -949,6 +987,11 @@ sub print_modify_student_form { my $enddateform = &Apache::lonhtmlcommon::date_setter('studentform', 'enddate', $endtime); + # + if (! exists($ENV{'form.Status'}) || + $ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) { + $ENV{'form.Status'} = 'crap'; + } # Make sure student is enrolled in course $r->print(<@@ -998,8 +1043,10 @@ END # sub modify_single_student { my $r = shift; - # Get the 'sortby' variable so the user does not need to re-sort + # Get the 'sortby' and 'Status' variables so the user goes back to their + # previous screen my $sortby = $ENV{'form.sortby'}; + my $status = $ENV{'form.Status'}; # # We always need this information my $slogin = $ENV{'form.slogin'}; @@ -1010,6 +1057,8 @@ sub modify_single_student { ['firstname','middlename', 'lastname','generation','id'], $sdom, $slogin); + $old{'section'} = &Apache::lonnet::getsection($sdom,$slogin, + $ENV{'request.course.id'}); my ($tmp) = keys(%old); if ($tmp =~ /^(con_lost|error|no_such_host)/i) { $r->print("There was an error determining the environment values ". @@ -1071,11 +1120,14 @@ sub modify_single_student {
Section | $section |
Start Time | $displayable_starttime |
End Time | $displayable_endtime |
-Modify another students data + + + +Modify another students data