Diff for /loncom/interface/lonpopulate.pm between versions 1.15 and 1.16

version 1.15, 2004/06/28 15:41:20 version 1.16, 2004/06/29 04:30:00
Line 52  ENDHEAD Line 52  ENDHEAD
 ###############################################################  ###############################################################
   
 sub choose_header {  sub choose_header {
       my $action = shift;
     my $bodytag=&Apache::loncommon::bodytag('Classlist Manager');      my $bodytag=&Apache::loncommon::bodytag('Classlist Manager');
     my $scripttag = qq|      my $scripttag = qq|
 <script language='javascript' type='text/javascript'>  <script language='javascript' type='text/javascript'>
 <!--  <!--
 function process(calling) {  function process(calling,numauto,nummanual,numlock,numunlock) {
  var checker = 1   var checker = 1
  var rad1 = 0   var rad1 = 0
  var rad2 = 0   var rad2 = 0
Line 119  function process(calling) { Line 120  function process(calling) {
  }   }
  if (calling == "viewclass") {   if (calling == "viewclass") {
      document.forms.studentform.state.value = "process";       document.forms.studentform.state.value = "process";
      checker = 1;           var totcheck = 0
        if (numauto > 0) {
           for (var i=0; i<document.studentform.chgauto.length; i++) {
               if (document.studentform.chgauto[i].checked == true) {
                   totcheck ++
               }
           }
        }
        if (nummanual > 0) {
           for (var i=0; i<document.studentform.chgmanual.length; i++) {
               if (document.studentform.chgmanual[i].checked == true) {
                   totcheck ++
               }
           }
        }
        if (numlock > 0) {
           for (var i=0; i<document.studentform.lockchg.length; i++) {
               if (document.studentform.lockchg[i].checked == true) {
                   totcheck ++
               }
           }
        }
        if (numunlock > 0) {
           for (var i=0; i<document.studentform.unlockchg.length; i++) {
               if (document.studentform.unlockchg[i].checked == true) {
                   totcheck ++
               }
           }
        }
        if (totcheck > 0) {
           checker = 1
        } else {
           alert("You must check at least one checkbox, before proceeding to the next page")
           checker = 0
        }
  }    } 
  if (checker == 1) {     if (checker == 1) {  
      formName.submit();       formName.submit();
  }   }
 }  }
   |;
       if ($action eq 'viewclass') {
           $scripttag .= qq|
   function checkAll(field) {
       for (i = 0; i < field.length; i++)
           field[i].checked = true ;
   }
   
   function uncheckAll(field) {
       for (i = 0; i < field.length; i++)
           field[i].checked = false ;
   }
   |;
       }
       $scripttag .= qq|
 // End hiding -->  // End hiding -->
 </script>  </script>
 |;  |;
Line 241  sub print_main_frame { Line 291  sub print_main_frame {
               <td><b>Use the menu on the left to choose an enrollment management task.</b><br/><br/></td>                <td><b>Use the menu on the left to choose an enrollment management task.</b><br/><br/></td>
             <tr>              <tr>
               <td>&nbsp;</td>                <td>&nbsp;</td>
               <td>Use <i>"Automated adds/drops"</i> to enable or disable automatic nightly adds or drops in your LON-CAPA course based on instututional enrollment information.</td>                <td>Use <i>"Automated adds/drops"</i> to enable or disable automatic nightly adds or drops in your LON-CAPA course based on institutional enrollment information.</td>
             </tr>              </tr>
             <tr>              <tr>
               <td>&nbsp;</td>                <td>&nbsp;</td>
Line 271  sub print_main_frame { Line 321  sub print_main_frame {
               <td>Use <i>"Update roster now"</i> to add and/or drop students from your course based on the <b>most current</b> institutional classlist information.</td>                <td>Use <i>"Update roster now"</i> to add and/or drop students from your course based on the <b>most current</b> institutional classlist information.</td>
             </tr>              </tr>
             <tr>              <tr>
                 <td>&nbsp;</td>
                 <td>Use <i>"View students and change type"</i> to display the current course roster, and (optionally) change enrollment type for selected students from 'auto' to 'manual' and vice versa.</td>
               </tr>
               <tr>
              <td colspan='2'>&nbsp;</td>               <td colspan='2'>&nbsp;</td>
             </tr>              </tr>
             <tr>              <tr>
Line 921  Note: Any students previously added manu Line 975  Note: Any students previously added manu
                      <td align=\"left\"><b>$$tasktitleref{$action}</b>                       <td align=\"left\"><b>$$tasktitleref{$action}</b>
                      </td>                       </td>
                     </tr>                      </tr>
                       <tr>
                        <td>Section changes, name changes, and class drops that can be set to occur either automatically or when using the <b>'Update roster now'</b> feature, will affect only those students with an enroll type of <b>'auto'</b>. Students with an enroll type of <b>'manual'</b>, 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.  Use the 'Lock' checkbox for any manually enrolled students for whom you wish to prevent type conversion. Use the 'Change' checkbox to switch the enroll type from auto to manual, and vice versa. Use the 'Unlock' checkbox for any maually enrolled students for whom you no longer wish to lock the enroll type.  Click the 'Go' button at the end of the page to process your desired changes.</td>
                       </tr>
                       <tr><td>&nbsp;</td></tr> 
                    </table>                     </table>
                    <table>                     <table>
                     <tr>                      <tr>
Line 943  Note: Any students previously added manu Line 1001  Note: Any students previously added manu
           $r->print('<input type="submit" value="'.&mt('Update Display').'" />'.            $r->print('<input type="submit" value="'.&mt('Update Display').'" />'.
               "\n</p>\n");                "\n</p>\n");
   
           my $studentcount = &Apache::londropadd::show_class_list($r,'autoenroll','nothing',$ENV{'form.Status'},$classlist,$keylist);            my ($studentcount,$autocount,$manualcount,$lockcount,$unlockcount) = &Apache::londropadd::show_class_list($r,'autoenroll','nothing',$ENV{'form.Status'},$classlist,$keylist);
           $r->print("            $r->print("
                      </td>                       </td>
                     </tr>                      </tr>
           ");            ");
           if ($studentcount > 0) {            if ($studentcount > 0) {
               $r->print("                $r->print("
                     <tr>                      <tr><td><table border=\"0\" cellpadding=\"5\"><tr>
                 ");
                 my $cellcount = 0;
                 if ($autocount > 0) {
                     $cellcount ++;
                     $r->print(<<END);
                          <td><fieldset><legend>&nbsp;<b>Change auto</b></legend><input type="button" value="check all" onclick="javascript:checkAll(document.studentform.chgauto)" />&nbsp;&nbsp;
                          <input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.studentform.chgauto)" /></fieldset></td>
   END
                 }
                 if ($manualcount > 0) {
                     $cellcount ++;
                     $r->print(<<END);
                          <td><fieldset><legend>&nbsp;<b>Change manual</b></legend><input type="button" value="check all" onclick="javascript:checkAll(document.studentform.chgmanual)" />&nbsp;&nbsp;
                          <input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.studentform.chgmanual)" /></fieldset></td>
   END
                 }
                 if ($lockcount > 0) {
                     if ($cellcount == 2) {
                         $r->print("</tr><tr>");
                     }
                     $cellcount ++;
                     $r->print(<<END);
                          <td><fieldset><legend>&nbsp;<b>Lock manual</b></legend><input type="button" value="check all" onclick="javascript:checkAll(document.studentform.lockchg)" />&nbsp;&nbsp;
                          <input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.studentform.lockchg)" /></fieldset></td>
   END
                 }
                 if ($unlockcount > 0) {
                     if ($cellcount == 2) {
                         $r->print("</tr><tr>");
                     }
                     $cellcount ++;
                     $r->print(<<END);
                          <td><fieldset><legend>&nbsp;<b>Unlock manual</b></legend><input type="button" value="check all" onclick="javascript:checkAll(document.studentform.unlockchg)" />&nbsp;&nbsp;
                          <input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.studentform.unlockchg)" /></fieldset></td>
   END
                 }
                 $r->print("
                          </tr>
                         </table>
                      <td>&nbsp;</td>                       <td>&nbsp;</td>
                     </tr>                      </tr>
                     <tr>                      <tr>
                      <td align=\"right\">                       <td align=\"right\">
                       <input type=\"button\" name=\"viewclass\" value=\"Go\" onClick=\"process('viewclass')\" />                        <input type=\"button\" name=\"viewclass\" value=\"Go\" onClick=\"process('viewclass','$autocount','$manualcount','$lockcount','$unlockcount')\" />
                      </td>                       </td>
                     </tr>                      </tr>
               ");                ");
Line 992  sub print_accessdate_table { Line 1089  sub print_accessdate_table {
          'setl' => 'Set date of last access',           'setl' => 'Set date of last access',
          'freg' => 'for registered students added via automated enrollment',           'freg' => 'for registered students added via automated enrollment',
          '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.',
            'ncds'  => 'changing default start and end access dates will affect future enrollments and ALSO currently inactive students (i.e., those for whom access will begin in the future).  To change access dates for currently active students, you should change the access dates via this screen, then use Enrollment manager -> Drop Students to drop the students, and then use Automated Enrollment Manager -> Update roster now to re-enroll them with the new access dates.'
   
     );      );
     my $dateshow;      my $dateshow;
     if ( ($oldendshow eq '') && ($oldstartshow eq '') ) {      if ( ($oldendshow eq '') && ($oldstartshow eq '') ) {
Line 1071  ENDFOUR Line 1170  ENDFOUR
                    <tr>                     <tr>
                     <td colspan=\"2\"><font color=\"#888888\">$lt{'ifad'}</font></td>                      <td colspan=\"2\"><font color=\"#888888\">$lt{'ifad'}</font></td>
                    </tr>                     </tr>
                      <tr>
                       <td colspan=\"2\">&nbsp;</td>
                      </tr>
                      <tr>
                       <td colspan=\"2\"><b>".&mt('Note').":</b> ".$lt{'ncds'}."</td>
                      </tr>
                   </table>                    </table>
         ");          ");
     } elsif ($action eq 'updatenow') {      } elsif ($action eq 'updatenow') {
Line 2087  sub print_viewclass_response { Line 2192  sub print_viewclass_response {
     my $chgok = 0;      my $chgok = 0;
     my $chgfail = 0;      my $chgfail = 0;
     my $othdom = 0;      my $othdom = 0;
       my $locktotal = 0;
       my $lockok = 0;
       my $lockfail = 0;
     my $cid = $dom."_".$crs;      my $cid = $dom."_".$crs;
     my %chg = ();      my %chg = ();
     my %nochg = ();      my %nochg = ();
     my %otherdom = ();      my %otherdom = ();
     my $modreply = '';       my %lockchg = ();
       my %nolockchg = ();
     my $classlist = &Apache::loncoursedata::get_classlist($cid,$dom,$crs);      my $classlist = &Apache::loncoursedata::get_classlist($cid,$dom,$crs);
     my $endidx = &Apache::loncoursedata::CL_END;      my $endidx = &Apache::loncoursedata::CL_END;
     my $startidx = &Apache::loncoursedata::CL_START;      my $startidx = &Apache::loncoursedata::CL_START;
     my $ididx=&Apache::loncoursedata::CL_ID;      my $ididx=&Apache::loncoursedata::CL_ID;
     my $secidx=&Apache::loncoursedata::CL_SECTION;      my $secidx=&Apache::loncoursedata::CL_SECTION;
     my $typeidx=&Apache::loncoursedata::CL_TYPE;      my $typeidx=&Apache::loncoursedata::CL_TYPE;
     foreach (sort keys %ENV) {      my $lockedidx=&Apache::loncoursedata::CL_LOCKEDTYPE;
         if (/^form\.switch:(.+)$/) {      my @typechglist = ();
             my $student = $1;      my @lockchglist = ();
             my ($uname,$udom) = split/:/,$student;      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['chgauto','chgmanual','lockchg','unlockchg']);
             my $sdata    = $classlist->{$student};      if ($ENV{'form.chgauto'}) {
             my $section  = $sdata->[$secidx];          if (ref($ENV{'form.chgauto'}) eq 'ARRAY') {
             my $uid       = $sdata->[$ididx];              push @typechglist, @{$ENV{'form.chgauto'}};
             my $start    = $sdata->[$startidx];          } else {
             my $end      = $sdata->[$endidx];              push @typechglist, $ENV{'form.chgauto'};
             my $type     = $sdata->[$typeidx];          }
             $chgtotal ++;      }
             my $newtype = 'auto';      if ($ENV{'form.chgmanual'}) {
             my $change = 'auto';          if (ref($ENV{'form.chgmanual'}) eq 'ARRAY') {
             my $oldtype = 'manual';              push @typechglist, @{$ENV{'form.chgmanual'}};
             if ($type eq 'auto') {           } else {
                 $oldtype = 'auto';              push @typechglist, $ENV{'form.chgmanual'};
                 $newtype = '';          }
                 $change = 'manual';      }
       if ($ENV{'form.lockchg'}) {
           if (ref($ENV{'form.lockchg'}) eq 'ARRAY') {
               push @lockchglist, @{$ENV{'form.lockchg'}};
           } else {
               push @lockchglist, $ENV{'form.lockchg'};
           }
       }
       if ($ENV{'form.unlockchg'}) {
           if (ref($ENV{'form.unlockchg'}) eq 'ARRAY') {
               push @lockchglist, @{$ENV{'form.unlockchg'}};
           } else {
               push @lockchglist, $ENV{'form.unlockchg'};
           }
       }
       foreach my $student (sort @typechglist) {
           my ($uname,$udom) = split/:/,$student;
           my $sdata    = $classlist->{$student};
           my $section  = $sdata->[$secidx];
           my $uid       = $sdata->[$ididx];
           my $start    = $sdata->[$startidx];
           my $end      = $sdata->[$endidx];
           my $type     = $sdata->[$typeidx];
           my $lock   = $sdata->[$lockedidx];
           my $newlock = $lock;
           $chgtotal ++;
           my $newtype = 'auto';
           my $change = 'auto';
           my $oldtype = 'manual';
           if ($type eq 'auto') { 
               $oldtype = 'auto';
               $newtype = '';
               $change = 'manual';
           }
           if ($udom eq $dom) {
               if ($newtype eq 'auto') {
                   $newlock = '';
               } elsif ($newtype eq '') {
                   $newlock = '1';
             }              }
             if ($udom eq $dom) {              my $modreply = &Apache::lonnet::modify_student_enrollment($udom,$uname,$uid,'','','','',$section,$end,$start,$newtype,$newlock,$cid);
                 $modreply = &Apache::lonnet::modify_student_enrollment($udom,$uname,$uid,'','','','',$section,$end,$start,$newtype,$cid);              if ($modreply eq 'ok') {
                 if ($modreply eq 'ok') {                  $chgok ++;
                     $chgok ++;                  $chg{$student} = "Changed to $change";
                     $chg{$student} = "Changed to $change";  
                 } else {  
                     $chgfail ++;  
                     $nochg{$student} = "Still set to $oldtype";  
                 }   
             } else {              } else {
                 $othdom ++;                  $chgfail ++;
                 $otherdom{$student} = "Still set to $oldtype";                   $nochg{$student} = "Still set to $oldtype";
               } 
           } else {
               $othdom ++;
               $otherdom{$student} = "Still set to $oldtype"; 
           }
       }
       foreach my $student (@lockchglist) {
           my ($uname,$udom) = split/:/,$student;
           my $sdata    = $classlist->{$student};
           my $section  = $sdata->[$secidx];
           my $uid       = $sdata->[$ididx];
           my $start    = $sdata->[$startidx];
           my $end      = $sdata->[$endidx];
           my $type     = $sdata->[$typeidx];
           my $lock   = $sdata->[$lockedidx];
           my $newlock = 1;
           my $oldlockname = &mt('unlocked');
           my $newlockname = &mt('locked');
           $locktotal++;
           unless ($type eq 'auto') {
               if ($lock) {
                   $newlock = '';
                   $newlockname = &mt('unlocked');
                   $oldlockname = &mt('locked'); 
               }
               my $lockreply = &Apache::lonnet::modify_student_enrollment($udom,$uname,$uid,'','','','',$section,$end,$start,$type,$newlock,$cid);
               if ($lockreply eq 'ok') {
                   $lockok ++;
                   $lockchg{$student} = 'Changed to '.$newlockname;
               } else {
                   $lockfail ++;
                   $nolockchg{$student} = 'Still set to '.$oldlockname;
             }              }
         }          }
     }      }
Line 2147  sub print_viewclass_response { Line 2321  sub print_viewclass_response {
             $response .= "The following $othdom students were not modified because students must be in the same LON-CAPA domain as the course, in order to be set to an enrollment type of 'auto':<br />";               $response .= "The following $othdom students were not modified because students must be in the same LON-CAPA domain as the course, in order to be set to an enrollment type of 'auto':<br />"; 
             $response .= &enrolltype_result(\%otherdom,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx);              $response .= &enrolltype_result(\%otherdom,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx);
         }          }
           $response .= "<br /><br />";
       }
       if ($locktotal > 0) {
           $response .= "You requested locking/unlocking for $locktotal manually enrolled students.<br /><br />\n";
           $classlist = &Apache::loncoursedata::get_classlist($cid,$dom,$crs);
           if ($lockok > 0) {
               $response .= "The following $lockok changes were successful:<br />";
               $response .= &enrolltype_result(\%lockchg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx,$lockedidx);
           }
           if ($lockfail > 0) {
               $response .= "The following $lockfail students were not modified successfully:&nbsp;<br />";
               $response .= &enrolltype_result(\%nolockchg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx,$lockedidx);
           }
     }      }
     &print_reply($r,$response,$$tasktitleref{$action});      &print_reply($r,$response,$$tasktitleref{$action});
     return;      return;
 }  }
   
 sub enrolltype_result {  sub enrolltype_result {
     my ($changes,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx) = @_;      my ($changes,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx,$lockedidx) = @_;
     my $reply = "      my $reply = "
             <table border='2'>              <table border='2'>
              <tr>               <tr>
Line 2362  sub handler { Line 2549  sub handler {
                updatenow => "Update roster now",                 updatenow => "Update roster now",
                newcross => "Add crosslistings",                 newcross => "Add crosslistings",
                newsections => "Add sections",                 newsections => "Add sections",
                viewclass => "View students and type",                 viewclass => "View students and change type",
     );      );
                                                                                                                                                                     
     my %tasktitle = (      my %tasktitle = (
Line 2405  sub handler { Line 2592  sub handler {
         $r->print(&header());           $r->print(&header()); 
     } else {      } else {
         if ($state eq "choose") {          if ($state eq "choose") {
             $r->print(&choose_header());              $r->print(&choose_header($action));
         } 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());                          $r->print(&choose_header($action));
                     } else {                      } else {
                         $r->print(&header());                          $r->print(&header());
                     }                      }
Line 2420  sub handler { Line 2607  sub handler {
             } 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());                          $r->print(&choose_header($action));
                     } else {                      } else {
                         $r->print(&header());                          $r->print(&header());
                     }                      }

Removed from v.1.15  
changed lines
  Added in v.1.16


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