[LON-CAPA-cvs] cvs: loncom /enrollment Enrollment.pm /interface loncommon.pm lonmodifycourse.pm lonpopulate.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Fri, 16 Sep 2005 16:01:21 -0000


raeburn		Fri Sep 16 12:01:21 2005 EDT

  Modified files:              
    /loncom/interface	lonmodifycourse.pm lonpopulate.pm loncommon.pm 
    /loncom/enrollment	Enrollment.pm 
  Log:
  Moved check_user_status() from Enrollment.pm to loncommon.pm.  Now returns: active, previous or future (instead of ok or expired)
  
  
Index: loncom/interface/lonmodifycourse.pm
diff -u loncom/interface/lonmodifycourse.pm:1.18 loncom/interface/lonmodifycourse.pm:1.19
--- loncom/interface/lonmodifycourse.pm:1.18	Wed Apr 27 15:09:30 2005
+++ loncom/interface/lonmodifycourse.pm	Fri Sep 16 12:01:18 2005
@@ -226,8 +226,8 @@
         my @roleinfo = split/:/,$_;
         if ( ($roleinfo[0] eq 'cc')  && ($roleinfo[2] eq $dom) )  {
             unless (grep/^$roleinfo[1]$/,@local_ccs) {
-                $active_cc = &LONCAPA::Enrollment::check_user_status($roleinfo[2],$roleinfo[1],$dom,$course,'cc');
-                if ($active_cc eq 'ok') {
+                $active_cc = &Apache::loncommon::check_user_status($roleinfo[2],$roleinfo[1],$dom,$course,'cc');
+                if ($active_cc eq 'active') {
                     push @local_ccs, $roleinfo[1];
                     $pname{$roleinfo[1]} = &Apache::loncommon::plainname($roleinfo[1],$roleinfo[2]);
                     $cc_status{$roleinfo[1]} = $lt{'actv'};
@@ -238,8 +238,8 @@
     unless ( (grep/^$enrollvar{'courseowner'}$/,@local_ccs) || ($enrollvar{'courseowner'} eq '') )  {
         push @local_ccs, $enrollvar{'courseowner'};
         $pname{$enrollvar{'courseowner'}} =  &Apache::loncommon::plainname($enrollvar{'courseowner'},$dom);
-        $active_cc = &LONCAPA::Enrollment::check_user_status($dom,$enrollvar{'coursecode'},$dom,$course,'cc');
-        if ($active_cc eq 'ok') {
+        $active_cc = &Apache::loncommon::check_user_status($dom,$enrollvar{'coursecode'},$dom,$course,'cc');
+        if ($active_cc eq 'active') {
             $cc_status{$enrollvar{'courseowner'}} = $lt{'actv'};
         } else {
             $cc_status{$enrollvar{'courseowner'}} = $lt{'inac'};
Index: loncom/interface/lonpopulate.pm
diff -u loncom/interface/lonpopulate.pm:1.25 loncom/interface/lonpopulate.pm:1.26
--- loncom/interface/lonpopulate.pm:1.25	Wed Sep 14 17:25:52 2005
+++ loncom/interface/lonpopulate.pm	Fri Sep 16 12:01:18 2005
@@ -1,5 +1,5 @@
 # automated enrollment configuration handler
-# $Id: lonpopulate.pm,v 1.25 2005/09/14 21:25:52 raeburn Exp $
+# $Id: lonpopulate.pm,v 1.26 2005/09/16 16:01:18 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -540,8 +540,8 @@
           my @roleinfo = split/:/,$_;
           if ($roleinfo[0] eq 'cc')  {
               unless (grep/^$roleinfo[1]\@$roleinfo[2]/,@ccs) {
-                  my $active_cc = &LONCAPA::Enrollment::check_user_status($roleinfo[2],$roleinfo[1],$dom,$crs,'cc');
-                  if ($active_cc eq 'ok') {
+                  my $active_cc = &Apache::loncommon::check_user_status($roleinfo[2],$roleinfo[1],$dom,$crs,'cc');
+                  if ($active_cc eq 'active') {
                       push @ccs, "$roleinfo[1]\@$roleinfo[2]";
                       $pname{"$roleinfo[1]\@$roleinfo[2]"} = &Apache::loncommon::plainname($roleinfo[1],$roleinfo[2]);
                       if (grep/^$roleinfo[1]\@$roleinfo[2]$/,@notified) {
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.273 loncom/interface/loncommon.pm:1.274
--- loncom/interface/loncommon.pm:1.273	Wed Sep 14 17:25:52 2005
+++ loncom/interface/loncommon.pm	Fri Sep 16 12:01:18 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.273 2005/09/14 21:25:52 raeburn Exp $
+# $Id: loncommon.pm,v 1.274 2005/09/16 16:01:18 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2946,6 +2946,60 @@
 
 =pod
 
+=item check_user_status
+
+Determines current status of supplied role for a
+specific user. Roles can be active, previous or future.
+
+Inputs: 
+user's domain, user's username, course's domain,
+course's number, optional section/group.
+
+Outputs:
+role status: active, previous or future. 
+
+=cut
+
+sub check_user_status {
+    my ($udom,$uname,$cdom,$crs,$role,$secgrp) = @_;
+    my %userinfo = &Apache::lonnet::dump('roles',$udom,$uname);
+    my @uroles = keys %userinfo;
+    my $srchstr;
+    my $active_chk = 'none';
+    if (@uroles > 0) {
+        if (($role eq 'cc') || ($secgrp eq '') || (!defined($secgrp))) {
+            $srchstr = '/'.$cdom.'/'.$crs.'_'.$role;
+        } else {
+            $srchstr = '/'.$cdom.'/'.$crs.'/'.$secgrp.'_'.$role;         }
+        if (grep/^$srchstr$/,@uroles) {
+            my $role_end = 0;
+            my $role_start = 0;
+            $active_chk = 'active';
+            if ($userinfo{$srchstr} =~ m/^($role)_(\d+)/) {
+                $role_end = $2;
+                if ($userinfo{$srchstr} =~ m/^($role)_($role_end)_(\d+)$/) {
+                    $role_start = $3;
+                }
+            }
+            if ($role_start > 0) {
+                if (time < $role_start) {
+                    $active_chk = 'future';
+                }
+            }
+            if ($role_end > 0) {
+                if (time > $role_end) {
+                    $active_chk = 'previous';
+                }
+            }
+        }
+    }
+    return $active_chk;
+}
+
+###############################################
+
+=pod
+
 =item get_sections
 
 Determines all the sections for a course including
@@ -2998,6 +3052,8 @@
     return $numsections;
 }
 
+###############################################
+
 
 sub get_posted_cgi {
     my $r=shift;
Index: loncom/enrollment/Enrollment.pm
diff -u loncom/enrollment/Enrollment.pm:1.24 loncom/enrollment/Enrollment.pm:1.25
--- loncom/enrollment/Enrollment.pm:1.24	Wed Aug 31 02:21:58 2005
+++ loncom/enrollment/Enrollment.pm	Fri Sep 16 12:01:19 2005
@@ -1,5 +1,5 @@
 # Automated Enrollment manager
-# $Id: Enrollment.pm,v 1.24 2005/08/31 06:21:58 raeburn Exp $
+# $Id: Enrollment.pm,v 1.25 2005/09/16 16:01:19 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -779,44 +779,6 @@
     return ($passwd);
 }
 
-sub check_user_status {
-    my ($udom,$uname,$cdom,$crs,$role,$secgrp) = @_;
-    my %userinfo = &Apache::lonnet::dump('roles',$udom,$uname);
-    my @uroles = keys %userinfo;
-    my $srchstr;
-    my $active_chk = 'none';
-    if (@uroles > 0) {
-        if ( ($role eq 'cc') || ($secgrp eq '') || ( !defined($secgrp) ) ) {
-            $srchstr = '/'.$cdom.'/'.$crs.'_'.$role;
-        } else {
-            $srchstr = '/'.$cdom.'/'.$crs.'/'.$secgrp.'_'.$role;
-        }
-        if (grep/^$srchstr$/,@uroles) {
-            my $role_end = 0;
-            my $role_start = 0;
-            $active_chk = 'ok';
-            if ( $userinfo{$srchstr} =~ m/^($role)_(\d+)/ ) {
-                $role_end = $2;
-                if ( $userinfo{$srchstr} =~ m/^($role)_($role_end)_(\d+)$/ )
-                {
-                    $role_start = $3;
-                }
-            }   
-            if ($role_start > 0) {
-                if (time < $role_start) {
-                    $active_chk = 'expired';
-                }
-            }
-            if ($role_end > 0) {
-                if (time > $role_end) {
-                    $active_chk = 'expired';
-                }
-            }
-        }
-    }
-    return $active_chk;
-}
-
 sub get_courseinfo {
     my ($dom,$crs,$courseinfo) = @_;
     my $owner;