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

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 29 Apr 2002 14:36:24 -0000


matthew		Mon Apr 29 10:36:24 2002 EDT

  Modified files:              
    /loncom/interface	londropadd.pm 
  Log:
  Fix for users not really being enrolled in courses.
  
  
Index: loncom/interface/londropadd.pm
diff -u loncom/interface/londropadd.pm:1.32 loncom/interface/londropadd.pm:1.33
--- loncom/interface/londropadd.pm:1.32	Fri Apr 26 15:10:54 2002
+++ loncom/interface/londropadd.pm	Mon Apr 29 10:36:23 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to drop and add students in courses 
 #
-# $Id: londropadd.pm,v 1.32 2002/04/26 19:10:54 matthew Exp $
+# $Id: londropadd.pm,v 1.33 2002/04/29 14:36:23 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -75,7 +75,7 @@
 
 # =========== Drop student from all sections of a course, except optional $csec
 sub modifystudent {
-    my ($udom,$unam,$courseid,$csec)=@_;
+    my ($udom,$unam,$courseid,$csec,$desiredhost)=@_;
     # if $csec is undefined, drop the student from all the courses matching
     # this one.  If $csec is defined, drop them from all other sections of 
     # this course and add them to section $csec
@@ -97,7 +97,8 @@
                 my $now=time;
                 if (!($start && ($now<$start)) || !($end && ($now>$end))) {
                     my $reply=&Apache::lonnet::modifystudent
-                        ($udom,$unam,'','','','','','','',$section,time);
+                        ($udom,$unam,'','','','','','','',
+                         $section,time,undef,undef,$desiredhost);
                 }
             }
         }
@@ -534,6 +535,9 @@
 	    if (!$genpwd) { $genpwd=" "; }
 	}
         if (($amode) && ($genpwd)) {
+            &modifystudent($ENV{'form.lcdomain'},$ENV{'form.cuname'},
+                           $ENV{'request.course.id'},$ENV{'form.csec'},
+                            $desiredhost);
           $r->print(&Apache::lonnet::modifystudent(
                       $ENV{'form.lcdomain'},$ENV{'form.cuname'},
                       $ENV{'form.cstid'},$amode,$genpwd,
@@ -542,8 +546,6 @@
                       $ENV{'form.csec'},$ENV{'form.enddate'},
                       $ENV{'form.startdate'},$ENV{'form.forceid'},
                     $desiredhost));
-            &modifystudent($ENV{'form.lcdomain'},$ENV{'form.cuname'},
-                           $ENV{'request.course.id'},$ENV{'form.csec'});
 	} else {
            $r->print('Invalid login mode or password');    
         }          
@@ -871,11 +873,12 @@
                         }
                     }
                     if ($password) {
+                        &modifystudent($domain,$username,$cid,$sec,
+                                       $desiredhost);
                         my $reply=&Apache::lonnet::modifystudent
                             ($domain,$username,$id,$amode,$password,
                              $fname,$mname,$lname,$gen,$sec,$enddate,
                              $startdate,$ENV{'form.forceid'},$desiredhost);
-                        &modifystudent($domain,$username,$cid,$sec);
                         if ($reply ne 'ok') {
                             $r->print('<p><b>'.
                                       'Error enrolling '.$username.': '.