Diff for /loncom/interface/lonpopulate.pm between versions 1.7 and 1.11

version 1.7, 2003/12/15 07:55:59 version 1.11, 2004/04/16 13:26:44
Line 329  Note: Any students added manually by cou Line 329  Note: Any students added manually by cou
       ");        ");
   } elsif ($action eq "setdates") {    } elsif ($action eq "setdates") {
       my ($start_table,$end_table) = &date_setting_table($enrollvar{autostart},$enrollvar{autoend});        my ($start_table,$end_table) = &date_setting_table($enrollvar{autostart},$enrollvar{autoend});
       my $oldstartshow = localtime($enrollvar{autostart});        my $oldstartshow = '';
       my $oldendshow = localtime($enrollvar{autoend});        my $oldendshow = '';
       if ($enrollvar{autoend} == 0) {        if ( defined($enrollvar{autostart}) ) {
           $oldendshow = "No ending date";            $oldstartshow = localtime($enrollvar{autostart});
         }
         if ( defined($enrollvar{autoend}) ) {
             $oldendshow = localtime($enrollvar{autoend});
             if ($enrollvar{autoend} == 0) {
                 $oldendshow = "No ending date";
             }
         }
         my $dateshow;
         if ( ($oldendshow eq '') && ($oldstartshow eq '') ) {
            $dateshow = "<br/><font size='+1'>Warning</font>. Currently <b>NO</b> first enrollment or last enrollment dates are set. You <b>must</b> use this menu to set a start date and an end date (or check the 'no ending date' checkbox) if you plan to utilise automated adds and/or drops in this course.\n";
         } else {
            $dateshow = "Currently: First enrollment: <b><i>$oldstartshow</i></b>, Last enrollment: <b><i>$oldendshow</i></b>\n";
       }        }
       $r->print(<<ENDTWO);        $r->print(<<ENDTWO);
                   <form name="enter" method="post"><br/>                                  <form name="enter" method="post"><br/>              
                   <table width="100%" border="0" cellpadding="2" cellspacing="2">                    <table width="100%" border="0" cellpadding="2" cellspacing="2">
            <tr>             <tr>
             <td align="left"><b>$$tasktitleref{$action}</b><br/>              <td align="left"><b>$$tasktitleref{$action}</b><br/><br/>
              Currently: First enrollment: <i>$oldstartshow</i>, Last enrollment: <i>$oldendshow</i>                       $dateshow
             </td>              </td>
                    </tr>                     </tr>
           </table>            </table>
Line 645  ENDTWO Line 657  ENDTWO
           }            }
       }        }
       if (@sections > 0) {        if (@sections > 0) {
           if (@sections > 1) {            my $secshow = @sections;
               my $secshow = @sections;            $r->print("
               $r->print("  
             <form name=\"enter\" method=\"post\"><br/>              <form name=\"enter\" method=\"post\"><br/>
             <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">              <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
              <tr>               <tr>
Line 669  your changes.</td> Line 680  your changes.</td>
               <td><b>LON-CAPA section/group ID</b></td>                <td><b>LON-CAPA section/group ID</b></td>
               <td><b>Enrollment in this course?</b></td>                <td><b>Enrollment in this course?</b></td>
              </tr>               </tr>
               ");            ");
               for (my $i=0; $i<@sections; $i++) {            for (my $i=0; $i<@sections; $i++) {
                   my $colflag = $i%2;                my $colflag = $i%2;
                   my $shrflag = 0;                my $shrflag = 0;
                   $r->print("<tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">                $r->print("<tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">
                    <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>                     <td>
                   ");                ");
                   if (grep/^$sections[$i]$/,@currsections) {                if (grep/^$sections[$i]$/,@currsections) {
                       $r->print("Enrollment active");                    $r->print("Enrollment active");
                       $shrflag = 1;                    $shrflag = 1;
                   } else {                } else {
                       $r->print("Enrollment inactive");                    $r->print("Enrollment inactive");
                   }  
                   if ($shrflag) {  
                       $r->print("</td><td><input type=\"text\" size=\"10\" name=\"loncapasec_$i\" value=\"$sec_id{$sections[$i]}\"></td><td><input type=\"checkbox\" name=\"sec_$i\" checked=\"true\" /></td></tr>");   
                   } else {  
                       $r->print("</td><td><input type=\"text\" size=\"10\" name=\"loncapasec_$i\" value=\"\"><td><input type=\"checkbox\" name=\"sec_$i\" /></td></tr>");  
                   }  
               }                }
               $r->print("                if ($shrflag) {
                     $r->print("</td><td><input type=\"text\" size=\"10\" name=\"loncapasec_$i\" value=\"$sec_id{$sections[$i]}\"></td><td><input type=\"checkbox\" name=\"sec_$i\" checked=\"true\" /></td></tr>"); 
                 } else {
                     $r->print("</td><td><input type=\"text\" size=\"10\" name=\"loncapasec_$i\" value=\"\"><td><input type=\"checkbox\" name=\"sec_$i\" /></td></tr>");
                 }
             }
             $r->print("
             </table>              </table>
             <br/>              <br/>
             <table width=\"100%\" border=\"0\" cellspacing=\"3\" cellpadding=\"3\">              <table width=\"100%\" border=\"0\" cellspacing=\"3\" cellpadding=\"3\">
Line 703  your changes.</td> Line 714  your changes.</td>
             <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>
               ");            ");
           } else {  
               $r->print("<br/>              
             <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">  
              <tr>  
               <td align=\"left\">  
                <b>$$tasktitleref{$action}</b><br/>  
               </td>  
              </tr>  
             </table>  
             <table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">  
              <tr>  
               <td>As your institution's course catalog only includes a single section for this course, there are no additional sections that can be set for inclusion in the LON-CAPA roster for the course.</td>  
             </tr>  
             </table>  
               ");  
           }   
       } else {        } else {
           $r->print("            $r->print("
             <form name=\"enter\" method=\"post\"><br/>              <form name=\"enter\" method=\"post\"><br/>
Line 902  ENDBASE Line 897  ENDBASE
 ###################################################################  ###################################################################
 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.autoadds','internal.autodrops'],$dom,$crs);    my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.crosslistings','internal.autostart','internal.autoend','internal.autoadds','internal.autodrops'],$dom,$crs);
   my $curradds = $settings{'internal.autoadds'};    my $currend = '';
   my $currdrops = $settings{'internal.autodrops'};    my $currstart = '';
     my $currsecs = '';
     my $currxlists = '';
     my $curradds = '';
     my $currdrops = '';
     if ( defined($settings{'internal.autoadds'}) ) {
         $curradds = $settings{'internal.autoadds'};
     }
     if ( defined($settings{'internal.autodrops'}) ) {
         $currdrops = $settings{'internal.autodrops'};
     }
     if ( defined($settings{'internal.autostart'}) ) {
         $currstart = $settings{'internal.autostart'};
     }
     if ( defined($settings{'internal.autoend'}) ) {
         $currend = $settings{'internal.autoend'};
     }
     if ( defined($settings{'internal.sectionnums'}) ) {
         $currsecs = $settings{'internal.sectionnums'};
     }
     if ( defined($settings{'internal.crosslistings'}) ) {
         $currxlists = $settings{'internal.crosslistings'}
     }
   my $autoadds = '';    my $autoadds = '';
   my $autodrops = '';    my $autodrops = '';
   
Line 916  sub print_chgsettings_response { Line 933  sub print_chgsettings_response {
   }    }
   
   my $response = "";    my $response = "";
     my $warning = "";
     my $warn_prefix = "";
     my $warn_suffix = "";
     my $warnfiller = "";
   my %cenv = ('internal.autoadds' => $autoadds,    my %cenv = ('internal.autoadds' => $autoadds,
               'internal.autodrops' => $autodrops);                'internal.autodrops' => $autodrops);
   my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);    my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
Line 927  sub print_chgsettings_response { Line 948  sub print_chgsettings_response {
               $response = "Nightly additions based on classlist changes still <b>enabled</b><br/>";                $response = "Nightly additions based on classlist changes still <b>enabled</b><br/>";
           } else {            } else {
               $response = "Nightly additions based on classlist changes now <b>enabled</b><br/>";                $response = "Nightly additions based on classlist changes now <b>enabled</b><br/>";
           }             }
       } else {        } else {
           if ($curradds) {            if ($curradds) {
               $response = "Nightly additions based on classlist changes now <b>disabled</b><br/>";                $response = "Nightly additions based on classlist changes now <b>disabled</b><br/>";
Line 948  sub print_chgsettings_response { Line 969  sub print_chgsettings_response {
               $response .= "Nightly removals based on classlist changes still <b>disabled</b>";                $response .= "Nightly removals based on classlist changes still <b>disabled</b>";
           }            }
       }        }
         if ($autoadds || $autodrops) {
             $warning = &warning_message($dom,$crs,$action);
             $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you indicated that nightly ";
             $warn_suffix = " should be enabled, additional action is required.<br/>";
         }
         if ($autoadds) {
             if ($autodrops) {
                 $warnfiller = "adds and drops";
             } else {
                 $warnfiller = "adds";
             }
         } else {
             if ($autodrops) {
                 $warnfiller = "drops";
             }
         }
         unless ($warning eq '') {
             $response = $warn_prefix.$warnfiller.$warn_suffix.$warning;
         }
   }    }
   &print_reply($r,$response,$$tasktitleref{$action});    &print_reply($r,$response,$$tasktitleref{$action});
   return;    return;
Line 962  sub print_setdates_response { Line 1002  sub print_setdates_response {
   my ($autostart,$autoend) = &get_dates_from_form();    my ($autostart,$autoend) = &get_dates_from_form();
   my $showstart = localtime($autostart);    my $showstart = localtime($autostart);
   my $showend = '';    my $showend = '';
     my $warning = '';
     my $warn_prefix = '';
   if ($autoend) {    if ($autoend) {
       $showend = localtime($autoend);        $showend = localtime($autoend);
   } else {    } else {
Line 982  sub print_setdates_response { Line 1024  sub print_setdates_response {
       if ($currend == $autoend) {        if ($currend == $autoend) {
           $response .= "The last date for automated enrollment has been left unchanged as $showend.<br/>";            $response .= "The last date for automated enrollment has been left unchanged as $showend.<br/>";
       } else {        } else {
           $response .= "The last date for enrollment has been left unchanged as $showend.<br/>";            $response .= "The last date for automated enrollment has been changed to $showend.<br/>";
       }        }
     
 # Generate message in case where old first access date was later than today, but new first access date is now today or earlier.  # Generate message in case where old first access date was later than today, but new first access date is now today or earlier.
Line 1000  sub print_setdates_response { Line 1042  sub print_setdates_response {
       my $lastmidnt = timelocal(0,0,0,$date_list[3],$date_list[4],$date_list[5]);        my $lastmidnt = timelocal(0,0,0,$date_list[3],$date_list[4],$date_list[5]);
       my $nextmidnt = 86400 + $lastmidnt;        my $nextmidnt = 86400 + $lastmidnt;
   
       my $todayupdate = timelocal(0,40,4,$date_list[3],$date_list[4],$date_list[5]);        my $todayupdate = timelocal(0,30,1,$date_list[3],$date_list[4],$date_list[5]);
       my $lastupdate = $todayupdate - 86400;        my $lastupdate = $todayupdate - 86400;
       if ($nowstamp < $todayupdate) {        if ($nowstamp < $todayupdate) {
           $nextupdate = "today";            $nextupdate = "today";
Line 1017  sub print_setdates_response { Line 1059  sub print_setdates_response {
               $firstaccess = "a date prior to today";                $firstaccess = "a date prior to today";
           }            }
           if (($nowstamp >= $autostart) && ($rosterupdated == 0)) {            if (($nowstamp >= $autostart) && ($rosterupdated == 0)) {
               $response .= qq|<br>Although you have now set the first enrollment date to $firstaccess, automatic enrollment will <b>not</b> occur until the next automatic enrollment update occurs for all LON-CAPA courses at 4.40 am $nextupdate. If you wish to grant immediate course access for registered students included in the institutional classlist for this class, please visit the <a href="/adm/populate?action=updatenow">roster update page</a>.<br>|;                $response .= qq|<br>Although you have now set the first enrollment date to $firstaccess, automatic enrollment will <b>not</b> occur until the next automatic enrollment update occurs for all LON-CAPA courses at 1.30 am $nextupdate. If you wish to grant immediate course access for registered students included in the institutional classlist for this class, please visit the <a href="/adm/populate?action=updatenow">roster update page</a>.<br>|;
           }            }
       }        }
         $warning = &warning_message($dom,$crs,$action);
         $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you set a start and end date for auto-enrollment, additional action is required.<br/>";
         unless ($warning eq '') {
             $response .= $warn_prefix.$warning;
         }
   }    }
   &print_reply($r,$response,$$tasktitleref{$action});    &print_reply($r,$response,$$tasktitleref{$action});
   return;    return;
Line 1224  sub print_crosslistings_response () { Line 1271  sub print_crosslistings_response () {
   my $coursecode = $settings{'internal.coursecode'};    my $coursecode = $settings{'internal.coursecode'};
   my $owner = $settings{'internal.courseowner'};    my $owner = $settings{'internal.courseowner'};
   my $response = '';    my $response = '';
     my $warning = '';
     my $warn_prefix = '';
   
   if ($xliststr =~ m/,/) {    if ($xliststr =~ m/,/) {
       @allxlists = split/,/,$xliststr;        @allxlists = split/,/,$xliststr;
Line 1309  sub print_crosslistings_response () { Line 1358  sub print_crosslistings_response () {
       $response .= "</ul><br/><br/>\n";        $response .= "</ul><br/><br/>\n";
   }    }
   
     if (@allxlists > 0) {
         $warning = &warning_message($dom,$crs,$action);
         $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you have selected crosslisted courses to contribute enrollment to this course, additional action is required.<br/>";
         unless ($warning eq '') {
             $response .= $warn_prefix.$warning;
         }
     }
   
   &print_reply($r,$response,$$tasktitleref{$action});    &print_reply($r,$response,$$tasktitleref{$action});
   return;    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 = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode'],$dom,$crs);    my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode','internal.courseowner'],$dom,$crs);
   my @currsections = ();    my @currsections = ();
   my @sections = ();    my @sections = ();
     my @badowner = ();
     my @badsections = ();
   my $seccount = 0;    my $seccount = 0;
   my $removecount = 0;    my $removecount = 0;
   my $addcount = 0;    my $addcount = 0;
   my $secstr = '';    my $secstr = '';
   my $response = '';    my $response = '';
     my $warning = "";
     my $warn_prefix = "";
   my $coursecode = $settings{'internal.coursecode'};    my $coursecode = $settings{'internal.coursecode'};
     my $owner = $settings{'internal.courseowner'};
   if ($settings{'internal.sectionnums'} =~ m/,/) {    if ($settings{'internal.sectionnums'} =~ m/,/) {
       @currsections = split/,/,$settings{'internal.sectionnums'};        @currsections = split/,/,$settings{'internal.sectionnums'};
   } elsif ($settings{'internal.sectionnums'} ne '') {    } elsif ($settings{'internal.sectionnums'} ne '') {
Line 1331  sub print_sections_menu () { Line 1393  sub print_sections_menu () {
   }    }
   
   if ( exists($ENV{'form.secshow'}) ) {    if ( exists($ENV{'form.secshow'}) ) {
      for (my $i=0; $i<$ENV{'form.secshow'}; $i++) {        for (my $i=0; $i<$ENV{'form.secshow'}; $i++) {
          my $gp = "loncapasec_".$i;            my $gp = "loncapasec_".$i;
          my $secnum = "secnum_".$i;            my $secnum = "secnum_".$i;
          my $sec = "sec_".$i;            my $sec = "sec_".$i;
          if ( exists( $ENV{"form.$sec"} ) ) {            if ( exists( $ENV{"form.$sec"} ) ) {
             my $secentry;                my $secentry;
             if ( exists( $ENV{"form.$secnum"} ) ) {                 if ( exists( $ENV{"form.$secnum"} ) ) { 
                 $secentry = $ENV{"form.$secnum"}.':';                    $secentry = $ENV{"form.$secnum"}.':';
             }                }
             if ( exists( $ENV{"form.$gp"} ) ) {                if ( exists( $ENV{"form.$gp"} ) ) {
                 $secentry .= $ENV{"form.$gp"};                    $secentry .= $ENV{"form.$gp"};
             }                }
             push @sections, $secentry;                if ( grep/^$ENV{"form.$secnum"}:/,@currsections) {
             $seccount ++;                    push @sections, $secentry;
             unless (grep/^$ENV{"form.$secnum"}:/,@currsections) {                    $seccount ++;
                 $addcount ++;                } else {
             }                    my $newsec = $coursecode.$ENV{"form.$secnum"};
          }                    my $coursecheck = &localenroll::validate_courseID($newsec);
      }                    if ($coursecheck eq 'ok') {
      if (@currsections > 0) {                        my $addcheck = &localenroll::new_course($newsec,$owner);
          for (my $i=0; $i<@currsections; $i++) {                        if ($addcheck eq 'ok') {
              if ($currsections[$i] =~ m/^(\w+:)/ ) {                            push @sections,$ENV{"form.$secnum"}.":".$ENV{"form.$gp"};
                 my $oldsec  = $1;                            $seccount ++;
                 unless (grep/^$oldsec/,@sections) {                            $addcount ++;
                     $removecount ++;                        } else {
                 }                            push @badowner,$ENV{"form.$secnum"}.":".$ENV{"form.$gp"};
              }                        }
          }                    } else {
      }                        push @badsections, $ENV{"form.$secnum"}.":".$ENV{"form.$gp"}.":".$coursecheck;
                     }
                 }
             }
         }
         if (@currsections > 0) {
             for (my $i=0; $i<@currsections; $i++) {
                 if ($currsections[$i] =~ m/^(\w+:)/ ) {
                     my $oldsec  = $1;
                     unless (grep/^$oldsec/,@sections) {
                         $removecount ++;
                     }
                 }
             }
         }
   } elsif (@currsections > 0) {    } elsif (@currsections > 0) {
       for (my $i=0; $i<@currsections; $i++) {        for (my $i=0; $i<@currsections; $i++) {
           my $sec = "sec_".$i;            my $sec = "sec_".$i;
Line 1407  sections which contribute to enrollment Line 1483  sections which contribute to enrollment
       }        }
   }    }
   
     if (@badsections > 0) {
         $response .= "The sections listed below could not be included in the sections for this LON-CAPA course, because they are not valid section numbers according to your institution's official schedule of classes and sections.<br/><ul>\n";
         foreach (@badsections) {
             my ($secnum,$gp,$prob) = split/:/,$_;
             $response .= "<li>$secnum - ID: $gp - Error: $prob</li>\n";
         }
         $response .= "</ul><br/><br/>\n";
     }
   
     if (@badowner > 0) {
         $response .= "The sections listed below could not be included in the sections for this LON-CAPA course, because the owner of this course - $owner - does not have rights to view enrollment in those classes as determined by your instititution's policies on access to official classlists.<br/><ul>\n";
         foreach (@badowner) {
             my ($secnum,$gp) = split/:/,$_;
             $response .= "<li>$secnum - ID: $gp</li>\n";
         }
         $response .= "</ul><br/><br/>\n";
     }
   
     if ($seccount > 0) {
         $warning = &warning_message($dom,$crs,$action);
         $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you have selected sections to contribute enrollment to this course, additional action is required.<br/>";
         unless ($warning eq '') {
             $response .= $warn_prefix.$warning;
         }
     }
   
   if ( exists($ENV{'form.numsec'}) ) {    if ( exists($ENV{'form.numsec'}) ) {
       my $numsec = $ENV{'form.numsec'};        my $numsec = $ENV{'form.numsec'};
       if ($numsec > 0) {        if ($numsec > 0) {
Line 1454  sections which contribute to enrollment Line 1556  sections which contribute to enrollment
   
 sub print_sections_response () {  sub print_sections_response () {
   my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;    my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
   my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode'],$dom,$crs);    my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode','internal.courseowner'],$dom,$crs);
   my @currsections = ();    my @currsections = ();
   my @sections = ();    my @sections = ();
   my @allsections = ();    my @allsections = ();
     my @badowner = ();
     my @badsections = ();
   my $numsec = 0;    my $numsec = 0;
   my $secstr =  $settings{'internal.sectionnums'};    my $secstr =  $settings{'internal.sectionnums'};
   my $coursecode = $settings{'internal.coursecode'};    my $coursecode = $settings{'internal.coursecode'};
     my $owner = $settings{'internal.courseowner'};
   my $response = '';    my $response = '';
                                                                                                          my $putreply = '';
     my $warning = '';
     my $warn_prefix = '';
   if ($secstr =~ m/,/) {    if ($secstr =~ m/,/) {
       @allsections = split/,/,$secstr;        @allsections = split/,/,$secstr;
   } else {    } else {
Line 1472  sub print_sections_response () { Line 1579  sub print_sections_response () {
   if ( exists($ENV{'form.numsec'}) ) {    if ( exists($ENV{'form.numsec'}) ) {
       $numsec = $ENV{'form.numsec'};        $numsec = $ENV{'form.numsec'};
   }    }
                                                                                                        
   if ($numsec > 0) {    if ($numsec > 0) {
       for (my $i=0; $i<$numsec; $i++) {        for (my $i=0; $i<$numsec; $i++) {
           my $sec = "newsec_".$i;            my $sec = "newsec_".$i;
           my $gp = "newsecgp_".$i;            my $gp = "newsecgp_".$i;
           if ( exists($ENV{"form.$sec"}) ) {            if ( exists($ENV{"form.$sec"}) ) {
               push @sections,$ENV{"form.$sec"}.":".$ENV{"form.$gp"};                unless ( (grep/^$ENV{"form.$sec"}:/,@allsections) || (grep/^$ENV{"form.$sec"}:/,@sections) ) {
                     my $newsec = $coursecode.$ENV{"form.$sec"};
                     my $coursecheck = &localenroll::validate_courseID($newsec);
                     if ($coursecheck eq 'ok') {
                         my $addcheck = &localenroll::new_course($newsec,$owner);
                         if ($addcheck eq 'ok') {
                             push @sections,$ENV{"form.$sec"}.":".$ENV{"form.$gp"};
                         } else {
                             push @badowner,$ENV{"form.$sec"}.":".$ENV{"form.$gp"};
                         }
                     } else {
                         push @badsections, $ENV{"form.$sec"}.":".$ENV{"form.$gp"}.":".$coursecheck;
                     }
                 }
           }            }
       }        }
       push @allsections, @sections;        push @allsections, @sections;
   }    }
                                                                                                        
   if (@sections > 0 ) {    if (@sections > 0 ) {
       unless ($secstr eq '') { $secstr .= ","; }         unless ($secstr eq '') { $secstr .= ","; } 
       if (@sections > 1) {        if (@sections > 1) {
Line 1492  sub print_sections_response () { Line 1612  sub print_sections_response () {
           $secstr .= $sections[0];            $secstr .= $sections[0];
       }        }
       my %cenv = ('internal.sectionnums' => $secstr);        my %cenv = ('internal.sectionnums' => $secstr);
       my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);        $putreply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
       if ($reply !~ /^ok$/) {        if ($putreply !~ /^ok$/) {
           $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";            $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/><br/>";
       } else {  
           $response = "Students enrolling in the sections listed below will be automatically added to the class roster for LON-CAPA course $realm ($coursecode), if you have chosen to enable a nightly automated enrollment update.<br/><ul>\n";  
       }        }
   }    }
                                                                                                        
   foreach (@allsections) {    if ($putreply =~ /^ok/) {
       my ($sec,$gp) = split/:/,$_;        $response = "Students enrolling in the sections listed below will be automatically added to the class roster for LON-CAPA course $realm ($coursecode), if you have chosen to enable a nightly automated enrollment update.<br/><ul>\n";
       $response .= "<li>$sec - ID: $gp</li>\n";        foreach (@allsections) {
             my ($sec,$gp) = split/:/,$_;
             $response .= "<li>$sec - ID: $gp</li>\n";
         }
         $response .= "</ul><br/><br/>\n";
   }    }
   $response .= "</ul><br/>\n";  
                                                                                                          if (@badsections > 0) {
         $response .= "The sections listed below could not be included in the sections for this LON-CAPA course, because they are not valid section numbers according to your institution's official schedule of classes and sections.<br/><ul>\n";
         foreach (@badsections) {
             my ($secnum,$gp,$prob) = split/:/,$_;
             $response .= "<li>$secnum - ID: $gp - Error: $prob</li>\n";
         }
         $response .= "</ul><br/><br/>\n";
     }
   
     if (@badowner > 0) {
         $response .= "The sections listed below could not be included in the sections for this LON-CAPA course, because the owner of this course - $owner - does not have rights to view enrollment in those classes as determined by your instititution's policies on access to official classlists.<br/><ul>\n";
         foreach (@badowner) {
             my ($secnum,$gp) = split/:/,$_;
             $response .= "<li>$secnum - ID: $gp</li>\n";
         }
         $response .= "</ul><br/><br/>\n";
     }
   
     if (@allsections > 0) {
         $warning = &warning_message($dom,$crs,$action);
         $warn_prefix = "<br/><font size ='+1'><b>Warning</b></font>. Although you have selected sections to contribute enrollment to this course, additional action is required.<br/>";
         unless ($warning eq '') {
             $response .= $warn_prefix.$warning;
         }
     }
   
   &print_reply($r,$response,$$tasktitleref{$action});    &print_reply($r,$response,$$tasktitleref{$action});
   return;    return;
 }  }
Line 1518  sub print_photos_response () { Line 1665  sub print_photos_response () {
   if ( exists($ENV{'form.showphotos'}) ) {    if ( exists($ENV{'form.showphotos'}) ) {
       $showphotos=$ENV{'form.showphotos'};        $showphotos=$ENV{'form.showphotos'};
   }    }
                                                                                               
   my $response = "";    my $response = "";
   my %cenv = ('internal.showphotos' => $showphotos);    my %cenv = ('internal.showphotos' => $showphotos);
   my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);    my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
Line 1640  sub print_update_result () { Line 1787  sub print_update_result () {
   return;    return;
 }  }
   
   sub warning_message {
       my ($dom,$crs,$caller) = @_;
       my %settings = &Apache::lonnet::get('environment',['internal.autoadds','internal.autodrops','internal.sectionnums','internal.crosslistings','internal.autostart','internal.autoend'],$dom,$crs);
       my $currend = '';
       my $currstart = '';
       my $currsecs = '';
       my $currxlists = '';
       my $warning = '';
       my $curradds = '';
       my $currdrops = '';
       if ( defined($settings{'internal.autoadds'}) ) {
           $curradds = $settings{'internal.autoadds'};
       }
       if (defined($settings{'internal.autodrops'}) ) {
           $currdrops = $settings{'internal.autodrops'};
       }
       if ( defined($settings{'internal.autostart'}) ) {
           $currstart = $settings{'internal.autostart'};
       }
       if ( defined($settings{'internal.autoend'}) ) {
           $currend = $settings{'internal.autoend'};
       }
       if ( defined($settings{'internal.sectionnums'}) ) {
           $currsecs = $settings{'internal.sectionnums'};
       }
       if ( defined($settings{'internal.crosslistings'}) ) {
           $currxlists = $settings{'internal.crosslistings'}
       }
       unless ($caller eq 'setdates') {
           if ( ($currstart eq '') && ($currend eq '') )  {
               $warning = "You <b>must</b> now use <a href='/adm/populate?action=setdates'>Change enrollment dates</a> to set a start date <i>and</i> an end date for the enrollment (or check the 'No end date' checkbox) for the nightly adds process to actually occur.</br></br>";
           }
       }
       unless ( ($caller eq 'sections') || ($caller eq 'crosslist') ) {
           if ( ($currsecs eq '') && ($currxlists eq '') ) {
               $warning .= "You <b>must</b> now use <a href='/adm/populate?action=sections'>Section settings</a> and/or <a href='/adm/populate?action=crosslist'>Change crosslistings</a> to choose at least one section of the course, or at least one crosslisted course which will contribute enrollment to this LON-CAPA course.  At present there are <b>NO</b> sections or crosslisted courses that are affiliated with this course that are set to contribute to the automated enrollment process.<br/><br/>";
           }
       }
       unless ( $caller eq 'chgsettings') {
           if ( (!$curradds) && (!$currdrops) ) {
               $warning .= "You <b>must</b> now use <a href='/adm/populate?action=chgsettings'>Automated adds/drops</a> to enable automated adds and/or drops if you want automatic enrollment updates to occur in this course.<br/><br/>.";
           }
       }
       return $warning;
   }
   
 sub print_reply () {  sub print_reply () {
   my ($r,$response,$caller) = @_;    my ($r,$response,$caller) = @_;
   $r->print("    $r->print("
Line 1655  sub print_reply () { Line 1848  sub print_reply () {
   
 sub setup_date_selectors {  sub setup_date_selectors {
     my ($starttime,$endtime) = @_;      my ($starttime,$endtime) = @_;
     if ($endtime == 0) {  
         $endtime = 1999915200;  
     }  
     if (! defined($starttime)) {      if (! defined($starttime)) {
         $starttime = time;          $starttime = time;
         if (exists($ENV{'course.'.$ENV{'request.course.id'}.          if (exists($ENV{'course.'.$ENV{'request.course.id'}.

Removed from v.1.7  
changed lines
  Added in v.1.11


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