[LON-CAPA-cvs] cvs: loncom /homework daxeopen.pm daxepage.pm /html/adm/help/tex Domain_Configuration_Course_Defaults.tex Modify_Course_Resource_Editors.tex /html/res/adm/pages crseditors.png /interface domainprefs.pm loncommon.pm lonhtmlcommon.pm lonmodifycourse.pm /lonnet/perl lonnet.pm /xml londefdef.pm lonxml.pm

raeburn raeburn at source.lon-capa.org
Sun Apr 14 13:12:30 EDT 2024


raeburn		Sun Apr 14 17:12:30 2024 EDT

  Added files:                 
    /loncom/html/res/adm/pages	crseditors.png 
    /loncom/html/adm/help/tex	Modify_Course_Resource_Editors.tex 

  Modified files:              
    /loncom/interface	domainprefs.pm lonmodifycourse.pm loncommon.pm 
                     	lonhtmlcommon.pm 
    /loncom/homework	daxepage.pm daxeopen.pm 
    /loncom/xml	londefdef.pm lonxml.pm 
    /loncom/lonnet/perl	lonnet.pm 
    /loncom/html/adm/help/tex	Domain_Configuration_Course_Defaults.tex 
  Log:
  - Available editors in Course Authoring Space, or when editing an html file
    created in a course folder using the Course Editor is a domain default,
    which can be overridden in specific course(s) by a Domain Coordinator.
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.437 loncom/interface/domainprefs.pm:1.438
--- loncom/interface/domainprefs.pm:1.437	Sun Mar  3 00:08:37 2024
+++ loncom/interface/domainprefs.pm	Sun Apr 14 17:12:27 2024
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.437 2024/03/03 00:08:37 raeburn Exp $
+# $Id: domainprefs.pm,v 1.438 2024/04/14 17:12:27 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -6917,6 +6917,7 @@
         domexttool           => 'External Tools defined in the domain may be used in courses/communities (by type)',
         exttool              => 'External Tools can be defined and configured in courses/communities (by type)',
         crsauthor            => 'Standard LON-CAPA problems can be created within a course/community (by type)',
+        crseditors           => 'Available editors for web pages and/or problems created in a course/community',
     );
     my %staticdefaults = (
                            anonsurvey_threshold => 10,
@@ -6927,6 +6928,7 @@
                            domexttool           => 1,
                            exttool              => 0,
                            crsauthor            => 1,
+                           crseditors           => ['edit','xml'],  
                          );
     if ($position eq 'top') {
         %defaultchecked = (
@@ -7048,6 +7050,7 @@
         my %domexttool;
         my %exttool;
         my %crsauthor;
+        my %crseditors;
         my @types = ('official','unofficial','community','textbook','placement');
         if (ref($settings) eq 'HASH') {
             if ($settings->{'ltiauth'}) {
@@ -7086,6 +7089,15 @@
                     }
                 }
             }
+            if (ref($settings->{'crseditors'}) eq 'ARRAY') {
+                foreach my $editor (@{$settings->{'crseditors'}}) {
+                    $crseditors{$editor} = ' checked="checked"';
+                }
+            } else {
+                foreach my $editor (@{$staticdefaults{'crseditors'}}) {
+                    $crseditors{$editor} = ' checked="checked"';
+                }
+            }
             $currdefresponder = $settings->{'anonsurvey_threshold'};
             if (ref($settings->{'uploadquota'}) eq 'HASH') {
                 foreach my $type (keys(%{$settings->{'uploadquota'}})) {
@@ -7149,6 +7161,9 @@
                     $crsauthor{$type} = ' checked="checked"';
                 }
             }
+            foreach my $editor (@{$staticdefaults{'crseditors'}}) {
+                $crseditors{$editor} = ' checked="checked"';
+            }
         }
         if (!$currdefresponder) {
             $currdefresponder = $staticdefaults{'anonsurvey_threshold'};
@@ -7276,9 +7291,9 @@
         foreach my $type (@types) {
             $datatable .= '<td style="text-align: left">'.
                           '<span class="LC_nobreak">'.
-                          '<input type="checkbox" name="domexttool"'.
+                          '<label><input type="checkbox" name="domexttool"'.
                           ' value="'.$type.'"'.$domexttool{$type}.' />'.
-                          &mt($type).'</span></td>'."\n";
+                          &mt($type).'</label></span></td>'."\n";
         }
         $datatable .= '</tr></table></td></tr>'."\n";
         $itemcount ++;
@@ -7291,9 +7306,9 @@
         foreach my $type (@types) {
             $datatable .= '<td style="text-align: left">'.
                           '<span class="LC_nobreak">'.
-                          '<input type="checkbox" name="exttool"'.
+                          '<label><input type="checkbox" name="exttool"'.
                           ' value="'.$type.'"'.$exttool{$type}.' />'.
-                          &mt($type).'</span></td>'."\n";
+                          &mt($type).'</label></span></td>'."\n";
         }
         $datatable .= '</tr></table></td></tr>'."\n";
         $itemcount ++;
@@ -7306,9 +7321,26 @@
         foreach my $type (@types) {
             $datatable .= '<td style="text-align: left">'.
                           '<span class="LC_nobreak">'.
-                          '<input type="checkbox" name="crsauthor"'.
+                          '<label><input type="checkbox" name="crsauthor"'.
                           ' value="'.$type.'"'.$crsauthor{$type}.' />'.
-                          &mt($type).'</span></td>'."\n";
+                          &mt($type).'</label></span></td>'."\n";
+        }
+        $datatable .= '</tr></table></td></tr>'."\n";
+        $itemcount ++;
+        $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+        $datatable .= '<tr'.$css_class.'><td><span class="LC_nobreak">'.
+                      $choices{'crseditors'}.
+                      '</span></td>'.
+                      '<td style="text-align: right" class="LC_right_item">'.
+                      '<table><tr>';
+        my @editors = ('edit','xml','daxe');
+        my %editornames = &crseditor_titles();
+        foreach my $editor (@editors) {
+            $datatable .= '<td style="text-align: left">'.
+                          '<span class="LC_nobreak">'.
+                          '<label><input type="checkbox" name="crseditors"'.
+                          ' value="'.$editor.'"'.$crseditors{$editor}.' />'.
+                          $editornames{$editor}.'</label></span></td>'."\n";
         }
         $datatable .= '</tr></table></td></tr>'."\n";
     }
