--- loncom/interface/Attic/londropadd.pm 2002/04/30 13:51:00 1.34 +++ loncom/interface/Attic/londropadd.pm 2002/05/01 20:15:41 1.36 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to drop and add students in courses # -# $Id: londropadd.pm,v 1.34 2002/04/30 13:51:00 matthew Exp $ +# $Id: londropadd.pm,v 1.36 2002/05/01 20:15:41 albertel 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'; + } elsif ($result =~ /^(ok:)+$/) { + $result eq 'ok'; + } + 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
}
@@ -939,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.'
');
+ my $result = &modifystudent($udom,$uname,$ENV{'request.course.id'});
+ if ($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).');