--- loncom/interface/Attic/londropadd.pm 2002/04/30 13:51:00 1.34 +++ 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.34 2002/04/30 13:51:00 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
}
@@ -679,6 +687,7 @@ sub get_current_classlist {
}
return (undef,%currentlist);
} else {
+ $tmp =~ s/^error://;
return ($tmp,undef);
}
}
@@ -687,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 @@ -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.'
Dropped '.$count.' student(s).');