--- loncom/interface/Attic/londropadd.pm 2002/04/29 14:36:23 1.33 +++ loncom/interface/Attic/londropadd.pm 2002/05/03 16:30:48 1.38 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to drop and add students in courses # -# $Id: londropadd.pm,v 1.33 2002/04/29 14:36:23 matthew Exp $ +# $Id: londropadd.pm,v 1.38 2002/05/03 16:30:48 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -84,25 +84,32 @@ sub modifystudent { my %roles = &Apache::lonnet::dump('roles',$udom,$unam); my ($tmp) = keys(%roles); # Bail out if we were unable to get the students roles - return if ($tmp =~ /^(con_lost|error|no_such_host)/i); + return "$1" if ($tmp =~ /^(con_lost|error|no_such_host)/i); # Go through the roles looking for enrollment in this course + my $result = ''; foreach my $course (keys(%roles)) { - my $value = $roles{$course}; - if ($course=~/^$courseid(?:\/)*(\w+)*\_st$/) { + if ($course=~/^$courseid(?:\/)*(?:\s+)*(\w+)*\_st$/) { # We are in this course my $section=$1; $section='' if ($course eq $courseid.'_st'); - if (((!$section) && (!$csec)) || ($section ne $csec)) { + if ( ((!$section) && (!$csec)) || ($section ne $csec) ) { my (undef,$end,$start)=split(/\_/,$roles{$course}); my $now=time; if (!($start && ($now<$start)) || !($end && ($now>$end))) { my $reply=&Apache::lonnet::modifystudent ($udom,$unam,'','','','','','','', $section,time,undef,undef,$desiredhost); + $result .= $reply.':'; } } } } + if ($result eq '') { + $result eq 'Unable to find section for this student'; + } else { + $result =~ s/(ok:)+/ok/g; + } + return $result; } # ============ build a domain and server selection form @@ -168,7 +175,8 @@ sub phase_two_header { Total number of records found in file: $distotal
Disable ID/Student Number Safeguard and Force Change of Conflicting IDs (only do if you know what you are doing)
-
+
Note: for large courses, this operation might be time consuming.
ENDPICK
}
@@ -503,7 +511,8 @@ sub menu_phase_two_upload {
sub enroll_single_student {
my $r=shift;
$r->print('
Enrolling '.$ENV{'form.cuname'}." in domain ". + $ENV{'form.lcdomain'}.'
'); if (($ENV{'form.cuname'})&&($ENV{'form.cuname'}!~/\W/)&& ($ENV{'form.lcdomain'})&&($ENV{'form.lcdomain'}!~/\W/)) { # Deal with home server selection @@ -519,7 +528,7 @@ sub enroll_single_student { return; } } - $r->print(" with server $desiredhost :"); + $r->print(" with server $desiredhost :") if (defined($desiredhost)); # End of home server selection logic my $amode=''; my $genpwd=''; @@ -534,7 +543,9 @@ sub enroll_single_student { $genpwd=$ENV{'form.locarg'}; if (!$genpwd) { $genpwd=" "; } } - if (($amode) && ($genpwd)) { + my $home = &Apache::lonnet::homeserver($ENV{'form.cuname'}, + $ENV{'form.lcdomain'}); + if ((($amode) && ($genpwd)) || ($home ne 'no_host')) { &modifystudent($ENV{'form.lcdomain'},$ENV{'form.cuname'}, $ENV{'request.course.id'},$ENV{'form.csec'}, $desiredhost); @@ -547,7 +558,9 @@ sub enroll_single_student { $ENV{'form.startdate'},$ENV{'form.forceid'}, $desiredhost)); } else { - $r->print('Invalid login mode or password'); + $r->print('ERROR '. + 'Invalid login mode or password. '. + 'Unable to enroll '.$ENV{'form.cuname'}.'.
'); } } else { $r->print('Invalid username or domain'); @@ -674,6 +687,7 @@ sub get_current_classlist { } return (undef,%currentlist); } else { + $tmp =~ s/^error://; return ($tmp,undef); } } @@ -682,12 +696,11 @@ sub get_current_classlist { sub menu_phase_two_drop { my $r=shift; my $cid=$ENV{'request.course.id'}; - my ($error,%currentlist)=&get_current_classlist($ENV{'course.'.$cid.'.domain'}, - $ENV{'course.'.$cid.'.num'}); + my ($error,%currentlist)=&get_current_classlist + ($ENV{'course.'.$cid.'.domain'},$ENV{'course.'.$cid.'.num'}); if (defined($error)) { - $r->print('ERROR:$error'); - } - if (!defined(%currentlist)) { + $r->print("
ERROR:$error"); + } elsif (!defined(%currentlist)) { $r->print("There are no students currently enrolled.\n"); } else { # Print out the available choices @@ -934,10 +947,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.'
Dropped '.$count.' student(s).');