[LON-CAPA-cvs] cvs: loncom /interface lonpopulate.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Thu, 15 Jan 2004 05:56:34 -0000


This is a MIME encoded message

--raeburn1074146194
Content-Type: text/plain

raeburn		Thu Jan 15 00:56:34 2004 EDT

  Modified files:              
    /loncom/interface	lonpopulate.pm 
  Log:
  bugs 2596 and 2599 
  Auto-enrollment does not work until three sets of parameters are set using the Automated Enrollment Manager:
  
  (a) Auto adds and/or drops are enabled.
  (b) Start and End dates are set for operation of the auto-enrollment process.
  (c) Sections and/or crosslisted classes are selected to contribute enrollment.
  
  When a course coordinator now sets one of these required parameters, the enrollment manager will detect whether one or both of the other critical parameters has NOT been set, and display an appropriate warning.
  
  
--raeburn1074146194
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20040115005634.txt"

Index: loncom/interface/lonpopulate.pm
diff -u loncom/interface/lonpopulate.pm:1.9 loncom/interface/lonpopulate.pm:1.10
--- loncom/interface/lonpopulate.pm:1.9	Wed Jan 14 20:47:21 2004
+++ loncom/interface/lonpopulate.pm	Thu Jan 15 00:56:34 2004
@@ -1,5 +1,5 @@
 # automated enrollment configuration handler
-# $Id: lonpopulate.pm,v 1.9 2004/01/15 01:47:21 raeburn Exp $
+# $Id: lonpopulate.pm,v 1.10 2004/01/15 05:56:34 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -329,17 +329,29 @@
       ");
   } elsif ($action eq "setdates") {
       my ($start_table,$end_table) = &date_setting_table($enrollvar{autostart},$enrollvar{autoend});
-      my $oldstartshow = localtime($enrollvar{autostart});
-      my $oldendshow = localtime($enrollvar{autoend});
-      if ($enrollvar{autoend} == 0) {
-          $oldendshow = "No ending date";
+      my $oldstartshow = '';
+      my $oldendshow = '';
+      if ( defined($enrollvar{autostart}) ) {
+          $oldstartshow = localtime($enrollvar{autostart});
+      }
+      if ( defined($enrollvar{autoend}) ) {
+          $oldendshow = localtime($enrollvar{autoend});
+          if ($enrollvar{autoend} == 0) {
+              $oldendshow = "No ending date";
+          }
+      }
+      my $dateshow;
+      if ( ($oldendshow eq '') && ($oldstartshow eq '') ) {
+         $dateshow = "<br/><font size='+1'>Warning</font>. Currently <b>NO</b> first enrollment or last enrollment dates are set. You <b>must</b> use this menu to set a start date and an end date (or check the 'no ending date' checkbox) if you plan to utilise automated adds and/or drops in this course.\n";
+      } else {
+         $dateshow = "Currently: First enrollment: <b><i>$oldstartshow</i></b>, Last enrollment: <b><i>$oldendshow</i></b>\n";
       }
       $r->print(<<ENDTWO);
                   <form name="enter" method="post"><br/>              
                   <table width="100%" border="0" cellpadding="2" cellspacing="2">
 	           <tr>
-	            <td align="left"><b>$$tasktitleref{$action}</b><br/>
-	             Currently: First enrollment: <i>$oldstartshow</i>, Last enrollment: <i>$oldendshow</i>
+	            <td align="left"><b>$$tasktitleref{$action}</b><br/><br/>
+                     $dateshow
 	            </td>
                    </tr>
 	          </table>
@@ -885,9 +897,31 @@
 ###################################################################
 sub print_chgsettings_response {
   my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
-  my %settings = &Apache::lonnet::get('environment',['internal.autoadds','internal.autodrops'],$dom,$crs);
-  my $curradds = $settings{'internal.autoadds'};
-  my $currdrops = $settings{'internal.autodrops'};
+  my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.crosslistings','internal.autostart','internal.autoend','internal.autoadds','internal.autodrops'],$dom,$crs);
+  my $currend = '';
+  my $currstart = '';
+  my $currsecs = '';
+  my $currxlists = '';
+  my $curradds = '';
+  my $currdrops = '';
+  if ( defined($settings{'internal.autoadds'}) ) {
+      $curradds = $settings{'internal.autoadds'};
+  }
+  if ( defined($settings{'internal.autodrops'}) ) {
+      $currdrops = $settings{'internal.autodrops'};
+  }
+  if ( defined($settings{'internal.autostart'}) ) {
+      $currstart = $settings{'internal.autostart'};
+  }
+  if ( defined($settings{'internal.autoend'}) ) {
+      $currend = $settings{'internal.autoend'};
+  }
+  if ( defined($settings{'internal.sectionnums'}) ) {
+      $currsecs = $settings{'internal.sectionnums'};
+  }
+  if ( defined($settings{'internal.crosslistings'}) ) {
+      $currxlists = $settings{'internal.crosslistings'}
+  }
   my $autoadds = '';
   my $autodrops = '';
 
@@ -899,6 +933,10 @@
   }
 
   my $response = "";
+  my $warning = "";
+  my $warn_prefix = "";
+  my $warn_suffix = "";
+  my $warnfiller = "";
   my %cenv = ('internal.autoadds' => $autoadds,
               'internal.autodrops' => $autodrops);
   my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
@@ -910,7 +948,7 @@
               $response = "Nightly additions based on classlist changes still <b>enabled</b><br/>";
           } else {
               $response = "Nightly additions based on classlist changes now <b>enabled</b><br/>";
-          } 
+          }
       } else {
           if ($curradds) {
               $response = "Nightly additions based on classlist changes now <b>disabled</b><br/>";
@@ -931,6 +969,25 @@
               $response .= "Nightly removals based on classlist changes still <b>disabled</b>";
           }
       }
