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

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 17 Apr 2002 13:55:35 -0000


matthew		Wed Apr 17 09:55:35 2002 EDT

  Modified files:              
    /loncom/interface	londropadd.pm 
  Log:
  Fixed bug in modifystudent introduced in last commit, changed return value
  for get_current_classlist so that we detect when the classlist is empty
  instead of assuming it is an error.
  
  
Index: loncom/interface/londropadd.pm
diff -u loncom/interface/londropadd.pm:1.26 loncom/interface/londropadd.pm:1.27
--- loncom/interface/londropadd.pm:1.26	Tue Apr 16 17:02:17 2002
+++ loncom/interface/londropadd.pm	Wed Apr 17 09:55:35 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to drop and add students in courses 
 #
-# $Id: londropadd.pm,v 1.26 2002/04/16 21:02:17 matthew Exp $
+# $Id: londropadd.pm,v 1.27 2002/04/17 13:55:35 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -59,8 +59,7 @@
 # ================================================================ Print header
 
 sub header {
-    my $r=shift;
-    $r->print(<<ENDHEAD);
+    return(<<ENDHEAD);
 <html>
 <head>
 <title>LON-CAPA Student Drop/Add</title>
@@ -94,9 +93,9 @@
             my $section=$1;
             $section='' if ($course eq $courseid.'_st');
             if (((!$section) && (!$csec)) || ($section ne $csec)) {
-                my (undef,$end,$start)=split(/\_/,$course);
+                my (undef,$end,$start)=split(/\_/,$roles{$course});
                 my $now=time;
-                if (($start) && ($end) && ($now>$start) && ($now<$end)) {
+                if (!($start && ($now<$start)) || !($end && ($now>$end))) {
                     my $reply=&Apache::lonnet::modifystudent
                         ($udom,$unam,'','','','','','','',$section,time);
                 }
@@ -654,9 +653,9 @@
                 $currentlist{$student}=1;
             }
         }
-        return %currentlist;
+        return (undef,%currentlist);
     } else {
-        return undef;
+        return ($tmp,undef);
     }
 }
 
@@ -664,11 +663,13 @@
 sub menu_phase_two_drop {
     my $r=shift;
     my $cid=$ENV{'request.course.id'};
-    my %currentlist=&get_current_classlist($ENV{'course.'.$cid.'.domain'},
+    my ($error,%currentlist)=&get_current_classlist($ENV{'course.'.$cid.'.domain'},
                                            $ENV{'course.'.$cid.'.num'});
+    if (defined($error)) {
+        $r->print('<pre>ERROR:$error</pre>');
+    }
     if (!defined(%currentlist)) { 
-        $r->print('<font color=red>'.
-                  '<h3> Could not access classlist.</h3></font>');
+        $r->print("There are no students currently enrolled.\n");
     } else {
         # Print out the available choices
         &show_drop_list($r,%currentlist);
@@ -854,9 +855,12 @@
         if ($ENV{'form.fullup'} eq 'yes') {
             $r->print('<h3>Dropping Students</h3>');
             #  Get current classlist
-            my %currentlist=&get_current_classlist
+            my ($error,%currentlist)=&get_current_classlist
                 ($ENV{'course.'.$cid.'.domain'},
                  $ENV{'course.'.$cid.'.num'});
+            if (defined($error)) {
+                $r->print('<pre>ERROR:$error</pre>');
+            }
             if (defined(%currentlist)) {
                 # Drop the students
                 foreach (@studentdata) {
@@ -870,8 +874,7 @@
                 # Print out list of dropped students
                 &show_drop_list($r,%currentlist);
             } else {
-                $r->print('<font color=red>'.
-                          '<h3>Could not access classlist</h3></font>');
+                $r->print("There are no students currently enrolled.\n");
             }
         }
     } # end of unless
@@ -906,7 +909,7 @@
         # Start page
         $r->content_type('text/html');
         $r->send_http_header;
-        &header($r);
+        $r->print(&header());
         # Phase one, initial screen
         unless ($ENV{'form.phase'}) {
             &menu_phase_one($r);