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

raeburn raeburn at source.lon-capa.org
Fri Jan 14 11:27:20 EST 2022


raeburn		Fri Jan 14 16:27:20 2022 EDT

  Modified files:              
    /loncom/enrollment	localenroll.pm Autoupdate.pl 
  Log:
  - Provide mechanism to (optionally) log counts to autoupdate.log when running
    Autoupdate.pl to update user information for users in a domain.
  
  
Index: loncom/enrollment/localenroll.pm
diff -u loncom/enrollment/localenroll.pm:1.62 loncom/enrollment/localenroll.pm:1.63
--- loncom/enrollment/localenroll.pm:1.62	Sun Jun 20 20:35:05 2021
+++ loncom/enrollment/localenroll.pm	Fri Jan 14 16:27:20 2022
@@ -1,6 +1,6 @@
 # functions to glue school database system into Lon-CAPA for 
 # automated enrollment
-# $Id: localenroll.pm,v 1.62 2021/06/20 20:35:05 raeburn Exp $
+# $Id: localenroll.pm,v 1.63 2022/01/14 16:27:20 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1072,6 +1072,13 @@
  (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.
+ (e) $counts - reference to hash (optional), for use when called 
+               from Autoupdate.pl which can contain counts for
+               user-specified items retrieved in allusers_info()
+               or in custom subroutines which it calls. Key in
+               hashref, and count value will be printed to 
+               autoupdate.log by Autoupdate.pl.  
+                 
  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.
@@ -1082,7 +1089,7 @@
 =cut
 
 sub allusers_info {
-    my ($dom,$instusers,$instids,$lc_users) = @_;
+    my ($dom,$instusers,$instids,$lc_users,$counts) = @_;
     my $outcome = 'ok';
     return $outcome; 
 }
Index: loncom/enrollment/Autoupdate.pl
diff -u loncom/enrollment/Autoupdate.pl:1.24 loncom/enrollment/Autoupdate.pl:1.25
--- loncom/enrollment/Autoupdate.pl:1.24	Wed Sep  1 02:14:42 2021
+++ loncom/enrollment/Autoupdate.pl	Fri Jan 14 16:27:20 2022
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 #
 # Automated Userinfo update script
-# $Id: Autoupdate.pl,v 1.24 2021/09/01 02:14:42 raeburn Exp $
+# $Id: Autoupdate.pl,v 1.25 2022/01/14 16:27:20 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -74,16 +74,25 @@
         # get courseIDs for domain
         my %courses=&Apache::lonnet::courseiddump($dom,'.',1,'.','.','.',1,[$hostid],'.');
         # get user information
-        my (%users,%instusers,%instids);
+        my (%users,%instusers,%instids,%counts);
         my $dir = $Apache::lonnet::perlvar{lonUsersDir}.'/'.$dom;
         &descend_tree($dom,$dir,0,\%users,\%courses,$allowed_inactivity,$check_unexpired);
-        my $resp = &localenroll::allusers_info($dom,\%instusers,\%instids,\%users);
+        my $resp = &localenroll::allusers_info($dom,\%instusers,\%instids,\%users,\%counts);
         if ($resp ne 'ok') {
             print $fh &mt('Problem retrieving institutional data for users in domain: [_1].',$dom)."\n".
                       &mt('Error: [_1].',$resp)."\n".
                       "-- \n".&Apache::lonlocal::locallocaltime(time).' '.
                       &mt('Autoupdate messages end')."\n*******************\n\n";
+            close($fh);
             next;
+        } else {
+            if (keys(%counts)) {
+                foreach my $key (sort(keys(%counts))) {
+                    if ($counts{$key} ne '') {
+                        print $fh "Count for $key = $counts{$key}\n";
+                    }
+                }
+            }
         }
         my (%unamechg,%possnames);
         my @types = ('active','future');




More information about the LON-CAPA-cvs mailing list