Diff for /loncom/interface/lonmodifycourse.pm between versions 1.50 and 1.55

version 1.50, 2010/03/08 22:31:27 version 1.55, 2010/05/28 17:09:06
Line 208  sub print_course_selection_page { Line 208  sub print_course_selection_page {
 sub print_modification_menu {  sub print_modification_menu {
     my ($r,$cdesc,$domdesc,$dom,$type) = @_;      my ($r,$cdesc,$domdesc,$dom,$type) = @_;
     &print_header($r,$type);      &print_header($r,$type);
     my ($ccrole,$setquota_text,$setparams_text,$cat_text);      my ($ccrole,$categorytitle,$setquota_text,$setparams_text,$cat_text);
     if ($type eq 'Community') {      if ($type eq 'Community') {
         $ccrole = 'co';          $ccrole = 'co';
     } else {      } else {
         $ccrole = 'cc';          $ccrole = 'cc';
     }       } 
     my $action = '/adm/modifycourse';  
     if ($type eq 'Community') {      if ($type eq 'Community') {
           $categorytitle = 'View/Modify Community Settings';
         $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a community.');          $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a community.');
         $setparams_text = 'View/Modify community owner';          $setparams_text = 'View/Modify community owner';
         $cat_text = 'View/Modify catalog settings for community';          $cat_text = 'View/Modify catalog settings for community';
     } else {      } else {
           $categorytitle = 'View/Modify Course Settings';
         $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a course.');          $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a course.');
         $setparams_text = 'View/Modify course owner, institutional code, and default authentication';          $setparams_text = 'View/Modify course owner, institutional code, and default authentication';
         $cat_text = 'View/Modify catalog settings for course';           $cat_text = 'View/Modify catalog settings for course'; 
     }      }
     my @menu =  
         (  
           { text => $setparams_text,  
              phase => 'setparms',  
           },  
           { text  => 'View/Modify quota for group portfolio files',  
             phase => 'setquota',  
           }  
     );  
     my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);      my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
     my @additional_params = &catalog_settable($domconf{'coursecategories'},$type);      my @additional_params = &catalog_settable($domconf{'coursecategories'},$type);
     if (@additional_params > 0) {  
         push (@menu, { text => $cat_text,      sub phaseurl {
                        phase => 'catsettings',          my $phase = shift;
                      });          return "javascript:changePage(document.menu,'$phase')"
     }      }
     unless ($type eq 'Community') {      my @menu =
         push(@menu,          ({  categorytitle => $categorytitle,
            { text  => 'Display current settings for automated enrollment',          items => [
             phase => 'viewparms',              {
            }                  linktext => $setparams_text,
                   url => &phaseurl('setparms'),
                   permission => 1,
                   #help => '',
                   icon => 'crsconf.png',
                   linktitle => ''
               },
               {
                   linktext => 'View/Modify quota for group portfolio files',
                   url => &phaseurl('setquota'),
                   permission => 1,
                   #help => '',
                   icon => 'groupportfolioquota.png',
                   linktitle => ''
               },
               {
                   linktext => $cat_text,
                   url => &phaseurl('catsettings'),
                   permission => (@additional_params > 0),
                   #help => '',
                   icon => 'ccatconf.png',
                   linktitle => ''
               },
               {
                   linktext => 'Display current settings for automated enrollment',
                   url => &phaseurl('viewparms'),
                   permission => ($type ne 'Community'),
                   #help => '',
                   icon => 'roles.png',
                   linktitle => ''
               },
           ]
           },
         );          );
     }  
     my $menu_html = '<h3>'.&mt('View/Modify settings for: ').      my $menu_html =
                     ' <span class="LC_nobreak">'.$cdesc.'</span></h3>'."\n";          '<h3>'
          .&mt('View/Modify settings for: [_1]',
                   '<span class="LC_nobreak">'.$cdesc.'</span>')
          .'</h3>'."\n".'<p>';
     if ($type eq 'Community') {      if ($type eq 'Community') {
         $menu_html .= &mt('Although almost all community settings can be modified by a Coordinator, the following may only be set or modified by a Domain Coordinator:');          $menu_html .= &mt('Although almost all community settings can be modified by a Coordinator, the following may only be set or modified by a Domain Coordinator:');
     } else {      } else {
         $menu_html .= &mt('Although almost all course settings can be modified by a Course Coordinator, the following may only be set or modified by a Domain Coordinator:');          $menu_html .= &mt('Although almost all course settings can be modified by a Course Coordinator, the following may only be set or modified by a Domain Coordinator:');
     }      }
     $menu_html .= '<ul>';      $menu_html .= '</p>'."\n".'<ul>';
     if ($type eq 'Community') {      if ($type eq 'Community') {
         $menu_html .= '<li>'.&mt('Community owner (permitted to assign Coordinator roles in the community).').'</li>';          $menu_html .= '<li>'.&mt('Community owner (permitted to assign Coordinator roles in the community).').'</li>';
     } else {      } else {
Line 265  sub print_modification_menu { Line 293  sub print_modification_menu {
     foreach my $item (@additional_params) {      foreach my $item (@additional_params) {
         if ($type eq 'Community') {          if ($type eq 'Community') {
             if ($item eq 'togglecats') {              if ($item eq 'togglecats') {
                 $menu_html .= '  <li>'.&mt('Hiding/unhiding a community from the catalog (although can be [_1]configured[_2] to be modifiable by a Coordinator in community context).','<a href="/adm/domainprefs?actions=coursecategories&phase=display">','</a>').'</li>'."\n";                  $menu_html .= '  <li>'.&mt('Hiding/unhiding a community from the catalog (although can be [_1]configured[_2] to be modifiable by a Coordinator in community context).','<a href="/adm/domainprefs?actions=coursecategories&amp;phase=display">','</a>').'</li>'."\n";
             } elsif ($item eq 'categorize') {              } elsif ($item eq 'categorize') {
                 $menu_html .= '  <li>'.&mt('Manual cataloging of a community (although can be [_1]configured[_2] to be modifiable by a Coordinator in community context).','<a href="/adm/domainprefs?actions=coursecategories&phase=display">','</a>').'</li>'."\n";                  $menu_html .= '  <li>'.&mt('Manual cataloging of a community (although can be [_1]configured[_2] to be modifiable by a Coordinator in community context).','<a href="/adm/domainprefs?actions=coursecategories&amp;phase=display">','</a>').'</li>'."\n";
             }              }
         } else {          } else {
             if ($item eq 'togglecats') {              if ($item eq 'togglecats') {
                 $menu_html .= '  <li>'.&mt('Hiding/unhiding a course from the course catalog (although can be [_1]configured[_2] to be modifiable by a Course Coordinator in course context).','<a href="/adm/domainprefs?actions=coursecategories&phase=display">','</a>').'</li>'."\n";                  $menu_html .= '  <li>'.&mt('Hiding/unhiding a course from the course catalog (although can be [_1]configured[_2] to be modifiable by a Course Coordinator in course context).','<a href="/adm/domainprefs?actions=coursecategories&amp;phase=display">','</a>').'</li>'."\n";
             } elsif ($item eq 'categorize') {              } elsif ($item eq 'categorize') {
                 $menu_html .= '  <li>'.&mt('Manual cataloging of a course (although can be [_1]configured[_2] to be modifiable by a Course Coordinator in course context).','<a href="/adm/domainprefs?actions=coursecategories&phase=display">','</a>').'</li>'."\n";                  $menu_html .= '  <li>'.&mt('Manual cataloging of a course (although can be [_1]configured[_2] to be modifiable by a Course Coordinator in course context).','<a href="/adm/domainprefs?actions=coursecategories&amp;phase=display">','</a>').'</li>'."\n";
             }              }
         }          }
     }      }
     $menu_html .= ' </ul>      $menu_html .=
 <form name="menu" method="post" action="'.$action.'" />'."\n".          ' </ul>'
     &hidden_form_elements();         .'<form name="menu" method="post" action="/adm/modifycourse">'
     foreach my $menu_item (@menu) {         ."\n"
         $menu_html.='<h3>';         .&hidden_form_elements();
         $menu_html.=  
                 qq|<a href="javascript:changePage(document.menu,'$menu_item->{'phase'}')">|;  
         $menu_html.= &mt($menu_item->{'text'}).'</a>';  
         $menu_html.='</h3>';  
     }  
           
     $r->print($menu_html);      $r->print($menu_html);
       $r->print(&Apache::lonhtmlcommon::generate_menu(@menu));
       $r->print('</form>');
     return;      return;
 }  }
   
Line 779  sub modify_course { Line 804  sub modify_course {
                                         my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'});                                          my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'});
                 unless ($outcome eq 'ok') {                  unless ($outcome eq 'ok') {
                                                                 
             push(@warnings,&mt('If automatic enrollment is enabled for "[_1]" automated enrollment may fail for "[_2]" - section: [_3], for the following reason: "[_4]"',$description,$newattr{'coursecode'},$instsec,$outcome).'<br/>');              push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$outcome).'<br/>');
                 }                  }
             } else {              } else {
                                         push(@warnings,&mt('If automatic enrollment is enabled for "[_1]" automated enrollment may fail for "[_2]" - section: [_3], for the following reason: "[_4]"',$description,$newattr{'coursecode'},$instsec,$course_check));                                          push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$course_check));
             }              }
                 } else {                  } else {
             push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3], because this is not a valid section entry.',$description,$newattr{'coursecode'},$sec));              push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3], because this is not a valid section entry.',$description,$newattr{'coursecode'},$sec));
