Diff for /loncom/interface/lonmodifycourse.pm between versions 1.104 and 1.105

version 1.104, 2023/12/23 02:17:38 version 1.105, 2024/04/14 17:12:27
Line 434  sub print_modification_menu { Line 434  sub print_modification_menu {
                       'setltiauth'    => 'View/Modify re-authentication requirement for LTI launch of deep-linked item',                        'setltiauth'    => 'View/Modify re-authentication requirement for LTI launch of deep-linked item',
                       'setexttool'    => 'View/Modify External Tools permissions',                        'setexttool'    => 'View/Modify External Tools permissions',
                       'setcrsauthor'  => 'View/Modify In-course Authoring permissions',                        'setcrsauthor'  => 'View/Modify In-course Authoring permissions',
                         'setcrseditors' => 'View/Modify permitted course resource editors',
                     );                      );
     } else {      } else {
         %linktext = (          %linktext = (
Line 444  sub print_modification_menu { Line 445  sub print_modification_menu {
                       'setltiauth'    => 'View re-authentication requirement for LTI launch of deep-linked item',                        'setltiauth'    => 'View re-authentication requirement for LTI launch of deep-linked item',
                       'setexttool'    => 'View External Tools permissions',                        'setexttool'    => 'View External Tools permissions',
                       'setcrsauthor'  => 'View In-course Authoring permissions',                        'setcrsauthor'  => 'View In-course Authoring permissions',
                         'setcrseditors' => 'View permitted course resource editors',
                     );                      );
     }      }
     if ($type eq 'Community') {      if ($type eq 'Community') {
Line 592  sub print_modification_menu { Line 594  sub print_modification_menu {
                 permission => $permission->{'setcrsauthor'},                  permission => $permission->{'setcrsauthor'},
                 linktitle => '',                  linktitle => '',
             },              },
               {
                   linktext => $linktext{'setcrseditors'},
                   icon => 'crseditors.png',
                   #help => '',
                   url => &phaseurl('setcrseditors'),
                   permission => $permission->{'setcrseditors'},
                   linktitle => '',
               },
         ]          ]
         },          },
         );          );
