[LON-CAPA-cvs] cvs: loncom /enrollment Autoenroll.pl Enrollment.pm localenroll.pm /interface loncreatecourse.pm londropadd.pm lonmodifycourse.pm lonpopulate.pm /lonnet/perl lonnet.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Thu, 17 Jun 2004 18:31:25 -0000


This is a MIME encoded message

--raeburn1087497085
Content-Type: text/plain

raeburn		Thu Jun 17 14:31:25 2004 EDT

  Modified files:              
    /loncom/interface	lonpopulate.pm lonmodifycourse.pm 
                     	loncreatecourse.pm londropadd.pm 
    /loncom/enrollment	Autoenroll.pl Enrollment.pm localenroll.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  Calls to functions in localenroll.pm mediated by lonc/lond now include domain
  in the set of passed parameters to support domain-specific variants in a single 
  localenroll.pm file housed on a multi-domain library server.
  
  Automated enrollment now sets first access and last access dates for student
  roles based on defaults set on course creation, and modifiable via a number
  of mechanisms in the Enrollment Manager, and Automated Enrollment Manager.
  
  The Automated Enrollment Manager now provides a utility to allow enrollment type
  to be toggled between 'auto' and 'manual', so that students added via CSV file
  or singly can become liable for automated update (dropping, section switching 
  etc.).
  
  
--raeburn1087497085
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20040617143125.txt"

Index: loncom/interface/lonpopulate.pm
diff -u loncom/interface/lonpopulate.pm:1.13 loncom/interface/lonpopulate.pm:1.14
--- loncom/interface/lonpopulate.pm:1.13	Wed Jun  9 13:01:56 2004
+++ loncom/interface/lonpopulate.pm	Thu Jun 17 14:31:24 2004
@@ -1,5 +1,5 @@
 # automated enrollment configuration handler
-# $Id: lonpopulate.pm,v 1.13 2004/06/09 17:01:56 raeburn Exp $
+# $Id: lonpopulate.pm,v 1.14 2004/06/17 18:31:24 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -31,6 +31,7 @@
 use Apache::loncommon;
 use Apache::lonhtmlcommon;
 use Apache::lonlocal;
+use Apache::loncoursedata;
 use Apache::Constants qw(:common :http REDIRECT);
 use Time::Local;
 use LONCAPA::Enrollment;
@@ -60,6 +61,9 @@
  var rad1 = 0
  var rad2 = 0
  var formName = document.forms.enter
+ if (calling == "viewclass") {
+     formName = document.forms.studentform
+ }
  formName.action.value = calling
  if (calling == "chgsettings") {
    for (var j=0; j<formName.autoadds.length; j++) {
@@ -113,6 +117,10 @@
          checker = 0
      }
  }
+ if (calling == "viewclass") {
+     document.forms.studentform.state.value = "process";
+     checker = 1;    
+ } 
  if (checker == 1) {  
      formName.submit();
  }
@@ -220,6 +228,8 @@
   foreach my $item (keys %settings) {
       if ($item =~ m/^internal\.(.+)$/) {
           $enrollvar{$1} = $settings{$item};
+      } elsif ($item =~ /^default_enrollment_(start|end)_date$/) {
+          $enrollvar{$item} = $settings{$item};
       }
   }
 
@@ -239,6 +249,10 @@
             </tr>
             <tr>
               <td>&nbsp;</td>
+              <td>Use <i>"Change access dates"</i> to change the default start and/or end dates for student roles created by automated enrollment.</td>
+            </tr>
+            <tr>
+              <td>&nbsp;</td>
               <td>Use <i>"Notification of changes"</i> to enable or disable notification of enrollment changes and to add or remove course coordinators from the recipient list.</td>
             </tr>
             <tr>
