--- loncom/interface/Attic/londropadd.pm 2002/04/23 21:03:59 1.29
+++ loncom/interface/Attic/londropadd.pm 2002/08/21 17:18:08 1.46
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# $Id: londropadd.pm,v 1.29 2002/04/23 21:03:59 matthew Exp $
+# $Id: londropadd.pm,v 1.46 2002/08/21 17:18:08 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -59,23 +59,21 @@ use Apache::Constants qw(:common :http R
# ================================================================ Print header
sub header {
+ my $bodytag=&Apache::loncommon::bodytag('Enrollment Manager');
return(<
-
Drop/Add Students
-
+ + +
+END } # ================================================= Drop/Add from uploaded file @@ -713,8 +911,19 @@ sub upfile_drop_add { my $enddate = $ENV{'form.enddate'}; if ($startdate=~/\D/) { $startdate=''; } if ($enddate=~/\D/) { $enddate=''; } - # + # Determine domain and desired host (home server) my $domain=$ENV{'form.lcdomain'}; + my $desiredhost = $ENV{'form.lcserver'}; + if (lc($desiredhost) eq 'default') { + $desiredhost = undef; + } else { + my %home_servers = &Apache::loncommon::get_library_servers($domain); + if (! exists($home_servers{$desiredhost})) { + $r->print('Error:'. + 'Invalid home server specified'); + return; + } + } # Determine authentication mechanism my $amode = ''; my $genpwd = ''; @@ -797,11 +1006,12 @@ sub upfile_drop_add { } } if ($password) { - &modifystudent($domain,$username,$cid,$sec); + &modifystudent($domain,$username,$cid,$sec, + $desiredhost); my $reply=&Apache::lonnet::modifystudent ($domain,$username,$id,$amode,$password, $fname,$mname,$lname,$gen,$sec,$enddate, - $startdate,$ENV{'form.forceid'}); + $startdate,$ENV{'form.forceid'},$desiredhost); if ($reply ne 'ok') { $r->print(''.
'Error enrolling '.$username.': '.
@@ -857,10 +1067,21 @@ sub upfile_drop_add {
sub drop_student_list {
my $r=shift;
my $count=0;
- foreach (@{$ENV{'form.droplist'}}) {
+ my @droplist;
+ if (ref($ENV{'form.droplist'})) {
+ @droplist = @{$ENV{'form.droplist'}};
+ } else {
+ @droplist = ($ENV{'form.droplist'});
+ }
+ foreach (@droplist) {
my ($uname,$udom)=split(/\:/,$_);
- &modifystudent($udom,$uname,$ENV{'request.course.id'});
- $r->print('Dropped '.$uname.' at '.$udom.'
');
+ my $result = &modifystudent($udom,$uname,$ENV{'request.course.id'});
+ if ($result eq 'ok' || $result eq 'ok:') {
+ $r->print('Dropped '.$uname.' at '.$udom.'
');
+ } else {
+ $r->print('Error dropping '.$uname.' at '.$udom.': '.$result.
+ '
');
+ }
$count++;
}
$r->print('
Dropped '.$count.' student(s).'); @@ -870,7 +1091,6 @@ sub drop_student_list { # ================================================================ Main Handler sub handler { my $r=shift; - $Apache::lonxml::debug=1; if ($r->header_only) { $r->content_type('text/html'); $r->send_http_header; @@ -880,9 +1100,9 @@ sub handler { if (($ENV{'request.course.fn'}) && (&Apache::lonnet::allowed('cst',$ENV{'request.course.id'}))) { # Start page - $r->content_type('text/html'); + $r->content_type('text/html') if (! exists($ENV{'form.viewcsv'})); $r->send_http_header; - $r->print(&header()); + $r->print(&header()) if (! exists($ENV{'form.viewcsv'})); # Phase one, initial screen unless ($ENV{'form.phase'}) { &menu_phase_one($r); @@ -903,6 +1123,10 @@ sub handler { &menu_phase_two_enroll($r); } elsif ($ENV{'form.drop'}) { &menu_phase_two_drop($r); + } elsif ($ENV{'form.view'}) { + &menu_phase_two_view($r); + } elsif ($ENV{'form.viewcsv'}) { + &menu_phase_two_viewcsv($r); } } # Phase three @@ -920,7 +1144,7 @@ sub handler { &enroll_single_student($r); } # End - $r->print('