@@ -7316,6 +7348,14 @@
     return $datatable;
 }
 
+sub crseditor_titles {
+    return &Apache::lonlocal::texthash(
+               edit  => 'Standard editor (Edit)',
+               xml   => 'Text editor (EditXML)',
+               daxe  => 'Daxe editor (Daxe)',
+           );
+}
+
 sub print_authordefaults {
     my ($position,$dom,$settings,$rowtotal) = @_;
     my ($css_class,$datatable,%checkedon,%checkedoff);
@@ -21213,12 +21253,17 @@
                            mysqltables          => 172800,
                            domexttool           => 1,
                            crsauthor            => 1,
+                           crseditors           => ['edit','xml'],
                          );
     my %texoptions = (
                         MathJax  => 'MathJax',
                         mimetex  => &mt('Convert to Images'),
                         tth      => &mt('TeX to HTML'),
                      );
+
+    my @editors = ('edit','xml','daxe');
+    my %editornames = &crseditor_titles();
+
     $defaultshash{'coursedefaults'} = {};
 
     if (ref($domconfig{'coursedefaults'}) ne 'HASH') {
@@ -21404,10 +21449,12 @@
                 $changes{'postsubmit'} = 1;
             }
         }
-        my (%newdomexttool,%newexttool,%newcrsauthor,%olddomexttool,%oldexttool,%oldcrsauthor);
+        my (%newdomexttool,%newexttool,%newcrsauthor,%olddomexttool,%oldexttool,%oldcrsauthor,
+            %posscrseditors);
         map { $newdomexttool{$_} = 1; } &Apache::loncommon::get_env_multiple('form.domexttool');
         map { $newexttool{$_} = 1; } &Apache::loncommon::get_env_multiple('form.exttool');
         map { $newcrsauthor{$_} = 1; } &Apache::loncommon::get_env_multiple('form.crsauthor');
+        map { $posscrseditors{$_} = 1; } &Apache::loncommon::get_env_multiple('form.crseditors');
         if (ref($domconfig{'coursedefaults'}{'domexttool'}) eq 'HASH') {
             %olddomexttool = %{$domconfig{'coursedefaults'}{'domexttool'}};
         } else {
@@ -21441,6 +21488,27 @@
                }
             }
         }
+        my @newcrseditors = ();
+        foreach my $editor (@editors) {
+            if ($posscrseditors{$editor}) {
+                push(@newcrseditors,$editor);
+            }
+        }
+        if (ref($domconfig{'coursedefaults'}{'crseditors'}) eq 'ARRAY') {
+            my @diffs =
+                &Apache::loncommon::compare_arrays($domconfig{'coursedefaults'}{'crseditors'},
+                                                   \@newcrseditors);
+            if (@diffs) {
+                $changes{'crseditors'} = 1; 
+            }
+        } else {
+            my @diffs =
+                &Apache::loncommon::compare_arrays($staticdefaults{'crseditors'},
+                                                   \@newcrseditors);
+            unless (@diffs == 0) {
+                $changes{'crseditors'} = 1;
+            }       
+        }
         foreach my $type (@types) {
             unless ($newdomexttool{$type}) {
                 $newdomexttool{$type} = 0;
@@ -21464,6 +21532,7 @@
         $defaultshash{'coursedefaults'}{'domexttool'} = \%newdomexttool;
         $defaultshash{'coursedefaults'}{'exttool'} = \%newexttool;
         $defaultshash{'coursedefaults'}{'crsauthor'} = \%newcrsauthor;
+        $defaultshash{'coursedefaults'}{'crseditors'} = \@newcrseditors;
     }
     my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
                                              $dom);
@@ -21547,6 +21616,11 @@
                         }
                     }
                 }
+                if ($changes{'crseditors'}) {
+                    if (ref($defaultshash{'coursedefaults'}{'crseditors'}) eq 'ARRAY') {
+                        $domdefaults{'crseditors'}=join(',',@{$defaultshash{'coursedefaults'}{'crseditors'}});
+                    }
+                }
                 my $cachetime = 24*60*60;
                 &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
                 if (ref($lastactref) eq 'HASH') {
@@ -21726,6 +21800,16 @@
                     } else {
                         $resulttext .= '<li>'.$status{$item}{'default'}.'</li>';
                     }
