[LON-CAPA-cvs] cvs: loncom /enrollment Enrollment.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Wed, 14 Jan 2004 21:03:31 -0000


raeburn		Wed Jan 14 16:03:31 2004 EDT

  Modified files:              
    /loncom/enrollment	Enrollment.pm 
  Log:
  Old section roles now expired when student switches sections or course coordinator changes section/groupID for a specific section.
  
  
Index: loncom/enrollment/Enrollment.pm
diff -u loncom/enrollment/Enrollment.pm:1.9 loncom/enrollment/Enrollment.pm:1.10
--- loncom/enrollment/Enrollment.pm:1.9	Mon Dec 15 00:39:40 2003
+++ loncom/enrollment/Enrollment.pm	Wed Jan 14 16:03:31 2004
@@ -1,5 +1,5 @@
 # Automated Enrollment manager
-# $Id: Enrollment.pm,v 1.9 2003/12/15 05:39:40 raeburn Exp $
+# $Id: Enrollment.pm,v 1.10 2004/01/14 21:03:31 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -185,11 +185,23 @@
 # Check for section changes
                 unless ($$currlist{$uname}[$sec] eq $stuinfo[ $place{groupID} ]) {
                     if ( ($$currlist{$uname}[$type] eq "auto") && ($adds == 1) ) {
-                        my $modify_section_result = &Apache::lonnet::modify_student_enrollment($dom,$uname,undef,undef,undef,undef,undef,$stuinfo[ $place{groupID} ],$$currlist{$uname}[$cend],$$currlist{$uname}[$cstart],'auto',$cid);
-                        if ($modify_section_result =~ /^ok/) {
-                            $$logmsg .= "Section for $uname switched from old section: ".$$currlist{$uname}[$sec] ." to new section: ".$stuinfo[ $place{groupID} ].".".$linefeed;
+# Delete from roles.db for current section
+                        my $expiretime = time;
+                        my $uurl='/'.$cid;
+                        $uurl=~s/\_/\//g;
+                        if ($$currlist{$uname}[$sec]) {
+                            $uurl.='/'.$$currlist{$uname}[$sec];
+                        }
+                        my $expire_role_result = &Apache::lonnet::assignrole($dom,$uname,$uurl,'st',$expiretime);
+                        if ($expire_role_result eq 'ok') {
+                            my $modify_section_result = &Apache::lonnet::modify_student_enrollment($dom,$uname,undef,undef,undef,undef,undef,$stuinfo[ $place{groupID} ],$$currlist{$uname}[$cend],$$currlist{$uname}[$cstart],'auto',$cid);
+                            if ($modify_section_result =~ /^ok/) {
+                                $$logmsg .= "Section for $uname switched from old section: ".$$currlist{$uname}[$sec] ." to new section: ".$stuinfo[ $place{groupID} ].".".$linefeed;
+                            } else {
+                                $$logmsg .= "Error when attempting section change for $uname from old section ".$$currlist{$uname}[$sec]." to new section: ".$stuinfo[ $place{groupID} ]." -error: $modify_section_result".$linefeed;
+                            }
                         } else {
-                            $$logmsg .= "Error when attempting section change for $uname from old section ".$$currlist{$uname}[$sec]." to new section: ".$stuinfo[ $place{groupID} ]." -error: $modify_section_result".$linefeed;
+                            $$logmsg .= "Error when attempting to expire role for $uname in old section" .$$currlist{$uname}[$sec]." -error: $expire_role_result".$linefeed;
                         }
                     }
                 }