Diff for /loncom/interface/lonpopulate.pm between versions 1.2 and 1.5

version 1.2, 2003/12/08 17:06:26 version 1.5, 2003/12/11 02:54:51
Line 1 Line 1
   # automated enrollment configuration handler
   # $Id$
   #
   # Copyright Michigan State University Board of Trustees
   #
   # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
   #
   # LON-CAPA is free software; you can redistribute it and/or modify
   # it under the terms of the GNU General Public License as published by
   # the Free Software Foundation; either version 2 of the License, or
   # (at your option) any later version.
   #
   # LON-CAPA is distributed in the hope that it will be useful,
   # but WITHOUT ANY WARRANTY; without even the implied warranty of
   # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   # GNU General Public License for more details.
   #
   # You should have received a copy of the GNU General Public License
   # along with LON-CAPA; if not, write to the Free Software
   # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   #
   # /home/httpd/html/adm/gpl.txt
   #
   # http://www.lon-capa.org/
   #
 package Apache::lonpopulate;  package Apache::lonpopulate;
   
 use strict;  use strict;
Line 5  use lib qw(/home/httpd/lib/perl); Line 30  use lib qw(/home/httpd/lib/perl);
 use Apache::lonnet ();  use Apache::lonnet ();
 use Apache::loncommon ();  use Apache::loncommon ();
 use Apache::lonhtmlcommon ();  use Apache::lonhtmlcommon ();
 use Apache::lonlocal ();  use Apache::lonlocal;
 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 ();