+                } elsif ($item eq 'crseditors') {
+                    if (ref($defaultshash{'coursedefaults'}{$item}) eq 'ARRAY') {
+                        my $shown;
+                        if (@{$defaultshash{'coursedefaults'}{$item}}) {
+                            $shown = join(', ', map { $editornames{$_} } @{$defaultshash{'coursedefaults'}{$item}});
+                        } else {
+                            $shown = &mt('None');
+                        }
+                        $resulttext .= '<li>'.&mt('Available editors for course/community resources: [_1]',$shown).'</li>';
+                    }
                 }
             }
             $resulttext .= '</ul>';
Index: loncom/interface/lonmodifycourse.pm
diff -u loncom/interface/lonmodifycourse.pm:1.104 loncom/interface/lonmodifycourse.pm:1.105
--- loncom/interface/lonmodifycourse.pm:1.104	Sat Dec 23 02:17:38 2023
+++ loncom/interface/lonmodifycourse.pm	Sun Apr 14 17:12:27 2024
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # handler for DC-only modifiable course settings
 #
-# $Id: lonmodifycourse.pm,v 1.104 2023/12/23 02:17:38 raeburn Exp $
+# $Id: lonmodifycourse.pm,v 1.105 2024/04/14 17:12:27 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -434,6 +434,7 @@
                       'setltiauth'    => 'View/Modify re-authentication requirement for LTI launch of deep-linked item',
                       'setexttool'    => 'View/Modify External Tools permissions',
                       'setcrsauthor'  => 'View/Modify In-course Authoring permissions',
+                      'setcrseditors' => 'View/Modify permitted course resource editors',
                     );
     } else {
         %linktext = (
@@ -444,6 +445,7 @@
                       'setltiauth'    => 'View re-authentication requirement for LTI launch of deep-linked item',
                       'setexttool'    => 'View External Tools permissions',
                       'setcrsauthor'  => 'View In-course Authoring permissions',
+                      'setcrseditors' => 'View permitted course resource editors',
                     );
     }
     if ($type eq 'Community') {
@@ -592,6 +594,14 @@
                 permission => $permission->{'setcrsauthor'},
                 linktitle => '',
             },
+            {
+                linktext => $linktext{'setcrseditors'},
+                icon => 'crseditors.png',
+                #help => '',
+                url => &phaseurl('setcrseditors'),
+                permission => $permission->{'setcrseditors'},
+                linktitle => '',
+            },
         ]
         },
         );
@@ -1314,12 +1324,13 @@
 sub print_default_overrides {
     my ($r,$cdom,$cnum,$cdesc,$type,$readonly,$item) = @_;
     my (%titles,$checkeddom,$checkedcrs,$divsty,$currcrsval,$crsdefault,%crschecked,
-        $helpfile,$title,$crselements);
+        $helpfile,$title,$crselements, at currcrseditors);
     %titles = &default_overrides_titles($type);
     my ($title,$domdefdisplay,$settings,$optiontext,$options) =
         &default_overrides_common($item,$cdom,$cnum,$type,\%titles);
     $checkeddom = ' checked="checked"';
     $divsty = 'display:none';
+     
     if ($item eq 'ltiauth') {
         $helpfile = 'Modify_Course_LTI_Authen';
         $crsdefault = 0;
@@ -1330,6 +1341,9 @@
         } elsif ($item eq 'crsauthor') {
             $helpfile = 'Modify_Course_Crsauthor';
             $crsdefault = 1;
+        } elsif ($item eq 'crseditors') {
+            $helpfile = 'Modify_Course_Resource_Editors';
+            $crsdefault = 'edit,xml';
         }
     }
     $currcrsval = $settings->{'internal.'.$item};
@@ -1337,33 +1351,55 @@
         $checkedcrs = $checkeddom;
         $checkeddom = '';
         $divsty = 'display:inline-block';
+        if ($item eq 'crseditors') {
+            @currcrseditors = split(/,/,$currcrsval);
+        }        
         foreach my $option (@{$options}) {
-            if ($currcrsval eq $option) {
+            if ($item eq 'crseditors') {
+                if (grep(/^\Q$option\E$/, at currcrseditors)) {
+                    $crschecked{$option} = ' checked="checked"';
+                }
+            } elsif ($currcrsval eq $option) {
                 $crschecked{$option} = ' checked="checked"';
             } else {
                 $crschecked{$option} = '';
             }
         }
     } else {
+        if ($item eq 'crseditors') {
+            my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
+            @currcrseditors = split(/,/,$domdefs{'crseditors'});
+        } 
         foreach my $option (@{$options}) {
-            if ($crsdefault eq $option) {
+            if ($item eq 'crseditors') {
+                if (grep(/^\Q$option\E$/, at currcrseditors)) {
+                    $crschecked{$option} = ' checked="checked"';
+                }
+            } elsif ($crsdefault eq $option) {
                 $crschecked{$option} = ' checked="checked"';
             } else {
                 $crschecked{$option} = '';
             }
         }
     }
-    my ($disabled,$submit);
+    my ($disabled,$submit,$inputtype,$separator);
     if ($readonly) {
         $disabled = ' disabled="disabled"';
     } else {
         $submit = '<input type="button" onclick="javascript:changePage(this.form,'."'process${item}'".');" value="'.$titles{'modi'}.'" />';
     }
+    if ($item eq 'crseditors') {
+        $inputtype = 'checkbox';
+        $separator = ' 'x2;
+    } else {
+        $inputtype = 'radio';
+        $separator = '<br />';
+    }
     foreach my $option (@{$options}) {
         $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>'.
-                        '</span><br />'."\n";
+                        '</span>'.$separator."\n";
     }
     &print_header($r,$type);
     my $hidden_elements = &hidden_form_elements();
@@ -1406,6 +1442,10 @@
                 'dom' => 'Only external tools defined in domain 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",
+                'perc' => 'Permitted course resource editors', 
+                'edit' => 'Standard editor (Edit)',
+                'xml'  => 'Text editor (EditXML)',
+                'daxe' => 'Daxe editor (Daxe)',
                 'on'   => 'In-course authoring available',
                 'off'  => 'In-course authoring unavailable',
                 'used' => 'Use domain default',
@@ -1454,12 +1494,17 @@
                             1 => $titles->{'on'},
                             0 => $titles->{'off'},
                           );
