[LON-CAPA-cvs] cvs: modules /raeburn Enrollment.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 05 Dec 2003 16:12:33 -0000


albertel		Fri Dec  5 11:12:33 2003 EDT

  Modified files:              
    /modules/raeburn	Enrollment.pm 
  Log:
  - reverting to use standard lonnet routines
  
  
Index: modules/raeburn/Enrollment.pm
diff -u modules/raeburn/Enrollment.pm:1.2 modules/raeburn/Enrollment.pm:1.3
--- modules/raeburn/Enrollment.pm:1.2	Thu Dec  4 12:02:53 2003
+++ modules/raeburn/Enrollment.pm	Fri Dec  5 11:12:33 2003
@@ -225,7 +225,7 @@
                         }  
                     }
 # Now create user.
-                    my $reply=&modifystudent($$configvars{'lonHostID'},$dom,$cid,$crs,$uname,$pid,$auth,$authparam,$first,$middle,$last,$gene,$usec,$end,$start,'',undef,$emailaddr,'auto',$context);
+                    my $reply=&Apache::lonnet::modifystudent($dom,$uname,$pid,$auth,$authparam,$first,$middle,$last,$gene,$usec,$end,$start,'',undef,$emailaddr,'auto',$cid);
                     if ($reply eq 'ok') {
                         $enrollcount ++;
                         $addresult .= "$first $last ($pid) - $uname enrolled in section/group $usec.".$linefeed;
@@ -380,67 +380,6 @@
     print STDERR $logmsg;
     return $addresult.$dropresult; 
 } 
-
-sub modifystudent {
-    my ($hostID,$udom,$cid,$crs,$uname,$uid,$umode,$upass,$first,$middle,$last,$gene,$usec,$end,$start,$forceid,$desiredhome,$email,$type,$context)=@_;
-# --------------------------------------------------------------- Make the user
-    my $reply=&Apache::lonnet::modifyuser
-        ($udom,$uname,$uid,$umode,$upass,$first,$middle,$last,$gene,$forceid,
-         $desiredhome,$email);
-    unless ($reply eq 'ok') { return $reply; }
-    # This will cause &modify_student_enrollment to get the uid from the
-    # students environment
-    $uid = undef if (!$forceid);
-    if ($context eq "dadagrrg") {
-        $reply = &Apache::lonnet::modify_student_enrollment($udom,$cid,$uname,$uid,$first,$middle,$last,$gene,$usec,$end,$start,$type);
-    } else { 
-        $reply = &modify_student_enrollment($hostID,$udom,$cid,$crs,$uname,$uid,$first,$middle,$last,$gene,$usec,$end,$start,$type);
-    }
-    return $reply;
-}
-                                                                                       
-sub modify_student_enrollment {
-    my ($hostID,$udom,$cid,$crs,$uname,$uid,$first,$middle,$last,$gene,$usec,$end,$start,$type) = @_;
-    # Make sure the user exists
-    my $uhome=&Apache::lonnet::homeserver($uname,$udom);
-    if (($uhome eq '') || ($uhome eq 'no_host')) {
-        return 'error: no such user';
-    }
-    #
-    # Get student data if we were not given enough information
-    if (!defined($first)  || $first  eq '' ||
-        !defined($last)   || $last   eq '' ||
-        !defined($uid)    || $uid    eq '' ||
-        !defined($middle) || $middle eq '' ||
-        !defined($gene)   || $gene   eq '') {
-        # They did not supply us with enough data to enroll the student, so
-        # we need to pick up more information.
-        my %tmp = &Apache::lonnet::get('environment',
-                       ['firstname','middlename','lastname', 'generation','id']
-                       ,$udom,$uname);
-        foreach (keys(%tmp)) {
-            &Apache::lonnet::logthis("key $_ = ".$tmp{$_});
-        }
-        $first  = $tmp{'firstname'}  if (!defined($first)  || $first  eq '');
-        $middle = $tmp{'middlename'} if (!defined($middle) || $middle eq '');
-        $last   = $tmp{'lastname'}   if (!defined($last)   || $last eq '');
-        $gene   = $tmp{'generation'} if (!defined($gene)   || $gene eq '');
-        $uid    = $tmp{'id'}         if (!defined($uid)    || $uid  eq '');
-    }
-    my $fullname = &Apache::loncoursedata::ProcessFullName($last,$gene,$first,$middle);
-    my $reply=&Apache::lonnet::critical('put:'.$udom.':'.$crs.':classlist:'.&Apache::lonnet::escape($uname.':'.$udom).'='.&Apache::lonnet::escape(join(':',$end,$start,$uid,$usec,$fullname,$type)),$hostID);
-    unless (($reply eq 'ok') || ($reply eq 'delayed')) {
-        return 'error: '.$reply;
-    }
-
-    # Add student role to user
-    my $uurl='/'.$cid;
-    $uurl=~s/\_/\//g;
-    if ($usec) {
-        $uurl.='/'.$usec;
-    }
-    return &Apache::lonnet::assignrole($udom,$uname,$uurl,'st',$end,$start);
-}
 
 sub parse_classlist {
   my ($tmpdir,$dom,$crs,$class,$placeref,$groupID,$studentsref) = @_;