Diff for /loncom/interface/lonpopulate.pm between versions 1.76 and 1.92

version 1.76, 2013/03/01 05:21:17 version 1.92, 2022/02/16 16:38:11
Line 37  use Apache::lonuserutils; Line 37  use Apache::lonuserutils;
 use Apache::Constants qw(:common :http REDIRECT);  use Apache::Constants qw(:common :http REDIRECT);
 use Time::Local;  use Time::Local;
 use LONCAPA::Enrollment;  use LONCAPA::Enrollment;
   use LONCAPA qw(:DEFAULT :match);
   
 ###############################################################  ###############################################################
 sub header {  sub header {
     my ($action) = @_;      my ($action,$permref) = @_;
     my $args = &make_crumbs($action);      my $args = &make_crumbs($action,$permref);
     return       return 
         &Apache::loncommon::start_page('Classlist Manager',undef,$args);          &Apache::loncommon::start_page('Classlist Manager',undef,$args);
 }  }
Line 49  sub header { Line 50  sub header {
 ###############################################################  ###############################################################
   
 sub choose_header {  sub choose_header {
     my ($action) = @_;      my ($action,$permref,$dom) = @_;
     my $notify_check = '/^note_[0-9]+$/';      my $notify_check = '/^note_[0-9]+$/';
     my %lt =       my $additems;
       my %js_lt = 
         &Apache::lonlocal::texthash(          &Apache::lonlocal::texthash(
             adds => 'You must select either "Enable" or "Disable" for nightly additions based on classlist changes',              adds => 'You must select either "Enable" or "Disable" for nightly additions based on classlist changes',
             drop => 'You must select either "Enable" or "Disable" for nightly removals based on classlist changes',              drop => 'You must select either "Enable" or "Disable" for nightly removals based on classlist changes',
Line 60  sub choose_header { Line 62  sub choose_header {
             eras => 'Click "OK" to erase all recipients, or "Cancel".',              eras => 'Click "OK" to erase all recipients, or "Cancel".',
             ynot => 'You have indicated that you want notification of roster changes messages to be sent, but you have not selected any recipients.',              ynot => 'You have indicated that you want notification of roster changes messages to be sent, but you have not selected any recipients.',
             atle => 'You must check at least one checkbox, before proceeding to the next page',              atle => 'You must check at least one checkbox, before proceeding to the next page',
               noed => 'You do not have rights to modify automated enrollment settings',
     );      );
     $lt{'both'} = &mt('You have selected "No" for both addition and removal of students[_1] in the institutional classlist but not in your LON-CAPA course.[_1]','\\n');      $js_lt{'both'} = &mt('You have selected "No" for both addition and removal of students[_1] in the institutional classlist but not in your LON-CAPA course.[_1]',"\n");
     $lt{'nnot'} = &mt('You have indicated that you do not want notification of roster changes messages to be sent, but [_1] have been checked as recipients.[_2]',"'+totalnote+'",'\\n');      $js_lt{'nnot'} = &mt('You have indicated that you do not want notification of roster changes messages to be sent, but [_1] have been checked as recipients.[_2]',"'+totalnote+'","\n");
           &js_escape(\%js_lt);
     my $scripttag = <<ENDJSONE;  
       my $scripttag = '
 <script type="text/javascript" language="JavaScript">  <script type="text/javascript" language="JavaScript">
 // <![CDATA[  // <![CDATA[
   ';
       if ((ref($permref) ne 'HASH') || (!$permref->{'edit'})) {
           $scripttag .= <<ENDJS;
   function process(calling,numauto,nummanual,numlock,numunlock) {
       alert('$js_lt{'noed'}');
       return false;
   }
   ENDJS
       } else {
           $scripttag .= <<ENDJSONE;
 function process(calling,numauto,nummanual,numlock,numunlock) {  function process(calling,numauto,nummanual,numlock,numunlock) {
  var checker = 1   var checker = 1
  var rad1 = 0   var rad1 = 0
Line 88  function process(calling,numauto,nummanu Line 102  function process(calling,numauto,nummanu
        }         }
    }     }
    if (rad1 == 0) {     if (rad1 == 0) {
        alert('$lt{'adds'}');         alert('$js_lt{'adds'}');
        checker = 0         checker = 0
    }     }
    if (rad2 == 0) {     if (rad2 == 0) {
        alert('$lt{'drop'}');         alert('$js_lt{'drop'}');
        checker = 0         checker = 0
    }     }
  }   }
Line 116  function process(calling,numauto,nummanu Line 130  function process(calling,numauto,nummanu
          }           }
      }       }
      if (rad1 == 0) {       if (rad1 == 0) {
          alert('$lt{'drop'}');           alert('$js_lt{'drop'}');
          checker = 0;           checker = 0;
      }       }
      if (rad2 == 0) {       if (rad2 == 0) {
          alert('$lt{'ysno'}');           alert('$js_lt{'ysno'}');
          checker = 0;           checker = 0;
      }       }
      if (formName.updatedrops[unenrolldis].checked && formName.updateadds[enrolldis].checked ) {       if (formName.updatedrops[unenrolldis].checked && formName.updateadds[enrolldis].checked ) {
          alert('$lt{'both'}$lt{'noup'}');           alert('$js_lt{'both'}$js_lt{'noup'}');
          checker = 0;           checker = 0;
      }       }
  }   }
Line 141  function process(calling,numauto,nummanu Line 155  function process(calling,numauto,nummanu
      }       }
      if (totalnote > 0) {       if (totalnote > 0) {
  if (formName.notify[1].checked == true) {   if (formName.notify[1].checked == true) {
      if (confirm('$lt{'nnot'}$lt{'eras'}')) {       if (confirm('$js_lt{'nnot'}$js_lt{'eras'}')) {
  checker = 1;   checker = 1;
      } else {       } else {
  checker = 0;   checker = 0;
Line 149  function process(calling,numauto,nummanu Line 163  function process(calling,numauto,nummanu
  }   }
      } else {       } else {
  if (formName.notify[0].checked == true) {   if (formName.notify[0].checked == true) {
      alert('$lt{'ynot'}');       alert('$js_lt{'ynot'}');
      checker = 0;       checker = 0;
  }   }
      }       }
Line 177  function process(calling,numauto,nummanu Line 191  function process(calling,numauto,nummanu
         document.forms.studentform.state.value = "process";          document.forms.studentform.state.value = "process";
      }       }
      if (totcheck == 0) {       if (totcheck == 0) {
         alert('$lt{'atle'}')          alert('$js_lt{'atle'}')
         checker = 0;          checker = 0;
      }       }
  }    } 
Line 186  function process(calling,numauto,nummanu Line 200  function process(calling,numauto,nummanu
  }   }
 }  }
 ENDJSONE  ENDJSONE
       }
     if ($action eq 'viewclass') {      if ($action eq 'viewclass') {
         $scripttag .= &Apache::loncommon::check_uncheck_jscript();          $scripttag .= &Apache::loncommon::check_uncheck_jscript();
         $scripttag .= <<ENDJSTWO;          $scripttag .= <<ENDJSTWO;
Line 206  function countChecked(field) { Line 221  function countChecked(field) {
 }  }
   
 ENDJSTWO  ENDJSTWO
       } elsif ($action eq 'chgfailsafe') {
           my %domconfig =
               &Apache::lonnet::get_dom('configuration',['autoenroll'],$dom);
           my $includedom = 1;
           if (ref($domconfig{'autoenroll'}) eq 'HASH') {
               if ($domconfig{'autoenroll'}->{'failsafe'} eq 'off') {
                   $includedom = 0;
               }
           }
           $scripttag .= <<ENDJSTHREE;
   
   function toggleFailsafe(form) {
       var radioname = 'autodropfailsafetype';
       var divid = 'autodropfailsafe';
       var num = form.elements[radioname].length;
       if (num) {
           var includedom = '$includedom';
           var setvis = '';
           for (var i=0; i<num; i++) {
               if (form.elements[radioname][i].checked) {
                   if ((form.elements[radioname][i].value == 'zero') || (form.elements[radioname][i].value == 'any') || ((form.elements[radioname][i].value == 'dom') && (includedom == 1))) {
                       if (document.getElementById(divid)) {
                           document.getElementById(divid).style.display = 'inline-block';
                       }
                       setvis = 1;
                   }
                   break;
               }
           }
           if (!setvis) {
               if (document.getElementById(divid)) {
                   document.getElementById(divid).style.display = 'none';
               }
           }
       }
       return;
   }
   
   ENDJSTHREE
           $additems = { 'onload' => "toggleFailsafe(document.enter);" };
     }      }
     $scripttag .= <<ENDJS;      $scripttag .= <<ENDJS;
 // ]]>  // ]]>
 </script>  </script>
 ENDJS  ENDJS
     my $args = &make_crumbs($action);      my $args = &make_crumbs($action,$permref,$additems);
     return &Apache::loncommon::start_page('Classlist Manager',      return &Apache::loncommon::start_page('Classlist Manager',
   $scripttag,$args);    $scripttag,$args);
 }  }
   
 sub make_crumbs {  sub make_crumbs {
     my ($action) = @_;      my ($action,$permref,$additems) = @_;
     my ($tasklong,$tasktitle) = &get_task_text();      my ($tasklong,$tasktitle) = &get_task_text($permref);
     my $brcrum = [{href=>"/adm/createuser",      my $brcrum = [{href=>"/adm/createuser",
                    text=>"User Management",},                     text=>"User Management",},
                  {href=>"/adm/populate",                   {href=>"/adm/populate",
Line 230  sub make_crumbs { Line 285  sub make_crumbs {
     } elsif ($action eq 'newsections') {      } elsif ($action eq 'newsections') {
         $action = 'sections';          $action = 'sections';
     }      }
     my ($tasklong,$tasktitle) = &get_task_text();  
     my $text;      my $text;
     if (ref($tasklong) eq 'HASH') {      if (ref($tasklong) eq 'HASH') {
         $text = $tasklong->{$action};          $text = $tasklong->{$action};
Line 242  sub make_crumbs { Line 296  sub make_crumbs {
             );              );
     }      }
     return {bread_crumbs           => $brcrum,      return {bread_crumbs           => $brcrum,
             bread_crumbs_component => 'Automated Management'};              bread_crumbs_component => 'Automated Management',
               add_entries => $additems};
 }  }
   
 sub print_navmenu {  sub print_navmenu {
Line 281  sub print_navmenu { Line 336  sub print_navmenu {
 ###############################################################  ###############################################################
   
 sub print_main_frame {  sub print_main_frame {
   my ($r,$realm,$dom,$crs,$tasktitleref) = @_;    my ($r,$realm,$dom,$crs,$tasktitleref,$permref) = @_;
   my $action = "information";    my $action = "information";
   if (exists($env{'form.action'}) ) {    if (exists($env{'form.action'}) ) {
       $action = $env{'form.action'};        $action = $env{'form.action'};
   }    }
     my ($disabled,$readonly);
     unless ($permref->{'edit'}) {
         $disabled = ' disabled="disabled"';
         $readonly = 1;
     }
   
 # Get course settings  # Get course settings
   my %enrollvar;    my %enrollvar;
   my %settings = &Apache::lonnet::dump('environment',$dom,$crs);    my %settings = &Apache::lonnet::dump('environment',$dom,$crs);
   foreach my $item (keys %settings) {    foreach my $item (keys(%settings)) {
       if ($item =~ m/^internal\.(.+)$/) {        if ($item =~ m/^internal\.(.+)$/) {
           $enrollvar{$1} = $settings{$item};            $enrollvar{$1} = $settings{$item};
       } elsif ($item =~ /^default_enrollment_(start|end)_date$/) {        } elsif ($item =~ /^default_enrollment_(start|end)_date$/) {
Line 304  sub print_main_frame { Line 364  sub print_main_frame {
             <tr>              <tr>
               <td>&nbsp;</td>                <td>&nbsp;</td>
               <td><b>'.&mt('Use the menu on the left to choose an enrollment management task.').'</b><br /><br /></td>                <td><b>'.&mt('Use the menu on the left to choose an enrollment management task.').'</b><br /><br /></td>
             </tr>              </tr>');
         if ($permref->{'edit'}) {
             $r->print(' 
             <tr>              <tr>
               <td>&nbsp;</td>                <td>&nbsp;</td>
               <td>'.&mt('Use [_1]Automated adds/drops[_2] to enable or disable automatic nightly adds or drops in your LON-CAPA course based on institutional enrollment information.','<i>"','"</i>').'</td>                <td>'.&mt('Use [_1]Automated adds/drops[_2] to enable or disable automatic nightly adds or drops in your LON-CAPA course based on institutional enrollment information.','<i>"','"</i>').'</td>
Line 349  sub print_main_frame { Line 411  sub print_main_frame {
               <td>'.&mt('Use [_1]View students and change type[_2] to display the current course roster, and (optionally) change enrollment type for selected students from "auto" to "manual" and vice versa.','<i>"','"</i>').'</td>                <td>'.&mt('Use [_1]View students and change type[_2] to display the current course roster, and (optionally) change enrollment type for selected students from "auto" to "manual" and vice versa.','<i>"','"</i>').'</td>
             </tr>              </tr>
             <tr>              <tr>
                <td>&nbsp;</td>
                <td>'.&mt('Use [_1]View/change enrollment failsafe[_2] to (a) set number of drops from existing enrollments in an institutional section above which no automated drops will occur (e.g., when section enrollment retrieved from institutional data is incomplete) and (b) set whether this only applies when retrieved data contains zero records for the institutional section.','<i>"','"</i>').'</td>
               </tr>');
         } else {
             if (($permref->{'view'}) || ($permref->{'view_section'} ne '')) {
                 $r->print('
               <tr>
                 <td>&nbsp;</td>
                 <td>'.&mt('Use [_1]Automated adds/drops[_2] to display status of automatic nightly adds or drops based on institutional enrollment information.','<i>"','"</i>').'</td>
               </tr>
               <tr>
                 <td>&nbsp;</td>
                 <td>'.&mt('Use [_1]Enrollment dates[_2] to display the date of first automated enrollment and last automated enrollment for registered students.','<i>"','"</i>').'</td>
               </tr>
               <tr>
                 <td>&nbsp;</td>
                 <td>'.&mt('Use [_1]Access dates[_2] to display the default start and/or end dates for student roles created by automated enrollment.','<i>"','"</i>').'</td>
               </tr>
               <tr>
                 <td>&nbsp;</td>
                 <td>'.&mt('Use [_1]Notification of changes[_2] to display which course coordinators (if any) receive notification of enrollment changes.','<i>"','"</i>').'</td>
               </tr>
               <tr>
                 <td>&nbsp;</td>
                 <td>'.&mt('Use [_1]Crosslisting[_2] to display enrollment settings for crosslisted classes.',
                           '<i>"','"</i>').'</td>
               </tr>
               <tr>
                 <td>&nbsp;</td>
                 <td>'.&mt('Use [_1]Section settings[_2] to display sections included for enrollment.',
                           '<i>"','"</i>').'</td>
               </tr>
               <tr>
                 <td>&nbsp;</td>
                 <td>'.&mt('Use [_1]Student photo settings[_2] to display settings for automatic import of photos for registered students.',
                           '<i>"','"</i>').'</td>
               </tr>
               <tr>
                <td>&nbsp;</td>
                <td>'.&mt('Use [_1]Enrollment failsafe[_2] to display (a) number of drops from existing enrollments in an institutional section above which no automated drops occur (e.g., when section enrollment retrieved from institutional data is incomplete), and (b) whether this only applies when retrieved data contains zero records for the institutional section.','<i>"','"</i>').'</td>
               </tr>');
             }
             if (($permref->{'show'}) || ($permref->{'show_section'} ne '')) {
                 $r->print('
               <tr>
                 <td>&nbsp;</td>
                 <td>'.&mt('Use [_1]View students and enrollment type[_2] to display the current course roster and enrollment type ("auto" or "manual").','<i>"','"</i>').'</td>
               </tr>');
             }
             $r->print('
               <tr>
              <td colspan="2">&nbsp;</td>               <td colspan="2">&nbsp;</td>
             </tr>              </tr>
             <tr>              <tr>
Line 356  sub print_main_frame { Line 469  sub print_main_frame {
              <td><b>'.&mt('Note: if automated adds and/or drops are enabled, the nightly enrollment update will ONLY occur once the first enrollment date has been reached.').'</b></td>               <td><b>'.&mt('Note: if automated adds and/or drops are enabled, the nightly enrollment update will ONLY occur once the first enrollment date has been reached.').'</b></td>
             </tr>              </tr>
           </table>');            </table>');
         }
   } elsif ($action eq 'chgsettings') {    } elsif ($action eq 'chgsettings') {
       my @autosets = (&mt('OFF'),&mt('ON'));        my @autosets = (&mt('OFF'),&mt('ON'));
       $r->print('        $r->print('
Line 373  sub print_main_frame { Line 487  sub print_main_frame {
         '.&mt('Additions based on classlist changes:').'&nbsp;&nbsp;');          '.&mt('Additions based on classlist changes:').'&nbsp;&nbsp;');
       if ($enrollvar{autoadds}) {        if ($enrollvar{autoadds}) {
           $r->print('            $r->print('
     <label><input type="radio" name="autoadds" value="1" checked="checked" />&nbsp;'.      <label><input type="radio" name="autoadds" value="1" checked="checked"'.$disabled.' />&nbsp;'.
                             &mt('Enable').'&nbsp;&nbsp;&nbsp;</label>                              &mt('Enable').'&nbsp;&nbsp;&nbsp;</label>
     <label><input type="radio" name="autoadds" value="0" />&nbsp;'.      <label><input type="radio" name="autoadds" value="0"'.$disabled.' />&nbsp;'.
                             &mt('Disable').'</label>');                              &mt('Disable').'</label>');
       } else {        } else {
           $r->print('            $r->print('
                             <label><input type="radio" name="autoadds" value="1" />&nbsp;'.                              <label><input type="radio" name="autoadds" value="1"'.$disabled.' />&nbsp;'.
                             &mt('Enable').'&nbsp;&nbsp;&nbsp;</label>                              &mt('Enable').'&nbsp;&nbsp;&nbsp;</label>
                             <label><input type="radio" name="autoadds" value="0" checked="checked" />&nbsp;'.                              <label><input type="radio" name="autoadds" value="0" checked="checked"'.$disabled.' />&nbsp;'.
                             &mt('Disable').'</label>');                              &mt('Disable').'</label>');
       }        }
       $r->print('        $r->print('
Line 392  sub print_main_frame { Line 506  sub print_main_frame {
         '.&mt('Removals based on classlist changes:').'&nbsp;&nbsp;');          '.&mt('Removals based on classlist changes:').'&nbsp;&nbsp;');
       if ($enrollvar{autodrops}) {        if ($enrollvar{autodrops}) {
           $r->print('            $r->print('
                 <label><input type="radio" name="autodrops" value="1" checked="checked" />&nbsp;'.                  <label><input type="radio" name="autodrops" value="1" checked="checked"'.$disabled.' />&nbsp;'.
                 &mt('Enable').'&nbsp;&nbsp;&nbsp;</label>                  &mt('Enable').'&nbsp;&nbsp;&nbsp;</label>
                 <label><input type="radio" name="autodrops" value="0" />&nbsp;'.                  <label><input type="radio" name="autodrops" value="0"'.$disabled.' />&nbsp;'.
                 &mt('Disable').'</label>');                  &mt('Disable').'</label>');
       } else {        } else {
           $r->print('            $r->print('
                 <label><input type="radio" name="autodrops" value="1" />&nbsp;'.                  <label><input type="radio" name="autodrops" value="1"'.$disabled.' />&nbsp;'.
                 &mt('Enable').'&nbsp;&nbsp;&nbsp;</label>                  &mt('Enable').'&nbsp;&nbsp;&nbsp;</label>
                 <label><input type="radio" name="autodrops" value="0" checked="checked" />&nbsp;'.                  <label><input type="radio" name="autodrops" value="0" checked="checked"'.$disabled,' />&nbsp;'.
                 &mt('Disable').'</label>');                  &mt('Disable').'</label>');
       }        }
       $r->print('        $r->print('
Line 415  sub print_main_frame { Line 529  sub print_main_frame {
              </tr>               </tr>
              <tr>               <tr>
               <td align="right">                <td align="right">
                <input type="button" name="chgsettings" value="'.&mt('Go').'" onclick="process('."'chgsettings'".')" />                 <input type="button" name="chgsettings" value="'.&mt('Go').'" onclick="process('."'chgsettings'".')"'.$disabled.' />
       </td>        </td>
              </tr>               </tr>
     </table>      </table>
             <input type="hidden" name="action" value="'.$action.'" />              <input type="hidden" name="action" value="'.$action.'" />
             <input type="hidden" name="state" value="process" />              <input type="hidden" name="state" value="process" />
             </form>'."\n");              </form>'."\n");
     } elsif ($action eq 'chgfailsafe') {
         my ($autofailsafe,$failsafetype,$failsafesty,%failsafechecked);
         $failsafesty = 'inline-block';
         %failsafechecked = (
             dom => ' checked="checked"',
         );
         my $domdefault;
         my %domconfig =
             &Apache::lonnet::get_dom('configuration',['autoenroll'],$dom);
         if (ref($domconfig{'autoenroll'}) eq 'HASH') {
             $autofailsafe = $domconfig{'autoenroll'}->{'autofailsafe'};
             if ($autofailsafe =~ /\D/) {
                 undef($autofailsafe);
             }
             if ($domconfig{'autoenroll'}->{'failsafe'} eq 'off') {
                 undef($autofailsafe);
                 $failsafesty = 'none';
                 $failsafetype = 'off';
                 $domdefault = &mt('Failsafe is not in use.');
             } elsif ($domconfig{'autoenroll'}->{'failsafe'} eq 'any') {
                 $failsafesty = 'inline-block';
                 $failsafetype = 'any';
                 $domdefault = &mt('Failsafe will apply if retrieved enrollment for institutional section is zero or greater.');
             } else {
                 $failsafesty = 'inline-block';
                 $failsafetype = 'zero';
                 $domdefault = &mt('Failsafe will only apply if retrieved enrollment for institutional section is zero.');
             }
         }
         if ((exists($enrollvar{'autodropfailsafetype'})) &&
             ($enrollvar{'autodropfailsafetype'} ne '')) {
             if ($enrollvar{'autodropfailsafetype'} eq 'off') {
                 $failsafesty = 'none';
                 $failsafechecked{'dom'} = '';
                 $failsafechecked{'off'} = ' checked="checked"';
             } elsif ($enrollvar{'autodropfailsafetype'} eq 'any') {
                 $failsafesty = 'inline-block';
                 $failsafechecked{'dom'} = '';
                 $failsafechecked{'any'} = ' checked="checked"';
             } elsif ($enrollvar{'autodropfailsafetype'} eq 'zero') {
                 $failsafesty = 'inline-block';
                 $failsafechecked{'dom'} = '';
                 $failsafechecked{'zero'} = ' checked="checked"';
             }
         }
         $r->print('
             <form name="enter" method="post" action=""><br />
              <table width="100%" border="0" cellpadding="2" cellspacing="2">
               <tr>
                <td align="left"><b>'.$$tasktitleref{$action}.'</b><br /><p>'.
                &mt('The "failsafe" mechanism for automated enrollment can prevent unwanted expiration of student roles for registered students in an institutional section, in the case where either no enrollment, or only partial enrollment, is returned for that particular section because of a temporary institutional data retrieval problem external to LON-CAPA.').'</p>'.
               '<p>'.&mt('For example if the threshold is set to 10, and the current LON-CAPA enrollment count is 11 or more for a particular course section, no role expiration will occur if the latest retrieved enrollment count is zero for that institutional section (or cross-listing).').'</p>');
         if ($enrollvar{'autodropfailsafe'} eq '') {
             $r->print('<p>'.&mt('Currently no course-specific failsafe threshold is set.').' ');
             if ($autofailsafe eq '') {
                 $r->print(&mt('Currently no domain default failsafe is set either.'));
             } else {
                 $r->print(&mt('The current domain default of [_1] will apply unless a value is set here specific to this course.','<b>'.$autofailsafe.'</b>'));
             }
             $r->print('</p>');
         } else {
             unless (($enrollvar{'autodropfailsafetype'} eq 'off') || 
                     (($enrollvar{'autodropfailsafetype'} eq '') && ($failsafetype eq 'off'))) {
                 $r->print('<p>'.&mt('Currently, the course-specific failsafe is set to [_1].',"<i>$enrollvar{'autodropfailsafe'}</i>").'</p>');
             }
         }
         unless (($enrollvar{'autodropfailsafe'} eq '') && ($autofailsafe eq '')) {
             if ($enrollvar{'autodropfailsafetype'} eq '') {
                 $r->print('<p>'.&mt('Currently no course-specific failsafe condition is set.').' ');
                 if ($failsafetype eq 'any') {
                     $r->print(&mt('The current domain default, whereby the failsafe is in effect if the retrieved section enrollment is zero or greater, will apply unless overridden here for this specific course.'));
                 } elsif ($failsafetype eq 'zero') {
                     $r->print(&mt('The current domain default, whereby the failsafe is only in effect if the retrieved section enrollment is zero, will apply unless overridden here for this specific course.'));
                 } elsif ($failsafetype eq 'off') {
                     $r->print(&mt('The current domain default (failsafe not in use) will apply unless overridden here for this specific course.'));
                 }
                 $r->print('</p>');
             } else {
                 if ($enrollvar{'autodropfailsafetype'} eq 'zero') {
                     $r->print('<p>'.&mt('Currently, the course-specific failsafe condition is set such that any failsafe threshold is only in effect when the retrieved institutional section enrollment is zero.'));
                 } elsif ($enrollvar{'autodropfailsafetype'} eq 'any') {
                     $r->print('<p>'.&mt('Currently, the course-specific failsafe condition is set such that any failsafe threshold is in effect when the retrieved institutional section enrollment is zero (or greater).'));
                 } elsif ($enrollvar{'autodropfailsafetype'} eq 'off') {
                     $r->print('<p>'.&mt('Currently, the course-specific failsafe condition is set such that a failsafe will not be used.'));
                 }
                 $r->print('</p>');
             }
         }
         $r->print('
                </td>
               </tr>
              </table>
              <table width="100%" border="0" cellpadding="3" cellspacing="3">
                <tr>
                <td><b>'.&mt('Condition for use of failsafe in this course').'</b><br />
                <span class="LC_nobreak"><label><input type="radio" name="autodropfailsafetype" value="dom" onclick="toggleFailsafe(this.form);"'.$failsafechecked{'dom'}.$disabled.' />'.&mt('Use domain default').'</label></span>&nbsp;--&nbsp;'.$domdefault.'<br />
                <span class="LC_nobreak"><label><input type="radio" name="autodropfailsafetype" value="zero" onclick="toggleFailsafe(this.form);"'.$failsafechecked{'zero'}.$disabled.' />'.&mt('Failsafe will apply if retrieved institutional section enrollment is zero.').'</label></span><br />
                <span class="LC_nobreak"><label><input type="radio" name="autodropfailsafetype" value="any" onclick="toggleFailsafe(this.form);"'.$failsafechecked{'any'}.$disabled.' />'.&mt('Failsafe will apply if retrieved institutional section enrollment is zero or greater.').'</label></span><br />
                <span class="LC_nobreak"><label><input type="radio" name="autodropfailsafetype" value="off" onclick="toggleFailsafe(this.form);"'.$failsafechecked{'off'}.$disabled.' />'.&mt('Failsafe will not be in use in this course.').'</label></span><br />
                <div class="LC_floatleft" style="display:'.$failsafesty.';" id="autodropfailsafe">
                <span class="LC_nobreak"><b>'.
                &mt('Failsafe threshold (enter an integer)').'</b>&nbsp;&nbsp;
                <input type="text" name="autodropfailsafe" value="'.$enrollvar{'autodropfailsafe'}.'" size="4"'.$disabled.' /></span><br />');
          if ($autofailsafe) {
              $r->print(&mt('Leave blank to use domain default of [_1].','<b>'.$autofailsafe.'</b>'));
          } else {
              $r->print(&mt('As no domain default is set, failsafe will not be used if blank.'));
          }
          $r->print('</div>
                </td>
               </tr>
               <tr>
                 <td>&nbsp;</td>
               </tr>
               <tr>
                 <td>'.&mt('Push "Go" to save your changes').'
               <tr>
                 <td>&nbsp;</td>
               </tr>
               <tr>
                <td align="right">
                 <input type="button" name="updatefailsafe" value="'.&mt('Go').'" onclick="'."process('chgfailsafe')".'"'.$disabled.' />
                </td>
               </tr>
              </table>
              <input type="hidden" name="action" value="'.$action.'" />
              <input type="hidden" name="state" value="process" />
              </form>'."\n");
   } elsif ($action eq 'setdates') {    } elsif ($action eq 'setdates') {
       my ($start_table,$end_table) = &date_setting_table($enrollvar{autostart},$enrollvar{autoend},$action);        my ($start_table,$end_table) = &date_setting_table($enrollvar{autostart},$enrollvar{autoend},$action,$readonly);
       my $oldstartshow = '';        my $oldstartshow = '';
       my $oldendshow = '';        my $oldendshow = '';
       if ( defined($enrollvar{autostart}) ) {        if ( defined($enrollvar{autostart}) ) {
Line 494  sub print_main_frame { Line 736  sub print_main_frame {
                   <table width="100%">                    <table width="100%">
                    <tr>                     <tr>
                     <td align="right">                      <td align="right">
                       <input type="button" name="setdates" value="'.&mt('Go').'" onclick="process('."'setdates'".')" />                        <input type="button" name="setdates" value="'.&mt('Go').'" onclick="process('."'setdates'".')"'.$disabled.' />
                     </td>                      </td>
            </tr>             </tr>
                   </table>                    </table>
Line 503  sub print_main_frame { Line 745  sub print_main_frame {
                   </form>                    </form>
 ');  ');
   } elsif ($action eq 'setaccess') {    } elsif ($action eq 'setaccess') {
       &print_accessdate_table($r,\%enrollvar,$tasktitleref,$action);        &print_accessdate_table($r,\%enrollvar,$tasktitleref,$action,$readonly);
       $r->print('        $r->print('
                   <table width="100%">                    <table width="100%">
                    <tr>                     <tr>
                     <td align="right">                      <td align="right">
                       <input type="button" name="'.$action.'" value="'.&mt('Go').'" onclick="'."process('$action')".'" />                        <input type="button" name="'.$action.'" value="'.&mt('Go').'" onclick="'."process('$action')".'"'.$disabled.' />
                     </td>                      </td>
                    </tr>                     </tr>
                   </table>                    </table>
Line 571  sub print_main_frame { Line 813  sub print_main_frame {
       );        );
       if ($notifycount) {        if ($notifycount) {
           $r->print('            $r->print('
                         <label><input type="radio" name="notify" value="1" checked="checked" />&nbsp;'.&mt('Yes').'&nbsp;&nbsp;&nbsp;</label>                          <label><input type="radio" name="notify" value="1" checked="checked"'.$disabled.' />&nbsp;'.&mt('Yes').'&nbsp;&nbsp;&nbsp;</label>
                         <label><input type="radio" name="notify" value="0" />&nbsp;'.&mt('No').'</label>                          <label><input type="radio" name="notify" value="0"'.$disabled.' />&nbsp;'.&mt('No').'</label>
           ');            ');
       } else {        } else {
           $r->print('            $r->print('
                         <label><input type="radio" name="notify" value="1" />&nbsp;'.&mt('Yes').'&nbsp;&nbsp;&nbsp;</label>                          <label><input type="radio" name="notify" value="1"'.$disabled.' />&nbsp;'.&mt('Yes').'&nbsp;&nbsp;&nbsp;</label>
                         <label><input type="radio" name="notify" value="0" checked="checked" />&nbsp;'.&mt('No').'</label>                          <label><input type="radio" name="notify" value="0" checked="checked"'.$disabled.' />&nbsp;'.&mt('No').'</label>
           ');            ');
       }        }
       $r->print('        $r->print('
Line 640  sub print_main_frame { Line 882  sub print_main_frame {
               <td>                <td>
           ');            ');
           $r->print(&notifier_tables('cc',\%lt,\@ccs,\%status,\%notifystate,            $r->print(&notifier_tables('cc',\%lt,\@ccs,\%status,\%notifystate,
                                      \%pname,\$notifyshow));                                       \%pname,\$notifyshow,undef,undef,$disabled));
           $r->print('</td></tr>');            $r->print('</td></tr>');
       } else {        } else {
           $r->print('            $r->print('
Line 700  sub print_main_frame { Line 942  sub print_main_frame {
              <tr>               <tr>
               <td>');                <td>');
           $r->print(&notifier_tables('dc',\%lt,\@showdom,\%status,\%notifystate,\%pname,            $r->print(&notifier_tables('dc',\%lt,\@showdom,\%status,\%notifystate,\%pname,
                                      \$notifyshow,\@olddomcoord,\@futuredomcoord));                                       \$notifyshow,\@olddomcoord,\@futuredomcoord,$disabled));
           $r->print('            $r->print('
              </td>               </td>
           </tr>');            </tr>');
Line 718  sub print_main_frame { Line 960  sub print_main_frame {
            <table width="100%" border="0" cellpadding="2" cellspacing="2">             <table width="100%" border="0" cellpadding="2" cellspacing="2">
             <tr>              <tr>
              <td align="right">               <td align="right">
               <input type="button" name="notifyset" value="'.&mt('Go').'" onclick="'."process('notify')".'" />                <input type="button" name="notifyset" value="'.&mt('Go').'" onclick="'."process('notify')".'"'.$disabled.' />
              </td>               </td>
             </tr>              </tr>
            </table>             </table>
Line 749  sub print_main_frame { Line 991  sub print_main_frame {
           $r->print(            $r->print(
               &mt('Currently, this LON-CAPA course is crosslisted with [quant,_1,course section,course sections].',$cross_str).' '.                &mt('Currently, this LON-CAPA course is crosslisted with [quant,_1,course section,course sections].',$cross_str).' '.
               &mt('Students enrolling in these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.').' '.                &mt('Students enrolling in these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.').' '.
               &mt('For each crosslisting, leave the checkbox checked if you want registered students in that course to be included in the student roster for LON-CAPA course: [_1; otherwise uncheck it.',"<b>$realm ($enrollvar{coursecode})</b>").' '.                &mt('For each crosslisting, leave the checkbox checked if you want registered students in that course to be included in the student roster for LON-CAPA course: [_1]; otherwise uncheck it.',"<b>$realm ($enrollvar{coursecode})</b>").' '.
               &mt('If you wish to change the section ID assigned in your LON-CAPA course for a crosslisted course, enter the new section ID in the appropriate textbox.').' '.                &mt('If you wish to change the section ID assigned in your LON-CAPA course for a crosslisted course, enter the new section ID in the appropriate textbox.').' '.
               &mt('The LON-CAPA section ID can be left (or set to) empty, if you do not wish to tie a section ID to this crosslisting.').' '.                &mt('The LON-CAPA section ID can be left (or set to) empty, if you do not wish to tie a section ID to this crosslisting.').' '.
               &mt('If you wish to add new crosslisted courses, enter the number of new courses to add in the textbox at the bottom of the page.').' '.                &mt('If you wish to add new crosslisted courses, enter the number of new courses to add in the textbox at the bottom of the page.').' '.
Line 768  sub print_main_frame { Line 1010  sub print_main_frame {
                  <th>'.&mt('LON-CAPA section ID').'</th>                   <th>'.&mt('LON-CAPA section ID').'</th>
           ');            ');
           $r->print(&Apache::loncommon::end_data_table_row());            $r->print(&Apache::loncommon::end_data_table_row());
           for (my $i=0; $i<@xlists; $i++) {            my @showable;
             &reformat_xlists($dom,$crs,$enrollvar{'coursecode'},\@xlists,\@showable);
             for (my $i=0; $i<@showable; $i++) {
               my $xl = '&nbsp;';                my $xl = '&nbsp;';
               my $lc_sec = '&nbsp;';                my $lc_sec = '&nbsp;';
               if ($xlists[$i] =~ /^([^:]+):?(.*)$/) {                if ($showable[$i] =~ /^([^:]+):?(.*)$/) {
                   $xl = $1;                    $xl = $1;
                   $lc_sec = $2;                    $lc_sec = $2;
               }                               }               
               $r->print(&Apache::loncommon::start_data_table_row());                $r->print(&Apache::loncommon::start_data_table_row());
               $r->print('                $r->print('
                  <td><input type="checkbox" name="cross_'.$i.'" checked="checked" /></td>                   <td><input type="checkbox" name="cross_'.$i.'" checked="checked"'.$disabled.' /></td>
                  <td>'.$xl.'</td>                   <td>'.$xl.'</td>
                  <td><input type="text" size="10" name="lcsec_'.$i.'" value="'.$lc_sec.'" /></td>                   <td><input type="text" size="10" name="lcsec_'.$i.'" value="'.$lc_sec.'"'.$disabled.' /></td>
               ');                ');
               $r->print(&Apache::loncommon::end_data_table_row());                $r->print(&Apache::loncommon::end_data_table_row());
           }            }
Line 799  sub print_main_frame { Line 1043  sub print_main_frame {
              <tr>               <tr>
               <td align="left">                <td align="left">
                <b>'.&mt('Add new crosslistings.').'</b><br />'.                 <b>'.&mt('Add new crosslistings.').'</b><br />'.
                &mt('Number of new crosslistings to add:[_1]','&nbsp;&nbsp;<input type="text" size="2" name="numcross" value="0" />').'                 &mt('Number of new crosslistings to add:[_1]','&nbsp;&nbsp;<input type="text" size="2" name="numcross" value="0"'.$disabled.' />').'
               </td>                </td>
              </tr>               </tr>
             </table>              </table>
Line 807  sub print_main_frame { Line 1051  sub print_main_frame {
             <table width="100%" border="0" cellpadding="2" cellspacing="2">              <table width="100%" border="0" cellpadding="2" cellspacing="2">
              <tr>               <tr>
               <td align="right">                <td align="right">
                <input type="button" name="crosslist" value="',&mt('Go').'" onclick="'."process('crosslist')".'" />                 <input type="button" name="crosslist" value="',&mt('Go').'" onclick="'."process('crosslist')".'"'.$disabled.' />
               </td>                </td>
              </tr>               </tr>
             </table>              </table>
Line 862  sub print_main_frame { Line 1106  sub print_main_frame {
                   $checked = ' checked="checked"';                    $checked = ' checked="checked"';
               }                }
               $r->print(&Apache::loncommon::start_data_table_row().'                $r->print(&Apache::loncommon::start_data_table_row().'
                   <td><input type="checkbox" name="sec_'.$i.'"'.$checked.' /></td>                    <td><input type="checkbox" name="sec_'.$i.'"'.$checked.$disabled.' /></td>
                   <td>'.$sections[$i].'<input type="hidden" name="secnum_'.$i.'" value="'.$sections[$i].'" /></td>                    <td>'.$sections[$i].'<input type="hidden" name="secnum_'.$i.'" value="'.$sections[$i].'" /></td>
                   <td><input type="text" size="10" name="loncapasec_'.$i.'" value="'.$sec_id{$sections[$i]}.'" /></td>'.                    <td><input type="text" size="10" name="loncapasec_'.$i.'" value="'.$sec_id{$sections[$i]}.'"'.$disabled.' /></td>'.
                   &Apache::loncommon::end_data_table_row());                    &Apache::loncommon::end_data_table_row());
           }            }
           $r->print(&Apache::loncommon::end_data_table());            $r->print(&Apache::loncommon::end_data_table());
Line 874  sub print_main_frame { Line 1118  sub print_main_frame {
              <tr>                <tr> 
               <td align="right">                <td align="right">
                <input type="hidden" name="secshow" value="'.$secshow.'" />                 <input type="hidden" name="secshow" value="'.$secshow.'" />
                <input type="button" name="sections" value="'.&mt('Go').'" onclick="'."process('sections')".'" />                 <input type="button" name="sections" value="'.&mt('Go').'" onclick="'."process('sections')".'"'.$disabled.' />
               </td>                </td>
              </tr>               </tr>
             </table>              </table>
Line 914  sub print_main_frame { Line 1158  sub print_main_frame {
               for (my $j=0; $j<@currsections; $j++) {                for (my $j=0; $j<@currsections; $j++) {
                   $r->print(                    $r->print(
                  &Apache::loncommon::start_data_table_row().                   &Apache::loncommon::start_data_table_row().
                  '<td><input type="checkbox" name="sec_'.$j.'" checked="checked" /></td>                   '<td><input type="checkbox" name="sec_'.$j.'" checked="checked"'.$disabled.' /></td>
                  <td>'.$currsections[$j].'</td>                   <td>'.$currsections[$j].'</td>
                  <td><input type="text" name="lcsec_'.$j.'" size="10" value="'.$sec_id{$currsections[$j]}.'" /></td>                   <td><input type="text" name="lcsec_'.$j.'" size="10" value="'.$sec_id{$currsections[$j]}.'"'.$disabled.' /></td>
                  '.&Apache::loncommon::end_data_table_row());                   '.&Apache::loncommon::end_data_table_row());
               }                }
               $r->print(&Apache::loncommon::end_data_table());                $r->print(&Apache::loncommon::end_data_table());
Line 934  sub print_main_frame { Line 1178  sub print_main_frame {
              <tr>               <tr>
               <td align="left">                <td align="left">
                <b>'.&mt('Add enrollment from additional sections.').'</b><br />'.                 <b>'.&mt('Add enrollment from additional sections.').'</b><br />'.
                &mt('Number of new sections to add:').'&nbsp;&nbsp;<input type="text" size="2" name="numsec" value="0" />                 &mt('Number of new sections to add:').'&nbsp;&nbsp;<input type="text" size="2" name="numsec" value="0"'.$disabled.' />
               </td>                </td>
              </tr>               </tr>
             </table>              </table>
Line 942  sub print_main_frame { Line 1186  sub print_main_frame {
             <table width="100%" border="0" cellpadding="2" cellspacing="2">              <table width="100%" border="0" cellpadding="2" cellspacing="2">
              <tr>               <tr>
               <td align="right">                <td align="right">
                <input type="button" name="sections" value="'.&mt('Go').'" onclick="'."process('sections')".'" />                 <input type="button" name="sections" value="'.&mt('Go').'" onclick="'."process('sections')".'"'.$disabled.' />
               </td>                </td>
              </tr>               </tr>
             </table>              </table>
Line 968  sub print_main_frame { Line 1212  sub print_main_frame {
                          '.&mt('Automatic import of student photos from institutional data repository:').'&nbsp;&nbsp;');                           '.&mt('Automatic import of student photos from institutional data repository:').'&nbsp;&nbsp;');
       if ($enrollvar{showphoto}) {        if ($enrollvar{showphoto}) {
           $r->print('            $r->print('
                         <label><input type="radio" name="showphotos" value="1" checked="checked" />&nbsp;'.&mt('Yes').'&nbsp;&nbsp;&nbsp;</label>                          <label><input type="radio" name="showphotos" value="1" checked="checked"'.$disabled.' />&nbsp;'.&mt('Yes').'&nbsp;&nbsp;&nbsp;</label>
                         <label><input type="radio" name="showphotos" value="0" />&nbsp;'.&mt('No').'</label>                          <label><input type="radio" name="showphotos" value="0"'.$disabled.' />&nbsp;'.&mt('No').'</label>
           ');            ');
       } else {        } else {
           $r->print('            $r->print('
                         <label><input type="radio" name="showphotos" value="1" />&nbsp;'.&mt('Yes').'&nbsp;&nbsp;&nbsp;</label>                          <label><input type="radio" name="showphotos" value="1"'.$disabled.' />&nbsp;'.&mt('Yes').'&nbsp;&nbsp;&nbsp;</label>
                         <label><input type="radio" name="showphotos" value="0" checked="checked" />&nbsp;'.&mt('No').'</label>                          <label><input type="radio" name="showphotos" value="0" checked="checked"'.$disabled.' />&nbsp;'.&mt('No').'</label>
           ');            ');
       }        }
       $r->print('        $r->print('
Line 996  sub print_main_frame { Line 1240  sub print_main_frame {
 &mt('Previously the owner of this course agreed to the conditions of use of digital student photos required by [_1].', $institution).'<br />'.  &mt('Previously the owner of this course agreed to the conditions of use of digital student photos required by [_1].', $institution).'<br />'.
 &mt('As a result [_1]s can choose to automatically import student photos into this course.',&Apache::lonnet::plaintext('cc')).  &mt('As a result [_1]s can choose to automatically import student photos into this course.',&Apache::lonnet::plaintext('cc')).
 '<br /><span class="LC_nobreak"><label>'.  '<br /><span class="LC_nobreak"><label>'.
 &mt('[_1]Cancel[_2] owner acceptance of these conditions of use?','<b>','</b>').'&nbsp;<input type="checkbox" name="cancel_agreement" value="1" /></label></span>  &mt('[_1]Cancel[_2] owner acceptance of these conditions of use?','<b>','</b>').'&nbsp;<input type="checkbox" name="cancel_agreement" value="1"'.$disabled.' /></label></span>
                      </td>                       </td>
                     </tr>                      </tr>
                       ');                        ');
Line 1063  sub print_main_frame { Line 1307  sub print_main_frame {
                     </tr>                      </tr>
                     <tr>                      <tr>
                      <td align="right">                       <td align="right">
                       <input type="button" name="showphotos" value="Go" onclick="process('."'photos'".')" />                        <input type="button" name="showphotos" value="'.&mt('Go').'" onclick="process('."'photos'".')"'.$disabled.' />
                      </td>                       </td>
                     </tr>                      </tr>
                    </table>                     </table>
Line 1084  sub print_main_frame { Line 1328  sub print_main_frame {
     <tr>      <tr>
      <td>'.       <td>'.
              &mt('Add any students currently included in institutional classlist(s) but not enrolled in your LON-CAPA course.').'<br />                 &mt('Add any students currently included in institutional classlist(s) but not enrolled in your LON-CAPA course.').'<br />  
       <label><input type="radio" name="updateadds" value="1" />&nbsp;'.&mt('Yes').'&nbsp;</label>        <label><input type="radio" name="updateadds" value="1"'.$disabled.' />&nbsp;'.&mt('Yes').'&nbsp;</label>
                       <label><input type="radio" name="updateadds" value="0" />&nbsp;'.&mt('No').'&nbsp;</label>                        <label><input type="radio" name="updateadds" value="0"'.$disabled.' />&nbsp;'.&mt('No').'&nbsp;</label>
                      </td>                       </td>
                     </tr>                      </tr>
                     <tr>                      <tr>
                      <td>'.                       <td>'.
               &mt('Expire students previously added by nightly enrollment process, but no longer listed in institutional classlist(s).').'<br />                &mt('Expire students previously added by nightly enrollment process, but no longer listed in institutional classlist(s).').'<br />
                       <label><input type="radio" name="updatedrops" value="1" />&nbsp;'.&mt('Yes').'&nbsp;</label>                        <label><input type="radio" name="updatedrops" value="1"'.$disabled.' />&nbsp;'.&mt('Yes').'&nbsp;</label>
                       <label><input type="radio" name="updatedrops" value="0" />&nbsp;'.&mt('No').'&nbsp;</label><br />                        <label><input type="radio" name="updatedrops" value="0"'.$disabled.' />&nbsp;'.&mt('No').'&nbsp;</label><br />
                      </td>                       </td>
                     </tr>                      </tr>
                     <tr>                      <tr>
Line 1104  sub print_main_frame { Line 1348  sub print_main_frame {
                     <tr>                      <tr>
                      <td>                       <td>
       ');        ');
       &print_accessdate_table($r,\%enrollvar,$tasktitleref,$action);        &print_accessdate_table($r,\%enrollvar,$tasktitleref,$action,$readonly);
       $r->print('        $r->print('
                      </td>                       </td>
                     </tr>                      </tr>
                     <tr>                      <tr>
                      <td align="right">                       <td align="right">
                       <input type="button" name="updatenow" value="'.&mt('Go').'" onclick="'."process('updatenow')".'" />                        <input type="button" name="updatenow" value="'.&mt('Go').'" onclick="'."process('updatenow')".'"'.$disabled.' />
                      </td>                       </td>
                     </tr>                      </tr>
            </table>             </table>
Line 1132  sub print_main_frame { Line 1376  sub print_main_frame {
               $r->print('<br />'.$commentary.'<br /><br />                $r->print('<br />'.$commentary.'<br /><br />
 <form name="photoupdate" method="post" action="">  <form name="photoupdate" method="post" action="">
 <input type="button" name="retrieve" value="'.&mt('Update photo repository').'"  <input type="button" name="retrieve" value="'.&mt('Update photo repository').'"
 onclick="javascript:document.photoupdate.submit()" />  onclick="javascript:document.photoupdate.submit()"'.$disabled.' />
 <input type="hidden" name="action" value="'.$action.'" />  <input type="hidden" name="action" value="'.$action.'" />
 <input type="hidden" name="state" value="process" />  <input type="hidden" name="state" value="process" />
 </form>');  </form>');
Line 1161  onclick="javascript:document.photoupdate Line 1405  onclick="javascript:document.photoupdate
                 &mt("Students with an enroll type of [_1]manual[_2], will be converted automatically to the 'auto' type, when they first appear in the institutional classlist for the course - as long as nightly adds are enabled and active, or the update roster utility is used.","'<b>","'</b>").' '.                  &mt("Students with an enroll type of [_1]manual[_2], will be converted automatically to the 'auto' type, when they first appear in the institutional classlist for the course - as long as nightly adds are enabled and active, or the update roster utility is used.","'<b>","'</b>").' '.
                 &mt("Use the 'Lock' checkbox for any manually enrolled students for whom you wish to prevent type conversion.").' '.                  &mt("Use the 'Lock' checkbox for any manually enrolled students for whom you wish to prevent type conversion.").' '.
                 &mt("Use the 'Change' checkbox to switch the enroll type from auto to manual, and vice versa.").' '.                  &mt("Use the 'Change' checkbox to switch the enroll type from auto to manual, and vice versa.").' '.
                 &mt("Use the 'Unlock' checkbox for any maually enrolled students for whom you no longer wish to lock the enroll type.").' '.                  &mt("Use the 'Unlock' checkbox for any manually enrolled students for whom you no longer wish to lock the enroll type.").' '.
                 &mt("Click the 'Go' button at the end of the page to process your desired changes.").'</td>                  &mt("Click the 'Go' button at the end of the page to process your desired changes.").'</td>
                     </tr>                      </tr>
                     <tr><td>&nbsp;</td></tr>                       <tr><td>&nbsp;</td></tr> 
Line 1206  onclick="javascript:document.photoupdate Line 1450  onclick="javascript:document.photoupdate
               "\n");                "\n");
           my $context = 'course';            my $context = 'course';
           my $mode = 'autoenroll';            my $mode = 'autoenroll';
           my ($studentcount,$autocount,$manualcount,$lockcount,$unlockcount) = &Apache::lonuserutils::show_users_list($r,$context,$mode,$permission,$env{'form.Status'},\%userlist,$keylist);            my ($studentcount,$autocount,$manualcount,$lockcount,$unlockcount) = 
                 &Apache::lonuserutils::show_users_list($r,$context,$mode,$permission,$env{'form.Status'},\%userlist,$keylist);
           $r->print('            $r->print('
                      </td>                       </td>
                     </tr>                      </tr>
Line 1219  onclick="javascript:document.photoupdate Line 1464  onclick="javascript:document.photoupdate
               if ($autocount > 0) {                if ($autocount > 0) {
                   $cellcount ++;                    $cellcount ++;
                   $r->print('                    $r->print('
                       <td><fieldset><legend>'.&mt('Change auto').'</legend><input type="button" value="'.&mt('check all').'" onclick="javascript:checkAll(document.studentform.chgauto)" />&nbsp;&nbsp;                        <td><fieldset><legend>'.&mt('Change auto').'</legend><input type="button" value="'.&mt('check all').'" onclick="javascript:checkAll(document.studentform.chgauto)"'.$disabled.' />&nbsp;&nbsp;
                       <input type="button" value="'.&mt('uncheck all').'" onclick="javascript:uncheckAll(document.studentform.chgauto)" /></fieldset></td>                        <input type="button" value="'.&mt('uncheck all').'" onclick="javascript:uncheckAll(document.studentform.chgauto)"'.$disabled.' /></fieldset></td>
                   ');                    ');
               }                }
               if ($manualcount > 0) {                if ($manualcount > 0) {
                   $cellcount ++;                    $cellcount ++;
                   $r->print('                    $r->print('
                       <td><fieldset><legend>'.&mt('Change manual').'</legend><input type="button" value="'.&mt('check all').'" onclick="javascript:checkAll(document.studentform.chgmanual)" />&nbsp;&nbsp;                        <td><fieldset><legend>'.&mt('Change manual').'</legend><input type="button" value="'.&mt('check all').'" onclick="javascript:checkAll(document.studentform.chgmanual)"'.$disabled.' />&nbsp;&nbsp;
                       <input type="button" value="'.&mt('uncheck all').'" onclick="javascript:uncheckAll(document.studentform.chgmanual)" /></fieldset></td>                        <input type="button" value="'.&mt('uncheck all').'" onclick="javascript:uncheckAll(document.studentform.chgmanual)"'.$disabled.' /></fieldset></td>
                   ');                    ');
               }                }
               if ($lockcount > 0) {                if ($lockcount > 0) {
Line 1236  onclick="javascript:document.photoupdate Line 1481  onclick="javascript:document.photoupdate
                   }                    }
                   $cellcount ++;                    $cellcount ++;
                   $r->print('                    $r->print('
                        <td><fieldset><legend>'.&mt('Lock manual').'</legend><input type="button" value="'.&mt('check all').'" onclick="javascript:checkAll(document.studentform.lockchg)" />&nbsp;&nbsp;                         <td><fieldset><legend>'.&mt('Lock manual').'</legend><input type="button" value="'.&mt('check all').'" onclick="javascript:checkAll(document.studentform.lockchg)"'.$disabled.' />&nbsp;&nbsp;
                        <input type="button" value="'.&mt('uncheck all').'" onclick="javascript:uncheckAll(document.studentform.lockchg)" /></fieldset></td>                         <input type="button" value="'.&mt('uncheck all').'" onclick="javascript:uncheckAll(document.studentform.lockchg)"'.$disabled.' /></fieldset></td>
                   ');                    ');
               }                }
               if ($unlockcount > 0) {                if ($unlockcount > 0) {
Line 1247  onclick="javascript:document.photoupdate Line 1492  onclick="javascript:document.photoupdate
                   $cellcount ++;                    $cellcount ++;
                   $r->print('                    $r->print('
                        <td><fieldset><legend>'.&mt('Unlock manual').'                         <td><fieldset><legend>'.&mt('Unlock manual').'
                        </legend><input type="button" value="'.&mt('check all').'" onclick="javascript:checkAll(document.studentform.unlockchg)" />&nbsp;&nbsp;                         </legend><input type="button" value="'.&mt('check all').'" onclick="javascript:checkAll(document.studentform.unlockchg)"'.$disabled.' />&nbsp;&nbsp;
                        <input type="button" value="'.&mt('uncheck all').'" onclick="javascript:uncheckAll(document.studentform.unlockchg)" /></fieldset></td>');                         <input type="button" value="'.&mt('uncheck all').'" onclick="javascript:uncheckAll(document.studentform.unlockchg)"'.$disabled.' /></fieldset></td>');
               }                }
               $r->print('                $r->print('
                        </tr>                         </tr>
Line 1257  onclick="javascript:document.photoupdate Line 1502  onclick="javascript:document.photoupdate
                     </tr>                      </tr>
                     <tr>                      <tr>
                      <td align="right">                       <td align="right">
                       <input type="button" name="viewclass" value="'.&mt('Go').'" onclick="'."process('viewclass','$autocount','$manualcount','$lockcount','$unlockcount')".'" />                        <input type="button" name="viewclass" value="'.&mt('Go').'" onclick="'."process('viewclass','$autocount','$manualcount','$lockcount','$unlockcount')".'"'.$disabled.' />
                      </td>                       </td>
                     </tr>                      </tr>
               ');                ');
Line 1282  onclick="javascript:document.photoupdate Line 1527  onclick="javascript:document.photoupdate
   
 sub notifier_tables {  sub notifier_tables {
     my ($role,$lt,$users,$status,$notifystate,$pname,$notifyshow,$olddomcoord,      my ($role,$lt,$users,$status,$notifystate,$pname,$notifyshow,$olddomcoord,
         $futuredomcoord) = @_;          $futuredomcoord,$disabled) = @_;
     my $output = &Apache::loncommon::start_data_table();      my $output = &Apache::loncommon::start_data_table();
     $output .= &Apache::loncommon::start_data_table_header_row();      $output .= &Apache::loncommon::start_data_table_header_row();
     $output .= "<th>$$lt{name}</th>      $output .= "<th>$$lt{name}</th>
Line 1325  sub notifier_tables { Line 1570  sub notifier_tables {
         if ($$notifystate{$$users[$i]} == 1) {          if ($$notifystate{$$users[$i]} == 1) {
             $output .= ' checked="checked"';              $output .= ' checked="checked"';
         }          }
         $output .= ' /></td>';          $output .= $disabled.' /></td>';
         $output .= &Apache::loncommon::end_data_table_row();          $output .= &Apache::loncommon::end_data_table_row();
         $$notifyshow ++;          $$notifyshow ++;
     }      }
Line 1334  sub notifier_tables { Line 1579  sub notifier_tables {
 }  }
   
 sub print_accessdate_table {  sub print_accessdate_table {
     my ($r,$enrollvar,$tasktitleref,$action) = @_;      my ($r,$enrollvar,$tasktitleref,$action,$readonly) = @_;
     my ($start_table,$end_table) = &date_setting_table($$enrollvar{'default_enrollment_start_date'},$$enrollvar{'default_enrollment_end_date'},$action);      my ($start_table,$end_table) = &date_setting_table($$enrollvar{'default_enrollment_start_date'},$$enrollvar{'default_enrollment_end_date'},$action,$readonly);
     my ($oldstartshow,$oldendshow);      my ($oldstartshow,$oldendshow);
     if ( defined($$enrollvar{'default_enrollment_start_date'}) ) {      if ( defined($$enrollvar{'default_enrollment_start_date'}) ) {
         $oldstartshow = &Apache::lonlocal::locallocaltime($$enrollvar{'default_enrollment_start_date'});          $oldstartshow = &Apache::lonlocal::locallocaltime($$enrollvar{'default_enrollment_start_date'});
Line 1356  sub print_accessdate_table { Line 1601  sub print_accessdate_table {
          'fnew' => 'for new students added when you update the class roster',           '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.',           '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.',
     );      );
     $lt{'ncds'} = &mt('changing default start and end access dates will affect [_1]future enrollments[_2] and also [_1]currently inactive[_2] students (i.e., those for whom access will begin in the future).','<b>','</b>');      $lt{'ncds'} = &mt('Changing default start and end access dates will affect [_1]future enrollments[_2] and also [_1]currently inactive[_2] students (i.e., those for whom access will begin in the future).','<b>','</b>');
     $lt{'tcha'} = &mt('To change access dates for [_1]currently active[_2] students, use User Management -> "Manage Course Users" to display currently active students, then use the dropdown menu for "Action to take for selected users:" to choose "Change starting/ending dates", select the students to change, and click "Proceed".','<b>','</b>');      $lt{'tcha'} = &mt('To change access dates for [_1]currently active[_2] students, use User Management -> "Manage Course Users" to display currently active students, then use the dropdown menu for "Action to take for selected users:" to choose "Change starting/ending dates", select the students to change, and click "Proceed".','<b>','</b>');
     my $dateshow;      my $dateshow;
     if ( ($oldendshow eq '') && ($oldstartshow eq '') ) {      if ( ($oldendshow eq '') && ($oldstartshow eq '') ) {
Line 1466  sub print_doc_base { Line 1711  sub print_doc_base {
 ###################################################################  ###################################################################
 sub print_chgsettings_response {  sub print_chgsettings_response {
     my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;      my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
     my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.crosslistings','internal.autostart','internal.autoend','internal.autoadds','internal.autodrops'],$dom,$crs);      my %settings = &Apache::lonnet::get('environment',['internal.autoadds','internal.autodrops'],$dom,$crs);
     my ($currend,$currstart,$currsecs,$currxlists,$curradds,$currdrops,      my ($curradds,$currdrops,$autoadds,$autodrops,$response,$warning,
         $autoadds,$autodrops,$response,$warning,$warn_prefix,$warn_suffix,          $warn_prefix,$warn_suffix,$warnfiller);
         $warnfiller);  
     if ( defined($settings{'internal.autoadds'}) ) {      if ( defined($settings{'internal.autoadds'}) ) {
  $curradds = $settings{'internal.autoadds'};   $curradds = $settings{'internal.autoadds'};
     }      }
     if ( defined($settings{'internal.autodrops'}) ) {      if ( defined($settings{'internal.autodrops'}) ) {
  $currdrops = $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'}  
     }  
     if ( exists($env{'form.autoadds'}) ) {      if ( exists($env{'form.autoadds'}) ) {
  $autoadds=$env{'form.autoadds'};   $autoadds=$env{'form.autoadds'};
     }      }
Line 1537  sub print_chgsettings_response { Line 1769  sub print_chgsettings_response {
             unless ($warning eq '') {              unless ($warning eq '') {
         $response .= '<br /><span class="LC_warning">'.          $response .= '<br /><span class="LC_warning">'.
                              '<b>'.&mt('Warning.').'</b> ';                               '<b>'.&mt('Warning.').'</b> ';
                 if ($autodrops && $autodrops) {                  if ($autoadds && $autodrops) {
                     $response .=                       $response .= 
                         &mt('Although you indicated that nightly adds and drops should be enabled, additional action is required.');                          &mt('Although you indicated that nightly adds and drops should be enabled, additional action is required.');
                 } elsif ($autoadds) {                  } elsif ($autoadds) {
Line 1555  sub print_chgsettings_response { Line 1787  sub print_chgsettings_response {
     return;      return;
 }  }
   
   sub print_chgfailsafe_response {
       my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
       my %settings = &Apache::lonnet::get('environment',
                                           ['internal.autodropfailsafe',
                                            'internal.autodropfailsafetype'],
                                           $dom,$crs);
       my ($currfailsafe,$newfailsafe,$currfailsafetype,$newfailsafetype,$response);
       if (defined($settings{'internal.autodropfailsafe'})) {
           $currfailsafe = $settings{'internal.autodropfailsafe'};
       }
       if (defined($settings{'internal.autodropfailsafetype'})) {
           $currfailsafetype = $settings{'internal.autodropfailsafetype'};
       }
       if (exists($env{'form.autodropfailsafe'})) {
           $env{'form.autodropfailsafe'} =~ s{^\s+|\s+$}{}g;
           if ($env{'form.autodropfailsafe'} !~ /\D/) { 
               $newfailsafe = $env{'form.autodropfailsafe'};
           }
       }
       if ($env{'form.autodropfailsafetype'} =~ /^(any|zero|off)$/) {
           $newfailsafetype = $env{'form.autodropfailsafetype'};
       }
       if (($currfailsafe ne $newfailsafe) || ($currfailsafetype ne $newfailsafetype)) {
           my %cenv = ('internal.autodropfailsafe' => $newfailsafe,
                       'internal.autodropfailsafetype' => $newfailsafetype,
                      );
           my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
           if ($reply ne 'ok') {
               $response =
                   &mt('There was a problem processing your requested changes.').' '.
                   &mt('The automated enrollment settings for this course have been left unchanged.').'<br />';
           } else {
               if ($currfailsafetype ne $newfailsafetype) {
                   if ($env{'form.autodropfailsafetype'} eq 'dom') {
                       $response = &mt('Course-specific setting for condition for when failsafe applies deleted; domain default now applies.');
                   } elsif ($newfailsafetype eq 'off') {
                       $response = &mt('Course-specific setting set to disable failsafe use.');
                   } elsif ($newfailsafetype eq 'zero') {
                       $response = &mt('Course-specific setting set so failsafe applies when zero enrollment retrieved for an institutional section.');
                   } else {
                       $response = &mt('Course-specific setting set so failsafe applies when zero or greater enrollment is retrieved for an institutional section.');
                   }
                   $response .= '<br />';
               }
               if ($currfailsafe ne $newfailsafe) {
                   if ($newfailsafe ne '') {
                       $response .= &mt('Course-specific setting for drop failsafe threshold set to [_1]',$newfailsafe);
                   } else {
                       $response .= &mt('Course-specific setting for drop failsafe threshold deleted; domain default now applies.');
                   }
               }
           }
       } else {
           $response = &mt('The new values for the automated drop failsafe threshold and conditions under which failsafe applies were the same as the existing values, so no changes have been made.'); 
       }
       &print_reply($r,$response,$$tasktitleref{$action});
       return;
   }
   
 sub print_setdates_response {  sub print_setdates_response {
     my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;      my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
     my %settings =       my %settings = 
Line 1706  sub print_setaccess_response { Line 1997  sub print_setaccess_response {
                 '<br />'.                  '<br />'.
                 &mt('Any change in access dates will only apply to students who are not currently active, i.e., those who currently have access start dates in the future, and to those added by future automated enrollment.').                  &mt('Any change in access dates will only apply to students who are not currently active, i.e., those who currently have access start dates in the future, and to those added by future automated enrollment.').
                 '<br /><br />'.                  '<br /><br />'.
                  &mt('To change access dates for any currently active students, use User Management -> "Manage Users" to display currently active students, then use the dropdown menu for "Action to take for selected users:" to choose "Change starting/ending dates", select the students to change, and click "Proceed".').                   &mt('To change access dates for [_1]currently active[_2] students, use User Management -> "Manage course users" to display currently active students, then use the dropdown menu for "Action to take for selected users:" to choose "Change starting/ending dates", select the students to change, and click "Proceed".','<b>','</b>').
                 '<br />';                  '<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 access date was later than today, but new first access date is now today or earlier.
Line 1907  sub print_crosslistings_menu { Line 2198  sub print_crosslistings_menu {
  if ($crosscount > 0) {   if ($crosscount > 0) {
     $response .= &mt('The [quant,_1,course] listed below remain crosslisted with this LON-CAPA course, and students enrolling in these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.',$crosscount).      $response .= &mt('The [quant,_1,course] listed below remain crosslisted with this LON-CAPA course, and students enrolling in these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.',$crosscount).
                          '<br /><ul>'."\n";                           '<br /><ul>'."\n";
     foreach my $xl (@xlists) {              my @showable;
  my ($xlist,$lc_sec) = split(/:/,$xl);              &reformat_xlists($dom,$crs,$coursecode,\@xlists,\@showable);
               foreach my $item (@showable) {
                   my ($xlist,$lc_sec) = split(/:/,$item);
  $response .=    $response .= 
                     '<li>'.&mt('[_1] - ID: [_2]',$xlist,$lc_sec).'</li>'."\n";                      '<li>'.&mt('[_1] - ID: [_2]',$xlist,$lc_sec).'</li>'."\n";
     }      }
Line 1918  sub print_crosslistings_menu { Line 2211  sub print_crosslistings_menu {
     if ( exists($env{'form.numcross'}) ) {      if ( exists($env{'form.numcross'}) ) {
  my $numcross = $env{'form.numcross'};   my $numcross = $env{'form.numcross'};
  if ($numcross) {   if ($numcross) {
     $response .=               my (@codetitles,%cat_titles,%cat_order,@code_order);
                 &mt('You indicated that you wish to add an additional [quant,_1,crosslisting].',$numcross).' '.              &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
                 &mt('For each new crosslisting enter the insititutional course section code (e.g., fs03zol101001, for section 001 of zol101 for fs03 semester), and the LON-CAPA section ID you wish to assign to students who will be enrolled in your LON-CAPA class as a result of their registration in the crosslisted course section.').' '.                                                       \%cat_order,\@code_order);       
                 &mt('The LON-CAPA section ID can be left blank, if you do not wish to tie a section ID to this crosslisting.').' '.      $response .=
                 &mt("The institutional course section code should only contain letters and/or numbers, and must be consistent with the scheme adopted by your Domain Coordinator to map course codes (and section numbers) to your institution's student information system.").                  &mt('You indicated that you wish to add an additional [quant,_1,crosslisting].',$numcross).' ';
                 '<br /><br />              if (@codetitles > 0) {
            <form name="enter" method="post" action="">'.                  my $lastitem = pop(@codetitles);
            &Apache::loncommon::start_data_table().                  $response .=
            &Apache::loncommon::start_data_table_row().'                      &mt('For each new crosslisting select [_1], and enter the [_2] and the LON-CAPA section ID.',join(', ',@codetitles),$lastitem).' '.
                  <th>'.&mt('Crosslisting').'</th>                      &mt('The LON-CAPA section ID can be left blank, if you do not wish to tie a section ID to this crosslisting.').' '.
                  <th>'.&mt('LON-CAPA section ID').'</th>'."\n".                      '<br /><br />'.
            &Apache::loncommon::end_data_table_row();                      '<form name="enter" method="post" action="">'."\n".
    for (my $i=0; $i<$numcross; $i++) {                      &Apache::loncommon::start_data_table()."\n".
                $response .=                       &Apache::loncommon::start_data_table_header_row()."\n";
                    &Apache::loncommon::start_data_table_row().'                  foreach my $title (@codetitles) {
                    <td><input type="text" size="15" name="newcross_'.$i.'" /></td>                      if (ref($cat_order{$title}) eq 'ARRAY') {
                     <td align="right"><input type="text" size="10" name="newlcsec_'.$i.'" /></td>'.                          if (@{$cat_order{$title}} > 0) {
                               $response .= '<th>'.$title.'</th>';
                           }
                       }
                   }
                   $response .= '<th>'.$lastitem.'</th>'."\n".
                                '<th>'.&mt('Institutional section').'</th>'."\n".
                                '<th>'.&mt('LON-CAPA section').'</th>'."\n".
                                &Apache::loncommon::end_data_table_header_row()."\n";
                   for (my $i=0; $i<$numcross; $i++) {
                       $response .=
                           &Apache::loncommon::start_data_table_row()."\n";
                       foreach my $title (@codetitles) {
                           if (ref($cat_order{$title}) eq 'ARRAY') {
                               if (@{$cat_order{$title}} > 0) {
                                   $response .= '<td align="center">'.
                                                '<select name="newcross_'.$i.'_'.$title.'">'."\n".
                                                ' <option value="" selected="selected">'.
                                                &mt('Select').'</option>'."\n";
                                   foreach my $item (@{$cat_order{$title}}) {
                                       my $longitem = $item;
                                       if (ref($cat_titles{$title}) eq 'HASH') {
                                           if ($cat_titles{$title}{$item} ne '') {
                                               $longitem = $cat_titles{$title}{$item};
                                           }
                                       }
                                       $response .= '<option value="'.$item.'">'.$longitem.
                                                    '</option>'."\n";
                                   }
                                   $response .= '</select></td>'."\n";
                               }
                           }
                       }
                       $response .= '<td align="center">'.
                                    '<input type="text" size="5" name="newcross_'.$i.'_'.$lastitem.'" />'.
                                    '</td>'."\n".'<td align="center">'.
                                    '<input type="text" size="10" name="newcross_'.$i.'_instsec" />'.
                                    '</td>'."\n".'<td align="center">'.
                                    '<input type="text" size="10" name="newlcsec_'.$i.'" /></td>'.
                                    &Apache::loncommon::end_data_table_row()."\n";
                   }
                   $response .= &Apache::loncommon::end_data_table()."\n";
               } else {
                   $response .=              
                       &mt('For each new crosslisting enter the institutional course section code (e.g., fs03zol101001, for section 001 of zol101 for fs03 semester), and the LON-CAPA section ID you wish to assign to students who will be enrolled in your LON-CAPA class as a result of their registration in the crosslisted course section.').' '.
                       &mt('The LON-CAPA section ID can be left blank, if you do not wish to tie a section ID to this crosslisting.').' '.
                       &mt("The institutional course section code should only contain letters and/or numbers, and must be consistent with the scheme adopted by your Domain Coordinator to map course codes (and section numbers) to your institution's student information system.").
                       '<br /><br />'.
                       '<form name="enter" method="post" action="">'."\n".
                       &Apache::loncommon::start_data_table()."\n".
                       &Apache::loncommon::start_data_table_row()."\n".
                       '<th>'.&mt('Crosslisting').'</th>'."\n".
                       '<th>'.&mt('LON-CAPA section ID').'</th>'."\n".
                     &Apache::loncommon::end_data_table_row();                      &Apache::loncommon::end_data_table_row();
     }         for (my $i=0; $i<$numcross; $i++) {
             $response .= &Apache::loncommon::end_data_table().'                     $response .= 
                          &Apache::loncommon::start_data_table_row().'
                          <td><input type="text" size="15" name="newcross_'.$i.'" /></td>
                          <td align="right"><input type="text" size="10" name="newlcsec_'.$i.'" /></td>'.
                          &Apache::loncommon::end_data_table_row();
           }
                   $response .= &Apache::loncommon::end_data_table();
               }
               $response .= '
               </td>                </td>
              </tr>               </tr>
              <tr>               <tr>
Line 1978  sub print_crosslistings_response { Line 2331  sub print_crosslistings_response {
     }      }
     if ($numcross) {      if ($numcross) {
         my %curr_groups = &Apache::longroup::coursegroups();          my %curr_groups = &Apache::longroup::coursegroups();
           my (@codetitles,%cat_titles,%cat_order,@code_order);
           &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
                                                    \%cat_order,\@code_order);
           my $lastitem = $codetitles[-1];
  for (my $i=0; $i<$numcross; $i++) {   for (my $i=0; $i<$numcross; $i++) {
     my $xl = "newcross_".$i;      my $xl = '';
               if (@code_order > 0) {
                   foreach my $item (@code_order) {
                       my $possval = $env{'form.newcross_'.$i.'_'.$item};
                       if ($item eq $lastitem) {
                           $xl .= $possval;
                       } else {
                           my $possval = $env{'form.newcross_'.$i.'_'.$item};
                           if (ref($cat_order{$item}) eq 'ARRAY') {
                               if (grep(/^\Q$possval\E$/,@{$cat_order{$item}})) {
                                   $xl .= $possval;
                               }
                           }
                       }
                   }
                   if ($xl ne '') {
                       my $crskey = $crs.':'.$xl;
                       if ($env{'form.newcross_'.$i.'_instsec'} ne '') {
                           my $poss_sec = $env{'form.newcross_'.$i.'_instsec'};
                           my %formatted = &Apache::lonnet::auto_instsec_reformat($dom,'clutter',
                                                                                  {$crskey => [$poss_sec]});
                           if (ref($formatted{$crskey}) eq 'ARRAY') {
                               $xl .= $formatted{$crskey}->[0];
                           }
                       }
                   }
               } else {
                   $xl = $env{'form.newcross_'.$i};
               }
     my $lc_sec = "newlcsec_".$i;      my $lc_sec = "newlcsec_".$i;
     if ( exists($env{"form.$xl"}) ) {      if ($xl ne '') {
                 if (exists($env{"form.$lc_sec"})) {                  if (exists($env{"form.$lc_sec"})) {
                     my $lc_sec_check = &validate_lcsec(\%curr_groups,                      my $lc_sec_check = &validate_lcsec(\%curr_groups,
                                                     $env{"form.$lc_sec"});                                                      $env{"form.$lc_sec"});
                     if ($lc_sec_check eq 'reserved') {                      if ($lc_sec_check eq 'reserved') {
                         push(@reserved,$env{"form.$xl"}.":".$env{"form.$lc_sec"});                          push(@reserved,$xl.':'.$env{"form.$lc_sec"});
                         next;                          next;
                     } elsif ($lc_sec_check eq 'group') {                      } elsif ($lc_sec_check eq 'group') {
                         push(@matchgroup,$env{"form.$xl"}.":".$env{"form.$lc_sec"});                          push(@matchgroup,$xl.':'.$env{"form.$lc_sec"});
                         next;                          next;
                     }                      }
                 }                  }
  my $coursecheck =    my $coursecheck =
                     &Apache::lonnet::auto_validate_courseID($crs,$dom,$env{"form.$xl"});                      &Apache::lonnet::auto_validate_courseID($crs,$dom,$xl);
  if ($coursecheck eq 'ok') {   if ($coursecheck eq 'ok') {
     my $addcheck = '';      my $addcheck = '';
     $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$env{"form.$xl"},$owner,$coowners);      $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$xl,$owner,$coowners);
     if ($addcheck eq 'ok') {      unless ($addcheck eq 'ok') {
  push(@xlists,$env{"form.$xl"}.":".$env{"form.$lc_sec"});                          if ($coowners) {
     } else {                              foreach my $user (split(/,/,$coowners)) {
  push(@badowner,$env{"form.$xl"}.":".$env{"form.$lc_sec"});                                  if ($user =~ /^($match_username):($match_domain)$/) {
                                       if (&Apache::lonnet::auto_validate_inst_crosslist($crs,$dom,$coursecode,
                                                                                         $xl,$user) eq 'valid') {
                                           $addcheck = 'ok';
                                           last;
                                       }
                                   }
                               }
                           }
                       }
                       if ($addcheck eq 'ok') {
                           push(@xlists,$xl.':'.$env{"form.$lc_sec"});
                       } else { 
    push(@badowner,$xl.':'.$env{"form.$lc_sec"});
     }      }
  } else {   } else {
     push(@badxlists,$env{"form.$xl"}.":".$env{"form.$lc_sec"}.":".$coursecheck);      push(@badxlists,$xl.':'.$env{"form.$lc_sec"}.":".$coursecheck);
  }   }
     }      }
  }   }
Line 2024  sub print_crosslistings_response { Line 2422  sub print_crosslistings_response {
                 '<br /><br />';                  '<br /><br />';
  } else {   } else {
     $response = &mt('The courses listed below are now crosslisted with this LON-CAPA course, and students enrolling in these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.').'<br /><ul>'."\n";      $response = &mt('The courses listed below are now crosslisted with this LON-CAPA course, and students enrolling in these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.').'<br /><ul>'."\n";
     foreach my $item (@allxlists) {              my @showable;
               &reformat_xlists($dom,$crs,$coursecode,\@allxlists,\@showable);
               foreach my $item (@showable) {
  my ($xlist,$lc_sec) = split(/:/,$item);   my ($xlist,$lc_sec) = split(/:/,$item);
  $response .= '<li>'.&mt('[_1] - ID: [_2]',$xlist,$lc_sec).'</li>'.   $response .= '<li>'.&mt('[_1] - ID: [_2]',$xlist,$lc_sec).'</li>'.
                               "\n";                                "\n";
Line 2036  sub print_crosslistings_response { Line 2436  sub print_crosslistings_response {
     my @oldxlists = split(/,/,$xliststr);      my @oldxlists = split(/,/,$xliststr);
     $response .= &mt('Although no new crosslistings were added, the courses listed below continue to be crosslisted with your LON-CAPA course.').      $response .= &mt('Although no new crosslistings were added, the courses listed below continue to be crosslisted with your LON-CAPA course.').
                          '<br /><ul>'."\n";                           '<br /><ul>'."\n";
     foreach my $xl (@oldxlists) {              my @showable;
  my ($xlist,$lc_sec) = split(/:/,$xl);              &reformat_xlists($dom,$crs,$coursecode,\@oldxlists,\@showable);
               foreach my $item (@showable) {
    my ($xlist,$lc_sec) = split(/:/,$item);
  $response .= '<li>'.&mt('[_1] - ID: [_2]',$xlist,$lc_sec).'</li>'.   $response .= '<li>'.&mt('[_1] - ID: [_2]',$xlist,$lc_sec).'</li>'.
                              "\n";                               "\n";
     }      }
Line 2047  sub print_crosslistings_response { Line 2449  sub print_crosslistings_response {
     if (@badxlists > 0) {      if (@badxlists > 0) {
  $response .= &mt("The courses listed below could not be included in the crosslistings for this LON-CAPA course, because they are not valid courses according to your institution's official schedule of classes and sections.").   $response .= &mt("The courses listed below could not be included in the crosslistings for this LON-CAPA course, because they are not valid courses according to your institution's official schedule of classes and sections.").
                      '<br /><ul>'."\n";                       '<br /><ul>'."\n";
  foreach my $item (@badxlists) {          my @showable;
           &reformat_xlists($dom,$crs,$coursecode,\@badxlists,\@showable);
           foreach my $item (@showable) {
     my ($xlist,$lc_sec,$prob) = split(/:/,$item);      my ($xlist,$lc_sec,$prob) = split(/:/,$item);
     $response .= '<li>'.      $response .= '<li>'.
                          &mt('[_1] - ID: [_2] - Error: [_3]',                           &mt('[_1] - ID: [_2] - Error: [_3]',
Line 2059  sub print_crosslistings_response { Line 2463  sub print_crosslistings_response {
     if (@badowner > 0) {      if (@badowner > 0) {
  $response .= &mt("The courses listed below could not be included in the crosslistings for this LON-CAPA course, because the owner of this course - [_1] - does not have rights to view enrollment in those classes, as determined by your instititution's policies on access to official classlists.",$owner).   $response .= &mt("The courses listed below could not be included in the crosslistings for this LON-CAPA course, because the owner of this course - [_1] - does not have rights to view enrollment in those classes, as determined by your instititution's policies on access to official classlists.",$owner).
                      '<br /><ul>'."\n";                       '<br /><ul>'."\n";
  foreach my $item (@badowner) {          my @showable;
           &reformat_xlists($dom,$crs,$coursecode,\@badowner,\@showable);
           foreach my $item (@showable) {
     my ($xlist,$lc_sec) = split(/:/,$item);      my ($xlist,$lc_sec) = split(/:/,$item);
     $response .= '<li>'.&mt('[_1] - ID: [_2]',$xlist,$lc_sec).'</li>'.      $response .= '<li>'.&mt('[_1] - ID: [_2]',$xlist,$lc_sec).'</li>'.
                          "\n";                           "\n";
Line 2071  sub print_crosslistings_response { Line 2477  sub print_crosslistings_response {
                      &mt('Please [_1]go back[_2]</a> and change the section ID for each of these courses.',                       &mt('Please [_1]go back[_2]</a> and change the section ID for each of these courses.',
                          '<a href="javascript:history(-1)">','>/a>').                           '<a href="javascript:history(-1)">','>/a>').
                      '<br /><ul>'."\n";                         '<br /><ul>'."\n";  
         foreach my $item (@reserved) {          my @showable;
           &reformat_xlists($dom,$crs,$coursecode,\@reserved,\@showable);
           foreach my $item (@showable) {
             my ($xlist,$lc_sec) = split(/:/,$item);              my ($xlist,$lc_sec) = split(/:/,$item);
             $response .= '<li>'.&mt('[_1] - ID: [_2]',$xlist,$lc_sec).'</li>'.              $response .= '<li>'.&mt('[_1] - ID: [_2]',$xlist,$lc_sec).'</li>'.
                          "\n";                           "\n";
Line 2083  sub print_crosslistings_response { Line 2491  sub print_crosslistings_response {
         $response .= &mt('The courses listed below could not be included in the crosslistings for this LON-CAPA course, because the section ID associated with the crosslisted course is the name of a group in this course.').' '.          $response .= &mt('The courses listed below could not be included in the crosslistings for this LON-CAPA course, because the section ID associated with the crosslisted course is the name of a group in this course.').' '.
                      &mt('Please [_1]go back[_2] and change the section ID for each of these courses.','<a href="javascript:history(-1)">','</a>').                       &mt('Please [_1]go back[_2] and change the section ID for each of these courses.','<a href="javascript:history(-1)">','</a>').
                      '<br /><ul>'."\n";                       '<br /><ul>'."\n";
         foreach my $item (@matchgroup) {          my @showable;
           &reformat_xlists($dom,$crs,$coursecode,\@matchgroup,\@showable);
           foreach my $item (@showable) {
             my ($xlist,$lc_sec) = split(/:/,$item);              my ($xlist,$lc_sec) = split(/:/,$item);
             $response .= '<li>'.&mt('[_1] - ID: [_2]',$xlist,$lc_sec).'</li>'.              $response .= '<li>'.&mt('[_1] - ID: [_2]',$xlist,$lc_sec).'</li>'.
                          "\n";                           "\n";
Line 2103  sub print_crosslistings_response { Line 2513  sub print_crosslistings_response {
     return;      return;
 }  }
   
   sub reformat_xlists {
       my ($dom,$crs,$coursecode,$xlistsref,$showxlistsref) = @_;
       return unless ((ref($xlistsref) eq 'ARRAY') && (ref($showxlistsref) eq 'ARRAY'));
       my $crskey = $crs.':'.$coursecode;
       my (@xlcodes,@lcsecs,@extras);
       foreach my $xl (@{$xlistsref}) {
           my ($instcodesec,$lc_sec,$extra) = split(/:/,$xl);
           push(@xlcodes,$instcodesec);
           push(@lcsecs,$lc_sec);
           push(@extras,$extra);
       }
       my %reformatted =
           &Apache::lonnet::auto_instsec_reformat($dom,'declutter',
                                                  {$crskey => \@xlcodes});
       if (ref($reformatted{$crskey}) eq 'ARRAY') {
           @xlcodes = @{$reformatted{$crskey}};
           for (my $i=0; $i<@xlcodes; $i++) {
               my $value = $xlcodes[$i].':'.$lcsecs[$i];
               if ($extras[$i] ne '') {
                   $value .= ':'.$extras[$i];
               }
               push(@{$showxlistsref},$value);
           }
       }
       return;
   }
   
 sub print_sections_menu {  sub print_sections_menu {
     my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;      my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
     my %settings =       my %settings = 
Line 2138  sub print_sections_menu { Line 2575  sub print_sections_menu {
     push(@sections,$secentry);      push(@sections,$secentry);
     $seccount ++;      $seccount ++;
  } else {   } else {
     my $newsec = $coursecode.$env{"form.$secnum"};                      my $newsec;
                       my $crskey = $crs.':'.$coursecode;
                       my %formattedsec = &Apache::lonnet::auto_instsec_reformat($dom,'clutter',
                                                                     {$crskey => [$env{"form.$secnum"}]});
                       if (ref($formattedsec{$crskey}) eq 'ARRAY') {
                           $newsec = $coursecode.$formattedsec{$crskey}->[0];
                       } else {
                           $newsec = $coursecode.$env{"form.$secnum"};
                       }
     my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec);      my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec);
     if ($coursecheck eq 'ok') {      if ($coursecheck eq 'ok') {
  my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner,$coowners);   my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner,$coowners);
Line 2250  sub print_sections_menu { Line 2695  sub print_sections_menu {
  if ($numsec > 0) {   if ($numsec > 0) {
     $response .=       $response .= 
                 &mt('You indicated that you wish to incorporate student enrollment in your LON-CAPA course from an additional [quant,_1,section].',$numsec).' '.                  &mt('You indicated that you wish to incorporate student enrollment in your LON-CAPA course from an additional [quant,_1,section].',$numsec).' '.
                &mt('For each new section enter the insititutional section code (e.g., 004), and the LON-CAPA section ID you wish to assign to students who will be enrolled in your LON-CAPA class as a result of their registration in this particular section.').' '.                 &mt('For each new section enter the institutional section code (e.g., 004), and the LON-CAPA section ID you wish to assign to students who will be enrolled in your LON-CAPA class as a result of their registration in this particular section.').' '.
                &mt('The LON-CAPA section ID can be left blank, if you do not wish to designate a section ID for this course section.').' '.                 &mt('The LON-CAPA section ID can be left blank, if you do not wish to designate a section ID for this course section.').' '.
                &mt("The institutional section code should only contain letters and/or numbers, and must be consistent with the scheme adopted by your Domain Coordinator to map course section numbers to your institution's student information system.").'                 &mt("The institutional section code should only contain letters and/or numbers, and must be consistent with the scheme adopted by your Domain Coordinator to map course section numbers to your institution's student information system.").'
                <br /><br />                 <br /><br />
Line 2326  sub print_sections_response { Line 2771  sub print_sections_response {
                         push(@matchgroup,$env{"form.$sec"}.":".$env{"form.$lc_sec"});                          push(@matchgroup,$env{"form.$sec"}.":".$env{"form.$lc_sec"});
                         next;                          next;
                     }                      }
     my $newsec = $coursecode.$env{"form.$sec"};                      my $newsec;
                       my $crskey = $crs.':'.$coursecode;
                       my %formattedsec = &Apache::lonnet::auto_instsec_reformat($dom,'clutter',
                                                                     {$crskey => [$env{"form.$sec"}]});
                       if (ref($formattedsec{$crskey}) eq 'ARRAY') {
                           $newsec = $coursecode.$formattedsec{$crskey}->[0];
                       } else {
                           $newsec = $coursecode.$env{"form.$sec"};
                       }
     my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec);      my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec);
     if ($coursecheck eq 'ok') {      if ($coursecheck eq 'ok') {
  my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner,$coowners);   my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner,$coowners);
Line 2356  sub print_sections_response { Line 2809  sub print_sections_response {
  }   }
     }      }
   
     if ($putreply ne 'ok') {      if ($putreply eq 'ok') {
  $response = &mt('Students enrolling in the sections listed below will be automatically added to the class roster for LON-CAPA course [_1], if you have chosen to enable a nightly automated enrollment update.',   $response = &mt('Students enrolling in the sections listed below will be automatically added to the class roster for LON-CAPA course [_1], if you have chosen to enable a nightly automated enrollment update.',
                         "$realm ($coursecode)").'<br /><ul>'."\n";                          "$realm ($coursecode)").'<br /><ul>'."\n";
  foreach my $section (@allsections) {   foreach my $section (@allsections) {
Line 2645  sub print_photoupdate_response { Line 3098  sub print_photoupdate_response {
  'internal.sectionnums',   'internal.sectionnums',
  'internal.crosslistings'],   'internal.crosslistings'],
  $dom,$crs);   $dom,$crs);
     &Apache::loncommon::get_institutional_codes(\%settings,\@allcourses,\%LC_code);      &Apache::loncommon::get_institutional_codes($dom,$crs,\%settings,\@allcourses,\%LC_code);
     if (@allcourses > 0) {      if (@allcourses > 0) {
         @{$affiliates{$crs}} = @allcourses;          @{$affiliates{$crs}} = @allcourses;
         $outcome = &Apache::lonnet::auto_photoupdate(\%affiliates,$dom,$crs,\%changes);          $outcome = &Apache::lonnet::auto_photoupdate(\%affiliates,$dom,$crs,\%changes);
Line 2726  sub print_update_result { Line 3179  sub print_update_result {
     my %settings =       my %settings = 
         &Apache::lonnet::get('environment',          &Apache::lonnet::get('environment',
             ['internal.coursecode','internal.sectionnums','internal.crosslistings',              ['internal.coursecode','internal.sectionnums','internal.crosslistings',
              'internal.authtype','internal.autharg','internal.showphoto','internal.defaultcredits'],               'internal.authtype','internal.autharg','internal.showphoto','internal.defaultcredits',
                'internal.autodropfailsafe','internal.autodropfailsafetype','internal.textbook'],
             $dom,$crs);              $dom,$crs);
     my $coursecode = $settings{'internal.coursecode'};      my $coursecode = $settings{'internal.coursecode'};
     my $authtype = $settings{'internal.authtype'};      my $authtype = $settings{'internal.authtype'};
     my $autharg = $settings{'internal.autharg'};      my $autharg = $settings{'internal.autharg'};
     my $showphotos = $settings{'internal.showphoto'};      my $showphotos = $settings{'internal.showphoto'};
       my $textbook = $settings{'internal.textbook'};
     my ($showcredits,$defaultcredits);      my ($showcredits,$defaultcredits);
     my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);      my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
     if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'}) {      if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'}) {
         $showcredits = 1;          $showcredits = 1;
         $defaultcredits = $settings{'internal.defaultcredits'};          $defaultcredits = $settings{'internal.defaultcredits'};
         if ($defaultcredits eq '') {          if ($defaultcredits eq '') {
             if ($coursecode ne '') {              if ($coursecode ne '') {
                 $defaultcredits = $domdefaults{'officialcredits'};                     $defaultcredits = $domdefaults{'officialcredits'};   
               } elsif ($textbook ne '') {
                   $defaultcredits = $domdefaults{'textbookcredits'};
             } else {              } else {
                 $defaultcredits = $domdefaults{'unofficialcredits'};                  $defaultcredits = $domdefaults{'unofficialcredits'};
             }              }
         }          }
     }      }
       my $failsafetype = $settings{'internal.autodropfailsafetype'};
       if ($failsafetype eq '') {
           $failsafetype = $domdefaults{'failsafe'};
       }
       my $failsafe = $settings{'internal.autodropfailsafe'};
       if ($failsafe eq '') {
           $failsafe = $domdefaults{'autofailsafe'};
       }
     my ($startaccess,$endaccess) = &get_dates_from_form();      my ($startaccess,$endaccess) = &get_dates_from_form();
     if ( exists($env{'form.updateadds'}) ) {      if ( exists($env{'form.updateadds'}) ) {
         $updateadds = $env{'form.updateadds'};          $updateadds = $env{'form.updateadds'};
Line 2767  sub print_update_result { Line 3232  sub print_update_result {
  $response = &mt('There was a problem retrieving the course code for this LON-CAPA course.').' '.   $response = &mt('There was a problem retrieving the course code for this LON-CAPA course.').' '.
                     &mt('An update of the class roster has not been carried out, and enrollment remains unchanged.');                      &mt('An update of the class roster has not been carried out, and enrollment remains unchanged.');
     } else {      } else {
         &Apache::loncommon::get_institutional_codes(\%settings,\@allcourses,\%LC_code);          &Apache::loncommon::get_institutional_codes($dom,$crs,\%settings,\@allcourses,\%LC_code);
  if (@allcourses > 0) {   if (@allcourses > 0) {
     @{$affiliates{$crs}} = @allcourses;      @{$affiliates{$crs}} = @allcourses;
     my $outcome = &Apache::lonnet::fetch_enrollment_query('updatenow',\%affiliates,\%reply,$dom,$crs);      my $outcome = &Apache::lonnet::fetch_enrollment_query('updatenow',\%affiliates,\%reply,$dom,$crs);
Line 2779  sub print_update_result { Line 3244  sub print_update_result {
                                  ": ".$outcome);                                   ": ".$outcome);
             }              }
     if ($reply{$crs} > 0) {      if ($reply{$crs} > 0) {
  ($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$updateadds,$updatedrops,$startaccess,$endaccess,$authtype,$autharg,$showcredits,$defaultcredits,\@allcourses,\%LC_code,\$logmsg,\$newusermsg,"updatenow",\%phototypes);   ($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$updateadds,$updatedrops,$startaccess,$endaccess,$authtype,$autharg,$showcredits,$defaultcredits,$failsafe,$failsafetype,\@allcourses,\%LC_code,\$logmsg,\$newusermsg,"updatenow",\%phototypes);
     } else {      } else {
  $response = &mt('There was a problem retrieving institutional class list data for the course sections and crosslisted courses which contribute enrollment to this course.').' '.   $response = &mt('There was a problem retrieving institutional class list data for the course sections and crosslisted courses which contribute enrollment to this course.').' '.
                             &mt('No updates have been carried out, and the roster remains unchanged.');                              &mt('No updates have been carried out, and the roster remains unchanged.');
Line 3034  sub warning_message { Line 3499  sub warning_message {
     unless ( $caller eq 'chgsettings') {      unless ( $caller eq 'chgsettings') {
         if ( (!$curradds) && (!$currdrops) ) {          if ( (!$curradds) && (!$currdrops) ) {
             $warning .= '<li>'.              $warning .= '<li>'.
                 &mt('You [_1]must[_2] now use [_3]Automated adds/drops[_4] to enable automated adds and/or drops if you want automatic enrollment updates to occur in this course.','<b>','</b>','<a href="/adm/populate?action=chgsettings">').'</li>';                  &mt('You [_1]must[_2] now use [_3]Automated adds/drops[_4] to enable automated adds and/or drops if you want automatic enrollment updates to occur in this course.','<b>','</b>','<a href="/adm/populate?action=chgsettings">','</a>').'</li>';
         }          }
     }      }
     if ($warning) {      if ($warning) {
Line 3057  sub print_reply { Line 3522  sub print_reply {
 }  }
   
 sub setup_date_selectors {  sub setup_date_selectors {
     my ($starttime,$endtime,$action) = @_;      my ($starttime,$endtime,$action,$readonly) = @_;
       my $disabled;
       if ($readonly) {
           $disabled = 'disabled';
       }
     if (! defined($starttime)) {      if (! defined($starttime)) {
         $starttime = time;          $starttime = time;
         if ($action eq 'setdates') {          if ($action eq 'setdates') {
Line 3080  sub setup_date_selectors { Line 3549  sub setup_date_selectors {
     }      }
     my $startdateform = &Apache::lonhtmlcommon::date_setter('enter',      my $startdateform = &Apache::lonhtmlcommon::date_setter('enter',
                                                             'startdate',                                                              'startdate',
                                                             $starttime);                                                              $starttime,'','',$disabled);
     my $enddateform = &Apache::lonhtmlcommon::date_setter('enter',      my $enddateform = &Apache::lonhtmlcommon::date_setter('enter',
                                                           'enddate',                                                            'enddate',
                                                           $endtime);                                                            $endtime,'','',$disabled);
     return ($startdateform,$enddateform);      return ($startdateform,$enddateform);
 }  }
   
Line 3098  sub get_dates_from_form { Line 3567  sub get_dates_from_form {
 }  }
   
 sub date_setting_table {  sub date_setting_table {
     my ($starttime,$endtime,$action) = @_;      my ($starttime,$endtime,$action,$readonly) = @_;
       my $disabled;
       if ($readonly) {
           $disabled = ' disabled="disabled"';
       }
     my ($startform,$endform) =       my ($startform,$endform) = 
         &setup_date_selectors($starttime,$endtime,$action);          &setup_date_selectors($starttime,$endtime,$action,$readonly);
     my $perpetual = '<span class="LC_nobreak"><label>'.      my $perpetual = '<span class="LC_nobreak"><label>'.
                     '<input type="checkbox" name="no_end_date"';                      '<input type="checkbox" name="no_end_date"';
     if (($action eq 'setdates' && defined($endtime) && $endtime == 0) ||       if (($action eq 'setdates' && defined($endtime) && $endtime == 0) || 
Line 3108  sub date_setting_table { Line 3581  sub date_setting_table {
          ($endtime eq '' || $endtime == 0)) ) {           ($endtime eq '' || $endtime == 0)) ) {
         $perpetual .= ' checked="checked"';          $perpetual .= ' checked="checked"';
     }      }
     $perpetual.= ' /> '.&mt('no end date').'</label></span>';      $perpetual.= $disabled.' /> '.&mt('no end date').'</label></span>';
     my $start_table = "<table>\n".      my $start_table = "<table>\n".
                       '<tr><td align="right">'.&mt('Starting Date').'</td>'.                        '<tr><td align="right">'.&mt('Starting Date').'</td>'.
                       '<td>'.$startform.'</td>'.                        '<td>'.$startform.'</td>'.
Line 3146  sub user_is_courseowner { Line 3619  sub user_is_courseowner {
 }  }
   
 sub get_task_text {  sub get_task_text {
     my %tasklong =       my ($permref) = @_;
       my %tasklong =
         &Apache::lonlocal::texthash(          &Apache::lonlocal::texthash(
                information   => 'Task information',             information   => 'Task information',
                chgsettings   => 'Automated adds/drops',             chgsettings   => 'Automated adds/drops',
                setdates      => 'Change enrollment dates',             chgfailsafe   => 'View/change enrollment failsafe',
                setaccess     => 'Change access dates',             setdates      => 'Change enrollment dates',
                notify        => 'Notification of changes',             setaccess     => 'Change access dates',
                crosslist     => 'Change crosslistings',             notify        => 'Notification of changes',
                sections      => 'Section settings',             crosslist     => 'Change crosslistings',
                photos        => 'Student photo settings',             sections      => 'Section settings',
                updatephotos  => 'Update student photos',             photos        => 'Student photo settings',
                updatenow     => 'Update roster now',             updatephotos  => 'Update student photos',
                newcross      => 'Add crosslistings',             updatenow     => 'Update roster now',
                newsections   => 'Add sections',             newcross      => 'Add crosslistings',
                viewclass     => 'View students and change type',             newsections   => 'Add sections',
              viewclass     => 'View students and change type',
     );      );
   
     my %tasktitle =       my %tasktitle =
         &Apache::lonlocal::texthash(          &Apache::lonlocal::texthash(
                chgsettings  => 'Changes to nightly automated enrollments',             chgsettings  => 'Changes to nightly automated enrollments',
                setdates     => 'Changes to first and/or last automated enrollment dates',             chgfailsafe  => 'Changes to failsafe protection for data retrieval problems',
                setaccess    => 'Changes to default start and/or end dates for student access',             setdates     => 'Changes to first and/or last automated enrollment dates',
                notify       => 'Notification of enrollment changes',             setaccess    => 'Changes to default start and/or end dates for student access',
                crosslist    => 'Changes to crosslistings',             notify       => 'Notification of enrollment changes',
                sections     => 'Changes to section settings',             crosslist    => 'Changes to crosslistings',
                photos       => 'Student photo settings',             sections     => 'Changes to section settings',
                updatephotos => 'Update student photos',             photos       => 'Student photo settings',
                updatenow => "Immediate course roster update",             updatephotos => 'Update student photos',
                newcross => "Adding new crosslisted courses",             updatenow => "Immediate course roster update",
                newsections => "Adding new course sections",             newcross => "Adding new crosslisted courses",
                viewclass => "Viewing class roster and enrollment type"             newsections => "Adding new course sections",
              viewclass => "Viewing class roster and enrollment type"
     );      );
   
       if ((ref($permref) eq 'HASH') && (!$permref->{'edit'})) {
           $tasklong{'chgfailsafe'} = &mt('Enrollment failsafe');
           $tasklong{'setdates'}    = &mt('Enrollment dates');
           $tasklong{'setaccess'}   = &mt('Access dates');
           $tasklong{'crosslist'}   = &mt('Crosslistings');
           $tasklong{'viewclass'}   = &mt('View students and type');
       }
     return (\%tasklong,\%tasktitle);      return (\%tasklong,\%tasktitle);
 }  }
   
   sub check_permission {
       my ($permref) = @_;
       return unless (ref($permref) eq 'HASH');
       my $hasaccess;
       if ($env{'request.course.id'}) {
           foreach my $priv ('cst','vpa','vcl') {
               my ($allowed,$section);
               if (&Apache::lonnet::allowed($priv,$env{'request.course.id'})) {
                   $allowed = 1;
               } elsif ($env{'request.course.sec'} ne '') {
                   if (&Apache::lonnet::allowed($priv,$env{'request.course.id'}.'/'.
                                                      $env{'request.course.sec'})) {
                       $allowed = 1;
                       $section = $env{'request.course.sec'};
                   }
               }
               if ($allowed) {
                   $hasaccess = 1;
                   if ($priv eq 'cst') {
                       if ($section ne '') {
                           $permref->{'edit_section'} = $section;
                       } else {
                           $permref->{'edit'} = 1;
                       }
                   } elsif ($priv eq 'vpa') {
                       if ($section ne '') {
                           $permref->{'view_section'} = $section;
                       } else {
                           $permref->{'view'} = 1;
                       }
                   } elsif ($priv eq 'vcl') {
                       if ($section ne '') {
                           $permref->{'show_section'} = $section;
                       } else {
                           $permref->{'show'} = 1;
                       }
                   }
               }
           }
       }
       return $hasaccess;
   }
   
           
 ###################################################################  ###################################################################
 sub handler {  sub handler {
Line 3191  sub handler { Line 3719  sub handler {
     }      }
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['action','state']);                                              ['action','state']);
       my %permhash;
     #  Needs to be in a course      #  Needs to be in a course
     if (! (($env{'request.course.fn'}) &&        if (!($env{'request.course.fn'})) {
            (&Apache::lonnet::allowed('cst',$env{'request.course.id'})))) {          # Not in a course
         # Not in a course, or not allowed to modify parms          $env{'user.error.msg'}="/adm/populate:cst:0:0:Cannot display automated enrollment";
         $env{'user.error.msg'}="/adm/populate:cst:0:0:Cannot drop or add students";  
         return HTTP_NOT_ACCEPTABLE;          return HTTP_NOT_ACCEPTABLE;
       } elsif (!&check_permission(\%permhash)) {
           # Not allowed to modify students, view settings, or view classlist.
           $env{'user.error.msg'}="/adm/populate:cst:0:0:Cannot display automated enrollment";
           return HTTP_NOT_ACCEPTABLE; 
     }      }
     # Start page      # Start page
     &Apache::loncommon::content_type($r,'text/html');      &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;      $r->send_http_header;
   
     my @tasks = ('information','chgsettings','setdates','setaccess','notify','crosslist',      my @tasks = ('information','chgsettings','setdates','setaccess','notify','crosslist',
                  'sections','photos','updatenow','updatephotos','viewclass');                   'sections','photos','updatenow','updatephotos','viewclass','chgfailsafe');
     
     my ($tasklong,$tasktitle) = &get_task_text();      my ($tasklong,$tasktitle) = &get_task_text(\%permhash);
     my $realm;      my $realm;
     if ( exists($env{'request.course.id'}) ) {      if ( exists($env{'request.course.id'}) ) {
         $realm=$env{'course.'.$env{'request.course.id'}.'.description'};          $realm=$env{'course.'.$env{'request.course.id'}.'.description'};
Line 3213  sub handler { Line 3745  sub handler {
     unless ($realm) { $realm='&nbsp;'; }      unless ($realm) { $realm='&nbsp;'; }
     my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};      my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};      my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
       
     #      #
     # Main switch on form.action and form.state, as appropriate      # Main switch on form.action and form.state, as appropriate
     #      #
Line 3229  sub handler { Line 3761  sub handler {
     }      }
   
     if ($action eq "information") {      if ($action eq "information") {
         $r->print(&header($action));          $r->print(&header($action,\%permhash));
     } else {      } else {
         if ($state eq "choose") {          if ($state eq "choose") {
             $r->print(&choose_header($action));              $r->print(&choose_header($action,\%permhash,$dom));
         } else {          } else {
             if ($action eq "crosslist") {              if ($action eq "crosslist") {
                 if ( exists($env{'form.numcross'}) ) {                  if ( exists($env{'form.numcross'}) ) {
                     if ( $env{'form.numcross'} > 0 ) {                      if ( $env{'form.numcross'} > 0 ) {
                         $r->print(&choose_header($action));                          $r->print(&choose_header($action,\%permhash,$dom));
                     } else {                      } else {
                         $r->print(&header($action));                          $r->print(&header($action,\%permhash));
                     }                      }
                 } else {                  } else {
                     $r->print(&header());                      $r->print(&header(undef,\%permhash));
                 }                  }
             } elsif ($action eq "sections") {              } elsif ($action eq "sections") {
                 if ( exists($env{'form.numsec'}) ) {                  if ( exists($env{'form.numsec'}) ) {
                     if ( $env{'form.numsec'} > 0 ) {                      if ( $env{'form.numsec'} > 0 ) {
                         $r->print(&choose_header($action));                          $r->print(&choose_header($action,\%permhash,$dom));
                     } else {                      } else {
                         $r->print(&header($action));                          $r->print(&header($action,\%permhash));
                     }                      }
                 } else {                  } else {
                     $r->print(&header($action));                      $r->print(&header($action,\%permhash));
                 }                  }
             } else {              } else {
                 $r->print(&header($action));                  $r->print(&header($action,\%permhash));
             }              }
         }          }
     }      }
Line 3266  sub handler { Line 3798  sub handler {
     &print_navmenu($r,\@tasks,$tasklong,$action,$state);      &print_navmenu($r,\@tasks,$tasklong,$action,$state);
   
     if (($state eq "choose") || ($action eq "information")) {      if (($state eq "choose") || ($action eq "information")) {
         &print_main_frame($r,$realm,$dom,$crs,$tasktitle);          &print_main_frame($r,$realm,$dom,$crs,$tasktitle,\%permhash);
     } elsif ($action eq "chgsettings") {      } elsif (($action eq "chgsettings") && ($permhash{'edit'})) {
         &print_chgsettings_response($r,$realm,$dom,$crs,$action,$tasktitle);          &print_chgsettings_response($r,$realm,$dom,$crs,$action,$tasktitle);
     } elsif ($action eq "setdates") {      } elsif (($action eq "chgfailsafe") && ($permhash{'edit'})) {
           &print_chgfailsafe_response($r,$realm,$dom,$crs,$action,$tasktitle);
       } elsif (($action eq "setdates") && ($permhash{'edit'})) {
         &print_setdates_response($r,$realm,$dom,$crs,$action,$tasktitle);          &print_setdates_response($r,$realm,$dom,$crs,$action,$tasktitle);
     } elsif ($action eq "setaccess") {      } elsif (($action eq "setaccess") && ($permhash{'edit'})) {
         &print_setaccess_response($r,$realm,$dom,$crs,$action,$tasktitle);          &print_setaccess_response($r,$realm,$dom,$crs,$action,$tasktitle);
     } elsif ($action eq "notify") {      } elsif (($action eq "notify") && ($permhash{'edit'})) {
         &print_notify_response($r,$realm,$dom,$crs,$action,$tasktitle);          &print_notify_response($r,$realm,$dom,$crs,$action,$tasktitle);
     } elsif ($action eq "sections") {      } elsif (($action eq "sections") && ($permhash{'edit'})) {
         &print_sections_menu($r,$realm,$dom,$crs,$action,$tasktitle);          &print_sections_menu($r,$realm,$dom,$crs,$action,$tasktitle);
     } elsif ($action eq "crosslist") {      } elsif (($action eq "crosslist") && ($permhash{'edit'})) {
         &print_crosslistings_menu($r,$realm,$dom,$crs,$action,$tasktitle);          &print_crosslistings_menu($r,$realm,$dom,$crs,$action,$tasktitle);
     } elsif ($action eq "updatenow") {      } elsif (($action eq "updatenow") && ($permhash{'edit'})) {
         &print_update_result($r,$realm,$dom,$crs,$action,$tasktitle);          &print_update_result($r,$realm,$dom,$crs,$action,$tasktitle);
     } elsif ($action eq "photos") {      } elsif (($action eq "photos") && ($permhash{'edit'})) {
         if ($state eq "photoupdate") {          if ($state eq "photoupdate") {
             &print_photoupdate_response($r,$realm,$dom,$crs,$action,$tasktitle);              &print_photoupdate_response($r,$realm,$dom,$crs,$action,$tasktitle);
         } else {           } else {
             &photo_permission($r,$realm,$dom,$crs,$action,$tasktitle);              &photo_permission($r,$realm,$dom,$crs,$action,$tasktitle);
         }          }
     } elsif ($action eq "updatephotos") {      } elsif (($action eq "updatephotos") && ($permhash{'edit'})) {
         &print_photoupdate_response($r,$realm,$dom,$crs,$action,$tasktitle);          &print_photoupdate_response($r,$realm,$dom,$crs,$action,$tasktitle);
     } elsif ($action eq "newcross") {      } elsif (($action eq "newcross") && ($permhash{'edit'})) {
         &print_crosslistings_response($r,$realm,$dom,$crs,$action,$tasktitle);              &print_crosslistings_response($r,$realm,$dom,$crs,$action,$tasktitle);    
     } elsif ($action eq "newsections") {      } elsif (($action eq "newsections") && ($permhash{'edit'})) {
         &print_sections_response($r,$realm,$dom,$crs,$action,$tasktitle);          &print_sections_response($r,$realm,$dom,$crs,$action,$tasktitle);
     } elsif ($action eq "viewclass") {      } elsif (($action eq "viewclass") && ($permhash{'edit'})) {
         &print_viewclass_response($r,$realm,$dom,$crs,$action,$tasktitle);          &print_viewclass_response($r,$realm,$dom,$crs,$action,$tasktitle);
     }      }
     &print_doc_base($r);        &print_doc_base($r);  

Removed from v.1.76  
changed lines
  Added in v.1.92


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