Line 420  ENDTWO Line 445  ENDTWO
   
       my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($dom.'/'.$crs);        my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($dom.'/'.$crs);
       foreach (sort keys %coursepersonnel) {        foreach (sort keys %coursepersonnel) {
           if ($_ eq &Apache::lonlocal::mt("Course Coordinator") )            if ($_ eq &mt("Course Coordinator") )
           {            {
               my @ccs = ();                my @ccs = ();
               if ($coursepersonnel{$_} =~ m/,/) {                if ($coursepersonnel{$_} =~ m/,/) {
Line 597  As you are the only user with the role o Line 622  As you are the only user with the role o
               </td>                </td>
              </tr>               </tr>
              <tr>               <tr>
               <td>For each section, check the checkbox if you want registered students in that section to be included in the student roster for LON-CAPA course: <b>$realm ($enrollvar{coursecode})</b>; otherwise uncheck it. If you want to change the section/group designation used for this section in LON-CAPA, delete the currecnt value in the LON-CAPA section/group textbox and enter the new value. The LON-CAPA section/group ID can be left (or set to) empty, if you do not wish to tie a section/group ID to this section. If you wish to add new course section, enter the number of new sections to add in the textbox at the bottom of the page. You will provide information about each of the new sections on a subsequent page. Click 'Go' to store your changes.</td>                <td>For each section, check the checkbox if you want registered students in that section to be included in the student roster for LON-CAPA course: <b>$realm ($enrollvar{coursecode})</b>; otherwise uncheck it. If you want to change the section/group designation used for this section in LON-CAPA, delete the current value in the LON-CAPA section/group textbox and enter the new value. The LON-CAPA section/group ID can be left (or set to) empty, if you do not wish to tie a section/group ID to this section. To add a new section, check the 'Enrollment in this course?' checkbox, and enter the desired LON-CAPA section/groupID in the appropriate textbox. Click 'Go' to store
   your changes.</td>
              </tr>               </tr>
             </table>              </table>
             <br/>              <br/>
Line 606  As you are the only user with the role o Line 632  As you are the only user with the role o
               <td>                <td>
                <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">                 <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"3\">
                 <tr bgcolor=\"#CCCCFF\">                  <tr bgcolor=\"#CCCCFF\">
                  <td><b>Course code</b>/td>                   <td><b>Section</b></td>
                  <td><b>Current status</b></td>                                 <td><b>Current status</b></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>
Line 615  As you are the only user with the role o Line 641  As you are the only user with the role o
               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=\"center\">                    $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) {
Line 676  As you are the only user with the role o Line 702  As you are the only user with the role o
           if (@currsections) {            if (@currsections) {
               my $secshow = @currsections;                my $secshow = @currsections;
               $r->print("                $r->print("
                 Currently, LON-CAPA course: $realm ($enrollvar{coursecode}) incorporates enrollment from $secshow sections.  Students enrolling in any of 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. For each section, uncheck the checkbox if you want registered students in that section to cease being included in the student roster for LON-CAPA course: <b>$realm ($enrollvar{coursecode})</b>; otherwise leave it checked. If you want to change the section/group designation used for this section in LON-CAPA, delete the current value in the LON-CAPA section/groupID textbox and enter the new value. If you wish to add new course section, enter the number of new sections to add in the textbox at the bottom of the page. You will provide information about each of the new sections on a subsequent page. Click 'Go' to store your changes.                  Currently, LON-CAPA course: $realm ($enrollvar{coursecode}) incorporates enrollment from $secshow sections.  Students enrolling in any of 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. For each section, uncheck the checkbox if you want registered students in that section to cease being included in the student roster for LON-CAPA course: <b>$realm ($enrollvar{coursecode})</b>; otherwise leave it checked. If you want to change the section/group designation used for this section in LON-CAPA, delete the current value in the LON-CAPA section/groupID textbox and enter the new value.  If you wish to add new course section, enter the number of new sections to add in the textbox at the bottom of the page. You will provide information about each of the new sections on a subsequent page. Click 'Go' to store your changes.
               </td>                </td>
              </tr>               </tr>
             </table>              </table>
Line 1085  sub print_crosslistings_menu () { Line 1111  sub print_crosslistings_menu () {
       $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/>";
   } else {    } else {
       if ($removecount > 0) {        if ($removecount > 0) {
           $response = "A total of $removecount courses are no longer crosslisted with LON-CAPA course: $realm ($coursecode).<br>/<br/>";            $response = "A total of $removecount courses are no longer crosslisted with LON-CAPA course: $realm ($coursecode).<br/><br/>";
       }        }
       if ($crosscount > 0) {        if ($crosscount > 0) {
           $response .=  "The $crosscount courses 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.<br/><ul>\n";            $response .=  "The $crosscount courses 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.<br/><ul>\n";
Line 1143  sub print_crosslistings_menu () { Line 1169  sub print_crosslistings_menu () {
   
 sub print_crosslistings_response () {  sub print_crosslistings_response () {
   my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;    my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
   my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode'],$dom,$crs);    my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode','internal.courseowner'],$dom,$crs);
   my @currxlists = ();    my @currxlists = ();
   my @xlists = ();    my @xlists = ();
   my @allxlists = ();    my @allxlists = ();
     my @badxlists = ();
     my @badowner = ();
   my $numcross = 0;    my $numcross = 0;
   my $xliststr =  $settings{'internal.crosslistings'};    my $xliststr =  $settings{'internal.crosslistings'};
   my $coursecode = $settings{'internal.coursecode'};    my $coursecode = $settings{'internal.coursecode'};
     my $owner = $settings{'internal.courseowner'};
   my $response = '';    my $response = '';
   
   if ($xliststr =~ m/,/) {    if ($xliststr =~ m/,/) {
Line 1167  sub print_crosslistings_response () { Line 1196  sub print_crosslistings_response () {
           my $xl = "newcross_".$i;            my $xl = "newcross_".$i;
           my $gp = "newgroupid_".$i;            my $gp = "newgroupid_".$i;
           if ( exists($ENV{"form.$xl"}) ) {            if ( exists($ENV{"form.$xl"}) ) {
               push @xlists,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};                my $coursecheck = &localenroll::validate_courseID($ENV{"form.$xl"});
                 if ($coursecheck eq 'ok') {
                     my $addcheck = &localenroll::new_course($ENV{"form.$xl"},$owner);
                     if ($addcheck eq 'ok') {
                        push @xlists,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};
                     } else {
                        push @badowner,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};
                     } 
                 } else {
                     push @badxlists, $ENV{"form.$xl"}.":".$ENV{"form.$gp"};
                 }
           }            }
       }        }
       push @allxlists, @xlists;        push @allxlists, @xlists;
Line 1193  sub print_crosslistings_response () { Line 1232  sub print_crosslistings_response () {
       my ($xlist,$gp) = split/:/,$_;        my ($xlist,$gp) = split/:/,$_;
       $response .= "<li>$xlist - ID: $gp</li>\n";        $response .= "<li>$xlist - ID: $gp</li>\n";
   }    }
   $response .= "</ul><br/>\n";    $response .= "</ul><br/><br/>\n";
   
     if (@badxlists > 0) {
         $response .= "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";
         foreach (@badxlists) {
             my ($xlist,$gp) = split/:/,$_;
             $response .= "<li>$xlist - ID: $gp</li>\n";
         }
         $response .= "</ul><br/><br/>\n";
     }
   
     if (@badowner > 0) {
         $response .= "The courses listed below could not be included in the crosslistings 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 ($xlist,$gp) = split/:/,$_;
             $response .= "<li>$xlist - ID: $gp</li>\n";
         }
         $response .= "</ul><br/><br/>\n";
     }
   
   &print_reply($r,$response,$$tasktitleref{$action});    &print_reply($r,$response,$$tasktitleref{$action});
   return;    return;
Line 1405  sub print_update_result () { Line 1462  sub print_update_result () {
   my @allcourses = ();    my @allcourses = ();
   my %LC_code = ();    my %LC_code = ();
   my $logmsg = '';    my $logmsg = '';
     my $newusermsg = '';
   
   my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.sectionnums','internal.crosslistings','internal.authtype','internal.autharg','internal.autostart','internal.autoend'],$dom,$crs);    my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.sectionnums','internal.crosslistings','internal.authtype','internal.autharg','internal.autostart','internal.autoend'],$dom,$crs);
   my $coursecode = $settings{'internal.coursecode'};    my $coursecode = $settings{'internal.coursecode'};
Line 1468  sub print_update_result () { Line 1526  sub print_update_result () {
           @{$affiliates{$crs}} = @allcourses;            @{$affiliates{$crs}} = @allcourses;
           &localenroll::fetch_enrollment($dom,\%affiliates,\%reply);            &localenroll::fetch_enrollment($dom,\%affiliates,\%reply);
           if ($reply{$crs} > 0) {            if ($reply{$crs} > 0) {
               ($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$updateadds,$updatedrops,$autostart,$autoend,$authtype,$autharg,\@allcourses,\%LC_code,\$logmsg,"updatenow");                ($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$updateadds,$updatedrops,$autostart,$autoend,$authtype,$autharg,\@allcourses,\%LC_code,\$logmsg,\$newusermsg,"updatenow");
               unless ($changecount == 0) {  
                   my $responselength = length($response);  
                   $response = substr($response,0,$responselength-4);  
               }  
           } else {            } else {
               $response = "There was a problem retrieving institutional class list data for the course sections and crosslisted courses which contribute enrollment to this course. No updates have been carried out, and the roster remains unchanged.";                $response = "There was a problem retrieving institutional class list data for the course sections and crosslisted courses which contribute enrollment to this course. No updates have been carried out, and the roster remains unchanged.";
           }              }  
Line 1485  sub print_update_result () { Line 1539  sub print_update_result () {
       $logmsg = substr($logmsg,0,$loglength-4);        $logmsg = substr($logmsg,0,$loglength-4);
       $logmsg = "<br/><br/>The following messages were generated by the roster update process: <br/><ul><li>".$logmsg."</ul><br/>";        $logmsg = "<br/><br/>The following messages were generated by the roster update process: <br/><ul><li>".$logmsg."</ul><br/>";
   }    }
   $response .= $logmsg;    unless ($newusermsg eq '') {
         $newusermsg = substr( $newusermsg,0,rindex($newusermsg,'<li>') );
         $newusermsg = "<br/><br/>The following new system user(s) who was/were created will be using internal authentication with an initial randomly generated password. A valid e-mail address was not available for this/these user(s) so LON-CAPA account credentials could not be sent via e-mail.<br/><ul><li>".$newusermsg."</ul><br/>";
     }
     $response .= $logmsg.$newusermsg;
   &print_reply($r,$response,$$tasktitleref{$action});    &print_reply($r,$response,$$tasktitleref{$action});
   return;    return;
 }  }

Removed from v.1.2  
changed lines
  Added in v.1.5


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