Line 1314  sub print_selfenrollconfig { Line 1324  sub print_selfenrollconfig {
 sub print_default_overrides {  sub print_default_overrides {
     my ($r,$cdom,$cnum,$cdesc,$type,$readonly,$item) = @_;      my ($r,$cdom,$cnum,$cdesc,$type,$readonly,$item) = @_;
     my (%titles,$checkeddom,$checkedcrs,$divsty,$currcrsval,$crsdefault,%crschecked,      my (%titles,$checkeddom,$checkedcrs,$divsty,$currcrsval,$crsdefault,%crschecked,
         $helpfile,$title,$crselements);          $helpfile,$title,$crselements,@currcrseditors);
     %titles = &default_overrides_titles($type);      %titles = &default_overrides_titles($type);
     my ($title,$domdefdisplay,$settings,$optiontext,$options) =      my ($title,$domdefdisplay,$settings,$optiontext,$options) =
         &default_overrides_common($item,$cdom,$cnum,$type,\%titles);          &default_overrides_common($item,$cdom,$cnum,$type,\%titles);
     $checkeddom = ' checked="checked"';      $checkeddom = ' checked="checked"';
     $divsty = 'display:none';      $divsty = 'display:none';
        
     if ($item eq 'ltiauth') {      if ($item eq 'ltiauth') {
         $helpfile = 'Modify_Course_LTI_Authen';          $helpfile = 'Modify_Course_LTI_Authen';
         $crsdefault = 0;          $crsdefault = 0;
Line 1330  sub print_default_overrides { Line 1341  sub print_default_overrides {
         } elsif ($item eq 'crsauthor') {          } elsif ($item eq 'crsauthor') {
             $helpfile = 'Modify_Course_Crsauthor';              $helpfile = 'Modify_Course_Crsauthor';
             $crsdefault = 1;              $crsdefault = 1;
           } elsif ($item eq 'crseditors') {
               $helpfile = 'Modify_Course_Resource_Editors';
               $crsdefault = 'edit,xml';
         }          }
     }      }
     $currcrsval = $settings->{'internal.'.$item};      $currcrsval = $settings->{'internal.'.$item};
Line 1337  sub print_default_overrides { Line 1351  sub print_default_overrides {
         $checkedcrs = $checkeddom;          $checkedcrs = $checkeddom;
         $checkeddom = '';          $checkeddom = '';
         $divsty = 'display:inline-block';          $divsty = 'display:inline-block';
           if ($item eq 'crseditors') {
               @currcrseditors = split(/,/,$currcrsval);
           }        
         foreach my $option (@{$options}) {          foreach my $option (@{$options}) {
             if ($currcrsval eq $option) {              if ($item eq 'crseditors') {
                   if (grep(/^\Q$option\E$/,@currcrseditors)) {
                       $crschecked{$option} = ' checked="checked"';
                   }
               } elsif ($currcrsval eq $option) {
                 $crschecked{$option} = ' checked="checked"';                  $crschecked{$option} = ' checked="checked"';
             } else {              } else {
                 $crschecked{$option} = '';                  $crschecked{$option} = '';
             }              }
         }          }
     } else {      } else {
           if ($item eq 'crseditors') {
               my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
               @currcrseditors = split(/,/,$domdefs{'crseditors'});
           } 
         foreach my $option (@{$options}) {          foreach my $option (@{$options}) {
             if ($crsdefault eq $option) {              if ($item eq 'crseditors') {
                   if (grep(/^\Q$option\E$/,@currcrseditors)) {
                       $crschecked{$option} = ' checked="checked"';
                   }
               } elsif ($crsdefault eq $option) {
                 $crschecked{$option} = ' checked="checked"';                  $crschecked{$option} = ' checked="checked"';
             } else {              } else {
                 $crschecked{$option} = '';                  $crschecked{$option} = '';
             }              }
         }          }
     }      }
     my ($disabled,$submit);      my ($disabled,$submit,$inputtype,$separator);
     if ($readonly) {      if ($readonly) {
         $disabled = ' disabled="disabled"';          $disabled = ' disabled="disabled"';
     } else {      } else {
         $submit = '<input type="button" onclick="javascript:changePage(this.form,'."'process${item}'".');" value="'.$titles{'modi'}.'" />';          $submit = '<input type="button" onclick="javascript:changePage(this.form,'."'process${item}'".');" value="'.$titles{'modi'}.'" />';
     }      }
       if ($item eq 'crseditors') {
           $inputtype = 'checkbox';
           $separator = '&nbsp;'x2;
       } else {
           $inputtype = 'radio';
           $separator = '<br />';
       }
     foreach my $option (@{$options}) {      foreach my $option (@{$options}) {
         $crselements .= '<span class="LC_nobreak">'.          $crselements .= '<span class="LC_nobreak">'.
                         '<label><input type="radio" name="'.$item.'" value="'.$option.'"'.                          '<label><input type="'.$inputtype.'" name="'.$item.'" value="'.$option.'"'.
                         $crschecked{$option}.$disabled.' />'.$optiontext->{$option}.'</label>'.                          $crschecked{$option}.$disabled.' />'.$optiontext->{$option}.'</label>'.
                         '</span><br />'."\n";                          '</span>'.$separator."\n";
     }      }
     &print_header($r,$type);      &print_header($r,$type);
     my $hidden_elements = &hidden_form_elements();      my $hidden_elements = &hidden_form_elements();
Line 1406  sub default_overrides_titles { Line 1442  sub default_overrides_titles {
                 'dom' => 'Only external tools defined in domain may be used',                  'dom' => 'Only external tools defined in domain may be used',
                 'both' => 'External tools defined/configured in either domain or course may be used',                  'both' => 'External tools defined/configured in either domain or course may be used',
                 'stan' => "'In-course' authoring of standard LON-CAPA problems",                  'stan' => "'In-course' authoring of standard LON-CAPA problems",
                   'perc' => 'Permitted course resource editors', 
                   'edit' => 'Standard editor (Edit)',
                   'xml'  => 'Text editor (EditXML)',
                   'daxe' => 'Daxe editor (Daxe)',
                 'on'   => 'In-course authoring available',                  'on'   => 'In-course authoring available',
                 'off'  => 'In-course authoring unavailable',                  'off'  => 'In-course authoring unavailable',
                 'used' => 'Use domain default',                  'used' => 'Use domain default',
Line 1454  sub default_overrides_common { Line 1494  sub default_overrides_common {
                             1 => $titles->{'on'},                              1 => $titles->{'on'},
                             0 => $titles->{'off'},                              0 => $titles->{'off'},
                           );                            );
           } elsif ($item eq 'crseditors') {
               $title = $titles->{'perc'};
               $domdef = 1;
               @options = ('edit','xml','daxe');
               map { $optiontext{$_} = $titles->{$_}; } @options;
         }          }
     }      }
     my %domconfig =      my %domconfig =
         &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);          &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
     if (ref($domconfig{'coursedefaults'}) eq 'HASH') {      if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
         if ($item eq 'ltiauth') {          if (($item eq 'ltiauth') || ($item eq 'crseditors')) {
             $domdef = $domconfig{'coursedefaults'}{$item};              $domdef = $domconfig{'coursedefaults'}{$item};
         } else {          } else {
             my $lctype = &get_lctype($type,\%settings);              my $lctype = &get_lctype($type,\%settings);
Line 1499  sub default_overrides_common { Line 1544  sub default_overrides_common {
         } else {          } else {
             $domdefdisplay = $titles->{'off'};              $domdefdisplay = $titles->{'off'};
         }          }
       } elsif ($item eq 'crseditors') {
           if (ref($domdef) eq 'ARRAY') {
               if (@{$domdef} == 0) {
                   $domdefdisplay = &mt('No permitted editors');
               } elsif (@{$domdef} == 1) {
                   $domdefdisplay = $titles->{$domdef->[0]}.' ('.&mt('only').')';
               } else {
                   $domdefdisplay = join(', ', map { $titles->{$_}; } @{$domdef});
               }
           } else {
               $domdefdisplay = join(', ', map { $titles->{$_}; } ('edit','xml'));
           }
     }      }
     return ($title,$domdefdisplay,\%settings,\%optiontext,\@options);      return ($title,$domdefdisplay,\%settings,\%optiontext,\@options);
 }  }