+        } elsif ($item eq 'crseditors') {
+            $title = $titles->{'perc'};
+            $domdef = 1;
+            @options = ('edit','xml','daxe');
+            map { $optiontext{$_} = $titles->{$_}; } @options;
         }
     }
     my %domconfig =
         &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
     if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
-        if ($item eq 'ltiauth') {
+        if (($item eq 'ltiauth') || ($item eq 'crseditors')) {
             $domdef = $domconfig{'coursedefaults'}{$item};
         } else {
             my $lctype = &get_lctype($type,\%settings);
@@ -1499,6 +1544,18 @@
         } else {
             $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);
 }
@@ -2533,7 +2590,13 @@
                                          chg   => 'In-course authoring permissions changed',
                                          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);
     $r->print('<h3>'.$title.'</h3>'."\n".
               '<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n".
@@ -2545,9 +2608,20 @@
             $change = 1;
         }
     } elsif ($env{'form.'.$item.'set'} eq 'course') {
-        my $posscrsval = $env{'form.'.$item};
-        if (grep(/^\Q$posscrsval\E$/,@{$options})) {
-            $newcrsval = $posscrsval;
+        if ($item eq 'crseditors') {
+            my @neweditors;
+            my @posseditors = &Apache::loncommon::get_env_multiple('form.'.$item);
+            foreach my $editor (@posseditors) {
+                if (grep(/^\Q$editor\E$/,@{$options})) {
+                    push(@neweditors,$editor);
+                }
+            }
+            $newcrsval = join(',', at neweditors); 
+        } else { 
+            my $posscrsval = $env{'form.'.$item};
+            if (grep(/^\Q$posscrsval\E$/,@{$options})) {
+                $newcrsval = $posscrsval;
+            }
         }
         if ($oldcrsval eq $newcrsval) {
             $nochange = 1;
@@ -2589,6 +2663,9 @@
     if ($itemvalue eq '') {
         $status = $titles{'used'}.': '.
                   '<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 {
         $status = $titles{'cour'}.': '.
                   '<span style="font-style:italic">'.$optiontext->{$itemvalue}.'</span>';
@@ -2767,7 +2844,8 @@
 
 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";
 function toggleOptions(form,phase) {
     var radioname;
@@ -2781,6 +2859,9 @@
     } else if (phase == 'setcrsauthor') {
         radioname = 'crsauthorset';
         divid = 'crscrsauthor';
+    } else if (phase == 'setcrseditors') {
+        radioname = 'crseditorsset';
+        divid = 'crscrseditors';
     }
     var num = form.elements[radioname].length;
     if (num) {
@@ -2816,7 +2897,7 @@
         $starthash = {
            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 = {
            add_entries => {'onload' => "toggleOptions(document.$env{'form.phase'},'$env{'form.phase'}');"},
                      };
@@ -2928,7 +3009,7 @@
           'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota',
           'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st',
           'sections','newsec','mysqltables','nopasswdchg','ltiauth','ltiauthset',
-          'exttoolset','exttool','crsauthorset','crsauthor'],
+          'exttoolset','exttool','crsauthorset','crsauthor','crseditorsset','crseditors'],
            ['^selfenrollmgr_','^selfenroll_'])."\n".
           '<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />';
     return $hidden_elements;
@@ -2968,6 +3049,8 @@
             processexttool    => 'edit',
             setcrsauthor      => 'edit',
             processcrsauthor  => 'edit',
+            setcrseditors     => 'edit',
+            processcrseditors => 'edit', 
         );
         if ($passwdconf{'crsownerchg'}) {
             $permission{passwdchg} = 'edit';
@@ -2986,6 +3069,7 @@
             setltiauth    => 'view',
             setexttool    => 'view',
             setcrsauthor  => 'view',
+            setcrseditors => 'view',
         );
         if ($passwdconf{'crsownerchg'}) {
             $permission{passwdchg} = 'view';
@@ -3225,6 +3309,18 @@
                              {href=>"javascript:changePage(document.$phase,'$phase')",
                               text=>"Result"});
                             &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 {
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1428 loncom/interface/loncommon.pm:1.1429
--- loncom/interface/loncommon.pm:1.1428	Sat Mar 23 22:05:16 2024
+++ loncom/interface/loncommon.pm	Sun Apr 14 17:12:27 2024
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1428 2024/03/23 22:05:16 raeburn Exp $
+# $Id: loncommon.pm,v 1.1429 2024/04/14 17:12:27 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -6656,20 +6656,32 @@
 Input: $uri (optional)
 
 Returns: %editors hash in which keys are editors
-         permitted in current Authoring Space.
+         permitted in current Authoring Space,
+         or in current course for web pages
+         created in a course.
+
          Value for each key is 1. Possible keys
-         are: edit, xml, and daxe. If no specific
+         are: edit, xml, and daxe.
+
+         For a regular Authoring Space, if no specific
          set of editors has been set for the Author
          who owns the Authoring Space, then the
          domain default will be used.  If no domain
          default has been set, then the keys will be
          edit and xml.
 
+         For a course author, or for web pages created
+         in a course, if no specific set of editors has
+         been set for the course, then the domain
+         course default will be used. If no domain
+         course default has been set, then the keys
+         will be edit and xml.
+
 =cut
 
 sub permitted_editors {
     my ($uri) = @_;
-    my ($is_author,$is_coauthor,$auname,$audom,%editors);
+    my ($is_author,$is_coauthor,$is_course,$auname,$audom,%editors);
     if ($env{'request.role'} =~ m{^au\./}) {
         $is_author = 1;
     } elsif ($env{'request.role'} =~ m{^(?:ca|aa)\./($match_domain)/($match_username)}) {
@@ -6683,20 +6695,32 @@
             }
         }
     } elsif ($env{'request.course.id'}) {
-        if ($env{'request.editurl'} =~ m{^/priv/($match_domain)/($match_username)/}) {
+        my ($cdom,$cnum);
+        $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+        $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+        if (($env{'request.editurl'} =~ m{^/priv/\Q$cdom/$cnum\E/}) ||
+            ($env{'request.editurl'} =~ m{^/uploaded/\Q$cdom/$cnum\E/(docs|supplemental)/})) {
+            $is_course = 1;
+        } elsif ($env{'request.editurl'} =~ m{^/priv/($match_domain)/($match_username)/}) {
             ($audom,$auname) = ($1,$2);
         } elsif ($env{'request.uri'} =~ m{^/priv/($match_domain)/($match_username)/}) {
             ($audom,$auname) = ($1,$2);
         } elsif (($uri eq '/daxesave') &&
+                 (($env{'form.path'} =~ m{^/daxeopen/priv/\Q$cdom/$cnum\E/}) ||
+                  ($env{'form.path'} =~ m{^/daxeopen/uploaded/\Q$cdom/$cnum\E/(docs|supplemental)/}))) {
+            $is_course = 1;
+        } elsif (($uri eq '/daxesave') &&
                  ($env{'form.path'} =~ m{^/daxeopen/priv/($match_domain)/($match_username)/})) {
             ($audom,$auname) = ($1,$2);
         }
-        if (($audom ne '') && ($auname ne '')) {
-            if (($env{'user.domain'} eq $audom) &&
-                ($env{'user.name'} eq $auname)) {
-                $is_author = 1;
-            } else {
-                $is_coauthor = 1;
+        unless ($is_course) {
+            if (($audom ne '') && ($auname ne '')) {
+                if (($env{'user.domain'} eq $audom) &&
+                    ($env{'user.name'} eq $auname)) {
+                    $is_author = 1;
+                } else {
+                    $is_coauthor = 1;
+                }
             }
         }
     }
@@ -6716,6 +6740,19 @@
                          xml => 1,
                        );
         }
+    } elsif ($is_course) {
+        if (exists($env{'course.'.$env{'request.course.id'}.'.internal.crseditors'})) {
+            map { $editors{$_} = 1; } split(/,/,$env{'course.'.$env{'request.course.id'}.'.internal.crseditors'});
+        } else {
+            my %domdefaults = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
+            if (exists($domdefaults{'crseditors'})) {
+                map { $editors{$_} = 1; } split(/,/,$domdefaults{'crseditors'});
+            } else {
+                %editors = ( edit => 1,
+                             xml => 1,
+                           );
+            }
+        }
     } else {
         %editors = ( edit => 1,
                      xml => 1,
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.410 loncom/interface/lonhtmlcommon.pm:1.411
--- loncom/interface/lonhtmlcommon.pm:1.410	Wed Sep 27 14:52:26 2023
+++ loncom/interface/lonhtmlcommon.pm	Sun Apr 14 17:12:27 2024
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.410 2023/09/27 14:52:26 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.411 2024/04/14 17:12:27 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -231,15 +231,16 @@
         $link = '/adm/dependencies?symb='.&HTML::Entities::encode($symb,'<>&"');
     } elsif ($folderpath) {
         $link = '/adm/dependencies?folderpath='.&HTML::Entities::encode($folderpath,'<>&"');
-         $url = $uri;
+        $url = $uri;
     } elsif ($uri =~ m{^/public/$match_domain/$match_courseid/syllabus$}) {
         $link = '/adm/dependencies';
     }
-    $link .= (($link=~/\?/)?'&':'?').'title='.
+    $link .= (($link=~/\?/)?'&':'?').'title='.
              &HTML::Entities::encode($title,'<>&"');
     if ($url) {
         $link .= '&url='.&HTML::Entities::encode($url,'<>&"');
     }
+    &js_escape(\$link);
     return <<ENDJS;
                 <script type="text/javascript">
                 // <![CDATA[
Index: loncom/homework/daxepage.pm
diff -u loncom/homework/daxepage.pm:1.14 loncom/homework/daxepage.pm:1.15
--- loncom/homework/daxepage.pm:1.14	Sun Mar 31 01:50:18 2024
+++ loncom/homework/daxepage.pm	Sun Apr 14 17:12:28 2024
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Page with Daxe on the left side and the preview on the right side
 #
-# $Id: daxepage.pm,v 1.14 2024/03/31 01:50:18 raeburn Exp $
+# $Id: daxepage.pm,v 1.15 2024/04/14 17:12:28 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -46,9 +46,26 @@
     my $uri = $request->uri;
     $uri =~ s{^/daxepage}{};
     &Apache::loncommon::content_type($request,'text/html');
-    my ($is_not_assess,$is_assess);
+    my ($is_not_assess,$is_assess,$is_course_doc,$is_supp,$supp_path,$supp_title);
     if ($uri =~/\.(xml|html|htm|xhtml|xhtm)$/) {
         $is_not_assess = 1;
+        if ($Apache::lonnet::env{'request.course.id'}) {
+            my $cid = $Apache::lonnet::env{'request.course.id'};
+            my $cdom = $Apache::lonnet::env{'course.'.$cid.'.domain'};
+            my $cnum = $Apache::lonnet::env{'course.'.$cid.'.num'};
+            if ($uri =~ m{^/uploaded/\Q$cdom/$cnum\E/(docs|supplemental)/}) {
+                if ($1 eq 'supplemental') {
+                    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+                                                            ['folderpath','title']);
+                    $is_supp = 1;
+                    $supp_path = &escape(&HTML::Entities::decode($Apache::lonnet::env{'form.folderpath'}));
+                    $supp_title = &escape(&HTML::Entities::decode($Apache::lonnet::env{'form.title'}));
+                    &Apache::lonhtmlcommon::clear_breadcrumbs();
+                }
+                $is_course_doc = 1;
+                $Apache::lonnet::env{'form.forceedit'} = 1;
+            }
+        }
     } elsif ($uri =~ /$LONCAPA::assess_re/) {
         unless ($uri =~ /\.form$/) {
             $is_assess = 1;
@@ -58,7 +75,7 @@
         $request->status(406);
         return OK;
     }
-    my %editors = &Apache::loncommon::permitted_editors();
+    my %editors = &Apache::loncommon::permitted_editors($uri);
     unless ($editors{'daxe'}) {
         my $msg = '<p class="LC_warning">'.
                   &mt('Daxe editor is not enabled for this Authoring Space.').'</p>';
@@ -73,7 +90,7 @@
                                           'noif' => 'No iframe support.',
                                           'show' => 'Show content in pop-up window',
                                           'save' => 'Save',
-                                          'text' => 'Text Editor', 
+                                          'text' => 'Text Editor',
                                           'oeds' => 'other editors',
                                           'othe' => 'other editor',
                                           'edit' => 'Save and Edit',
@@ -96,15 +113,18 @@
         $headjs .= &Apache::lonxml::setmode_javascript();
         $clickexit = "javascript:setmode(this.form,'view');";
     } else {
-        $headjs .= &Apache::lonxml::seteditor_javascript();
+        $headjs .= &Apache::lonxml::seteditor_javascript($is_course_doc,$is_supp,
+                                                         $supp_path,$supp_title);
         $clickexit = "javascript:seteditmode(this.form,'view');";
     }
     $clicksave = "javascript:daxesave('exit');";
     $clickedit = "javascript:daxesave();";
     my $form_events = &Apache::edit::form_change_detection();
-    my $editheader = '<form '.$form_events.' method="post" name="daxeedit" action="'.$uri.'">'.
-                     '<input type="hidden" name="problemmode" value="daxe" />'."\n".
-                     '<div class="LC_edit_problem_editxml_header">'."\n";
+    my $editheader = '<form '.$form_events.' method="post" name="daxeedit" action="'.$uri.'">';
+    if ($is_assess) {
+        $editheader .= '<input type="hidden" name="problemmode" value="daxe" />'."\n";
+    }
+    $editheader .= '<div class="LC_edit_problem_editxml_header">'."\n";
     my $saveeditbutton = '<input type="button" name="submitmode" accesskey="s" value="'.$lt{'edit'}.
                      '" onclick="'.$clickedit.'" />'."\n";
     my $exitbutton = '<input type="button" name="submitmode" accesskey="d" value="'.$lt{'disc'}.
@@ -121,7 +141,7 @@
         if ($is_not_assess) {
             $editheader .= '<input type="hidden" name="editmode" value="" />'."\n".
                            '<input type="button" name="editordefault" value="'.$lt{'text'}.
-                           '" onclick="seteditmode(this.form,'."'edit'".');" />'."\n";
+                           '" onclick="javascript:seteditmode(this.form,'."'edit'".');" />'."\n";
         } else {
             if ($editors{'edit'}) {
                 $editheader .= '<input type="button" name="submitmode" accesskey="e" value="'.&mt('Edit').'" '.
Index: loncom/homework/daxeopen.pm
diff -u loncom/homework/daxeopen.pm:1.14 loncom/homework/daxeopen.pm:1.15
--- loncom/homework/daxeopen.pm:1.14	Sun Nov 19 21:28:17 2023
+++ loncom/homework/daxeopen.pm	Sun Apr 14 17:12:28 2024
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Opening converted problems and directory listings for Daxe
 #
-# $Id: daxeopen.pm,v 1.14 2023/11/19 21:28:17 raeburn Exp $
+# $Id: daxeopen.pm,v 1.15 2024/04/14 17:12:28 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -49,7 +49,7 @@
     my $uri = $request->uri;
     $uri =~ s{^/daxeopen}{};
     &Apache::loncommon::no_cache($request);
-    my %editors = &Apache::loncommon::permitted_editors();
+    my %editors = &Apache::loncommon::permitted_editors($uri);
     unless ($editors{'daxe'}) {
         $request->content_type('text/plain');
         $request->print(&mt('Daxe editor is not enabled for this Authoring Space.'));
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.474 loncom/xml/londefdef.pm:1.475
--- loncom/xml/londefdef.pm:1.474	Tue Nov 28 04:48:14 2023
+++ loncom/xml/londefdef.pm	Sun Apr 14 17:12:28 2024
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module
 #
-# $Id: londefdef.pm,v 1.474 2023/11/28 04:48:14 raeburn Exp $
+# $Id: londefdef.pm,v 1.475 2024/04/14 17:12:28 raeburn Exp $
 #
 #
 # Copyright Michigan State University Board of Trustees
@@ -50,7 +50,7 @@
 use Apache::loncommon();
 use Apache::Constants qw(:common);
 use File::Basename;
-use LONCAPA();
+use LONCAPA;
 # use Data::Dumper;
 
 BEGIN {
@@ -658,7 +658,8 @@
 
 sub edit_controls {
     my ($nochgview) = @_;
-    my $result = &Apache::lonxml::seteditor_javascript().' 
+    my ($is_course_doc,$is_supp,$supp_path,$supp_title);
+    my $result = '
 <form method="post" action="">
 <div class="LC_edit_problem_header">'."\n";
     unless ($nochgview) {
@@ -676,7 +677,7 @@
     if ($env{'browser.type'} ne 'explorer' || $env{'browser.version'} > 9) {
         my $uri = $env{'request.uri'};
         if ($uri =~ /\.(xml|html|htm|xhtml|xhtm)$/) {
-            my %editors = &Apache::loncommon::permitted_editors();
+            my %editors = &Apache::loncommon::permitted_editors($uri);
             if ($editors{'daxe'}) {
                 my $daxeurl = '/daxepage'.$uri;
                 $result .= '<input type="button" name="editordaxe" value="'.&mt('Edit with Daxe').
@@ -691,11 +692,19 @@
             if ($env{'request.course.id'}) {
                 $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
                 $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+                if ($url =~ m{^\Q/uploaded/$cdom/$cnum/\E(supplemental|docs)/}) {
+                    if ($1 eq 'supplemental') {
+                        $is_supp = 1;
+                    }
+                    $is_course_doc = 1;
+                }
                 if ($env{'request.filename'} =~ m{/userfiles/supplemental/default|\d+/}) {
-                    if (&Apache::lonnet::is_course_upload($env{'request.filename'},
-                                                          $cnum,$cdom)) {
+                    my $fn=&Apache::lonnet::declutter($env{'request.filename'});
+                    if (&Apache::lonnet::is_course_upload($fn,$cnum,$cdom)) {
                         &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                                                 ['folderpath','title']);
+                        $supp_path = &escape(&HTML::Entities::decode($Apache::lonnet::env{'form.folderpath'}));
+                        $supp_title = &escape(&HTML::Entities::decode($Apache::lonnet::env{'form.title'}));
                     }
                 }
             }
@@ -723,7 +732,9 @@
 </div>
 </form>
 ';
-    return $result;
+    my $setedit_js = &Apache::lonxml::seteditor_javascript($is_course_doc,$is_supp,
+                                                           $supp_path,$supp_title);
+    return $setedit_js."\n".$result;
 }
 
 sub end_body {
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.569 loncom/xml/lonxml.pm:1.570
--- loncom/xml/lonxml.pm:1.569	Sun Mar 31 01:50:18 2024
+++ loncom/xml/lonxml.pm	Sun Apr 14 17:12:28 2024
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.569 2024/03/31 01:50:18 raeburn Exp $
+# $Id: lonxml.pm,v 1.570 2024/04/14 17:12:28 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1702,14 +1702,60 @@
 }
 
 sub seteditor_javascript {
+    my ($is_course_doc,$is_supp,$supp_path,$supp_title) = @_;
+    my $symb;
+    if ($is_course_doc) {
+        if (!$is_supp) {
+            ($symb) = &Apache::lonnet::whichuser();
+            if ($symb) {
+                $symb = &escape($symb);
+            }
+        }
+    }
     return <<"ENDSCRIPT";
 <script type="text/javascript">
 // <![CDATA[
 function seteditmode(form,editor) {
+    var querystr = '';
+    var supplemental = '$is_supp';
+    var coursedoc = '$is_course_doc';
+    if (coursedoc)  {
+        if (supplemental) {
+            var supppath = '$supp_path';
+            var supptitle = '$supp_title';
+            if (supppath) {
+                querystr = 'folderpath='+supppath;
+            }
+            if (supptitle) {
+                if (querystr) {
+                    querystr += '&';
+                }
+                querystr += 'title='+supptitle;
+            }
+        }
+    }
     if (editor == 'daxe') {
         var url = new URL(document.location.href);
-        window.location = url.protocol+'//'+url.hostname+'/daxepage'+url.pathname;
+        var newloc = url.protocol+'//'+url.hostname+'/daxepage'+url.pathname;
+        if (querystr) {
+            if (/\\?/.test(url.pathname)) {
+                newloc += '&';
+            } else {
+                newloc += '?';
+            }
+            newloc += querystr;
+        }
+        window.location = newloc;
     } else {
+        if (coursedoc) {
+            form.action += '?forceedit=1';
+            if (!supplemental) {
+                form.action += '&register=1';
+            }
+            if (querystr) {
+                form.action += '&'+querystr;
+            }
+        }
         if (editor == 'edit') {
             form.editmode.value = editor;
         } else {
@@ -1961,6 +2007,10 @@
                     if ($request->uri =~ m{^\Q/uploaded/$cdom/$cnum/supplemental/\E}) {
                         &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                                                 ['folderpath','title']);
+                        if (($env{'request.state'} eq 'edit') && ($env{'form.editmode'} eq 'edit') &&
+                            ($filetype eq 'html')) {
+                            &Apache::lonhtmlcommon::clear_breadcrumbs();
+                        }
                     } elsif ($request->uri =~ m{^\Q/uploaded/$cdom/$cnum/portfolio/syllabus/\E(.+)$}) {
                         my $filename = $1;
                         if ($1 eq 'loncapa.html') {
@@ -2058,6 +2108,7 @@
             }
             if ($title) {
                 push(@pathitems,&unescape($title));
+                $itemtitle = $title;
             }
             $displaypath = join(' » ', at pathitems);
         } else {
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1524 loncom/lonnet/perl/lonnet.pm:1.1525
--- loncom/lonnet/perl/lonnet.pm:1.1524	Fri Mar 29 17:32:03 2024
+++ loncom/lonnet/perl/lonnet.pm	Sun Apr 14 17:12:29 2024
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1524 2024/03/29 17:32:03 raeburn Exp $
+# $Id: lonnet.pm,v 1.1525 2024/04/14 17:12:29 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2858,6 +2858,9 @@
             } else {
                 $domdefaults{$type.'crsauthor'} = 1;
             }
+            if (ref($domconfig{'coursedefaults'}{'crseditors'}) eq 'ARRAY') {
+                $domdefaults{'crseditors'}=join(',',@{$domconfig{'coursedefaults'}{'crseditors'}});
+            }
         }
         if (ref($domconfig{'coursedefaults'}{'canclone'}) eq 'HASH') {
             if (ref($domconfig{'coursedefaults'}{'canclone'}{'instcode'}) eq 'ARRAY') {
Index: loncom/html/adm/help/tex/Domain_Configuration_Course_Defaults.tex
diff -u loncom/html/adm/help/tex/Domain_Configuration_Course_Defaults.tex:1.16 loncom/html/adm/help/tex/Domain_Configuration_Course_Defaults.tex:1.17
--- loncom/html/adm/help/tex/Domain_Configuration_Course_Defaults.tex:1.16	Sun Mar  3 22:30:56 2024
+++ loncom/html/adm/help/tex/Domain_Configuration_Course_Defaults.tex	Sun Apr 14 17:12:30 2024
@@ -71,7 +71,7 @@
 \item \textbf{Defaults that can be overridden in an individual course by a Domain
 Coordinator}
 
-Currently, there are ten domain defaults of this type (which can be overridden
+Currently, there are eleven domain defaults of this type (which can be overridden
 via the ``View or modify a course or community'' interface). 
 
 \begin{itemize}
@@ -122,7 +122,11 @@
 
 The Course/Community defaults in the domain include checkboxes for each of the different course container types, which when checked set the ability to select ``Course Resource'' as the location for a new standard problem being created. Resources created in that location are not listed when browsing or searching the shared content repository, and may only be imported into the course in which they were created, by using the ``Import from Course Resources'' icon/link.
 
-Neither the ``Import from Course Resources'' icon/link nor the ``Course Resource'' as destination for ``Standard Problem'' will be available if the Course/Community default for the course's/community's container type has been left unchecked, and there is no course-specific override of the domain default. 
+Neither the ``Import from Course Resources'' icon/link nor the ``Course Resource'' as destination for ``Standard Problem'' will be available if the Course/Community default for the course's/community's container type has been left unchecked, and there is no course-specific override of the domain default.
+
+\item Available editors for course/community resources
+
+For standard LON-CAPA problems created within Course Authoring Space the possible editors are: Standard editor (Edit), Text editor (EditXML), and the Daxe editor (Daxe). For web pages created within a Course Authoring Space, or created within a course folder using the Course Editor, the standard editor (Edit) will always be available, but the Daxe editor will only be available if that editor is also available for standard LON-CAPA problems.
 
 \end{itemize}
 

Index: loncom/html/adm/help/tex/Modify_Course_Resource_Editors.tex
+++ loncom/html/adm/help/tex/Modify_Course_Resource_Editors.tex
\label{Modify_Course_Resource_Editors}

A domain's default setting for available editors in a course's ``Course Authoring Space'' may be overridden on a course-by-course basis by checking "Use course-specific setting" in the ``Permitted course resource editors'' accessed via the "View or modify a course or community" item (Main Menu).

For standard LON-CAPA problems created within Course Authoring Space the possible editors are: Standard editor (Edit), Text editor (EditXML), and Daxe editor (Daxe). For web pages created within a Course Authoring Space, or created within a course folder using the Course Editor, the standard editor (Edit) will always be available, but the Daxe editor will only be available if that editor is also available for standard LON-CAPA problems.


More information about the LON-CAPA-cvs mailing list