[LON-CAPA-cvs] cvs: loncom /interface londropadd.pm

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 05 Nov 2003 20:55:59 -0000


matthew		Wed Nov  5 15:55:59 2003 EDT

  Modified files:              
    /loncom/interface	londropadd.pm 
  Log:
  Fixed bug which made it impossible to revoke the role of student for a
  student who had previously had a section but later did not have a section.
  Some better error reporting was added as well (returning '666' on error
  doesn't seem like a bright idea now).
  
  
Index: loncom/interface/londropadd.pm
diff -u loncom/interface/londropadd.pm:1.86 loncom/interface/londropadd.pm:1.87
--- loncom/interface/londropadd.pm:1.86	Mon Sep 29 12:09:20 2003
+++ loncom/interface/londropadd.pm	Wed Nov  5 15:55:59 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to drop and add students in courses 
 #
-# $Id: londropadd.pm,v 1.86 2003/09/29 16:09:20 www Exp $
+# $Id: londropadd.pm,v 1.87 2003/11/05 20:55:59 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -80,7 +80,7 @@
             # We are in this course
             my $section=$1;
             $section='' if ($course eq $courseid.'_st');
-            if ($section eq $csec) {
+            if (defined($csec) && $section eq $csec) {
                 $result .= 'ok:';
             } elsif ( ((!$section) && (!$csec)) || ($section ne $csec) ) {
                 my (undef,$end,$start)=split(/\_/,$roles{$course});
@@ -755,7 +755,6 @@
     if ($home ne 'no_host') {
         $new_user = 0;
     }
-    &Apache::lonnet::logthis('home = '.$home);
     #
     my $user_data_html = '';
     my $javascript_validations = '';
@@ -1150,6 +1149,11 @@
     }
     # determine the students starting and ending times and section
     my ($starttime,$endtime,$section) = &get_enrollment_data($sname,$sdom);
+    if ($starttime =~ /^error/) {
+        $r->print('<h2>Error</h2>');
+        $r->print('<p>'.$starttime.'</p>');
+        return;
+    }
     # Deal with date forms
     my $date_table = &date_setting_table($starttime,$endtime);
     #
@@ -1349,7 +1353,7 @@
     my %roles = &Apache::lonnet::dump('roles',$sdomain,$sname);
     my ($tmp) = keys(%roles);
     # Bail out if we were unable to get the students roles
-    return "666" if ($tmp =~ /^(con_lost|error|no_such_host)/i);
+    return ('error'.$tmp) if ($tmp =~ /^(con_lost|error|no_such_host)/i);
     # Go through the roles looking for enrollment in this course
     my ($end,$start) = (undef,undef);
     my $section = '';