Diff for /loncom/interface/lonmodifycourse.pm between versions 1.28 and 1.33

version 1.28, 2006/11/14 20:38:21 version 1.33, 2007/10/03 19:57:29
Line 67  sub get_enrollment_settings { Line 67  sub get_enrollment_settings {
                 } else {                  } else {
                     $enrollvar{$type} = localtime($settings{$item});                      $enrollvar{$type} = localtime($settings{$item});
                 }                  }
             } elsif ($type eq "sectionums") {              } elsif ($type eq "sectionnums") {
                 $enrollvar{$type} = $settings{$item};                  $enrollvar{$type} = $settings{$item};
                 $enrollvar{$type} =~ s/,/, /g;                  $enrollvar{$type} =~ s/,/, /g;
             } elsif ($type eq "authtype"              } elsif ($type eq "authtype"
Line 138  sub print_course_selection_page { Line 138  sub print_course_selection_page {
                       'ownerdomfilter','coursefilter'];                        'ownerdomfilter','coursefilter'];
     my %filter;      my %filter;
     my $type = $env{'form.type'};      my $type = $env{'form.type'};
       if ($type eq '') {
           $type = 'Course';
       }
     my $action = '/adm/modifycourse';      my $action = '/adm/modifycourse';
     my $dctitle = &Apache::lonnet::plaintext('dc');      my $dctitle = &Apache::lonnet::plaintext('dc');
     $r->print(&mt('Revise your search criteria for this domain').' ('.$domdesc.').<br /><br />');      $r->print(&mt('Revise your search criteria for this domain').' ('.$domdesc.').<br /><br />');
Line 310  all settings except course code, course Line 313  all settings except course code, course
             'usrd' => 'Use the radio buttons to select a different course owner.',              'usrd' => 'Use the radio buttons to select a different course owner.',
             'deam' => "Default Authentication method",              'deam' => "Default Authentication method",
             'deus' => "The default authentication method, and default authentication parameter (domain, initial password or argument) are used when automatic enrollment of students in a course requires addition of new user accounts in your domain, and the class list file contains empty entries for the &lt;authtype&gt; and &lt;autharg&gt; properties for the new student. If you choose 'internally authenticated', and leave the initial password field empty, the automated enrollment process will create a randomized password for each new student account that it adds to your LON-CAPA domain.",              'deus' => "The default authentication method, and default authentication parameter (domain, initial password or argument) are used when automatic enrollment of students in a course requires addition of new user accounts in your domain, and the class list file contains empty entries for the &lt;authtype&gt; and &lt;autharg&gt; properties for the new student. If you choose 'internally authenticated', and leave the initial password field empty, the automated enrollment process will create a randomized password for each new student account that it adds to your LON-CAPA domain.",
             'gobt' => "Modify settings",              'gobt' => "Save",
     );      );
     my @bgcolors = ('#eeeeee','#cccccc');      my @bgcolors = ('#eeeeee','#cccccc');
   
Line 365  all settings except course code, course Line 368  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);      my $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,
Line 374  all settings except course code, course Line 377  all settings except course code, course
            curr_authtype => $curr_authtype,             curr_authtype => $curr_authtype,
            curr_autharg => $enrollvar{'autharg'}              curr_autharg => $enrollvar{'autharg'} 
  );   );
     my $krbform = &Apache::loncommon::authform_kerberos(%param);      my (%authform,$authenitems);
     my $intform = &Apache::loncommon::authform_internal(%param);      $authform{'krb'} = &Apache::loncommon::authform_kerberos(%param);
     my $locform = &Apache::loncommon::authform_local(%param);      $authform{'int'} = &Apache::loncommon::authform_internal(%param);
       $authform{'loc'} = &Apache::loncommon::authform_local(%param);
       foreach my $item ('krb','int','loc') {
           if ($authform{$item} ne '') {
               $authenitems .= $authform{$item}.'<br />';
           }
       } 
     if ($numlocalcc == 0) {      if ($numlocalcc == 0) {
         $ownertable = $lt{'nocc'};          $ownertable = $lt{'nocc'};
     }      }
