[LON-CAPA-cvs] cvs: loncom /enrollment Autoupdate.pl localenroll.pm

raeburn raeburn at source.lon-capa.org
Fri Oct 14 13:13:25 EDT 2011


raeburn		Fri Oct 14 17:13:25 2011 EDT

  Modified files:              
    /loncom/enrollment	Autoupdate.pl localenroll.pm 
  Log:
  - Make Autoupdate.pl suitable for institutions which only allow a LON-CAPA 
    server to retrieve institutional user information when the user's  
    username is included in the query.
  
  
Index: loncom/enrollment/Autoupdate.pl
diff -u loncom/enrollment/Autoupdate.pl:1.19 loncom/enrollment/Autoupdate.pl:1.20
--- loncom/enrollment/Autoupdate.pl:1.19	Fri Mar 26 13:19:04 2010
+++ loncom/enrollment/Autoupdate.pl	Fri Oct 14 17:13:25 2011
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 #
 # Automated Userinfo update script
-# $Id: Autoupdate.pl,v 1.19 2010/03/26 13:19:04 raeburn Exp $
+# $Id: Autoupdate.pl,v 1.20 2011/10/14 17:13:25 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -65,16 +65,15 @@
         # get courseIDs for domain
         my %courses=&Apache::lonnet::courseiddump($dom,'.',1,'.','.','.',1,[$hostid],'.');
         # get user information
-        my (%instusers,%instids);
-        next if (&localenroll::allusers_info($dom,\%instusers,\%instids) ne 'ok');
-        my (%users,%unamechg,%possnames);
+        my (%users,%instusers,%instids);
+        my $dir = $Apache::lonnet::perlvar{lonUsersDir}.'/'.$dom;
+        &descend_tree($dir,0,\%users,\%courses);
+        next if (&localenroll::allusers_info($dom,\%instusers,\%instids,\%users) ne 'ok');
+        my (%unamechg,%possnames);
         my @types = ('active','future');
         my @roles = ('st');
         my @cdoms = ($dom);
-        my $dir = $Apache::lonnet::perlvar{lonUsersDir}.'/'.$dom;
-        &descend_tree($dir,0,\%users);
         foreach my $uname (sort(keys(%users))) {
-            next if ($courses{$dom.'_'.$uname});
             my %userhash = &Apache::lonnet::userenvironment($dom,$uname, at info);
             my (@inststatuses);
             if (!$userhash{'internalname'}) {
@@ -185,7 +184,7 @@
     }
 
 sub descend_tree {
-    my ($dir,$depth,$alldomusers) = @_;
+    my ($dir,$depth,$alldomusers,$coursesref) = @_;
     if (-d $dir) {
         opendir(DIR,$dir);
         my @contents = grep(!/^\./,readdir(DIR));
@@ -193,8 +192,11 @@
         $depth ++;
         foreach my $item (@contents) {
             if ($depth < 4) {
-                &descend_tree($dir.'/'.$item,$depth,$alldomusers);
+                &descend_tree($dir.'/'.$item,$depth,$alldomusers,$coursesref);
             } elsif (-e $dir.'/'.$item.'/passwd') {
+                if (ref($coursesref) eq 'HASH') {
+                    next if (exists($coursesref->{$item}));
+                }
                 $$alldomusers{$item} = '';
             }
         }
Index: loncom/enrollment/localenroll.pm
diff -u loncom/enrollment/localenroll.pm:1.42 loncom/enrollment/localenroll.pm:1.43
--- loncom/enrollment/localenroll.pm:1.42	Mon May 23 19:11:41 2011
+++ loncom/enrollment/localenroll.pm	Fri Oct 14 17:13:25 2011
@@ -1,6 +1,6 @@
 # functions to glue school database system into Lon-CAPA for 
 # automated enrollment
-# $Id: localenroll.pm,v 1.42 2011/05/23 19:11:41 raeburn Exp $
+# $Id: localenroll.pm,v 1.43 2011/10/14 17:13:25 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -735,6 +735,9 @@
                 keys will be unique IDs (student or faculty/staff ID)
                 values will be either: scalar (username) or an array 
                 if a single ID matches multiple usernames.
+ (d) $lc_users - reference to hash containing LON-CAPA usernames in 
+                 in domain $dom, as keys. Needed if institutional
+                 data source only allows query by username.
  returns 1 parameter - 'ok' if no processing error, or other value 
                        if an error occurred.
  side effects - populates the $instusers and $instids refs to hashes.
@@ -745,7 +748,7 @@
 =cut
 
 sub allusers_info {
-    my ($dom,$instusers,$instids) = @_;
+    my ($dom,$instusers,$instids,$lc_users) = @_;
     my $outcome = 'ok';
     return $outcome; 
 }




More information about the LON-CAPA-cvs mailing list