[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface lonmodifycourse.pm

raeburn raeburn at source.lon-capa.org
Tue Aug 27 11:34:34 EDT 2019


raeburn		Tue Aug 27 15:34:34 2019 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonmodifycourse.pm 
  Log:
  - For 2.11
    Backport 1.94
  
  
-------------- next part --------------
Index: loncom/interface/lonmodifycourse.pm
diff -u loncom/interface/lonmodifycourse.pm:1.79.2.7 loncom/interface/lonmodifycourse.pm:1.79.2.8
--- loncom/interface/lonmodifycourse.pm:1.79.2.7	Fri Jul 26 17:43:54 2019
+++ loncom/interface/lonmodifycourse.pm	Tue Aug 27 15:34:34 2019
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # handler for DC-only modifiable course settings
 #
-# $Id: lonmodifycourse.pm,v 1.79.2.7 2019/07/26 17:43:54 raeburn Exp $
+# $Id: lonmodifycourse.pm,v 1.79.2.8 2019/08/27 15:34:34 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -52,6 +52,10 @@
         if (&showcredits($cdom)) {
             push(@items,'defaultcredits');
         }
+        my %passwdconf = &Apache::lonnet::get_passwdconf($cdom);
+        if (($passwdconf{'crsownerchg'}) && ($type ne 'Placement')) {
+            push(@items,'nopasswdchg');
+        }
         return @items;
     }
 }
@@ -97,6 +101,7 @@
         @items = map { 'internal.'.$_; } (@{$internals});
         push(@items,@{$accessdates});
     }
+    push(@items,'internal.nopasswdchg');
     my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
     my %enrollvar;
     $enrollvar{'autharg'} = '';
@@ -122,7 +127,7 @@
             } elsif ($type eq "authtype"
                      || $type eq "autharg"    || $type eq "coursecode"
                      || $type eq "crosslistings" || $type eq "selfenrollmgr"
-                     || $type eq "autodropfailsafe") {
+                     || $type eq "autodropfailsafe" || $type eq 'nopasswdchg') {
                 $enrollvar{$type} = $settings{$item};
             } elsif ($type eq 'defaultcredits') {
                 if (&showcredits($cdom)) {
@@ -1014,6 +1019,7 @@
     my @specific_managebydc = split(/,/,$settings{'internal.selfenrollmgrdc'});
     my @specific_managebycc = split(/,/,$settings{'internal.selfenrollmgrcc'});
     my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
+    my %passwdconf = &Apache::lonnet::get_passwdconf($cdom);
     my @default_managebydc = split(/,/,$domdefaults{$type.'selfenrolladmdc'});
     if ($crstype eq 'Community') {
         $ccrole = 'co';
@@ -1088,7 +1094,8 @@
     if ($crstype eq 'Community') {
         $r->print(&Apache::lonhtmlcommon::row_title(
                   &Apache::loncommon::help_open_topic('Modify_Community_Owner').
-                  ' '.&mt('Community Owner'))."\n");
+                  ' '.&mt('Community Owner'))."\n".
+                  $ownertable."\n".&Apache::lonhtmlcommon::row_closure());
     } else {
         $r->print(&Apache::lonhtmlcommon::row_title(
                       &Apache::loncommon::help_open_topic('Modify_Course_Instcode').
@@ -1098,7 +1105,7 @@
         if (&showcredits($cdom)) {
             $r->print(&Apache::lonhtmlcommon::row_title(
                           &Apache::loncommon::help_open_topic('Modify_Course_Credithours').
-                      ' '.&mt('Credits (students)'))."\n".
+                          ' '.&mt('Credits (students)'))."\n".
                       '<input type="text" size="3" name="defaultcredits" value="'.$enrollvar{'defaultcredits'}.'"'.$disabled.' />'.
                       &Apache::lonhtmlcommon::row_closure());
         }
@@ -1108,8 +1115,21 @@
                   $authenitems."\n".
                   &Apache::lonhtmlcommon::row_closure().
                   &Apache::lonhtmlcommon::row_title(
-                  &Apache::loncommon::help_open_topic('Modify_Course_Owner').
-                     ' '.&mt('Course Owner'))."\n");
+                      &Apache::loncommon::help_open_topic('Modify_Course_Owner').
+                      ' '.&mt('Course Owner'))."\n".
+                  $ownertable."\n".&Apache::lonhtmlcommon::row_closure());
+        if (($passwdconf{'crsownerchg'}) && ($type ne 'Placement')) {
+            my $checked;
+            if ($enrollvar{'nopasswdchg'}) {
+                $checked = ' checked="checked"';
+            }
+            $r->print(&Apache::lonhtmlcommon::row_title(
+                         &Apache::loncommon::help_open_topic('Modify_Course_Chgpasswd').
+                         ' '.&mt('Changing passwords (internal)'))."\n".
+                         '<label><input type="checkbox" value="1" name="nopasswdchg"'.$checked.$disabled.' />'.
+                         &mt('Disable changing password for users with student role by course owner').'<label>'."\n".
+                         &Apache::lonhtmlcommon::row_closure());
+        }
     }
     my ($cctitle,$rolename,$currmanages,$ccchecked,$dcchecked,$defaultchecked);
     my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles();
@@ -1119,8 +1139,7 @@
         $cctitle = &mt('Course personnel');
     }
 