+      if ($autoadds || $autodrops) {
+          $warning = &warning_message($dom,$crs,$action);
+          $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you indicated that nightly ";
+          $warn_suffix = " should be enabled, additional action is required.<br/>";
+      }
+      if ($autoadds) {
+          if ($autodrops) {
+              $warnfiller = "adds and drops";
+          } else {
+              $warnfiller = "adds";
+          }
+      } else {
+          if ($autodrops) {
+              $warnfiller = "drops";
+          }
+      }
+      unless ($warning eq '') {
+          $response = $warn_prefix.$warnfiller.$warn_suffix.$warning;
+      }
   }
   &print_reply($r,$response,$$tasktitleref{$action});
   return;
@@ -945,6 +1002,8 @@
   my ($autostart,$autoend) = &get_dates_from_form();
   my $showstart = localtime($autostart);
   my $showend = '';
+  my $warning = '';
+  my $warn_prefix = '';
   if ($autoend) {
       $showend = localtime($autoend);
   } else {
@@ -983,7 +1042,7 @@
       my $lastmidnt = timelocal(0,0,0,$date_list[3],$date_list[4],$date_list[5]);
       my $nextmidnt = 86400 + $lastmidnt;
 
-      my $todayupdate = timelocal(0,40,4,$date_list[3],$date_list[4],$date_list[5]);
+      my $todayupdate = timelocal(0,30,1,$date_list[3],$date_list[4],$date_list[5]);
       my $lastupdate = $todayupdate - 86400;
       if ($nowstamp < $todayupdate) {
           $nextupdate = "today";
@@ -1000,9 +1059,14 @@
               $firstaccess = "a date prior to today";
           }
           if (($nowstamp >= $autostart) && ($rosterupdated == 0)) {
-              $response .= qq|<br>Although you have now set the first enrollment date to $firstaccess, automatic enrollment will <b>not</b> occur until the next automatic enrollment update occurs for all LON-CAPA courses at 4.40 am $nextupdate. If you wish to grant immediate course access for registered students included in the institutional classlist for this class, please visit the <a href="/adm/populate?action=updatenow">roster update page</a>.<br>|;
+              $response .= qq|<br>Although you have now set the first enrollment date to $firstaccess, automatic enrollment will <b>not</b> occur until the next automatic enrollment update occurs for all LON-CAPA courses at 1.30 am $nextupdate. If you wish to grant immediate course access for registered students included in the institutional classlist for this class, please visit the <a href="/adm/populate?action=updatenow">roster update page</a>.<br>|;
           }
       }
+      $warning = &warning_message($dom,$crs,$action);
+      $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you set a start and end date for auto-enrollment, additional action is required.<br/>";
+      unless ($warning eq '') {
+          $response .= $warn_prefix.$warning;
+      }
   }
   &print_reply($r,$response,$$tasktitleref{$action});
   return;
@@ -1207,6 +1271,8 @@
   my $coursecode = $settings{'internal.coursecode'};
   my $owner = $settings{'internal.courseowner'};
   my $response = '';
+  my $warning = '';
+  my $warn_prefix = '';
 
   if ($xliststr =~ m/,/) {
       @allxlists = split/,/,$xliststr;
@@ -1292,6 +1358,14 @@
       $response .= "</ul><br/><br/>\n";
   }
 
+  if (@allxlists > 0) {
+      $warning = &warning_message($dom,$crs,$action);
+      $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you have selected crosslisted courses to contribute enrollment to this course, additional action is required.<br/>";
+      unless ($warning eq '') {
+          $response .= $warn_prefix.$warning;
+      }
+  }
+
   &print_reply($r,$response,$$tasktitleref{$action});
   return;
 }