Line 421  all settings except course code, course Line 429  all settings except course code, course
     }      }
     &print_header($r,$cdesc,$javascript_validations);      &print_header($r,$cdesc,$javascript_validations);
     my $type = $env{'form.type'};      my $type = $env{'form.type'};
       if ($type eq '') {
           $type = 'Course';
       }
     my $dctitle = &Apache::lonnet::plaintext('dc');      my $dctitle = &Apache::lonnet::plaintext('dc');
     my $cctitle = &Apache::lonnet::plaintext('cc',$type);      my $cctitle = &Apache::lonnet::plaintext('cc',$type);
     my $mainheader = &mt('Course settings modifiable by [_1] only.',$dctitle);      my $mainheader = &mt('Course settings modifiable by [_1] only.',$dctitle);
     my $hidden_elements = &hidden_form_elements();      my $hidden_elements = &hidden_form_elements();
     $r->print(<<ENDDOCUMENT);      $r->print(<<ENDDOCUMENT);
 <form action="/adm/modifycourse" method="post" name="setparms">  <form action="/adm/modifycourse" method="post" name="cmod">
 <h3>$mainheader</h3>  <h3>$mainheader</h3>
 </p><p>  </p><p>
 <table width="100%" cellspacing="6" cellpadding="6">  <table width="100%" cellspacing="6" cellpadding="6">
  <tr>   <tr>
   <td colspan="2">Use the appropriate text boxes and radio buttons below to change some or all of the four automated enrollment settings that may only be changed by a Domain Coordinator. Click the <b>"$lt{'gobt'}"</b> button to save your changes.</td>    <td colspan="2">Use the appropriate text boxes and radio buttons below to change some or all of the four automated enrollment settings that may only be changed by a Domain Coordinator.
  </tr>   </tr>
  <tr>   <tr>
   <td width="50%" valign="top">    <td width="50%" valign="top">
Line 449  all settings except course code, course Line 460  all settings except course code, course
  <tr>   <tr>
   <td width="50%" valign="top">    <td width="50%" valign="top">
    <b>$lt{'deam'}:</b><br/><br/>     <b>$lt{'deam'}:</b><br/><br/>
    $krbform     $authenitems
    <br/>  
    $intform  
    <br/>  
    $locform  
    <br/>  
    <br/>     <br/>
    $lt{'deus'}.     $lt{'deus'}.
    </td>     </td>