@@ -328,21 +342,21 @@
             </form>
       ");
   } elsif ($action eq "setdates") {
-      my ($start_table,$end_table) = &date_setting_table($enrollvar{autostart},$enrollvar{autoend});
+      my ($start_table,$end_table) = &date_setting_table($enrollvar{autostart},$enrollvar{autoend},$action);
       my $oldstartshow = '';
       my $oldendshow = '';
       if ( defined($enrollvar{autostart}) ) {
-          $oldstartshow = localtime($enrollvar{autostart});
+          $oldstartshow = &Apache::lonlocal::locallocaltime($enrollvar{autostart});
       }
       if ( defined($enrollvar{autoend}) ) {
-          $oldendshow = localtime($enrollvar{autoend});
+          $oldendshow = &Apache::lonlocal::locallocaltime($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";
+         $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 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";
       }
@@ -400,8 +414,22 @@
                     </td>
 	           </tr>
                   </table>
-                  <input type=\"hidden\" name=\"action\" value=\"$action\">
-                  <input type=\"hidden\" name=\"state\" value=\"process\">
+                  <input type="hidden" name="action" value="$action">
+                  <input type="hidden" name="state" value="process">
+                  </form>
+ENDTWO
+  } elsif ($action eq "setaccess") {
+      &print_accessdate_table($r,\%enrollvar,$tasktitleref,$action);
+      $r->print(<<ENDTWO);
+                  <table width="100%">
+                   <tr>
+                    <td align="right">
+                      <input type="button" name="$action" value="Go" onClick="process('$action')" />
+                    </td>
+                   </tr>
+                  </table>
+                  <input type="hidden" name="action" value="$action">
+                  <input type="hidden" name="state" value="process">
                   </form>
 ENDTWO
   } elsif ($action eq "notify") {
@@ -591,7 +619,7 @@
           for (my $i=0; $i<@xlists; $i++) {
               my $xl = '&nbsp;';
               my $gp = '&nbsp;';
-              if ($xlists[$i] =~ /(\w+):(.+)$/) {
+              if ($xlists[$i] =~ /(\w+):?(.*)$/) {
                   $xl = $1;
                   $gp = $2;
               }               
@@ -858,30 +886,201 @@
                     <tr>
                      <td>
  	              Expire students previously added by nightly enrollment process, but no longer listed in institutional  classlist(s).                  
-                <input type=\"radio\" name=\"updatedrops\" value=\"1\">&nbsp;Yes&nbsp;
-                <input type=\"radio\" name=\"updatedrops\" value=\"0\">&nbsp;No&nbsp;<br/>
-              </td>
-             </tr>
-             <tr>
-              <td>
-               <font color=\"#888888\">
+                      <input type=\"radio\" name=\"updatedrops\" value=\"1\">&nbsp;Yes&nbsp;
+                      <input type=\"radio\" name=\"updatedrops\" value=\"0\">&nbsp;No&nbsp;<br/>
+                     </td>
+                    </tr>
+                    <tr>
+                     <td><font color=\"#888888\">
 Note: Any students previously added manually by course coordinator(s) using either 'Upload classlist CSV file' or 'Enroll a single user' will be unaffected by the removal process.
-               </font>
-              </td>
-             </tr>
-             <tr>
-              <td align=\"right\">
-               <input type=\"button\" name=\"updatenow\" value=\"Go\" onClick=\"process('updatenow')\">
-              </td>
-             </tr>
-	    </table>
-            <input type=\"hidden\" name=\"action\" value=\"$action\">
-            <input type=\"hidden\" name=\"state\" value=\"process\">
-            </form>
+                      </font>
+                     </td>
+                    </tr>
+                    <tr>
+                     <td>
+      ");
+      &print_accessdate_table($r,\%enrollvar,$tasktitleref,$action);
+      $r->print("
+                     </td>
+                    </tr>
+                    <tr>
+                     <td align=\"right\">
+                      <input type=\"button\" name=\"updatenow\" value=\"Go\" onClick=\"process('updatenow')\" />
+                     </td>
+                    </tr>
+	           </table>
+                   <input type=\"hidden\" name=\"action\" value=\"$action\" />
+                   <input type=\"hidden\" name=\"state\" value=\"process\" />
+                  </form>
+      ");
+  } elsif ($action eq 'viewclass') {
+      $r->print("
+                   <form name=\"studentform\" method=\"post\"><br/>
+                   <table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
+                    <tr>
+                     <td align=\"left\"><b>$$tasktitleref{$action}</b>
+                     </td>
+                    </tr>
+                   </table>
+                   <table>
+                    <tr>
+                     <td>
       ");
+      if (! exists($ENV{'form.sortby'})) {
+          $ENV{'form.sortby'} = 'username';
+      }
+      if ($ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) {
+          $ENV{'form.Status'} = 'Active';
+      }
+      my $status_select = &Apache::lonhtmlcommon::StatusOptions($ENV{'form.Status'});
+#  Get current classlist
+      my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
+      if (! defined($classlist)) {
+          $r->print(&mt('There are no students either currently or previously enrolled.').
+                      "\n");
+      } else {
+          $r->print(&mt('Student Status: [_1]',$status_select)."\n");
+          $r->print('<input type="submit" value="'.&mt('Update Display').'" />'.
+              "\n</p>\n");
+
+          my $studentcount = &Apache::londropadd::show_class_list($r,'autoenroll','nothing',$ENV{'form.Status'},$classlist,$keylist);
+          $r->print("
+                     </td>
+                    </tr>
+          ");
+          if ($studentcount > 0) {
+              $r->print("
+                    <tr>
+                     <td>&nbsp;</td>
+                    </tr>
+                    <tr>
+                     <td align=\"right\">
+                      <input type=\"button\" name=\"viewclass\" value=\"Go\" onClick=\"process('viewclass')\" />
+                     </td>
+                    </tr>
+              ");
+          }
+          $r->print("
+                   </table>
+                   <input type=\"hidden\" name=\"action\" value=\"$action\" />
+                   <input type=\"hidden\" name=\"state\" value=\"choose\" />
+                  </form>
+          ");
+      }
   }
 }
 
+sub print_accessdate_table {
+    my ($r,$enrollvar,$tasktitleref,$action) = @_;
+    my ($start_table,$end_table) = &date_setting_table($$enrollvar{'default_enrollment_start_date'},$$enrollvar{'default_enrollment_end_date'},$action);
+    my $oldstartshow = '';
+    my $oldendshow = '';
+    if ( defined($$enrollvar{'default_enrollment_start_date'}) ) {
+        $oldstartshow = &Apache::lonlocal::locallocaltime($$enrollvar{'default_enrollment_start_date'});
+    }
+    if ( defined($$enrollvar{'default_enrollment_end_date'}) ) {
+        $oldendshow = &Apache::lonlocal::locallocaltime($$enrollvar{default_enrollment_end_date});
+        if ($$enrollvar{'default_enrollment_end_date'} eq '0') {
+            $oldendshow = "No ending date";
+        }
+    }
+    my %lt =&Apache::lonlocal::texthash(
+         'cuno' => 'Currently NO default first access or last access dates are set.',
+         'ifyo' => 'If you do not set a start date and an end date, then student roles for students added by the automated enrollment process will start immediately when the student is added and will never become inactive.',
+         'ifyd' => 'If you do not set an access start date and an end date, then student roles for new students added when you click "Go" will become active immediately and will never become inactive.',
+         'setf' => 'Set date of first access',
+         'setl' => 'Set date of last access',
+         'freg' => 'for registered students added via automated enrollment',
+         'fnew' => 'for new students added when you update the class roster',
+         'ifad'  => 'If automated adds are enabled, then when students are added their student roles will become active on the date set here for first access, and their roles will become inactive on the date set here for last access.  These default access dates will be overridden for specific students if the institutional classlist data supplied to the automatic enrollment process includes entries for the startdate and enddate fields for those students.'
+    );
+    my $dateshow;
+    if ( ($oldendshow eq '') && ($oldstartshow eq '') ) {
+       $dateshow = "<br/><font size='+1'>".&mt('Warning')."</font>.&nbsp;".$lt{'cuno'}." ";
+       if ($action eq 'setaccess') {
+           $dateshow .= $lt{'ifyo'}."\n";
+       } elsif ($action eq 'updatenow') {
+           $dateshow .= $lt{'ifyd'}."\n";
+       }
+    } else {
+        $dateshow = &mt('Currently: default first access').": <b><i>$oldstartshow</i></b>, ".&mt('default last access').": <b><i>$oldendshow</i></b>\n";
+    }
+    if ($action eq 'setaccess') {
+        $r->print(<<ENDONE);
+                <form name="enter" method="post"><br/>
+                <table width="100%" border="0" cellpadding="2" cellspacing="2">
+                 <tr>
+                  <td align="left"><b>$$tasktitleref{$action}</b>
+                  <br /><br />
+                   $dateshow
+                  </td>
+                 </tr>
+                </table>
+ENDONE
+    } elsif ($action eq 'updatenow') {
+        $r->print("
+                <br /><br />$dateshow\n");
+    }
+    $r->print(<<ENDTWO);
+                <table width="100%" border="0" cellpadding="3" cellspacing="3">
+                 <tr>
+                  <td align="left" colspan="2">
+                   <table border="0" cellspacing="0" cellpadding="2">
+                    <tr>
+                     <td colspan="3">
+ENDTWO
+      if ($action eq 'setaccess') {
+          $r->print("<i>$lt{'setf'} $lt{'freg'}</i>");
+      } elsif ($action eq 'updatenow') {
+          $r->print("<i>$lt{'setf'} $lt{'fnew'}</i>");
+      }
+      $r->print(<<ENDTHREE); 
+                       </td>
+                      </tr>
+                      <tr>
+                       <td>$start_table
+                       </td>
+                      </tr>
+                     </table>
+                    </td>
+                   </tr>
+                   <tr>
+                    <td align="left" colspan="2">
+                     <table border="0' cellspacing="0" cellpadding="2">
+                      <tr>
+                       <td colspan="3">
+ENDTHREE
+    if ($action eq 'setaccess') {
+        $r->print("<i>$lt{'setl'} $lt{'freg'}</i>");
+    } elsif ($action eq 'updatenow') {
+        $r->print("<i>$lt{'setl'} $lt{'fnew'}</i>");
+    }
+    $r->print(<<ENDFOUR); 
+                       </td>
+                      </tr>
+                      <tr>
+                       <td>$end_table
+                       </td>
+                      </tr>
+                     </table>
+                    </td>
+                   </tr>
+ENDFOUR
+    if ($action eq 'setaccess') {
+        $r->print("
+                   <tr>
+                    <td colspan=\"2\"><font color=\"#888888\">$lt{'ifad'}</font></td>
+                   </tr>
+                  </table>
+        ");
+    } elsif ($action eq 'updatenow') {
+        $r->print("
+                   </tr>
+                  </table>
+        ");
+    }
+}
+
 ###############################################################
 sub print_doc_base {
   my $r = shift;
@@ -1001,12 +1200,12 @@
   my $currend = $settings{'internal.autoend'};
   my $response = '';
   my ($autostart,$autoend) = &get_dates_from_form();
-  my $showstart = localtime($autostart);
+  my $showstart = &Apache::lonlocal::locallocaltime($autostart);
   my $showend = '';
   my $warning = '';
   my $warn_prefix = '';
   if ($autoend) {
-      $showend = localtime($autoend);
+      $showend = &Apache::lonlocal::locallocaltime($autoend);
   } else {
       $showend = "'No end date'";
   } 
@@ -1028,7 +1227,7 @@
           $response .= "The last date for automated enrollment has been changed to $showend.<br/>";
       }
  
-# Generate message in case where old first access date was later than today, but new first access date is now today or earlier.
+# Generate message in case where old first enrollment date was later than today, but new first enrollment date is now today or earlier.
 
       my $rosterupdated = 0;
       my $firstaccess = "";
@@ -1060,7 +1259,7 @@
               $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 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>|;
+              $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 immediately enroll 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);
@@ -1073,6 +1272,99 @@
   return;
 }
 
+sub print_setaccess_response {
+  my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
+  my %settings = &Apache::lonnet::get('environment',['default_enrollment_start_date','default_enrollment_end_date','internal.autostart'],$dom,$crs);
+  my $currstart = $settings{'default_enrollment_start_date'};
+  my $currend = $settings{'default_enrollment_end_date'};
+  my $autostart = $settings{'internal.autostart'};
+  my $response = '';
+  my ($startaccess,$endaccess) = &get_dates_from_form();
+  my $showstart = &Apache::lonlocal::locallocaltime($startaccess);
+  my $showend = '';
+  my $warning = '';
+  my $warn_prefix = '';
+  if ($endaccess) {
+      $showend = &Apache::lonlocal::locallocaltime($endaccess);
+  } else {
+      $showend = "'No end date'";
+  }
+                                                                                   
+  my %cenv = ('default_enrollment_start_date' => $startaccess,
+              'default_enrollment_end_date' => $endaccess);
+  my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
+  if ($reply !~ /^ok$/) {
+       $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
+  } else {
+      if ($currstart == $startaccess) {
+          $response = "The first access date for students added via automated enrollment has been left unchanged as $showstart.<br/>";
+      } else {
+          $response = "The first access date for students added via automated enrollment has been changed to
+$showstart.<br/>";
+      }
+      if ($currend == $endaccess) {
+          $response .= "The last access date for students added via automated enrollment has been left unchanged as $showend.<br/>";
+      } else {
+          $response .= "The last access date for students automated enrollment has been changed to
+$showend.<br/>";
+      }
+                                                                                   
+# Generate message in case where old first access date was later than today, but new first access date is now today or earlier.
+                                                                                   
+      my $accessgiven= 0;
+      my $firstaccess = "";
+      my $nextupdate = "";
+      my $lastupdate = "";
+
+      my $nowstamp = time;
+      my @date_list=localtime(time);
+      my $cur_year = $date_list[5];
+      my $curday = $date_list[3];
+      my $curmonth = $date_list[4];
+      my $lastmidnt = timelocal(0,0,0,$date_list[3],$date_list[4],$date_list[5]);
+      my $nextmidnt = 86400 + $lastmidnt;
+
+      my $todayupdate = timelocal(0,30,1,$date_list[3],$date_list[4],$date_list[5]);
+      my $tomorrowupdate = $todayupdate + 86400;
+      my $lastupdate = $todayupdate - 86400;
+
+      if ($autostart < $nextmidnt) {
+          if ($nowstamp < $todayupdate) {
+              $nextupdate = "at 1.30 am today";
+          } else {
+              $nextupdate = "at 1.30 am tomorrow";
+          }
+      } else {
+          my @enrollstart = &Apache::lonlocal::locallocaltime($autostart);
+          $nextupdate = timelocal(0,30,1,$enrollstart[3],$enrollstart[4],$enrollstart[5]);
+          unless (($enrollstart[2] < 1) || ($enrollstart[2] == 1 && $enrollstart[1] <=30))  {
+              $nextupdate += 86400; 
+          }
+          $nextupdate = &Apache::lonlocal::locallocaltime($nextupdate);
+      }
+      if (($currstart < $lastupdate) && ($autostart < $lastupdate)) {
+          $accessgiven = 1;
+      }
+      if ($startaccess < $nextmidnt ) {
+          if ( $startaccess >= $lastmidnt) {
+              $firstaccess = "today";
+          } else {
+              $firstaccess = "a date prior to today";
+          }
+          if (($nowstamp >= $startaccess) && ($accessgiven == 0)) {
+              $response .= qq|<br>Although you have now set the first access date to $firstaccess, automatic enrollment will <b>not</b> occur until the next automatic enrollment update occurs for all LON-CAPA courses $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 have set default first and last access dates for students who are added via automatic enrollment, additional action is required.<br/>";
+      unless ($warning eq '') {
+          $response .= $warn_prefix.$warning;
+      }
+  }
+  &print_reply($r,$response,$$tasktitleref{$action});
+  return;
+}
+
 sub print_notify_response {
   my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
 
@@ -1178,8 +1470,8 @@
           my $gp = "gp_".$i;
           if ( exists($ENV{"form.$xlist"}) ) {
               my $xlistentry = '';
-              if ($currxlists[$i] =~ m/^(\w+:)/) {
-                  $xlistentry = $1;
+              if ($currxlists[$i] =~ m/^([^:]+)/) {
+                  $xlistentry = $1.':';
               }
               if ( exists($ENV{"form.$gp"}) ) {
                   $xlistentry .= $ENV{"form.$gp"};
@@ -1706,13 +1998,12 @@
   my $logmsg = '';
   my $newusermsg = '';
 
-  my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.sectionnums','internal.crosslistings','internal.authtype','internal.autharg','internal.autostart','internal.autoend'],$dom,$crs);
+  my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.sectionnums','internal.crosslistings','internal.authtype','internal.autharg'],$dom,$crs);
   my $coursecode = $settings{'internal.coursecode'};
   my $authtype = $settings{'internal.authtype'};
   my $autharg = $settings{'internal.autharg'};
-  my $autostart = $settings{'internal.autostart'};
-  my $autoend = $settings{'internal.autoend'};
- 
+  my ($startaccess,$endaccess) = &get_dates_from_form();
+
   if ( exists($ENV{'form.updateadds'}) ) {
       $updateadds = $ENV{'form.updateadds'};
   }
@@ -1766,9 +2057,9 @@
 
       if (@allcourses > 0) {
           @{$affiliates{$crs}} = @allcourses;
-          my $outcome = &Apache::lonnet::fetch_enrollment_query('updatenow',\%affiliates,\%reply,$crs,$dom);
+          my $outcome = &Apache::lonnet::fetch_enrollment_query('updatenow',\%affiliates,\%reply,$dom,$crs);
           if ($reply{$crs} > 0) {
-              ($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$updateadds,$updatedrops,$autostart,$autoend,$authtype,$autharg,\@allcourses,\%LC_code,\$logmsg,\$newusermsg,"updatenow");
+              ($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$updateadds,$updatedrops,$startaccess,$endaccess,$authtype,$autharg,\@allcourses,\%LC_code,\$logmsg,\$newusermsg,"updatenow");
           } else {
               $response = "There was a problem retrieving institutional class list data for the course sections and crosslisted courses which contribute enrollment to this course. No updates have been carried out, and the roster remains unchanged.";
           }  
@@ -1790,6 +2081,132 @@
   return;
 }
 
+sub print_viewclass_response {
+    my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
+    my $response;
+    my $chgtotal = 0;
+    my $chgok = 0;
+    my $chgfail = 0;
+    my $othdom = 0;
+    my $cid = $dom."_".$crs;
+    my %chg = ();
+    my %nochg = ();
+    my %otherdom = ();
+    my $modreply = ''; 
+    my $classlist = &Apache::loncoursedata::get_classlist($cid,$dom,$crs);
+    my $endidx = &Apache::loncoursedata::CL_END;
+    my $startidx = &Apache::loncoursedata::CL_START;
+    my $ididx=&Apache::loncoursedata::CL_ID;
+    my $secidx=&Apache::loncoursedata::CL_SECTION;
+    my $typeidx=&Apache::loncoursedata::CL_TYPE;
+    foreach (sort keys %ENV) {
+        if (/^form\.switch:(.+)$/) {
+            my $student = $1;
+            my ($uname,$udom) = split/:/,$student;
+            my $sdata    = $classlist->{$student};
+            my $section  = $sdata->[$secidx];
+            my $uid       = $sdata->[$ididx];
+            my $start    = $sdata->[$startidx];
+            my $end      = $sdata->[$endidx];
+            my $type     = $sdata->[$typeidx];
+            $chgtotal ++;
+            my $newtype = 'auto';
+            my $change = 'auto';
+            my $oldtype = 'manual';
+            if ($type eq 'auto') { 
+                $oldtype = 'auto';
+                $newtype = '';
+                $change = 'manual';
+            }
+            if ($udom eq $dom) {
+                $modreply = &Apache::lonnet::modify_student_enrollment($udom,$uname,$uid,'','','','',$section,$end,$start,$newtype,$cid);
+                if ($modreply eq 'ok') {
+                    $chgok ++;
+                    $chg{$student} = "Changed to $change";
+                } else {
+                    $chgfail ++;
+                    $nochg{$student} = "Still set to $oldtype";
+                } 
+            } else {
+                $othdom ++;
+                $otherdom{$student} = "Still set to $oldtype"; 
+            }
+        }
+    }
+    if ($chgtotal > 0) {
+        $response = "You requested a change in enrollment type for $chgtotal students.<br /><br />\n";
+        $classlist = &Apache::loncoursedata::get_classlist($cid,$dom,$crs);
+        if ($chgok > 0) {
+            $response .= "The following $chgok changes were successful:<br />";
+            $response .= &enrolltype_result(\%chg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx);
+        }
+        if ($chgfail > 0) {
+            $response .= "The following $chgfail students were not modified successfully:&nbsp;<br />";
+            $response .= &enrolltype_result(\%nochg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx);
+        }
+        if ($othdom > 0) {
+            $response .= "The following $othdom students were not modified because students must be in the same LON-CAPA domain as the course, in order to be set to an enrollment type of 'auto':<br />"; 
+            $response .= &enrolltype_result(\%otherdom,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx);
+        }
+    }
+    &print_reply($r,$response,$$tasktitleref{$action});
+    return;
+}
+
+sub enrolltype_result {
+    my ($changes,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx) = @_;
+    my $reply = "
+            <table border='2'>
+             <tr>
+              <th>username</th>
+              <th>domain</th>
+              <th>ID</th>
+              <th>student name</th>
+              <th>section</th>
+              <th>start date</th>
+              <th>end date</th>
+              <th>enrollment change</th>
+             </tr>";
+    foreach (sort keys %{$changes}) {
+        my $sdata  = $classlist->{$_};
+        my ($uname,$udom) = split/:/,$_;
+        my $section  = $sdata->[$secidx];
+        my $uid      = $sdata->[$ididx];
+        my $start    = $sdata->[$startidx];
+        my $end      = $sdata->[$endidx];
+        my $type     = $sdata->[$typeidx];
+        if (! defined($start) || $start == 0) {
+            $start = &mt('none');
+        } else {
+            $start = &Apache::lonlocal::locallocaltime($start);
+        }
+        if (! defined($end) || $end == 0) {
+            $end = &mt('none');
+        } else {
+            $end = &Apache::lonlocal::locallocaltime($end);
+        }
+        if (!defined($section) || ($section eq '')) {
+            $section eq '&nbsp;';
+        }
+        if (!defined($uid) || ($uid eq '')) {
+            $uid = '&nbsp';
+        }
+        $reply .= "
+             <tr>
+              <td>$uname</td>
+              <td>$udom</td>
+              <td>$uid</td>
+              <td>".&Apache::loncommon::plainname($uname,$udom)."</td>
+              <td>$section</td>
+              <td>$start</td>
+              <td>$end</td>
+              <td>$$changes{$_}</td>
+             </tr>";
+    }
+    $reply .= "</table>";
+    return $reply;
+}
+
 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);
@@ -1841,8 +2258,7 @@
   $r->print("
             <br/><table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
              <tr>
-              <tr align=\"left\"><b>$caller</b> - result<br/><br/>$response</td>
-              </td>
+              <td align=\"left\"><b>$caller</b> - result<br/><br/>$response</td>
              </tr>
             </table>
   ");
@@ -1850,21 +2266,25 @@
 }
 
 sub setup_date_selectors {
-    my ($starttime,$endtime) = @_;
+    my ($starttime,$endtime,$action) = @_;
     if (! defined($starttime)) {
         $starttime = time;
-        if (exists($ENV{'course.'.$ENV{'request.course.id'}.
+        if ($action eq 'setdates') {
+            if (exists($ENV{'course.'.$ENV{'request.course.id'}.
                             '.default_enrollment_start_date'})) {
-            $starttime = $ENV{'course.'.$ENV{'request.course.id'}.
+                $starttime = $ENV{'course.'.$ENV{'request.course.id'}.
                                   '.default_enrollment_start_date'};
+            }
         }
     }
     if (! defined($endtime)) {
         $endtime = time+(6*30*24*60*60); # 6 months from now, approx
-        if (exists($ENV{'course.'.$ENV{'request.course.id'}.
+        if ($action eq 'setdates') {
+            if (exists($ENV{'course.'.$ENV{'request.course.id'}.
                             '.default_enrollment_end_date'})) {
-            $endtime = $ENV{'course.'.$ENV{'request.course.id'}.
+                $endtime = $ENV{'course.'.$ENV{'request.course.id'}.
                                 '.default_enrollment_end_date'};
+            }
         }
     }
     my $startdateform = &Apache::lonhtmlcommon::date_setter('enter',
@@ -1877,8 +2297,10 @@
 }
 
 sub get_dates_from_form {
-    my $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate');
-    my $enddate   = &Apache::lonhtmlcommon::get_date_from_form('enddate');
+    my $startdate;
+    my $enddate;
+    $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate');
+    $enddate   = &Apache::lonhtmlcommon::get_date_from_form('enddate');
     if ( exists ($ENV{'form.no_end_date'}) ) {
         $enddate = 0;
     }
@@ -1886,10 +2308,10 @@
 }
 
 sub date_setting_table {
-    my ($starttime,$endtime) = @_;
-    my ($startform,$endform) = &setup_date_selectors($starttime,$endtime);
+    my ($starttime,$endtime,$action) = @_;
+    my ($startform,$endform) = &setup_date_selectors($starttime,$endtime,$action);
     my $perpetual = '<nobr><input type="checkbox" name="no_end_date"';
-    if (defined($endtime) && $endtime == 0) {
+    if (($action eq 'setdates' && defined($endtime) && $endtime == 0) || (($action eq 'setaccess' || $action eq 'updatenow') && ($endtime eq '' || $endtime == 0)) ) {
         $perpetual .= ' checked';
     }
     $perpetual.= ' />'.' no ending date</nobr>';
@@ -1927,31 +2349,35 @@
     $r->content_type('text/html');
     $r->send_http_header;
 
-    my @tasks = ("information","chgsettings","setdates","notify","crosslist","sections","photos","updatenow");
+    my @tasks = ("information","chgsettings","setdates","setaccess","notify","crosslist","sections","photos","updatenow","viewclass");
                                                                                  
     my %tasklong = (
                information => "Task information",
                chgsettings => "Automated adds/drops",
                setdates => "Change enrollment dates",
+               setaccess => "Change access dates",
                notify => "Notification of changes",
                crosslist => "Change crosslistings",
                sections => "Section settings",
                photos => "Student photos",
                updatenow => "Update roster now",
                newcross => "Add crosslistings",
-               newsections => "Add sections"
+               newsections => "Add sections",
+               viewclass => "View students and type",
     );
                                                                                  
     my %tasktitle = (
                chgsettings => "Changes to nightly automated enrollments",
                setdates => "Changes to first and/or last automated enrollment dates",
+               setaccess => "Changes to default start and/or end dates for student access",
                notify => "Notification of enrollment changes",
                crosslist => "Changes to crosslistings",
                sections => "Changes to section settings",
                photos => "Automatic import of student photos",
                updatenow => "Immediate course roster update",
                newcross => "Adding new crosslisted courses",
-               newsections => "Adding new course sections"
+               newsections => "Adding new course sections",
+               viewclass => "Viewing class roster and enrollment type"
     );
 
     my $realm = '';
@@ -2020,6 +2446,8 @@
         &print_chgsettings_response($r,$realm,$dom,$crs,$action,\%tasktitle);
     } elsif ($action eq "setdates") {
         &print_setdates_response($r,$realm,$dom,$crs,$action,\%tasktitle);
+    } elsif ($action eq "setaccess") {
+        &print_setaccess_response($r,$realm,$dom,$crs,$action,\%tasktitle);
     } elsif ($action eq "notify") {
         &print_notify_response($r,$realm,$dom,$crs,$action,\%tasktitle);
     } elsif ($action eq "sections") {
@@ -2034,6 +2462,8 @@
         &print_crosslistings_response($r,$realm,$dom,$crs,$action,\%tasktitle);    
     } elsif ($action eq "newsections") {
         &print_sections_response($r,$realm,$dom,$crs,$action,\%tasktitle);
+    } elsif ($action eq "viewclass") {
+        &print_viewclass_response($r,$realm,$dom,$crs,$action,\%tasktitle);
     }
     &print_doc_base($r);  
     return OK;
Index: loncom/interface/lonmodifycourse.pm
diff -u loncom/interface/lonmodifycourse.pm:1.8 loncom/interface/lonmodifycourse.pm:1.9
--- loncom/interface/lonmodifycourse.pm:1.8	Wed Jun  9 13:01:55 2004
+++ loncom/interface/lonmodifycourse.pm	Thu Jun 17 14:31:24 2004
@@ -197,9 +197,17 @@
 	        } else {
 	            $enrollvar{$1} = localtime($settings{$item});
 	        }
-            } elsif ($1 eq "courseowner" || $1 eq "authtype" || $1 eq "autharg" || $1 eq "sectionnums" || $1 eq "coursecode") {
+            } elsif ($1 eq "courseowner" || $1 eq "authtype" || $1 eq "autharg" || $1 eq "sectionnums" || $1 eq "coursecode" || $1 eq "crosslistings") {
 	        $enrollvar{$1} = $settings{$item};
             }
+        } elsif ($item =~ m/^default_enrollment_(start|end)_date$/) {
+            if ( ($1 eq 'end') && ($settings{$item} == 0) ) {
+                $enrollvar{$item} = $lt{'noen'};
+            } elsif ( ($1 eq 'start') && ($settings{$item} eq '') ) {
+                $enrollvar{$item} = 'When enrolled';
+            } else {
+                $enrollvar{$item} = localtime($settings{$item});
+            }
         }
     }
 
@@ -717,8 +725,10 @@
                        'autharg'  => 'Default authentication parameter',
                        'autoadds' => 'Automated adds',
                        'autodrops' => 'Automated drops',
-                       'autostart' => 'Date of first enrollment',
-                       'autoend' => 'Date of last enrollment',
+                       'autostart' => 'Date of first automated enrollment',
+                       'autoend' => 'Date of last automated enrollment',
+                       'default_enrollment_start_date' => 'Date of first student access',
+                       'default_enrollment_end_date' => 'Date of last student access',
                        'coursecode' => 'Official course code',
                        'courseowner' => "Username of course owner (\@$dom)",
                        'notifylist' => 'Course Coordinators to be notified of enrollment changes',
Index: loncom/interface/loncreatecourse.pm
diff -u loncom/interface/loncreatecourse.pm:1.59 loncom/interface/loncreatecourse.pm:1.60
--- loncom/interface/loncreatecourse.pm:1.59	Wed Jun  9 13:01:55 2004
+++ loncom/interface/loncreatecourse.pm	Thu Jun 17 14:31:24 2004
@@ -1,7 +1,7 @@
 #meserver The LearningOnline Network
 # Create a course
 #
-# $Id: loncreatecourse.pm,v 1.59 2004/06/09 17:01:55 raeburn Exp $
+# $Id: loncreatecourse.pm,v 1.60 2004/06/17 18:31:24 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -238,7 +238,8 @@
     my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript();
     my $starttime = time;
     my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
-    my $date_table = &Apache::londropadd::date_setting_table($starttime,$endtime,'createcourse');
+    my $enroll_table = &Apache::londropadd::date_setting_table($starttime,$endtime,'create_enrolldates');
+    my $access_table = &Apache::londropadd::date_setting_table($starttime,$endtime,'create_defaultdates');
     my ($krbdef,$krbdefdom) =
     &Apache::loncommon::get_kerberos_defaults($defdom);
     my $javascript_validations=&Apache::londropadd::javascript_validations('createcourse',$krbdefdom);
@@ -300,6 +301,7 @@
                     'no'   => "No",
                     'audr' => "Automated drops",
                     'dacu' => "Duration of automated classlist updates",
+                    'dacc' => "Default start and end dates for student access",
                     'psam' => "Please select the authentication mechanism",
                     'pcda' => "Please choose the default authentication method to be used by new users added to this LON-CAPA domain by the automated enrollment process",
                     'nech' => "Notification of enrollment changes",
@@ -436,8 +438,11 @@
 <input type="radio" name="autodrops" value="1" />$lt{'yes'} <input type="radio" name="autodrops" value="0" checked="true" />$lt{'no'}
 </p><p>
 <b>$lt{'dacu'}</b>
-$date_table
+$enroll_table
 </p><p>
+<b>$lt{'dacc'}</b>
+$access_table
+<p></p>
 <b>$lt{'psam'}.</b><br />
 $lt{'pcda'}.
 </p><p>
@@ -642,13 +647,17 @@
             $r->print ("</ul><br/><br/></font>\n");
         }
     }
-    my $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate');
-    my $enddate   = &Apache::lonhtmlcommon::get_date_from_form('enddate');
+    my $enrollstart = &Apache::lonhtmlcommon::get_date_from_form('startenroll');
+    my $enrollend   = &Apache::lonhtmlcommon::get_date_from_form('endenroll');
+    my $startaccess = &Apache::lonhtmlcommon::get_date_from_form('startaccess');
+    my $endaccess = &Apache::lonhtmlcommon::get_date_from_form('endaccess');
     if ($ENV{'form.no_end_date'}) {
-      $enddate = 0;
+      $endaccess = 0;
     }
-    $cenv{'internal.autostart'}=$startdate;
-    $cenv{'internal.autoend'}=$enddate;
+    $cenv{'internal.autostart'}=$enrollstart;
+    $cenv{'internal.autoend'}=$enrollend;
+    $cenv{'default_enrollment_start_date'}=$startaccess;
+    $cenv{'default_enrollment_end_date'}=$endaccess;
     if ($ENV{'form.showphotos'}) {
       $cenv{'internal.showphotos'}=$ENV{'form.showphotos'};
     }
Index: loncom/interface/londropadd.pm
diff -u loncom/interface/londropadd.pm:1.113 loncom/interface/londropadd.pm:1.114
--- loncom/interface/londropadd.pm:1.113	Wed Jun  9 13:08:27 2004
+++ loncom/interface/londropadd.pm	Thu Jun 17 14:31:24 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to drop and add students in courses 
 #
-# $Id: londropadd.pm,v 1.113 2004/06/09 17:08:27 raeburn Exp $
+# $Id: londropadd.pm,v 1.114 2004/06/17 18:31:24 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -786,7 +786,7 @@
     my ($starttime,$endtime,$mode) = @_;
     if (! defined($starttime)) {
         $starttime = time;
-        unless ($mode eq 'createcourse') {
+        unless ($mode eq 'create_enrolldates' || $mode eq 'create_defaultdates') {
             if (exists($ENV{'course.'.$ENV{'request.course.id'}.
                             '.default_enrollment_start_date'})) {
                 $starttime = $ENV{'course.'.$ENV{'request.course.id'}.
@@ -810,12 +810,20 @@
     my $enddateform = &Apache::lonhtmlcommon::date_setter('studentform',
                                                           'enddate',
                                                           $endtime);
-    if ($mode eq 'createcourse') {
+    if ($mode eq 'create_enrolldates') {
         $startdateform = &Apache::lonhtmlcommon::date_setter('ccrs',
-                                                            'startdate',
+                                                            'startenroll',
                                                             $starttime);
         $enddateform = &Apache::lonhtmlcommon::date_setter('ccrs',
-                                                          'enddate',
+                                                          'endenroll',
+                                                          $endtime);
+    }
+    if ($mode eq 'create_defaultdates') {
+        $startdateform = &Apache::lonhtmlcommon::date_setter('ccrs',
+                                                            'startaccess',
+                                                            $starttime);
+        $enddateform = &Apache::lonhtmlcommon::date_setter('ccrs',
+                                                          'endaccess',
                                                           $endtime);
     }
     return ($startdateform,$enddateform);
@@ -836,7 +844,7 @@
     my $dateDefault = '<nobr>'.
         '<input type="checkbox" name="makedatesdefault" /> '.
         &mt('make these dates the default for future enrollment');
-    if ($mode eq 'createcourse') {
+    if ($mode eq 'create_enrolldates' || $mode eq 'create_defaultdates') {
         $dateDefault = '&nbsp;';
     }
     my $perpetual = '<nobr><input type="checkbox" name="no_end_date"';
@@ -844,6 +852,9 @@
         $perpetual .= ' checked';
     }
     $perpetual.= ' /> '.&mt('no ending date').'</nobr>';
+    if ($mode eq 'create_enrolldates') {
+        $perpetual = '&nbsp;';
+    }
     my $result = '';
     $result .= "<table>\n";
     $result .= '<tr><td align="right">'.&mt('Starting Date').'</td>'.
@@ -1195,16 +1206,19 @@
     my ($CSVfile,$CSVfilename);
     #
     my $sortby = $ENV{'form.sortby'};
-    if ($sortby !~ /^(username|domain|section|fullname|id|start|end)$/) {
+    if ($sortby !~ /^(username|domain|section|fullname|id|start|end|type)$/) {
         $sortby = 'username';
     }
     # Print out header 
-    $r->print(<<END);
-
+    unless ($mode eq 'autoenroll') {
+        $r->print(<<END);
 <input type="hidden" name="state" value="$ENV{'form.state'}" />
+END
+    }
+    $r->print(<<END);
 <input type="hidden" name="sortby" value="$sortby" />
 END
-    if ($mode eq 'html' || $mode eq 'view') {
+    if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll') {
         if ($linkto eq 'aboutme') {
             $r->print(&mt('Select a user name to view the users personal page.'));
         } elsif ($linkto eq 'modify') {
@@ -1217,10 +1231,16 @@
                                            'sec'    => "section",
                                            'start'  => "start date",
                                            'end'    => "end date",
+                                           'type'   => "enroll type",
+                                           'chan'   => "change"
 					   );
-        $r->print(<<END);
+        unless ($mode eq 'autoenroll') {
+            $r->print(<<END);
 <input type="hidden" name="sname"  value="" />
 <input type="hidden" name="sdom"   value="" />
+END
+        }
+        $r->print(<<END);
 <p>
 <table border=2>
 <tr><th>Count
@@ -1239,8 +1259,16 @@
     </th><th>
        <a href="javascript:document.studentform.sortby.value='end';document.studentform.submit();">$lt{'end'}</a>
     </th>
-</tr>
 END
+        if ($mode eq 'autoenroll') {
+            $r->print("   <th>
+       <a href=\"javascript:document.studentform.sortby.value='type';document.studentform.submit();\">$lt{'type'}</a>
+    </th><th>
+         $lt{'chan'}?</th>");
+        }
+        $r->print("
+   </tr>
+        ");
     } elsif ($mode eq 'csv') {
 	#
 	# Open a file
@@ -1319,10 +1347,19 @@
         my $status   = $sdata->[$index{'status'}];
         my $start    = $sdata->[$index{'start'}];
         my $end      = $sdata->[$index{'end'}];
+        my $type     = $sdata->[$index{'type'}]; 
         next if (($statusmode ne 'Any') && ($status ne $statusmode));
-        if ($mode eq 'view' || $mode eq 'html') {
-            $start = &Apache::lonlocal::locallocaltime($start);
-            $end   = &Apache::lonlocal::locallocaltime($end);
+        if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll') {
+            if (! defined($start) || $start == 0) {
+                $start = &mt('none');
+            } else {
+                $start = &Apache::lonlocal::locallocaltime($start);
+            }
+            if (! defined($end) || $end == 0) {
+                $end = &mt('none');
+            } else {
+                $end = &Apache::lonlocal::locallocaltime($end);
+            }
             $r->print("<tr>\n    <td>".(++$studentcount)."</td><td>\n    ");
             if ($linkto eq 'nothing') {
                 $r->print($username);
@@ -1347,13 +1384,30 @@
     <td>$section</td>
     <td>$start</td>
     <td>$end</td>
-</tr>
 END
+            if ($mode eq 'autoenroll') {
+                my $longtype = &mt('manual').'&nbsp';
+                if ($type eq 'auto') {
+                    $longtype = &mt('auto').'&nbsp';
+                }
+                $r->print("<td><b>$longtype</b></td><td><input type=\"checkbox\" name=\"switch:$username:$domain\" /></td>");
+            }
+            $r->print("
+</tr>
+            ");
         } elsif ($mode eq 'csv') {
             next if (! defined($CSVfile));
             # no need to bother with $linkto
-            $start = &Apache::lonlocal::locallocaltime($start);
-            $end   = &Apache::lonlocal::locallocaltime($end);
+            if (! defined($start) || $start == 0) {
+                $start = &mt('none');
+            } else {
+                $start = &Apache::lonlocal::locallocaltime($start);
+            }
+            if (! defined($end) || $end == 0) {
+                $end = &mt('none');
+            } else {
+                $end = &Apache::lonlocal::locallocaltime($end);
+            }
             my @line = ();
             foreach ($username,$domain,$id,$name,$section,$start,$end) {
                 push @line,&Apache::loncommon::csv_translate($_);
@@ -1375,7 +1429,7 @@
             $row++;
         }
     }
-    if ($mode eq 'view' || $mode eq 'html') {
+    if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll') {
         $r->print('</table><br>');
     } elsif ($mode eq 'excel') {
         $excel_workbook->close();
@@ -1388,6 +1442,9 @@
                   "\n");
         $r->rflush();
     }
+    if ($mode eq 'autoenroll') {
+        return $studentcount;
+    }
 }
 
 
Index: loncom/enrollment/Autoenroll.pl
diff -u loncom/enrollment/Autoenroll.pl:1.10 loncom/enrollment/Autoenroll.pl:1.11
--- loncom/enrollment/Autoenroll.pl:1.10	Wed Jun  9 13:01:56 2004
+++ loncom/enrollment/Autoenroll.pl	Thu Jun 17 14:31:24 2004
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 #
 #Automated Enrollment script
-# $Id: Autoenroll.pl,v 1.10 2004/06/09 17:01:56 raeburn Exp $
+# $Id: Autoenroll.pl,v 1.11 2004/06/17 18:31:24 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -25,7 +25,6 @@
 #
 # http://www.lon-capa.org/
 #
-
     use strict;
     use lib '/home/httpd/lib/perl';
     use localenroll;
@@ -36,149 +35,153 @@
     use Apache::lonmsg;
     use HTML::Entities;
 
-#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 $dom = $$perlvarref{'lonDefDomain'};
     my $logfile = $$perlvarref{'lonDaemons'}.'/logs/autoenroll.log';
-    $ENV{'user.domain'} = $dom;
-    my $hostid = $$perlvarref{'lonHostID'};
+    my @domains = &Apache::lonnet::current_machine_domains();
+    my @hostids = &Apache::lonnet::current_machine_ids();
 
 # Determine the present time;
     my $timenow = time();
 
-# Determine the courses
-    my %courses = &Apache::lonnet::courseiddump($dom,'.',1,$hostid); 
-    my %affiliates = ();
-    my %enrollvar = ();
-    my %reply = ();
-    my %LC_code = ();
-    foreach my $key (sort keys %courses) {
-        my $crs;
-        if ($key =~ m/^($dom)_(\w+)$/) {
-            $crs = $2;
-        }
+# For each domain ......
+    foreach my $dom (@domains) {
+    #only run if configured to
+        if (! &localenroll::run($dom)) { next; }
+        $ENV{'user.domain'} = $dom;
+    # Determine the courses
+        my %courses = &Apache::lonnet::courseiddump($dom,'.',1,1,\@hostids); 
+        my %affiliates = ();
+        my %enrollvar = ();
+        my %reply = ();
+        my %LC_code = ();
+        foreach my $key (sort keys %courses) {
+            my $crs;
+            if ($key =~ m/^($dom)_(\w+)$/) {
+                $crs = $2;
+            }
 
 # Get course settings
-        my %settings = &Apache::lonnet::dump('environment',$dom,$crs);
-        %{$enrollvar{$crs}} = ();
-        @{$affiliates{$crs}} = ();
-        %{$LC_code{$crs}} = ();
-        foreach my $item (keys %settings) {
-            if ($item =~ m/^internal\.(.+)$/) {
-                $enrollvar{$crs}{$1} = $settings{$item};
-            } elsif ($item eq 'description') {
-                $enrollvar{$crs}{$item} = &HTML::Entities::decode($settings{$item});  
+            my %settings = &Apache::lonnet::dump('environment',$dom,$crs);
+            %{$enrollvar{$crs}} = ();
+            @{$affiliates{$crs}} = ();
+            %{$LC_code{$crs}} = ();
+            foreach my $item (keys %settings) {
+                if ($item =~ m/^internal\.(.+)$/) {
+                    $enrollvar{$crs}{$1} = $settings{$item};
+                } elsif ($item eq 'description') {
+                    $enrollvar{$crs}{$item} = &HTML::Entities::decode($settings{$item});  
+                } elsif ($item eq 'default_enrollment_start_date') {
+                    $enrollvar{$crs}{startdate} = $settings{$item};
+                }  elsif ($item eq 'default_enrollment_end_date') {
+                    $enrollvar{$crs}{enddate} = $settings{$item};
+                }
             }
-        }
-        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}{autostart} <= $timenow) && ( ($enrollvar{$crs}{autoend} > $timenow) || ($enrollvar{$crs}{autoend} == 0) ) ) {
+                if ( ($enrollvar{$crs}{autoadds} == 1) || ($enrollvar{$crs}{autodrops} == 1) ) {
 # Add to list of classes for retrieval
-                $enrollvar{$crs}{sectionnums} =~ s/ //g;
-                $enrollvar{$crs}{crosslistings} =~ s/ //g;
-                my @sections = ();
-                my @crosslistings = ();
-                if ($enrollvar{$crs}{sectionnums} =~ m/,/) {
-                    @sections = split/,/,$enrollvar{$crs}{sectionnums};
-                } else {
-                    $sections[0] = $enrollvar{$crs}{sectionnums};
-                }
-                if ($enrollvar{$crs}{crosslistings} =~ m/,/) {
-                    @crosslistings = split/,/,$enrollvar{$crs}{crosslistings}
-                } else {
-                    @crosslistings = $enrollvar{$crs}{crosslistings};
-                }
-                foreach my $sec (@sections) {
-                    if ($sec =~ m/^(\w+):(\w*)$/ ) {
-                        my $course_id = $enrollvar{$crs}{coursecode}.$1;
-                        my $gp = $2;
-                        if (!grep/^$course_id$/,@{$affiliates{$crs}}) {
-                            push @{$affiliates{$crs}}, $course_id;
-                            $LC_code{$crs}{$course_id} = $gp; 
+                    $enrollvar{$crs}{sectionnums} =~ s/ //g;
+                    $enrollvar{$crs}{crosslistings} =~ s/ //g;
+                    my @sections = ();
+                    my @crosslistings = ();
+                    if ($enrollvar{$crs}{sectionnums} =~ m/,/) {
+                        @sections = split/,/,$enrollvar{$crs}{sectionnums};
+                    } else {
+                        $sections[0] = $enrollvar{$crs}{sectionnums};
+                    }
+                    if ($enrollvar{$crs}{crosslistings} =~ m/,/) {
+                        @crosslistings = split/,/,$enrollvar{$crs}{crosslistings}
+                    } else {
+                        @crosslistings = $enrollvar{$crs}{crosslistings};
+                    }
+                    foreach my $sec (@sections) {
+                        if ($sec =~ m/^(\w+):(\w*)$/ ) {
+                            my $course_id = $enrollvar{$crs}{coursecode}.$1;
+                            my $gp = $2;
+                            if (!grep/^$course_id$/,@{$affiliates{$crs}}) {
+                                push @{$affiliates{$crs}}, $course_id;
+                                $LC_code{$crs}{$course_id} = $gp; 
+                            }
                         }
                     }
-                }
-                foreach my $xlist (@crosslistings) {
-                    if ($xlist =~ m/^(\w+):(\w*)$/) {
-                        my $course_id = $1;
-                        my $gp = $2;
-                        if (!grep/^$course_id$/,@{$affiliates{$crs}}) {
-                            push @{$affiliates{$crs}}, $course_id;
-                            $LC_code{$crs}{$course_id} = $gp;
+                    foreach my $xlist (@crosslistings) {
+                        if ($xlist =~ m/^(\w+):(\w*)$/) {
+                            my $course_id = $1;
+                            my $gp = $2;
+                            if (!grep/^$course_id$/,@{$affiliates{$crs}}) {
+                                push @{$affiliates{$crs}}, $course_id;
+                                $LC_code{$crs}{$course_id} = $gp;
+                            }
                         }
                     }
                 }
             }
         }
-    }
-    my $outcome = &Apache::lonnet::fetch_enrollment_query('automated',$dom,\%affiliates,\%reply);
+        my $outcome = &Apache::lonnet::fetch_enrollment_query('automated',\%affiliates,\%reply,$dom);
 
 # Now go through classes and perform required enrollment changes.
-    open (my $fh,">>$logfile");
-    print $fh "********************\n".localtime(time)." Enrollment messages start --\n";
-    foreach my $crs (sort keys %enrollvar) {
-        my $logmsg = '';
-        my $newusermsg = '';
-        if ($reply{$crs} > 0) {
-            if ( ($enrollvar{$crs}{autostart} < $timenow) && ( ($enrollvar{$crs}{autoend} > $timenow) || ($enrollvar{$crs}{autoend} == 0) ) ) {
-                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');
-                    print $fh "Messages start for $crs\n";
-                    print $fh "$logmsg\n";
-                    print $fh "Messages end for $crs\n";
-                    if ($changecount > 0) {
-                        unless ($enrollvar{$crs}{notifylist}  eq '') {
+        open (my $fh,">>$logfile");
+        print $fh "********************\n".localtime(time)." Enrollment messages start --\n";
+        foreach my $crs (sort keys %enrollvar) {
+            my $logmsg = '';
+            my $newusermsg = '';
+            if ($reply{$crs} > 0) {
+                if ( ($enrollvar{$crs}{autostart} < $timenow) && ( ($enrollvar{$crs}{autoend} > $timenow) || ($enrollvar{$crs}{autoend} == 0) ) ) {
+                    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');
+                        print $fh "Messages start for $crs\n";
+                        print $fh "$logmsg\n";
+                        print $fh "Messages end for $crs\n";
+                        if ($changecount > 0) {
+                            unless ($enrollvar{$crs}{notifylist}  eq '') {
 # Send message about enrollment changes to notifylist.
 # Set $ENV{'user.name'}, $ENV{'user.home'} for use by logging in lonmsg
-                            unless ( ($enrollvar{$crs}{'courseowner'} eq '') || (!defined($enrollvar{$crs}{'courseowner'}) )  ) {
-                                $ENV{'user.name'} = $enrollvar{$crs}{'courseowner'};
-                                $ENV{'user.home'} = &Apache::lonnet::homeserver($ENV{'user.name'},$dom);
-
-                                my $subject = "Student enrollment changes in $enrollvar{$crs}{coursecode}";
-                                my $message = "The following $changecount change(s) occurred in $enrollvar{$crs}{description} - $enrollvar{$crs}{coursecode} as a result of the automated classlist update:\n\n".$response;
-                                unless ($newusermsg eq '') 
-                                {
-                                   $message .= "\n".$newusermsg;
-                                }
-                                my @to_notify = ();
-                                if ($enrollvar{$crs}{notifylist} =~ m/,/) {
-                                    @to_notify = split/,/,$enrollvar{$crs}{notifylist};
-                                } else {
-                                    $to_notify[0] = $enrollvar{$crs}{notifylist};
+                                unless ( ($enrollvar{$crs}{'courseowner'} eq '') || (!defined($enrollvar{$crs}{'courseowner'}) )  ) {
+                                    $ENV{'user.name'} = $enrollvar{$crs}{'courseowner'};
+                                    $ENV{'user.home'} = &Apache::lonnet::homeserver($ENV{'user.name'},$dom);
+
+                                    my $subject = "Student enrollment changes in $enrollvar{$crs}{coursecode}";
+                                    my $message = "The following $changecount change(s) occurred in $enrollvar{$crs}{description} - $enrollvar{$crs}{coursecode} as a result of the automated classlist update:\n\n".$response;
+                                    unless ($newusermsg eq '') { 
+                                        $message .= "\n".$newusermsg;
+                                    }
+                                    my @to_notify = ();
+                                    if ($enrollvar{$crs}{notifylist} =~ m/,/) {
+                                        @to_notify = split/,/,$enrollvar{$crs}{notifylist};
+                                    } else {
+                                        $to_notify[0] = $enrollvar{$crs}{notifylist};
+                                    }
+                                    foreach my $cc (@to_notify) {
+                                        my ($ccname,$ccdom) = split/@/,$cc;
+                                        my $status =  &Apache::lonmsg::user_normal_msg($ccname,$ccdom,$subject,$message);
+                                    }
+                                    if ( ($enrollvar{$crs}{notifylist} eq '') && ($newusermsg ne '') ) {
+                                        my $subject = "New user accounts in  $enrollvar{$crs}{'coursecode'}";
+                                        my $status =  &Apache::lonmsg::user_normal_msg($ENV{'user.name'},$dom,$subject,$newusermsg);
+                                    }
+                                    delete($ENV{'user.name'});
+                                    delete($ENV{'user.home'});
                                 }
-                                foreach my $cc (@to_notify) {
-                                    my ($ccname,$ccdom) = split/@/,$cc;
-                                    my $status =  &Apache::lonmsg::user_normal_msg($ccname,$ccdom,$subject,$message);
-                                }
-                                if ( ($enrollvar{$crs}{notifylist} eq '') && ($newusermsg ne '') ) {
-                                     my $subject = "New user accounts in  $enrollvar{$crs}{'coursecode'}";
-                                     my $status =  &Apache::lonmsg::user_normal_msg($ENV{'user.name'},$dom,$subject,$newusermsg);
-                                }
-                                delete($ENV{'user.name'});
-                                delete($ENV{'user.home'});
                             }
                         }
                     }
                 }
-            }
-        } else {
-            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 {
+                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 "Not within time window for auto-enrollment in $crs\n";
+                    print $fh "Auto-enrollment not currently enabled for $crs\n";
                 }
-            } else {
-                print $fh "Auto-enrollment not currently enabled for $crs\n";
             }
         }
-    }
-    print $fh "-- ".localtime(time)." Enrollment messages end\n*******************\n\n";
-    close($fh);
-    delete($ENV{'user.domain'});
-
+        print $fh "-- ".localtime(time)." Enrollment messages end\n*******************\n\n";
+        close($fh);
+        delete($ENV{'user.domain'});
 # Check for photos
+    }
 
 1;
Index: loncom/enrollment/Enrollment.pm
diff -u loncom/enrollment/Enrollment.pm:1.14 loncom/enrollment/Enrollment.pm:1.15
--- loncom/enrollment/Enrollment.pm:1.14	Wed Mar 31 14:31:56 2004
+++ loncom/enrollment/Enrollment.pm	Thu Jun 17 14:31:24 2004
@@ -1,5 +1,5 @@
 # Automated Enrollment manager
-# $Id: Enrollment.pm,v 1.14 2004/03/31 19:31:56 raeburn Exp $
+# $Id: Enrollment.pm,v 1.15 2004/06/17 18:31:24 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -49,12 +49,19 @@
     my $status=&Apache::loncoursedata::CL_STATUS;
     my $type=&Apache::loncoursedata::CL_TYPE;
     my @localstudents = ();
+    my @futurestudents = ();
+    my @activestudents = ();
     my $currlist;
     foreach my $uname (keys %{$roster} ) {
         if ($uname =~ m/^(.+):$dom$/) {
             if ($$roster{$uname}[$status] eq "Active") {
+                push @activestudents, $1;
+                @{$$currlist{$1}} = @{$$roster{$uname}};
                 push @localstudents, $1;
+            } elsif ( ($$roster{$uname}[$cstart] > time)  && ($$roster{$uname}[$cend] > time || $$roster{$uname}[$cend] == 0 || $$roster{$uname}[$cend] eq '') ) {
+                push @futurestudents, $1;
                 @{$$currlist{$1}} = @{$$roster{$uname}};
+                push @localstudents, $1;
             }
         }
     }
@@ -174,6 +181,7 @@
         unless ($uname eq '') {
             my %uidhash=&Apache::lonnet::idrget($dom,$uname);
             my @stuinfo = @{$enrollinfo{$uname}};
+            my $access = '';
             if (grep/^$uname$/,@localstudents) {
 # Check for studentID changes
                 if ( ($uidhash{$uname}) && ($uidhash{$uname} !~ /error\:/) )  {
@@ -181,9 +189,34 @@
                         $$logmsg .= "Change in ID for $uname. StudentID in LON-CAPA system is $uidhash{$uname}; StudentID in institutional data is $stuinfo[ $place{studentID} ]".$linefeed; 
                     }
                 }
-
 # Check for section changes
-                unless ($$currlist{$uname}[$sec] eq $stuinfo[ $place{groupID} ]) {
+                if ($$currlist{$uname}[$sec] eq $stuinfo[ $place{groupID} ]) {
+# Check for access date changes for students with access starting in the future.
+                    if ( (grep/^$uname$/,@futurestudents) && ($$currlist{$uname}[$type] eq "auto") && ($adds == 1) ) {
+                        my $datechange = 0;
+                        unless ($$currlist{$uname}[$cstart] eq $startdate) {
+                            $datechange = 1;
+                        }
+                        if (!$datechange) {
+                            if (!$$currlist{$uname}[$cend]) {
+                                if ($enddate) {
+                                    $datechange = 1;
+                                }
+                            } elsif ($$currlist{$uname}[$cend] ne $enddate) {
+                                $datechange = 1;
+                            } 
+                        }
+                        if ($datechange) {
+                            my $modify_access_result = &Apache::lonnet::modify_student_enrollment($dom,$uname,undef,undef,undef,undef,undef,$stuinfo[ $place{groupID} ],$enddate,$startdate,'auto',$cid);
+                            $access = &showaccess($enddate,$startdate);
+                            if ($modify_access_result =~ /^ok/) {
+                                $$logmsg .= "Change in access dates for $uname.".$access.$linefeed;
+                            } else {
+                                $$logmsg .= "Error when attempting to change start and/or end access dates for $uname in section: ".$stuinfo[ $place{groupID} ]." -error $modify_access_result".$linefeed;
+                            }
+                        }
+                    }
+                } else {
                     if ( ($$currlist{$uname}[$type] eq "auto") && ($adds == 1) ) {
 # Delete from roles.db for current section
                         my $expiretime = time;
@@ -194,9 +227,15 @@
                         }
                         my $expire_role_result = &Apache::lonnet::assignrole($dom,$uname,$uurl,'st',$expiretime);
                         if ($expire_role_result eq 'ok') {
-                            my $modify_section_result = &Apache::lonnet::modify_student_enrollment($dom,$uname,undef,undef,undef,undef,undef,$stuinfo[ $place{groupID} ],$$currlist{$uname}[$cend],$$currlist{$uname}[$cstart],'auto',$cid);
+                            my $modify_section_result;
+                            if (grep/^$uname$/,@activestudents) {
+                                $modify_section_result = &Apache::lonnet::modify_student_enrollment($dom,$uname,undef,undef,undef,undef,undef,$stuinfo[ $place{groupID} ],$$currlist{$uname}[$cend],$$currlist{$uname}[$cstart],'auto',$cid);
+                            } else {
+                                $modify_section_result =  &Apache::lonnet::modify_student_enrollment($dom,$uname,undef,undef,undef,undef,undef,$stuinfo[ $place{groupID} ],$enddate,$startdate,'auto',$cid);
+                                $access =  &showaccess($enddate,$startdate);
+                            }
                             if ($modify_section_result =~ /^ok/) {
-                                $$logmsg .= "Section for $uname switched from old section: ".$$currlist{$uname}[$sec] ." to new section: ".$stuinfo[ $place{groupID} ].".".$linefeed;
+                                $$logmsg .= "Section for $uname switched from old section: ".$$currlist{$uname}[$sec] ." to new section: ".$stuinfo[ $place{groupID} ].".".$access.$linefeed;
                             } else {
                                 $$logmsg .= "Error when attempting section change for $uname from old section ".$$currlist{$uname}[$sec]." to new section: ".$stuinfo[ $place{groupID} ]." -error: $modify_section_result".$linefeed;
                             }
@@ -285,8 +324,9 @@
 # Now create user.
                             my $reply=&Apache::lonnet::modifystudent($dom,$uname,$pid,$auth,$authparam,$first,$middle,$last,$gene,$usec,$end,$start,'',undef,$emailaddr,'auto',$cid);
                             if ($reply eq 'ok') {
+                                $access = &showaccess($end,$start);
                                 $enrollcount ++;
-                                $addresult .= "$first $last ($pid) - $uname enrolled in section/group $usec.".$linefeed;
+                                $addresult .= "$first $last ($pid) - $uname enrolled in section/group $usec.".$access.$linefeed;
                                 if ($context eq 'automated') {
                                     $$logmsg .= "New $dom user $uname added successfully.";
                                 }
@@ -380,8 +420,9 @@
 # Assign the role of student in the course.
                         my $classlist_reply = &Apache::lonnet::modify_student_enrollment($dom,$uname,$pid,$first,$middle,$last,$gene,$usec,$end,$start,'auto',$cid);
                         if ($classlist_reply eq 'ok') {
+                            $access = &showaccess($end,$start);
                             $enrollcount ++;
-                            $addresult .= "$first $last ($pid) - $uname enrolled in section/group $usec.".$linefeed;
+                            $addresult .= "$first $last ($pid) - $uname enrolled in section/group $usec.".$access.$linefeed;
                             if ($context eq 'automated') {
                                 $$logmsg .= "Existing $dom user $uname enrolled successfully.".$linefeed;
                             }
@@ -406,7 +447,7 @@
                             push @saved,$uname;
                         }
                     } elsif (@saved == 0) {
-                        my $drop_reply = &Apache::lonnet::modifystudent($dom,$uname,'','','',undef,undef,undef,undef,$$currlist{$uname}[$sec],time,undef,undef,undef,undef,undef,$cid);
+                        my $drop_reply = &Apache::lonnet::modifystudent($dom,$uname,'','','',undef,undef,undef,undef,$$currlist{$uname}[$sec],time,undef,undef,undef,undef,'auto',$cid);
                         if ($drop_reply !~ /^ok/) {
                             $$logmsg .= "An error occured during the attempt to expire the $uname from the old section $$currlist{$uname}[$sec] - $drop_reply.".$linefeed;
                         } else {
@@ -463,6 +504,24 @@
     return ($changecount,$addresult.$dropresult); 
 }
 
+sub showaccess {
+    my ($end,$start) = @_;
+    my $showstart;
+    my $showend;
+    if ( (!$start) || ($start <= time) ) {
+        $showstart = 'immediately';
+    } else {
+        $showstart = &Apache::lonlocal::locallocaltime($start);
+    }
+    if (!$end) {
+        $showend = 'no end date';
+    } else {
+        $showend = &Apache::lonlocal::locallocaltime($end);
+    }
+    my $access_msg = " Access starts: ".$showstart.", ends: ".$showend.".";
+    return $access_msg;
+}
+
 sub parse_classlist {
     my ($tmpdir,$dom,$crs,$class,$placeref,$groupID,$studentsref) = @_;
     my $xmlfile = $tmpdir."/tmp/".$dom."_".$crs."_".$class."_classlist.xml";
Index: loncom/enrollment/localenroll.pm
diff -u loncom/enrollment/localenroll.pm:1.8 loncom/enrollment/localenroll.pm:1.9
--- loncom/enrollment/localenroll.pm:1.8	Wed Mar 17 20:02:20 2004
+++ loncom/enrollment/localenroll.pm	Thu Jun 17 14:31:25 2004
@@ -1,6 +1,6 @@
 # functions to glue school database system into Lon-CAPA for 
 # automated enrollment
-# $Id: localenroll.pm,v 1.8 2004/03/18 01:02:20 raeburn Exp $
+# $Id: localenroll.pm,v 1.9 2004/06/17 18:31:25 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -33,7 +33,10 @@
 # set this to return 1 if you want the auto enrollment to run
 ################################
 
-sub run { return 0; }
+sub run() {
+    my $dom = shift;
+    return 0;
+}
 
 ################################
 # sub fetch_enrollment
@@ -105,13 +108,14 @@
 #</students>
 #
 # The <startdate> and the <enddate> are the activation date and expiration date
-# for this student's role. If they are absent, then neither a start date nor an end
-# date will be set, and the student role will remain active until the role is 
-# explicitly expired using ENRL -> Drop students.    
-# An option to set a default activation date, and a default expiration date will
-# be added to loncreatecourse.pm, and lonpopulate.pm in a future release.
-# Once these default parameters are available, they will be used as the start date and
-# the end date in cases where the <startdate> and <enddate> fields are blank.
+# for this student's role. If they are absent, then the default access start and
+# default access end dates are used. The default access dates can be set when 
+# the course is created, and can be modified using the Automated Enrollment
+# Manager, or via the 'Upload a class list','Enroll a single student' or 
+# 'Modify student data' utilities in the Enrollment Manager, by checking the 
+# 'make these dates the default for future enrollment' checkbox. If no default 
+# dates have been set, then the tudent role will be active immediately, and will 
+# remain active until the role is explicitly expired using ENRL -> Drop students. 
 # If dates are to included in the XML file, they should be in the format
 # YYYY:MM:DD:HH:MM:SS (: separators required).
 #
@@ -173,7 +177,7 @@
 ################################ 
 
 sub get_sections {
-    my $coursecode = shift;
+    my ($coursecode,$dom) = @_;
     my @secs = ();
     return @secs;
 }
@@ -206,7 +210,7 @@
 #################################
 
 sub new_course  {
-    my ($course_id,$owner) = @_;
+    my ($course_id,$owner,$dom) = @_;
     my $outcome = 'ok';
     return $outcome;
 }
@@ -231,7 +235,7 @@
 ###############################  
 
 sub validate_courseID {
-    my $course_id = shift;
+    my ($course_id,$dom) = @_;
     my $outcome = 'ok';
     return $outcome;   
 }
@@ -268,7 +272,7 @@
 ###############################
 
 sub create_password {
-    my $authparam = shift;
+    my ($authparam,$dom) = @_;
     my $authchk = 'ok';
     my $create_passwd = 0;
     return ($authparam,$create_passwd,$authchk);
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.510 loncom/lonnet/perl/lonnet.pm:1.511
--- loncom/lonnet/perl/lonnet.pm:1.510	Sat Jun 12 18:09:32 2004
+++ loncom/lonnet/perl/lonnet.pm	Thu Jun 17 14:31:25 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.510 2004/06/12 22:09:32 www Exp $
+# $Id: lonnet.pm,v 1.511 2004/06/17 18:31:25 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1615,11 +1615,11 @@
 }
 
 sub courseiddump {
-    my ($domfilter,$descfilter,$sincefilter,$hostid)=@_;
+    my ($domfilter,$descfilter,$sincefilter,$hostidflag,$hostidref)=@_;
     my %returnhash=();
     unless ($domfilter) { $domfilter=''; }
     foreach my $tryserver (keys %libserv) {
-        if (($hostid && $tryserver eq $hostid) || (!$hostid)) {
+        if ( ($hostidflag == 1 && grep/^$tryserver$/,@{$hostidref}) || (!defined($hostidflag)) ) {
 	    if ((!$domfilter) || ($hostdom{$tryserver} eq $domfilter)) {
 	        foreach (
                  split(/\&/,&reply('courseiddump:'.$hostdom{$tryserver}.':'.
@@ -3057,7 +3057,7 @@
 # ------- Request retrieval of institutional classlists for course(s)
 
 sub fetch_enrollment_query {
-    my ($context,$affiliatesref,$replyref,$cnum,$dom) = @_;
+    my ($context,$affiliatesref,$replyref,$dom,$cnum) = @_;
     my $homeserver;
     if ($context eq 'automated') {
         $homeserver = $perlvar{'lonHostID'};
@@ -3151,7 +3151,7 @@
 sub auto_run {
     my ($cnum,$cdom) = @_;
     my $homeserver = &homeserver($cnum,$cdom);
-    my $response = &reply('autorun',$homeserver);
+    my $response = &reply('autorun:'.$cdom,$homeserver);
     return $response;
 }
                                                                                    
@@ -3159,7 +3159,7 @@
     my ($cnum,$cdom,$inst_coursecode) = @_;
     my $homeserver = &homeserver($cnum,$cdom);
     my @secs = ();
-    my $response=&unescape(&reply('autogetsections:'.$inst_coursecode,$homeserver));
+    my $response=&unescape(&reply('autogetsections:'.$inst_coursecode.':'.$cdom,$homeserver));
     unless ($response eq 'refused') {
         @secs = split/:/,$response;
     }
@@ -3169,14 +3169,14 @@
 sub auto_new_course {
     my ($cnum,$cdom,$inst_course_id,$owner) = @_;
     my $homeserver = &homeserver($cnum,$cdom);
-    my $response=&unescape(&reply('autonewcourse:'.$inst_course_id.':'.$owner,$homeserver));
+    my $response=&unescape(&reply('autonewcourse:'.$inst_course_id.':'.$owner,':'.$cdom,$homeserver));
     return $response;
 }
                                                                                    
 sub auto_validate_courseID {
     my ($cnum,$cdom,$inst_course_id) = @_;
     my $homeserver = &homeserver($cnum,$cdom);
-    my $response=&unescape(&reply('autovalidatecourse:'.$inst_course_id,$homeserver));
+    my $response=&unescape(&reply('autovalidatecourse:'.$inst_course_id.':'.$cdom,$homeserver));
     return $response;
 }
                                                                                    
@@ -3185,7 +3185,7 @@
     my $homeserver = &homeserver($cnum,$cdom); 
     my $create_passwd = 0;
     my $authchk = '';
-    my $response=&unescape(&reply('autocreatepassword:'.$authparam,$homeserver));
+    my $response=&unescape(&reply('autocreatepassword:'.$authparam.':'.$cdom,$homeserver));
     if ($response eq 'refused') {
         $authchk = 'refused';
     } else {

--raeburn1087497085--