@@ -1308,6 +1382,8 @@
   my $addcount = 0;
   my $secstr = '';
   my $response = '';
+  my $warning = "";
+  my $warn_prefix = "";
   my $coursecode = $settings{'internal.coursecode'};
   my $owner = $settings{'internal.courseowner'};
   if ($settings{'internal.sectionnums'} =~ m/,/) {
@@ -1425,6 +1501,14 @@
       $response .= "</ul><br/><br/>\n";
   }
 
+  if ($seccount > 0) {
+      $warning = &warning_message($dom,$crs,$action);
+      $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you have selected sections to contribute enrollment to this course, additional action is required.<br/>";
+      unless ($warning eq '') {
+          $response .= $warn_prefix.$warning;
+      }
+  }
+
   if ( exists($ENV{'form.numsec'}) ) {
       my $numsec = $ENV{'form.numsec'};
       if ($numsec > 0) {
@@ -1484,6 +1568,8 @@
   my $owner = $settings{'internal.courseowner'};
   my $response = '';
   my $putreply = '';
+  my $warning = '';
+  my $warn_prefix = '';
   if ($secstr =~ m/,/) {
       @allsections = split/,/,$secstr;
   } else {
@@ -1559,6 +1645,14 @@
       $response .= "</ul><br/><br/>\n";
   }
 
+  if (@allsections > 0) {
+      $warning = &warning_message($dom,$crs,$action);
+      $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you have selected sections to contribute enrollment to this course, additional action is required.<br/>";
+      unless ($warning eq '') {
+          $response .= $warn_prefix.$warning;
+      }
+  }
+
   &print_reply($r,$response,$$tasktitleref{$action});
   return;
 }
@@ -1691,6 +1785,52 @@
   $response .= $logmsg.$newusermsg;
   &print_reply($r,$response,$$tasktitleref{$action});
   return;
+}
+
+sub warning_message {
+    my ($dom,$crs,$caller) = @_;
+    my %settings = &Apache::lonnet::get('environment',['internal.autoadds','internal.autodrops','internal.sectionnums','internal.crosslistings','internal.autostart','internal.autoend'],$dom,$crs);
+    my $currend = '';
+    my $currstart = '';
+    my $currsecs = '';
+    my $currxlists = '';
+    my $warning = '';
+    my $curradds = '';
+    my $currdrops = '';
+    if ( defined($settings{'internal.autoadds'}) ) {
+        $curradds = $settings{'internal.autoadds'};
+    }
+    if (defined($settings{'internal.autodrops'}) ) {
+        $currdrops = $settings{'internal.autodrops'};
+    }
+    if ( defined($settings{'internal.autostart'}) ) {
+        $currstart = $settings{'internal.autostart'};
+    }
+    if ( defined($settings{'internal.autoend'}) ) {
+        $currend = $settings{'internal.autoend'};
+    }
+    if ( defined($settings{'internal.sectionnums'}) ) {
+        $currsecs = $settings{'internal.sectionnums'};
+    }
+    if ( defined($settings{'internal.crosslistings'}) ) {
+        $currxlists = $settings{'internal.crosslistings'}
+    }
+    unless ($caller eq 'setdates') {
+        if ( ($currstart eq '') && ($currend eq '') )  {
+            $warning = "You <b>must</b> now use <a href='/adm/populate?action=setdates'>Change enrollment dates</a> to set a start date <i>and</i> an end date for the enrollment (or check the 'No end date' checkbox) for the nightly adds process to actually occur.</br></br>";
+        }
+    }
+    unless ( ($caller eq 'sections') || ($caller eq 'crosslist') ) {
+        if ( ($currsecs eq '') && ($currxlists eq '') ) {
+            $warning .= "You <b>must</b> now use <a href='/adm/populate?action=sections'>Section settings</a> and/or <a href='/adm/populate?action=crosslist'>Change crosslistings</a> to choose at least one section of the course, or at least one crosslisted course which will contribute enrollment to this LON-CAPA course.  At present there are <b>NO</b> sections or crosslisted courses that are affiliated with this course that are set to contribute to the automated enrollment process.<br/><br/>";
+        }
+    }
+    unless ( $caller eq 'chgsettings') {
+        if ( (!$curradds) && (!$currdrops) ) {
+            $warning .= "You <b>must</b> now use <a href='/adm/populate?action=chgsettings'>Automated adds/drops</a> to enable automated adds and/or drops if you want automatic enrollment updates to occur in this course.<br/><br/>.";
+        }
+    }
+    return $warning;
 }
 
 sub print_reply () {

--raeburn1074146194--