Line 2533  sub modify_default_overrides { Line 2590  sub modify_default_overrides {
                                          chg   => 'In-course authoring permissions changed',                                           chg   => 'In-course authoring permissions changed',
                                          nochg => 'In-course authoring permissions unchanged',                                           nochg => 'In-course authoring permissions unchanged',
                                        );                                         );
     }      } elsif ($item eq 'crseditors') {
           %resulttext =
               &Apache::lonlocal::texthash(
                                            chg   => 'Permitted course resource editors changed',
                                            nochg => 'Permitted course resource editors unchanged',
                                          );
       } 
     &print_header($r,$type);      &print_header($r,$type);
     $r->print('<h3>'.$title.'</h3>'."\n".      $r->print('<h3>'.$title.'</h3>'."\n".
               '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".                '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
Line 2545  sub modify_default_overrides { Line 2608  sub modify_default_overrides {
             $change = 1;              $change = 1;
         }          }
     } elsif ($env{'form.'.$item.'set'} eq 'course') {      } elsif ($env{'form.'.$item.'set'} eq 'course') {
         my $posscrsval = $env{'form.'.$item};          if ($item eq 'crseditors') {
         if (grep(/^\Q$posscrsval\E$/,@{$options})) {              my @neweditors;
             $newcrsval = $posscrsval;              my @posseditors = &Apache::loncommon::get_env_multiple('form.'.$item);
               foreach my $editor (@posseditors) {
                   if (grep(/^\Q$editor\E$/,@{$options})) {
                       push(@neweditors,$editor);
                   }
               }
               $newcrsval = join(',',@neweditors); 
           } else { 
               my $posscrsval = $env{'form.'.$item};
               if (grep(/^\Q$posscrsval\E$/,@{$options})) {
                   $newcrsval = $posscrsval;
               }
         }          }
         if ($oldcrsval eq $newcrsval) {          if ($oldcrsval eq $newcrsval) {
             $nochange = 1;              $nochange = 1;
Line 2589  sub modify_default_overrides { Line 2663  sub modify_default_overrides {
     if ($itemvalue eq '') {      if ($itemvalue eq '') {
         $status = $titles{'used'}.': '.          $status = $titles{'used'}.': '.
                   '<span style="font-style:italic">'.$domdefdisplay.'</span>';                    '<span style="font-style:italic">'.$domdefdisplay.'</span>';
       } elsif ($item eq 'crseditors') {
           $status = $titles{'cour'}.': '.
                     '<span style="font-style:italic">'.join(', ', map { $titles{$_}; } split(/,/,$itemvalue)).'</span>';
     } else {      } else {
         $status = $titles{'cour'}.': '.          $status = $titles{'cour'}.': '.
                   '<span style="font-style:italic">'.$optiontext->{$itemvalue}.'</span>';                    '<span style="font-style:italic">'.$optiontext->{$itemvalue}.'</span>';
Line 2767  function togglePostsubmit(caller) { Line 2844  function togglePostsubmit(caller) {
   
 ENDSCRIPT  ENDSCRIPT
   
     } elsif (($phase eq 'setltiauth') || ($phase eq 'setexttool') || ($phase eq 'setcrsauthor')) {      } elsif (($phase eq 'setltiauth') || ($phase eq 'setexttool') ||
                ($phase eq 'setcrsauthor') || ($phase eq 'setcrseditors')) {
         $js .= <<"ENDJS";          $js .= <<"ENDJS";
 function toggleOptions(form,phase) {  function toggleOptions(form,phase) {
     var radioname;      var radioname;
Line 2781  function toggleOptions(form,phase) { Line 2859  function toggleOptions(form,phase) {
     } else if (phase == 'setcrsauthor') {      } else if (phase == 'setcrsauthor') {
         radioname = 'crsauthorset';          radioname = 'crsauthorset';
         divid = 'crscrsauthor';          divid = 'crscrsauthor';
       } else if (phase == 'setcrseditors') {
           radioname = 'crseditorsset';
           divid = 'crscrseditors';
     }      }
     var num = form.elements[radioname].length;      var num = form.elements[radioname].length;
     if (num) {      if (num) {
Line 2816  ENDJS Line 2897  ENDJS
         $starthash = {          $starthash = {
            add_entries => {'onload' => "hide_searching(); courseSet(document.filterpicker.official, 'load');"},             add_entries => {'onload' => "hide_searching(); courseSet(document.filterpicker.official, 'load');"},
                      };                       };
     } elsif ($env{'form.phase'} =~ /^set(ltiauth|exttool|crsauthor)$/) {      } elsif ($env{'form.phase'} =~ /^set(ltiauth|exttool|crsauthor|crseditors)$/) {
         $starthash = {          $starthash = {
            add_entries => {'onload' => "toggleOptions(document.$env{'form.phase'},'$env{'form.phase'}');"},             add_entries => {'onload' => "toggleOptions(document.$env{'form.phase'},'$env{'form.phase'}');"},
                      };                       };
Line 2928  sub hidden_form_elements { Line 3009  sub hidden_form_elements {
           'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota',            'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota',
           'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st',            'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st',
           'sections','newsec','mysqltables','nopasswdchg','ltiauth','ltiauthset',            'sections','newsec','mysqltables','nopasswdchg','ltiauth','ltiauthset',
           'exttoolset','exttool','crsauthorset','crsauthor'],            'exttoolset','exttool','crsauthorset','crsauthor','crseditorsset','crseditors'],
            ['^selfenrollmgr_','^selfenroll_'])."\n".             ['^selfenrollmgr_','^selfenroll_'])."\n".
           '<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />';            '<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />';
     return $hidden_elements;      return $hidden_elements;
Line 2968  sub get_permission { Line 3049  sub get_permission {
             processexttool    => 'edit',              processexttool    => 'edit',
             setcrsauthor      => 'edit',              setcrsauthor      => 'edit',
             processcrsauthor  => 'edit',              processcrsauthor  => 'edit',
               setcrseditors     => 'edit',
               processcrseditors => 'edit', 
         );          );
         if ($passwdconf{'crsownerchg'}) {          if ($passwdconf{'crsownerchg'}) {
             $permission{passwdchg} = 'edit';              $permission{passwdchg} = 'edit';
Line 2986  sub get_permission { Line 3069  sub get_permission {
             setltiauth    => 'view',              setltiauth    => 'view',
             setexttool    => 'view',              setexttool    => 'view',
             setcrsauthor  => 'view',              setcrsauthor  => 'view',
               setcrseditors => 'view',
         );          );
         if ($passwdconf{'crsownerchg'}) {          if ($passwdconf{'crsownerchg'}) {
             $permission{passwdchg} = 'view';              $permission{passwdchg} = 'view';
Line 3225  sub handler { Line 3309  sub handler {
                              {href=>"javascript:changePage(document.$phase,'$phase')",                               {href=>"javascript:changePage(document.$phase,'$phase')",
                               text=>"Result"});                                text=>"Result"});
                             &modify_default_overrides($r,$cdom,$cnum,$cdesc,$domdesc,$type,'crsauthor');                              &modify_default_overrides($r,$cdom,$cnum,$cdesc,$domdesc,$type,'crsauthor');
                           } elsif (($phase eq 'setcrseditors') && ($permission->{'setcrseditors'})) {
                               &Apache::lonhtmlcommon::add_breadcrumb
                               ({href=>"javascript:changePage(document.$phase,'$phase')",
                                 text=>"Available course resource editors"});
                               &print_default_overrides($r,$cdom,$cnum,$cdesc,$type,$readonly,'crseditors');
                           } elsif (($phase eq 'processcrseditors') && ($permission->{'processcrseditors'})) {
                               &Apache::lonhtmlcommon::add_breadcrumb
                               ({href=>"javascript:changePage(document.$phase,'setcrseditors')",
                                 text=>"Available course resource editors"},
                                {href=>"javascript:changePage(document.$phase,'$phase')",
                                 text=>"Result"});
                               &modify_default_overrides($r,$cdom,$cnum,$cdesc,$domdesc,$type,'crseditors');
                         }                          }
                     }                      }
                 } else {                  } else {

Removed from v.1.104  
changed lines
  Added in v.1.105


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