-    $r->print($ownertable."\n".&Apache::lonhtmlcommon::row_closure().
-              &Apache::lonhtmlcommon::row_title(
+    $r->print(&Apache::lonhtmlcommon::row_title(
               &Apache::loncommon::help_open_topic('Modify_Course_Selfenrolladmin').
                   ' '.&mt('Self-enrollment configuration')).
               &Apache::loncommon::start_data_table()."\n".
@@ -1299,6 +1318,10 @@
         if (&showcredits($cdom)) {  
             push(@items,'internal.defaultcredits');
         }
+        my %passwdconf = &Apache::lonnet::get_passwdconf($cdom);
+        if ($passwdconf{'crsownerchg'}) {
+            push(@items,'internal.nopasswdchg');
+        }
     }
     my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
     my $description = $settings{'description'};
@@ -1314,6 +1337,7 @@
     } else {
         %changed = ( code  => 0,
                      owner => 0,
+                     passwd => 0,
                    );
         $ccrole = 'cc';
         unless ($settings{'internal.sectionnums'} eq '') {
@@ -1366,9 +1390,21 @@
             $newattr{'mysqltables'} = $env{'form.mysqltables'};
             $newattr{'mysqltables'} =~ s/\D+//g;
         }
-        if (&showcredits($cdom) && exists($env{'form.defaultcredits'})) {
-            $newattr{'defaultcredits'}=$env{'form.defaultcredits'};
-            $newattr{'defaultcredits'} =~ s/[^\d\.]//g;
+        if ($type ne 'Placement') {
+            if (&showcredits($cdom) && exists($env{'form.defaultcredits'})) {
+                $newattr{'defaultcredits'}=$env{'form.defaultcredits'};
+                $newattr{'defaultcredits'} =~ s/[^\d\.]//g;
+            }
+            if (grep(/^nopasswdchg$/, at modifiable_params)) {
+                if ($env{'form.nopasswdchg'}) {
+                    $newattr{'nopasswdchg'} = 1;
+                    unless ($currattr{'nopasswdchg'}) {
+                        $changed{'passwd'} = 1;
+                    }
+                } elsif ($currattr{'nopasswdchg'}) {
+                    $changed{'passwd'} = 1;
+                }
+            }
         }
     }
 
@@ -1403,7 +1439,7 @@
         } 
     }
 
-    if ($changed{'owner'} || $changed{'code'}) {
+    if ($changed{'owner'} || $changed{'code'} || $changed{'passwd'}) {
         my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,
                                                     undef,undef,'.');
         if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
@@ -1413,9 +1449,16 @@
             if ($changed{'owner'}) {
                 $crsinfo{$env{'form.pickedcourse'}}{'owner'} = $env{'form.courseowner'};
             }
+            if ($changed{'passwd'}) {
+                if ($env{'form.nopasswdchg'}) {
+                    $crsinfo{$env{'form.pickedcourse'}}{'nopasswdchg'} = 1;
+                } else {
+                    delete($crsinfo{'nopasswdchg'});
+                }
+            }
             my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
             my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
-            if ($putres eq 'ok') {
+            if (($putres eq 'ok') && (($changed{'owner'} || $changed{'code'}))) {
                 &update_coowners($cdom,$cnum,$chome,\%settings,\%newattr);
                 if ($changed{'code'}) {
                     &Apache::lonnet::devalidate_cache_new('instcats',$cdom);
@@ -1474,6 +1517,12 @@
                         $shown = &mt('None');
                     } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
                         $shown = &mt('domain default');
+                    } elsif ($attr eq 'nopasswdchg') {
+                        if ($shown) {
+                            $shown = &mt('Yes');
+                        } else {
+                            $shown = &mt('No');
+                        }
                     }
                     $chgresponse .= '<li>'.&mt('[_1] now set to: [_2]',$longtype{$attr},$shown).'</li>';
                 } else {
@@ -1486,6 +1535,12 @@
                         $shown = &mt('None');
                     } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
                         $shown = &mt('domain default');
+                    } elsif ($attr eq 'nopasswdchg') {
+                        if ($shown) {
+                            $shown = &mt('Yes');
+                        } else {
+                            $shown = &mt('No');
+                        }
                     }
                     $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
                 }
@@ -2400,6 +2455,7 @@
                       'selfenrollmgrdc'  => "Course-specific self-enrollment configuration by Domain Coordinator",
                       'selfenrollmgrcc'  => "Course-specific self-enrollment configuration by Course personnel",
                       'mysqltables'      => '"Temporary" student performance tables lifetime (seconds)',
+                      'nopasswdchg' => 'Disable changing password for users with student role by course owner',
          );
     }
     return %longtype;
@@ -2412,7 +2468,8 @@
           'locarg','krbarg','krbver','counter','hidefromcat','usecategory',
           'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota',
           'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st',
-          'sections','newsec','mysqltables'],['^selfenrollmgr_','^selfenroll_'])."\n".
+          'sections','newsec','mysqltables','nopasswdchg'],
+          ['^selfenrollmgr_','^selfenroll_'])."\n".
           '<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />';
     return $hidden_elements;
 }
@@ -2428,6 +2485,7 @@
 sub get_permission {
     my ($dom) = @_;
     my ($allowed,%permission);
+    my %passwdconf = &Apache::lonnet::get_passwdconf($dom);
     if (&Apache::lonnet::allowed('ccc',$dom)) {
         $allowed = 1;
         %permission = (
@@ -2445,6 +2503,9 @@
             selfenroll        => 'edit',
             adhocrole         => 'coord',
         );
+        if ($passwdconf{'crsownerchg'}) {
+            $permission{passwdchg} = 'edit';
+        }
     } elsif (&Apache::lonnet::allowed('rar',$dom)) {
         $allowed = 1;
         %permission = (
@@ -2457,6 +2518,9 @@
             selfenroll    => 'view',
             adhocrole     => 'custom',
         );
+        if ($passwdconf{'crsownerchg'}) {
+            $permission{passwdchg} = 'view';
+        }
     }
     return ($allowed,\%permission);
 }


More information about the LON-CAPA-cvs mailing list