Diff for /loncom/enrollment/Autoenroll.pl between versions 1.4 and 1.10

version 1.4, 2003/12/11 03:24:20 version 1.10, 2004/06/09 17:01:56
Line 1 Line 1
 #!/usr/bin/perl  #!/usr/bin/perl
   #
   #Automated Enrollment script
   # $Id$
   #
   # Copyright Michigan State University Board of Trustees
   #
   # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
   #
   # LON-CAPA is free software; you can redistribute it and/or modify
   # it under the terms of the GNU General Public License as published by
   # the Free Software Foundation; either version 2 of the License, or
   # (at your option) any later version.
   #
   # LON-CAPA is distributed in the hope that it will be useful,
   # but WITHOUT ANY WARRANTY; without even the implied warranty of
   # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   # GNU General Public License for more details.
   #
   # You should have received a copy of the GNU General Public License
   # along with LON-CAPA; if not, write to the Free Software
   # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   #
   # /home/httpd/html/adm/gpl.txt
   #
   # http://www.lon-capa.org/
   #
   
     use strict;      use strict;
     use lib '/home/httpd/lib/perl';      use lib '/home/httpd/lib/perl';
Line 10 Line 36
     use Apache::lonmsg;      use Apache::lonmsg;
     use HTML::Entities;      use HTML::Entities;
   
 # Determine the library server's domain  #only run if configured to
       if (! &localenroll::run()) { exit; }
   
   # Determine the library server's domain and hostID
     my $perlvarref = LONCAPA::Configuration::read_conf('loncapa.conf');      my $perlvarref = LONCAPA::Configuration::read_conf('loncapa.conf');
     my $dom = $$perlvarref{'lonDefDomain'};      my $dom = $$perlvarref{'lonDefDomain'};
     my $logfile = $$perlvarref{'lonDaemons'}.'/logs/autoenroll.log';      my $logfile = $$perlvarref{'lonDaemons'}.'/logs/autoenroll.log';
     $ENV{'user.domain'} = $dom;      $ENV{'user.domain'} = $dom;
       my $hostid = $$perlvarref{'lonHostID'};
   
 # Determine the present time;  # Determine the present time;
     my $timenow = time();      my $timenow = time();
   
 # Determine the courses  # Determine the courses
     my %courses = &Apache::lonnet::courseiddump($dom,'.',1);       my %courses = &Apache::lonnet::courseiddump($dom,'.',1,$hostid); 
     my %affiliates = ();      my %affiliates = ();
     my %enrollvar = ();      my %enrollvar = ();
     my %reply = ();      my %reply = ();
Line 43 Line 73
                 $enrollvar{$crs}{$item} = &HTML::Entities::decode($settings{$item});                    $enrollvar{$crs}{$item} = &HTML::Entities::decode($settings{$item});  
             }              }
         }          }
         if (($enrollvar{$crs}{autostart} <= $timenow) && ($enrollvar{$crs}{autoend} > $timenow)) {          if (($enrollvar{$crs}{autostart} <= $timenow) && ( ($enrollvar{$crs}{autoend} > $timenow) || ($enrollvar{$crs}{autoend} == 0) ) ) {
             if ( ($enrollvar{$crs}{autoadds} == 1) || ($enrollvar{$crs}{autodrops} == 1) ) {              if ( ($enrollvar{$crs}{autoadds} == 1) || ($enrollvar{$crs}{autodrops} == 1) ) {
 # Add to list of classes for retrieval  # Add to list of classes for retrieval
                 $enrollvar{$crs}{sectionnums} =~ s/ //g;                  $enrollvar{$crs}{sectionnums} =~ s/ //g;
Line 83 Line 113
             }              }
         }          }
     }      }
     &localenroll::fetch_enrollment($dom,\%affiliates,\%reply);      my $outcome = &Apache::lonnet::fetch_enrollment_query('automated',$dom,\%affiliates,\%reply);
   
 # Now go through classes and perform required enrollment changes.  # Now go through classes and perform required enrollment changes.
     open (my $fh,">>$logfile");      open (my $fh,">>$logfile");
Line 92 Line 122
         my $logmsg = '';          my $logmsg = '';
         my $newusermsg = '';          my $newusermsg = '';
         if ($reply{$crs} > 0) {          if ($reply{$crs} > 0) {
             if (($enrollvar{$crs}{autostart} < $timenow) && ($enrollvar{$crs}{autoend} > $timenow)) {              if ( ($enrollvar{$crs}{autostart} < $timenow) && ( ($enrollvar{$crs}{autoend} > $timenow) || ($enrollvar{$crs}{autoend} == 0) ) ) {
                 if (($enrollvar{$crs}{autoadds} == 1) || ($enrollvar{$crs}{autodrops} == 1)) {                  if (($enrollvar{$crs}{autoadds} == 1) || ($enrollvar{$crs}{autodrops} == 1)) {
                     my ($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$enrollvar{$crs}{autoadds},$enrollvar{$crs}{autodrops},$enrollvar{$crs}{startdate},$enrollvar{$crs}{enddate},$enrollvar{$crs}{authtype},$enrollvar{$crs}{autharg},\@{$affiliates{$crs}},\%{$LC_code{$crs}},\$logmsg,\$newusermsg,'automated');                      my ($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$enrollvar{$crs}{autoadds},$enrollvar{$crs}{autodrops},$enrollvar{$crs}{startdate},$enrollvar{$crs}{enddate},$enrollvar{$crs}{authtype},$enrollvar{$crs}{autharg},\@{$affiliates{$crs}},\%{$LC_code{$crs}},\$logmsg,\$newusermsg,'automated');
                     print $fh "Messages start for $crs\n";                      print $fh "Messages start for $crs\n";
Line 134 Line 164
                 }                  }
             }              }
         } else {          } else {
             print $fh "No institutional classlist data could be retrieved for $crs\n";              if ( ($enrollvar{$crs}{autoadds} == 1) || ($enrollvar{$crs}{autodrops} == 1) ) {
                   if ( ($enrollvar{$crs}{autostart} < $timenow) && ( ($enrollvar{$crs}{autoend} > $timenow) || ($enrollvar{$crs}{autoend} == 0) ) ) {
                       print $fh "No institutional classlist data could be retrieved for $crs\n";
                   } else {
                       print $fh "Not within time window for auto-enrollment in $crs\n";
                   }
               } else {
                   print $fh "Auto-enrollment not currently enabled for $crs\n";
               }
         }          }
     }      }
     print $fh "-- ".localtime(time)." Enrollment messages end\n*******************\n\n";      print $fh "-- ".localtime(time)." Enrollment messages end\n*******************\n\n";

Removed from v.1.4  
changed lines
  Added in v.1.10


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>