Diff for /loncom/interface/lonmodifycourse.pm between versions 1.2 and 1.17

version 1.2, 2003/12/28 01:37:02 version 1.17, 2005/04/12 00:20:00
Line 1 Line 1
   # 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::lonmodifycourse;  package Apache::lonmodifycourse;
   
 use strict;  use strict;
Line 8  use Apache::lonlocal; Line 30  use Apache::lonlocal;
 use Apache::londropadd;  use Apache::londropadd;
 use LONCAPA::Enrollment;  use LONCAPA::Enrollment;
 use lib '/home/httpd/lib/perl';  use lib '/home/httpd/lib/perl';
 use localenroll;  
   
 sub print_course_selection_page {  sub print_course_selection_page {
     my ($r,$tasklongref) = @_;      my ($r,$tasklongref) = @_;
     my $dom = $ENV{'user.domain'};      my $dom = $env{'request.role.domain'};
     my %lt=&Apache::lonlocal::texthash(      my %lt=&Apache::lonlocal::texthash(
                     'csae' => "Course settings for automated enrollment",                      'csae' => "Course settings for automated enrollment",
                     'unst' => "Unlike standard LON-CAPA course parameters, such as course description, feedback addresses, and top level map, which are displayed and/or modified using the 'Course Environment Parameters' screen, settings that control automated enrollment based on classlist data available from your institution's student information system are handled differently.  Automated enrollment settings fall into two groups: (a) settings that can be modified by a Course Coordinator using the Automated Enrollment Manager and (b)  settings that may only be modified by a Domain Coordinator via the 'View/Modify Course settings' menu accessed from this page.",                       'unst' => "Unlike standard LON-CAPA course parameters, such as course description, feedback addresses, and top level map, which are displayed and/or modified using the 'Course Environment Parameters' screen, settings that control automated enrollment based on classlist data available from your institution's student information system are handled differently.  Automated enrollment settings fall into two groups: (a) settings that can be modified by a Course Coordinator using the Automated Enrollment Manager and (b)  settings that may only be modified by a Domain Coordinator via the 'View/Modify Course settings' menu accessed from this page.", 
Line 24  sub print_course_selection_page { Line 45  sub print_course_selection_page {
     );      );
                                                                                                                                                                               
 # Determine the courses  # Determine the courses
     my %courseIDs = &Apache::lonnet::courseiddump($dom,'.',1);      my %courseIDs = &Apache::lonnet::courseiddump($dom,'.',1,'.','.','.');
     &print_header($r,$tasklongref);      &print_header($r,$tasklongref);
     $r->print(<<ENDBLOCK);      $r->print(<<ENDBLOCK);
 <form action="/adm/modifycourse" method="post" name="cmod">  <form action="/adm/modifycourse" method="post" name="cmod">
 <h2>$lt{'csae'}</h2>  <h3>$lt{'csae'}</h3>
 <p>$lt{'unst'}  <p>$lt{'unst'}
 </p><p>$lt{'chcs'}  </p><p>$lt{'chcs'}
 <br/>$lt{'eaen'}  <br/>$lt{'eaen'}
Line 44  ENDBLOCK Line 65  ENDBLOCK
     foreach my $key (sort keys %courseIDs) {      foreach my $key (sort keys %courseIDs) {
 # Get current code  # Get current code
         my $crs;          my $crs;
         my $currcode;          my ($description,$currcode,$owner);
         if ($key =~ m/^($dom)_(\w+)$/) {          if ($courseIDs{$key} =~ m/^([^:]*):([^:]+)/ ) {
               $currcode = $2;
           } elsif ($key =~ m/^($dom)_(\w+)$/) {
             $crs = $2;              $crs = $2;
             my %settings = &Apache::lonnet::get('environment',['internal.coursecode'],$dom,$crs);              my %settings = &Apache::lonnet::get('environment',['internal.coursecode'],$dom,$crs);
             if (defined($settings{'internal.coursecode'}) ) {              if (defined($settings{'internal.coursecode'}) ) {
                 $currcode = $settings{'internal.coursecode'};                  $currcode = $settings{'internal.coursecode'};
                 if ($currcode eq '') {  
                     $currcode = "___".$iter;  
                     $iter ++;  
                 }  
     } else {  
                 $currcode = "___".$iter;  
                 $iter ++;  
             }              }
         } else {          }
           if ($currcode eq '') {
             $currcode = "___".$iter;              $currcode = "___".$iter;
             $iter ++;                  $iter ++;
         }          }
         unless (grep/^$currcode$/,@codes) {          unless (grep/^$currcode$/,@codes) {
             push @codes,$currcode;              push @codes,$currcode;
Line 78  ENDBLOCK Line 95  ENDBLOCK
             unless ($code =~m/^___\d+$/) {  $showcode = $code; }              unless ($code =~m/^___\d+$/) {  $showcode = $code; }
             if ($item =~ m/^($dom)_(\w+)$/) {              if ($item =~ m/^($dom)_(\w+)$/) {
                 $crs = $2;                  $crs = $2;
                 $description = $courseIDs{$item};                  if ($courseIDs{$item} =~ /^([^:]*):([^:]*):([^:]*)/) {
                       $description = &Apache::lonnet::unescape($1);
                       $owner = &Apache::lonnet::unescape($3);
                   } elsif ($courseIDs{$item} =~ /^([^:]*):([^:]*)$/) {
                       $description = &Apache::lonnet::unescape($1);
                   } else {   
                       $description = &Apache::lonnet::unescape($courseIDs{$item});
                   }
 # Get course owner  # Get course owner
                 my %settings = &Apache::lonnet::get('environment',['internal.courseowner'],$dom,$crs);                  if ($owner eq '') {
                 if ( defined($settings{'internal.courseowner'}) ) {                      my %settings = &Apache::lonnet::get('environment',['internal.courseowner'],$dom,$crs);
                     $owner = $settings{'internal.courseowner'};                      if ( defined($settings{'internal.courseowner'}) ) {
                           $owner = $settings{'internal.courseowner'};
                       }
                   }
                   unless ($owner eq '') {
                     $ownername = &Apache::loncommon::plainname($owner,$dom);                      $ownername = &Apache::loncommon::plainname($owner,$dom);
                 }                  }
                 $r->print("<option value=\"$crs\">$showcode -- $description ---------- $ownername");                  $r->print("<option value=\"$crs\">$showcode -- $description ---------- $ownername");
Line 102  ENDBLOCK Line 130  ENDBLOCK
 sub print_course_modification_page {  sub print_course_modification_page {
     my ($r,$tasklongref,$typeref) = @_;      my ($r,$tasklongref,$typeref) = @_;
     my %enrollvar = ();      my %enrollvar = ();
       my $javascript_validations;
       my $course = '';
       my $dom = $env{'request.role.domain'};
       if ( defined($env{'form.course'}) ) {
           $course = $env{'form.course'};
       }
       my $ok_course = 'ok';
       if ( ($course == -1) || ($course == '-2') || ($course eq '') ) {
           $ok_course = 'invalid';
       } else {
           $ok_course = &check_course($dom,$course);
       }
   
       unless ($ok_course eq 'ok') {
           &print_header($r,$tasklongref,'',\$javascript_validations);
           my $reply = "<br/>".&mt("The LON-CAPA course selected was not a valid course for this domain");
           $r->print($reply);
           &print_footer($r);
           return;
       }
   
     my @bgcolors=("#eeeeee","#cccccc");      my @bgcolors=("#eeeeee","#cccccc");
     my $course = $ENV{'form.course'};  
     my $dom = $ENV{'user.domain'};  
     my $ownertable;      my $ownertable;
     my %lt=&Apache::lonlocal::texthash(      my %lt=&Apache::lonlocal::texthash(
             'actv' => "Active",              'actv' => "Active",
Line 156  all settings except course code, course Line 203  all settings except course code, course
         } else {          } else {
             $enrollvar{$1} = localtime($settings{$item});              $enrollvar{$1} = localtime($settings{$item});
         }          }
             } else {              } elsif ($1 eq "courseowner" || $1 eq "authtype" || $1 eq "autharg" || $1 eq "sectionnums" || $1 eq "coursecode" || $1 eq "crosslistings") {
         $enrollvar{$1} = $settings{$item};          $enrollvar{$1} = $settings{$item};
             }              }
           } elsif ($item =~ m/^default_enrollment_(start|end)_date$/) {
               if ( ($1 eq 'end') && ($settings{$item} == 0) ) {
                   $enrollvar{$item} = $lt{'noen'};
               } elsif ( ($1 eq 'start') && ($settings{$item} eq '') ) {
                   $enrollvar{$item} = 'When enrolled';
               } else {
                   $enrollvar{$item} = localtime($settings{$item});
               }
         }          }
     }      }
   
Line 181  all settings except course code, course Line 236  all settings except course code, course
         }          }
     }      }
     unless ( (grep/^$enrollvar{'courseowner'}$/,@local_ccs) || ($enrollvar{'courseowner'} eq '') )  {      unless ( (grep/^$enrollvar{'courseowner'}$/,@local_ccs) || ($enrollvar{'courseowner'} eq '') )  {
         push @local_ccs, $enrollvar{'coursecode'};          push @local_ccs, $enrollvar{'courseowner'};
         $pname{$enrollvar{'courseowner'}} =  &Apache::loncommon::plainname($enrollvar{'courseowner'},$dom);          $pname{$enrollvar{'courseowner'}} =  &Apache::loncommon::plainname($enrollvar{'courseowner'},$dom);
         $active_cc = &LONCAPA::Enrollment::check_user_status($dom,$enrollvar{'coursecode'},$dom,$course,'cc');          $active_cc = &LONCAPA::Enrollment::check_user_status($dom,$enrollvar{'coursecode'},$dom,$course,'cc');
         if ($active_cc eq 'ok') {          if ($active_cc eq 'ok') {
Line 193  all settings except course code, course Line 248  all settings except course code, course
     my $numlocalcc = @local_ccs;      my $numlocalcc = @local_ccs;
     my $bodytag=&Apache::loncommon::bodytag(&mt("Modify Course Settings"));      my $bodytag=&Apache::loncommon::bodytag(&mt("Modify Course Settings"));
     my $helplink=&Apache::loncommon::help_open_topic('Modify_Course',&mt("Help on Modifying Courses"));      my $helplink=&Apache::loncommon::help_open_topic('Modify_Course',&mt("Help on Modifying Courses"));
     my $defdom=$ENV{'request.role.domain'};      my ($krbdef,$krbdefdom)=&Apache::loncommon::get_kerberos_defaults($dom);
     my ($krbdef,$krbdefdom)=&Apache::loncommon::get_kerberos_defaults($defdom);  
     my $curr_authtype = '';      my $curr_authtype = '';
     my $curr_authfield = '';      my $curr_authfield = '';
     if ($enrollvar{'authtype'} =~ /^krb/) {      if ($enrollvar{'authtype'} =~ /^krb/) {
Line 207  all settings except course code, course Line 261  all settings except course code, course
     unless ($curr_authtype eq '') {      unless ($curr_authtype eq '') {
         $curr_authfield = $curr_authtype.'arg';          $curr_authfield = $curr_authtype.'arg';
     }       } 
     my $javascript_validations=&Apache::londropadd::javascript_validations('modifycourse',$krbdefdom,$curr_authtype,$curr_authfield);      $javascript_validations=&Apache::londropadd::javascript_validations('modifycourse',$krbdefdom,$curr_authtype,$curr_authfield);
     my %param = ( formname => 'document.cmod',      my %param = ( formname => 'document.cmod',
    kerb_def_dom => $krbdefdom,     kerb_def_dom => $krbdefdom,
    kerb_def_auth => $krbdef,     kerb_def_auth => $krbdef,
Line 238  all settings except course code, course Line 292  all settings except course code, course
  <td>$$typeref{$key}</td>   <td>$$typeref{$key}</td>
  <td>$enrollvar{$key}</td>   <td>$enrollvar{$key}</td>
  </tr>";   </tr>";
        $iter ++;          $iter ++;
     }      }
     $disp_table .= "</table>      $disp_table .= "</table>
                    </td>                     </td>
Line 282  all settings except course code, course Line 336  all settings except course code, course
             my $colflag = $i%2;              my $colflag = $i%2;
             $ownertable .= "<tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">";              $ownertable .= "<tr bgcolor=\"$bgcolors[$colflag]\" align=\"left\">";
             if ($local_ccs[$i] eq $enrollvar{'courseowner'}) {              if ($local_ccs[$i] eq $enrollvar{'courseowner'}) {
                   $ownertable .= "<td><input type=\"radio\" name=\"courseowner\" value=\"$i\" checked=\"true\"/></td>";                    $ownertable .= "<td><input type=\"radio\" name=\"courseowner\" value=\"$local_ccs[$i]\" checked=\"true\"/></td>";
             } else {              } else {
                 $ownertable .= "<td><input type=\"radio\" name=\"courseowner\" value=\"$i\" /></td>";                  $ownertable .= "<td><input type=\"radio\" name=\"courseowner\" value=\"$local_ccs[$i]\" /></td>";
             }              }
             $ownertable .= "              $ownertable .= "
                  <td>$pname{$local_ccs[$i]}</td>                   <td>$pname{$local_ccs[$i]}</td>
                  <td><input type=\"hidden\" name=\"username_$i\" value=\"$local_ccs[$i]\" />$local_ccs[$i]</td>                   <td>$local_ccs[$i]</td>
                  <td>$cc_status{$local_ccs[$i]} $lt{'ccor'}</td></tr>";                   <td>$cc_status{$local_ccs[$i]} $lt{'ccor'}</td></tr>";
         }          }
         $ownertable .= "</table>          $ownertable .= "</table>
Line 305  all settings except course code, course Line 359  all settings except course code, course
     &print_header($r,$tasklongref,$settings{'description'},\$javascript_validations);      &print_header($r,$tasklongref,$settings{'description'},\$javascript_validations);
     $r->print(<<ENDDOCUMENT);      $r->print(<<ENDDOCUMENT);
 <form action="/adm/modifycourse" method="post" name="cmod">  <form action="/adm/modifycourse" method="post" name="cmod">
 <h2>$lt{'aecs'}</h2>  <h3>$lt{'aecs'}</h3>
 $lt{'cose'}<a href="/adm/populate">$lt{'aenm'}</a>$lt{'andb'}  $lt{'cose'}<a href="/adm/populate">$lt{'aenm'}</a>$lt{'andb'}
 <p>  <p>
 <table width="100%" cellspacing="0" cellpadding="0">  <table width="100%" cellspacing="0" cellpadding="0">
Line 377  $disp_table Line 431  $disp_table
 <br/>  <br/>
 ENDDOCUMENT  ENDDOCUMENT
     &print_footer($r);      &print_footer($r);
       return;
 }  }
   
 sub modify_course {  sub modify_course {
     my ($r,$tasklongref,$typeref) = @_;      my ($r,$tasklongref,$typeref) = @_;
     my $dom = $ENV{'user.domain'};      my $dom = $env{'user.domain'};
     my $crs = $ENV{'form.course'};      my $crs = $env{'form.course'};
       unless ( &check_course($dom,$crs) eq 'ok' ) {
           &print_header($r,$tasklongref);
           my $reply = "<br/>".&mt("The LON-CAPA course selected was not a valid course for this domain");
           $r->print($reply);
           &print_footer($r);
           return;
       }
   
     my %settings = &Apache::lonnet::get('environment',['internal.courseowner','internal.coursecode','internal.authtype','internal.autharg','internal.sectionnums','internal.crosslistings','description'],$dom,$crs);      my %settings = &Apache::lonnet::get('environment',['internal.courseowner','internal.coursecode','internal.authtype','internal.autharg','internal.sectionnums','internal.crosslistings','description'],$dom,$crs);
     my %currattr = ();      my %currattr = ();
     my %newattr = ();      my %newattr = ();
Line 422  sub modify_course { Line 485  sub modify_course {
     my $description = $settings{'description'};      my $description = $settings{'description'};
     my %cenv = ();      my %cenv = ();
   
     if ($ENV{'form.login'} eq 'krb') {      if ($env{'form.login'} eq 'krb') {
         $newattr{'authtype'} = $ENV{'form.login'};          $newattr{'authtype'} = $env{'form.login'};
         $newattr{'authtype'} .= $ENV{'form.krbver'};          $newattr{'authtype'} .= $env{'form.krbver'};
         $newattr{'autharg'} = $ENV{'form.krbarg'};          $newattr{'autharg'} = $env{'form.krbarg'};
         $newattr{'autharg'} =~ tr/a-z/A-Z/;       } elsif ($env{'form.login'} eq 'int') {
     } elsif ($ENV{'form.login'} eq 'int') {  
         $newattr{'authtype'} ='internal';          $newattr{'authtype'} ='internal';
         if ((defined($ENV{'form.intarg'})) && ($ENV{'form.intarg'})) {          if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
             $newattr{'autharg'} = $ENV{'form.intarg'};              $newattr{'autharg'} = $env{'form.intarg'};
         }          }
     } elsif ($ENV{'form.login'} eq 'loc') {      } elsif ($env{'form.login'} eq 'loc') {
         $newattr{'authtype'} = 'localauth';          $newattr{'authtype'} = 'localauth';
         if ((defined($ENV{'form.locarg'})) && ($ENV{'form.locarg'})) {          if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
             $newattr{'autharg'} = $ENV{'form.locarg'};              $newattr{'autharg'} = $env{'form.locarg'};
         }          }
     }      }
     if ( $newattr{'authtype'}=~ /^krb/) {      if ( $newattr{'authtype'}=~ /^krb/) {
Line 445  sub modify_course { Line 507  sub modify_course {
         }          }
     }      }
   
     if ( exists($ENV{'form.courseowner'}) ) {      if ( exists($env{'form.courseowner'}) ) {
          my $ownerparam = 'username_'.$ENV{'form.courseowner'};          $newattr{'courseowner'}=$env{'form.courseowner'};
          if ( exists($ENV{"form.$ownerparam"}) ) {            unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) {
             $newattr{'courseowner'}=$ENV{"form.$ownerparam"};              $changeowner = 1;
             unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) {  
                 $changeowner = 1;  
             }  
         }           } 
     }      }
               
     if ( exists($ENV{'form.coursecode'}) ) {      if ( exists($env{'form.coursecode'}) ) {
         $newattr{'coursecode'}=$ENV{'form.coursecode'};          $newattr{'coursecode'}=$env{'form.coursecode'};
         unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) {          unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) {
             $changecode = 1;              $changecode = 1;
         }          }
     }      }
       if ($changeowner == 1 || $changecode == 1) {
           my $courseid_entry = &Apache::lonnet::escape($dom.'_'.$crs).'='.&Apache::lonnet::escape($description).':'.&Apache::lonnet::escape($env{'form.coursecode'}).':'.&Apache::lonnet::escape($env{'form.courseowner'});
           &Apache::lonnet::courseidput($dom,$courseid_entry,&Apache::lonnet::homeserver($crs,$dom));
       }
   
     foreach (@params) {      foreach (@params) {
         if ($currattr{$_} eq $newattr{$_}) {          if ($currattr{$_} eq $newattr{$_}) {
Line 498  sub modify_course { Line 561  sub modify_course {
                         if ($changecode) {                          if ($changecode) {
                     foreach my $sec (@sections) {                      foreach my $sec (@sections) {
                 if ($sec =~ m/^(.+):/) {                  if ($sec =~ m/^(.+):/) {
                     my $course_id = $newattr{'coursecode'}.$1;                      my $inst_course_id = $newattr{'coursecode'}.$1;
 #            my $course_check = &localenroll::validate_courseID($course_id);                                      my $course_check = &Apache::lonnet::auto_validate_courseID($crs,$dom,$inst_course_id);
                                     my $course_check = 'ok';              if ($course_check eq 'ok') {
             if ($course_check eq 'ok') {                                            my $outcome = &Apache::lonnet::auto_new_course($crs,$dom,$inst_course_id,$newattr{'courseowner'});
 #                                        my $outcome = &localenroll::new_course($course_id,$newattr{'courseowner'});  
                 my $outcome = 'ok';  
                 unless ($outcome eq 'ok') {                   unless ($outcome eq 'ok') { 
             $warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for ").$newattr{'coursecode'}.&mt(" - section $1 for the following reason: $outcome.<br/>");              $warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for ").$newattr{'coursecode'}.&mt(" - section $1 for the following reason: $outcome.<br/>");
                 }                  }
Line 514  sub modify_course { Line 575  sub modify_course {
             $warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for ").$newattr{'coursecode'}.&mt(" - section $sec because this is not a valid section entry.<br/>");              $warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for ").$newattr{'coursecode'}.&mt(" - section $sec because this is not a valid section entry.<br/>");
                 }                  }
             }              }
                 }                   } elsif ($changeowner) {
                               foreach my $sec (@sections) {
                                   if ($sec =~ m/^(.+):/) {
                                       my $inst_course_id = $newattr{'coursecode'}.$1;
                                       my $outcome = &Apache::lonnet::auto_new_course($crs,$dom,$inst_course_id,$newattr{'courseowner'});
                                       unless ($outcome eq 'ok') {
                                           $warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for ").$newattr{'coursecode'}.&mt(" - section $1 for the following reason: $outcome.<br/>");
                                       }
                                   } else {
                                       $warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for ").$newattr{'coursecode'}.&mt(" - section $sec because this is not a valid section entry.<br/>");
                                   }
                               }
                           }
             } else {              } else {
                 $warning .= &mt("As no section numbers are currently listed for LON-CAPA course: ").$description.&mt(", automated enrollment will not occur for any sections of coursecode: ").$newattr{'coursecode'}."<br/>";                  $warning .= &mt("As no section numbers are currently listed for LON-CAPA course: ").$description.&mt(", automated enrollment will not occur for any sections of coursecode: ").$newattr{'coursecode'}."<br/>";
             }              }
             if ( (@xlists > 0) && ($changeowner) ) {              if ( (@xlists > 0) && ($changeowner) ) {
                 foreach my $xlist (@xlists) {                  foreach my $xlist (@xlists) {
             if ($xlist =~ m/^(.+):/) {              if ($xlist =~ m/^(.+):/) {
 #                                my $outcome = &localenroll::new_course($1,$newattr{'courseowner'});                                  my $outcome = &Apache::lonnet::auto_new_course($crs,$dom,$1,$newattr{'courseowner'});
                 my $outcome = 'ok';  
                 unless ($outcome eq 'ok') {                  unless ($outcome eq 'ok') {
             $warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for crosslisted class: ").$1.&mt(" for the following reason: $outcome.<br/>");              $warning .= &mt("If automatic enrollment is enabled for LON-CAPA course: ").$description.&mt(", automated enrollment may fail for crosslisted class: ").$1.&mt(" for the following reason: $outcome.<br/>");
                 }                  }
Line 534  sub modify_course { Line 606  sub modify_course {
         }          }
     } else {      } else {
         foreach my $attr (@params) {          foreach my $attr (@params) {
             $nochgresponse .= "<li>$$typeref{$attr} ".&mt("still set to \"").$currattr{$attr}."\".</li>";              $nochgresponse .= "<li>$$typeref{$attr} ".&mt("still set to")." \"".$currattr{$attr}."\".</li>";
         }          }
     }      }
   
Line 554  sub modify_course { Line 626  sub modify_course {
         $reply = $response;          $reply = $response;
     }      }
     &print_header($r,$tasklongref,$description);      &print_header($r,$tasklongref,$description);
     $r->print("<table><tr><td>$reply</td></tr></table");      $reply = "<h3>".&mt("Automated Enrollment Course Settings")."</h3><table><tr><td>".$reply."</td></tr></table>";
       $r->print($reply);
     &print_footer($r);      &print_footer($r);
     return;       return; 
 }  }
Line 568  sub print_header { Line 641  sub print_header {
              'comg' => 'Course Manager',               'comg' => 'Course Manager',
              );               );
     my $action = "start";      my $action = "start";
     if ( exists($ENV{'form.action'}) ) {      if ( exists($env{'form.action'}) ) {
         $action = $ENV{'form.action'};          $action = $env{'form.action'};
     }      }
     if ( ($description eq '') || (!defined($description)) ) {      if ( ($description eq '') || (!defined($description)) ) {
         $description = $lt{'comg'};          $description = $lt{'comg'};
Line 581  sub print_header { Line 654  sub print_header {
     } else {      } else {
         $page =  '<a href="/adm/modifycourse">'.$lt{'chco'}.'</a>';          $page =  '<a href="/adm/modifycourse">'.$lt{'chco'}.'</a>';
         if ( $action eq 'process' ) {          if ( $action eq 'process' ) {
             my $course = $ENV{'form.course'};              my $course = $env{'form.course'};
             $page .= "-&gt; <a href=\"/adm/modifycourse?action=display&course=$course\">".$$tasklongref{'display'}."</a> -&gt; <b>$$tasklongref{$action}</b> ";              $page .= "-&gt; <a href=\"/adm/modifycourse?action=display&course=$course\">".$$tasklongref{'display'}."</a> -&gt; <b>$$tasklongref{$action}</b> ";
         } else {          } else {
             $page .=  " -&gt; <b>".$$tasklongref{$action}."</b>";              $page .=  " -&gt; <b>".$$tasklongref{$action}."</b>";
         }          }
     }      }
       my $html=&Apache::lonxml::xmlbegin();
     $r->print("      $r->print("
 <html>  $html
 <head>");  <head>
   ");
     if ($action eq 'display') {      if ($action eq 'display') {
         $r->print("          $r->print("
 <script language=\"JavaScript\" type=\"text/javascript\">  <script language=\"JavaScript\" type=\"text/javascript\">
Line 611  $bodytag Line 686  $bodytag
  </tr>   </tr>
 </table>  </table>
 ENDTHIS  ENDTHIS
       return;
 }  }
   
 sub print_footer {  sub print_footer {
   my $r = shift;      my $r = shift;
   $r->print(<<ENDBASE);      $r->print(<<ENDBASE);
 <br/>  <br/>
 </body>  </body>
 </html>  </html>
 ENDBASE  ENDBASE
       return;
   }
   
   sub check_course {
       my ($dom,$course) = @_;
       my %courseIDs = &Apache::lonnet::courseiddump($dom,'.',1,'.','.');
       foreach my $key (sort keys %courseIDs) {
           if ($key =~ m/^($dom)_(\w+)$/) {
               if ($2 eq $course) {
                   return 'ok';
               }
           }
       }
       return 'invalid course';
 }  }
   
   
Line 631  sub handler { Line 721  sub handler {
         return OK;          return OK;
     }      }
                                                                                                                                                                       
     if (&Apache::lonnet::allowed('ccc',$ENV{'request.role.domain'})) {      if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
         &Apache::loncommon::content_type($r,'text/html');          &Apache::loncommon::content_type($r,'text/html');
         $r->send_http_header;          $r->send_http_header;
   
         &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','course']);          &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','course']);
         my $dom = $ENV{'user.domain'};          my $dom = $env{'user.domain'};
         my %longtype=&Apache::lonlocal::texthash(          my %longtype=&Apache::lonlocal::texthash(
                        'authtype' => 'Default authentication method',                         'authtype' => 'Default authentication method',
                        'autharg'  => 'Default authentication parameter',                         'autharg'  => 'Default authentication parameter',
                        'autoadds' => 'Automated adds',                         'autoadds' => 'Automated adds',
                        'autodrops' => 'Automated drops',                         'autodrops' => 'Automated drops',
                        'autostart' => 'Date of first enrollment',                         'autostart' => 'Date of first automated enrollment',
                        'autoend' => 'Date of last enrollment',                         'autoend' => 'Date of last automated enrollment',
                          'default_enrollment_start_date' => 'Date of first student access',
                          'default_enrollment_end_date' => 'Date of last student access',
                        'coursecode' => 'Official course code',                         'coursecode' => 'Official course code',
                        'courseowner' => "Username of course owner (\@$dom)",                         'courseowner' => "Username of course owner (\@$dom)",
                        'notifylist' => 'Course Coordinators to be notified of enrollment changes',                         'notifylist' => 'Course Coordinators to be notified of enrollment changes',
Line 656  sub handler { Line 748  sub handler {
                         'process'  => 'Results of changes',                          'process'  => 'Results of changes',
                        );                         );
                                                                                                                                                                       
         if ($ENV{'form.action'} eq 'process') {          if ($env{'form.action'} eq 'process') {
             &modify_course($r,\%tasklong,\%longtype);              &modify_course($r,\%tasklong,\%longtype);
         } elsif ($ENV{'form.action'} eq 'display')  {          } elsif ($env{'form.action'} eq 'display')  {
             &print_course_modification_page($r,\%tasklong,\%longtype);              &print_course_modification_page($r,\%tasklong,\%longtype);
         } else {          } else {
             &print_course_selection_page($r,\%tasklong);              &print_course_selection_page($r,\%tasklong);
         }          }
     } else {      } else {
         $ENV{'user.error.msg'}=          $env{'user.error.msg'}=
         "/adm/modifycourse:ccc:0:0:Cannot modify course settings";          "/adm/modifycourse:ccc:0:0:Cannot modify course settings";
         return HTTP_NOT_ACCEPTABLE;          return HTTP_NOT_ACCEPTABLE;
     }      }

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


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