Line 477  ENDDOCUMENT Line 483  ENDDOCUMENT
 }  }
   
 sub modify_course {  sub modify_course {
     my ($r,$cdom,$cnum,$cdesc,$domdesc) = @_;      my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
     my %longtype = &course_settings_descrip();      my %longtype = &course_settings_descrip();
     my %settings = &Apache::lonnet::get('environment',['internal.courseowner','internal.coursecode','internal.authtype','internal.autharg','internal.sectionnums','internal.crosslistings','description'],$cdom,$cnum);      my %settings = &Apache::lonnet::get('environment',['internal.courseowner','internal.coursecode','internal.authtype','internal.autharg','internal.sectionnums','internal.crosslistings','description'],$cdom,$cnum);
     my %currattr = ();      my %currattr = ();
Line 554  sub modify_course { Line 560  sub modify_course {
         }          }
     }      }
     if ($changeowner == 1 || $changecode == 1) {      if ($changeowner == 1 || $changecode == 1) {
         my $courseid_entry = &escape($cdom.'_'.$cnum).'='.&escape($description).':'.&escape($env{'form.coursecode'}).':'.&escape($env{'form.courseowner'});          my $courseid_entry = &escape($cdom.'_'.$cnum).'='.&escape($description).':'.&escape($env{'form.coursecode'}).':'.&escape($env{'form.courseowner'}).':'.&escape($type);
         &Apache::lonnet::courseidput($cdom,$courseid_entry,&Apache::lonnet::homeserver($cnum,$cdom));          my %courseid_entry = (
                $cdom.'_'.$cnum => {
                                   description => &escape($description),
                                   inst_code   => &escape($env{'form.coursecode'}),
                                   owner       => &escape($env{'form.courseowner'}),
                                   type        => &escape($type),
                                  },
           );
           &Apache::lonnet::courseidput($cdom,\%courseid_entry,
                                        &Apache::lonnet::homeserver($cnum,$cdom));
     }      }
   
     foreach my $param (@modifiable_params) {      foreach my $param (@modifiable_params) {
         if ($currattr{$param} eq $newattr{$param}) {          if ($currattr{$param} eq $newattr{$param}) {
             push(@nochanges,$param);              push(@nochanges,$param);
Line 567  sub modify_course { Line 581  sub modify_course {
             push(@changes,$param);              push(@changes,$param);
         }          }
     }      }
   
     if (@changes > 0) {      if (@changes > 0) {
         $chgresponse = &mt("The following automated enrollment parameters have been changed:<br/><ul>");          $chgresponse = &mt("The following automated enrollment parameters have been changed:<br/><ul>");
     }      }
     if (@nochanges > 0) {       if (@nochanges > 0) { 
         $nochgresponse = &mt("The following automated enrollment parameters remain unchanged:<br/><ul>");          $nochgresponse = &mt("The following automated enrollment parameters remain unchanged:<br/><ul>");
     }      }
     if (@changes > 0) {       if (@changes > 0) {
         my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);          my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
         if ($putreply !~ /^ok$/) {          if ($putreply !~ /^ok$/) {
             $response = &mt("There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>");              $response = &mt("There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>").&mt('Error: ').$putreply;
         } else {          } else {
             foreach my $attr (@modifiable_params) {              foreach my $attr (@modifiable_params) {
                 if (grep/^$attr$/,@changes) {                  if (grep/^$attr$/,@changes) {
Line 798  sub check_course { Line 811  sub check_course {
         my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});          my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
         if ($cdom eq $dom) {          if ($cdom eq $dom) {
             my %courseIDs = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',              my %courseIDs = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
                                                           $cnum,undef,undef,'.');                                                 $cnum,undef,undef,'.');
             if (keys(%courseIDs) > 0) {              if (keys(%courseIDs) > 0) {
                 $ok_course = 'ok';                  $ok_course = 'ok';
                 ($description,$instcode,$owner) =                   my ($description,$instcode,$owner);
                   if (ref($courseIDs{$cdom.'_'.$cnum}) eq 'HASH') {
                       $description = $courseIDs{$cdom.'_'.$cnum}{'description'};
                       $instcode = $courseIDs{$cdom.'_'.$cnum}{'inst_code'};
                       $owner = $courseIDs{$cdom.'_'.$cnum}{'owner'};          
                   } else {
                       ($description,$instcode,$owner) = 
                                        split(/:/,$courseIDs{$cdom.'_'.$cnum});                                         split(/:/,$courseIDs{$cdom.'_'.$cnum});
                   }
                 $description = &unescape($description);                  $description = &unescape($description);
                 $instcode = &unescape($instcode);                  $instcode = &unescape($instcode);
                 if ($instcode) {                  if ($instcode) {
Line 811  sub check_course { Line 831  sub check_course {
             }              }
         }          }
     }      }
   
     if ($ok_course ne 'ok') {  
         $r->print('<br/>'.&mt('The LON-CAPA course selected was not a valid course for the [_1] domain',$domdesc));  
     }  
     return ($ok_course,$description);      return ($ok_course,$description);
 }  }
   
Line 853  sub handler { Line 869  sub handler {
         return OK;          return OK;
     }      }
     my $dom = $env{'request.role.domain'};      my $dom = $env{'request.role.domain'};
     my $domdesc = $Apache::lonnet::domaindescription{$dom};       my $domdesc = &Apache::lonnet::domain($dom,'description');
     if (&Apache::lonnet::allowed('ccc',$dom)) {      if (&Apache::lonnet::allowed('ccc',$dom)) {
         &Apache::loncommon::content_type($r,'text/html');          &Apache::loncommon::content_type($r,'text/html');
         $r->send_http_header;          $r->send_http_header;
Line 878  sub handler { Line 894  sub handler {
                   text=>"Pick action"});                    text=>"Pick action"});
                 my ($checked,$cdesc) = &check_course($r,$dom,$domdesc);                  my ($checked,$cdesc) = &check_course($r,$dom,$domdesc);
                 my $type = $env{'form.type'};                  my $type = $env{'form.type'};
                   if ($type eq '') {
                       $type = 'Course';
                   }
                 if ($checked eq 'ok') {                  if ($checked eq 'ok') {
                     if ($phase eq 'menu') {                      if ($phase eq 'menu') {
                         &print_modification_menu($r,$cdesc);                          &print_modification_menu($r,$cdesc);
Line 913  sub handler { Line 932  sub handler {
                             &Apache::lonhtmlcommon::add_breadcrumb                              &Apache::lonhtmlcommon::add_breadcrumb
                             ({href=>"javascript:changePage(document.$phase,'$phase')",                              ({href=>"javascript:changePage(document.$phase,'$phase')",
                               text=>"Result"});                                text=>"Result"});
                             &modify_course($r,$cdom,$cnum,$cdesc,$domdesc);                              &modify_course($r,$cdom,$cnum,$cdesc,$domdesc,$type);
                         }                          }
                     }                      }
                 } else {                  } else {
                     $r->print(&mt('The course you selected is not a valid course in this domain')." ($domdesc)");                       $r->print('<span class="LC_error">'.&mt('The course you selected is not a valid course in this domain')." ($domdesc)".'</span>'); 
                 }                  }
             }              }
         }          }

Removed from v.1.28  
changed lines
  Added in v.1.33


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