Line 795  sub modify_course { Line 820  sub modify_course {
                                     my $inst_course_id = $newattr{'coursecode'}.$instsec;                                      my $inst_course_id = $newattr{'coursecode'}.$instsec;
                                     my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'});                                      my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'});
                                     unless ($outcome eq 'ok') {                                      unless ($outcome eq 'ok') {
                                         push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$outcome));                                          push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$outcome));
                                     }                                      }
                                 } else {                                  } else {
                                     push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section [_3] because this is not a valid section entry.',$description,$newattr{'coursecode'},$sec));                                      push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3], because this is not a valid section entry.',$description,$newattr{'coursecode'},$sec));
                                 }                                  }
                             }                              }
                         }                          }
             } else {              } else {
                 push(@warnings,&mt('As no section numbers are currently listed for "[_1]" automated enrollment will not occur for any sections of institutional course code: "[_2]".',$description,$newattr{'coursecode'}));                  push(@warnings,&mt('As no section numbers are currently listed for "[_1]", automated enrollment will not occur for any sections of institutional course code: "[_2]".',$description,$newattr{'coursecode'}));
             }              }
             if ( (@xlists > 0) && ($changed{'owner'}) ) {              if ( (@xlists > 0) && ($changed{'owner'}) ) {
                 foreach my $xlist (@xlists) {                  foreach my $xlist (@xlists) {
Line 877  sub update_coowners { Line 902  sub update_coowners {
     }      }
     if ($settings->{'internal.courseowner'} ne $newattr->{'courseowner'}) {      if ($settings->{'internal.courseowner'} ne $newattr->{'courseowner'}) {
         my $oldowner_to_coowner;          my $oldowner_to_coowner;
           my @types = ('co-owners');
         if (($newattr->{'coursecode'}) && ($autocoowners)) {          if (($newattr->{'coursecode'}) && ($autocoowners)) {
             my $oldowner = $settings->{'internal.courseowner'};              my $oldowner = $settings->{'internal.courseowner'};
             if ($cchash{$oldowner.':cc'}) {              if ($cchash{$oldowner.':cc'}) {
                 if ($settings->{'internal.co-owner'}) {                  my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$oldowner);
                     my @current = split(',',$settings->{'internal.co-owners'});                  if ($result eq 'valid') {
                     unless (grep(/^\Q$oldowner\E$/,@current)) {                      if ($settings->{'internal.co-owner'}) {
                           my @current = split(',',$settings->{'internal.co-owners'});
                           unless (grep(/^\Q$oldowner\E$/,@current)) {
                               $oldowner_to_coowner = 1;
                           }
                       } else {
                         $oldowner_to_coowner = 1;                          $oldowner_to_coowner = 1;
                     }                      }
                 } else {  
                     $oldowner_to_coowner = 1;  
                 }                  }
             }              }
           } else {
               push(@types,'pendingco-owners');
         }          }
         foreach my $type ('co-owners','pendingco-owners') {          foreach my $type (@types) {
             if ($settings->{'internal.'.$type}) {              if ($settings->{'internal.'.$type}) {
                 my @current = split(',',$settings->{'internal.'.$type});                  my @current = split(',',$settings->{'internal.'.$type});
                 my $newowner = $newattr->{'courseowner'};                  my $newowner = $newattr->{'courseowner'};
Line 925  sub update_coowners { Line 956  sub update_coowners {
                             my %pendinghash = (                              my %pendinghash = (
                                 'internal.pendingco-owners' => $pendingcoowners,                                  'internal.pendingco-owners' => $pendingcoowners,
                             );                              );
                             my $putresult = &put('environment',\%pendinghash,$cdom,$cnum);                              my $putresult = &Apache::lonnet::put('environment',\%pendinghash,$cdom,$cnum);
                             if ($putresult eq 'ok') {                              if ($putresult eq 'ok') {
                                 if ($env{'course.'.$cid.'.num'} eq $cnum) {                                  if ($env{'course.'.$cid.'.num'} eq $cnum) {
                                     &appenv({'course.'.$cid.'.internal.pendingco-owners' => $pendingcoowners});                                      &Apache::lonnet::appenv({'course.'.$cid.'.internal.pendingco-owners' => $pendingcoowners});
                                 }                                  }
                             }                              }
                         } else {                          } else {
Line 960  sub update_coowners { Line 991  sub update_coowners {
                     my @currcoown = split(',',$settings->{'internal.coowners'});                      my @currcoown = split(',',$settings->{'internal.coowners'});
                     my ($updatecoowners,$delcoowners);                      my ($updatecoowners,$delcoowners);
                     foreach my $person (@currcoown) {                      foreach my $person (@currcoown) {
                         my ($result,$desc) = &Apache::lonnet::valid_instcode();                          my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$person);
                         if ($result eq 'valid') {                          if ($result eq 'valid') {
                             push(@newcoowners,$person);                              push(@newcoowners,$person);
                         }                          }
                     }                      }
                     foreach my $item (sort(keys(%cchash))) {                      foreach my $item (sort(keys(%cchash))) {
                         my ($uname,$udom,$urole) = split(':',$item);                          my ($uname,$udom,$urole) = split(':',$item);
                           next if ($uname.':'.$udom eq $newattr->{'courseowner'});
                         unless (grep(/^\Q$uname\E:\Q$udom\E$/,@newcoowners)) {                          unless (grep(/^\Q$uname\E:\Q$udom\E$/,@newcoowners)) {
                             push(@newcoowners,$uname.':'.$udom);                              my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$uname.':'.$udom);
                               if ($result eq 'valid') {
                                   push(@newcoowners,$uname.':'.$udom);
                               }
                         }                          }
                     }                      }
                     if (@newcoowners) {                      if (@newcoowners) {

Removed from v.1.50  
changed lines
  Added in v.1.55


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