[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm /homework daxepage.pm /interface domainprefs.pm loncommon.pm lonpreferences.pm
raeburn
raeburn at source.lon-capa.org
Sat Mar 2 19:08:37 EST 2024
raeburn Sun Mar 3 00:08:37 2024 EDT
Modified files:
/loncom/auth lonroles.pm
/loncom/interface domainprefs.pm lonpreferences.pm loncommon.pm
/loncom/homework daxepage.pm
Log:
- Starting state of standard LON-CAPA menus (collapsed or expanded) when
using Daxe Editor is one of domain's Authoring Space defaults which can
be overridden by Author (or coauthor).
- "Authoring Space Configuration" in User Preferences (also accessed via:
Settings > Editing Options when author or co-author role is selected)
provides user with override when Daxe editor is a permitted editor.
-------------- next part --------------
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.269.2.34.2.1 loncom/auth/lonroles.pm:1.269.2.34.2.2
--- loncom/auth/lonroles.pm:1.269.2.34.2.1 Sat Oct 14 22:27:40 2017
+++ loncom/auth/lonroles.pm Mon May 25 16:23:54 2020
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.269.2.34.2.1 2017/10/14 22:27:40 raeburn Exp $
+# $Id: lonroles.pm,v 1.269.2.34.2.2 2020/05/25 16:23:54 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -209,7 +209,7 @@
my $r = shift;
# Check for critical messages and redirect if present.
- my ($redirect,$url) = &Apache::loncommon::critical_redirect(300);
+ my ($redirect,$url) = &Apache::loncommon::critical_redirect(300,'roles');
if ($redirect) {
&Apache::loncommon::content_type($r,'text/html');
$r->header_out(Location => $url);
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.436 loncom/interface/domainprefs.pm:1.437
--- loncom/interface/domainprefs.pm:1.436 Tue Feb 27 15:48:01 2024
+++ loncom/interface/domainprefs.pm Sun Mar 3 00:08:37 2024
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.436 2024/02/27 15:48:01 raeburn Exp $
+# $Id: domainprefs.pm,v 1.437 2024/03/03 00:08:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -7324,9 +7324,10 @@
if ($position eq 'top') {
my %defaultchecked = (
'nocodemirror' => 'off',
+ 'daxecollapse' => 'off',
'domcoordacc' => 'on',
);
- my @toggles = ('nocodemirror','domcoordacc');
+ my @toggles = ('nocodemirror','daxecollapse','domcoordacc');
($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
\%titles,$itemcount);
my %staticdefaults = (
@@ -7495,6 +7496,7 @@
webdav => 'WebDAV',
authorquota => 'Authoring Space quotas (MB)',
nocodemirror => 'Deactivate CodeMirror for EditXML editor',
+ daxecollapse => 'Daxe editor: LON-CAPA standard menus start collapsed',
domcoordacc => 'Dom. Coords. can enter Authoring Spaces in domain',
edit => 'Standard editor (Edit)',
xml => 'Text editor (EditXML)',
@@ -13381,13 +13383,14 @@
'copyright' => 'default',
'sourceavail' => 'closed',
'nocodemirror' => 'off',
+ 'daxecollapse' => 'off',
'domcoordacc' => 'on',
'editors' => ['edit','xml'].
'authorquota' => 500,
'webdav' => 0,
);
my %titles = &authordefaults_titles();
- foreach my $item ('nocodemirror','domcoordacc') {
+ foreach my $item ('nocodemirror','daxecollapse','domcoordacc') {
if ($env{'form.'.$item} =~ /^(0|1)$/) {
$confhash{$item} = $env{'form.'.$item};
}
@@ -13431,7 +13434,7 @@
$save_quotas{'webdav'}{'_LC_adv'} = $env{'form.webdav_LC_adv'};
}
if (ref($domconfig{'authordefaults'}) eq 'HASH') {
- foreach my $item ('nocodemirror','domcoordacc','copyright','sourceavail') {
+ foreach my $item ('nocodemirror','daxecollapse','domcoordacc','copyright','sourceavail') {
if ($domconfig{'authordefaults'}{$item} ne $confhash{$item}) {
$changes{$item} = 1;
}
@@ -13453,7 +13456,7 @@
}
} else {
my @offon = ('off','on');
- foreach my $item ('nocodemirror','domcoordacc') {
+ foreach my $item ('nocodemirror','daxecollapse','domcoordacc') {
if ($offon[$confhash{$item}] ne $staticdefaults{$item}) {
$changes{$item} = 1;
}
@@ -13522,7 +13525,7 @@
}
$resulttext = &mt('Changes made:').'<ul>';
my $authoroverride;
- foreach my $key ('nocodemirror','domcoordacc','copyright','sourceavail') {
+ foreach my $key ('nocodemirror','daxecollapse','domcoordacc','copyright','sourceavail') {
if (exists($changes{$key})) {
$domdefaults{$key} = $confhash{$key};
my $shown;
@@ -13530,7 +13533,7 @@
$resulttext .= '<li>'.&mt('Defaults which can be overridden by Author').'<ul>';
$authoroverride = 1;
}
- if (($key eq 'nocodemirror') || ($key eq 'domcoordacc')) {
+ if (($key eq 'nocodemirror') || ($key eq 'daxecollapse') || ($key eq 'domcoordacc')) {
$shown = ($confhash{$key} ? &mt('Yes') : &mt('No'));
} elsif ($key eq 'copyright') {
$shown = &Apache::loncommon::copyrightdescription($confhash{$key});
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.244 loncom/interface/lonpreferences.pm:1.245
--- loncom/interface/lonpreferences.pm:1.244 Sat Mar 2 18:47:15 2024
+++ loncom/interface/lonpreferences.pm Sun Mar 3 00:08:37 2024
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Preferences
#
-# $Id: lonpreferences.pm,v 1.244 2024/03/02 18:47:15 raeburn Exp $
+# $Id: lonpreferences.pm,v 1.245 2024/03/03 00:08:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2081,7 +2081,11 @@
my ($showdomdefs,$js,$args, at items);
my $returnurl = &HTML::Entities::encode($env{'form.returnurl'},'"<>&\'');
if (&expanded_authoring_settings()) {
- @items = ('nocodemirror','copyright','sourceavail');
+ @items = ('nocodemirror');
+ if (&daxe_permitted(\%author_roles)) {
+ push(@items,'daxecollapse');
+ }
+ push(@items,('copyright','sourceavail'));
$showdomdefs = 1;
$js = &toggle_options_js();
my $onload;
@@ -2097,13 +2101,15 @@
my %domdefs = &Apache::lonnet::get_domain_defaults($domain);
my %staticdefaults = (
'nocodemirror' => '0',
+ 'daxecollapse' => '0',
'copyright' => 'default',
'sourceavail' => 'closed',
);
my %lt = &authoring_settings_text();
my %titles = &authoring_settings_titles();
- $r->print("<h3>$lt{'auss'}</h3><br /><hr />\n".
+ $r->print("<h3>$lt{'auss'}</h3>".
'<form name="prefs" action="/adm/preferences" method="post">'."\n".
+ '<input type="submit" value="'.$lt{'save'}.'" /><br /><hr />'."\n".
'<input type="hidden" name="returnurl" value="'.$returnurl.'" />'."\n".
'<input type="hidden" name="action" value="change_authoring_settings" />'."\n");
foreach my $item (@items) {
@@ -2125,22 +2131,41 @@
$userelem = &selectbox('userchoice_'.$item,$userenv{$item},'',
\&Apache::loncommon::source_copyrightdescription,
(&Apache::loncommon::source_copyrightids));
- } elsif ($item eq 'nocodemirror') {
+ } elsif (($item eq 'nocodemirror') || ($item eq 'daxecollapse')) {
if ($domdef) {
- $domdefdisplay = $lt{'yes'};
+ if ($item eq 'daxecollapse') {
+ $domdefdisplay = $lt{'coll'};
+ } else {
+ $domdefdisplay = $lt{'yes'};
+ }
} else {
- $domdefdisplay = $lt{'no'};
+ if ($item eq 'daxecollapse') {
+ $domdefdisplay = $lt{'expa'};
+ } else {
+ $domdefdisplay = $lt{'no'};
+ }
}
- my %checked;
+ my (%checked,%text);
$checked{'no'} = ' checked="checked"';
if ($userenv{$item} eq 'yes') {
$checked{'yes'} = $checked{'no'};
$checked{'no'} = '';
}
+ if ($item eq 'daxecollapse') {
+ %text = (
+ yes => $lt{'coll'},
+ no => $lt{'expa'},
+ );
+ } else {
+ %text = (
+ yes => $lt{'yes'},
+ no => $lt{'no'},
+ );
+ }
$userelem = '<span class="LC_nobreak">';
foreach my $choice ('yes','no') {
$userelem .= '<label><input type="radio" name="userchoice_'.$item.'" value="'.$choice.'"'.
- $checked{$choice}.' />'.$lt{$choice}.'</label> ';
+ $checked{$choice}.' />'.$text{$choice}.'</label> ';
}
$userelem .= '</span>';
}
@@ -2161,8 +2186,7 @@
</fieldset><br /><hr />
END
}
- $r->print('<br />'.
- '<input type="submit" value="'.$lt{'save'}.'" />'.
+ $r->print('<input type="submit" value="'.$lt{'save'}.'" />'.
'</form>'."\n");
} else {
my $constchecked='';
@@ -2206,7 +2230,11 @@
$message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]','<i>'.&mt('Deactivate CodeMirror in Authoring Space').'</i>','<tt>'.$status.'</tt>'));
$message=&Apache::loncommon::confirmwrapper($message);
} else {
- my @items = ('nocodemirror','copyright','sourceavail');
+ my @items = ('nocodemirror');
+ if (&daxe_permitted(\%author_roles)) {
+ push(@items,'daxecollapse');
+ }
+ push(@items,('copyright','sourceavail'));
my %oldsettings = &Apache::lonnet::get('environment',\@items);
my %domdefs = &Apache::lonnet::get_domain_defaults($domain);
my %lt = &authoring_settings_text();
@@ -2222,7 +2250,7 @@
} elsif ($env{'form.'.$item} eq 'user') {
my $newval = $env{'form.userchoice_'.$item};
my @possibles;
- if ($item eq 'nocodemirror') {
+ if (($item eq 'nocodemirror') || ($item eq 'daxecollapse')) {
if ($newval =~ /^yes|no$/) {
$newsettings{$item} = $newval;
}
@@ -2277,6 +2305,12 @@
my $value = $changes{$item};
if ($item eq 'nocodemirror') {
$value = $lt{$changes{$item}};
+ } elsif ($item eq 'daxecollapse') {
+ if ($value eq 'yes') {
+ $value = $lt{'coll'};
+ } else {
+ $value = $lt{'expa'};
+ }
} elsif ($item eq 'copyright') {
$value = &Apache::loncommon::copyrightdescription($changes{$item});
} elsif ($item eq 'sourceavail') {
@@ -2324,12 +2358,15 @@
'save' => 'Save',
'yes' => 'Deactivated',
'no' => 'Activated',
+ 'expa' => 'Start Expanded',
+ 'coll' => 'Start Collapsed',
);
}
sub authoring_settings_titles {
return &Apache::lonlocal::texthash(
'nocodemirror' => 'CodeMirror for EditXML editor',
+ 'daxecollapse' => 'Daxe editor: collapsible standard LON-CAPA menus',
'copyright' => 'Default Copyright/Distribution in new metadata file',
'sourceavail' => 'Default Source Available in new metadata file',
);
@@ -2347,6 +2384,33 @@
return;
}
+sub daxe_permitted {
+ my ($aurolesref) = @_;
+ my $hasdaxe;
+ if (ref($aurolesref) eq 'HASH') {
+ my %editors;
+ foreach my $key (keys(%{$aurolesref})) {
+ if ($key =~ /^:$LONCAPA::match_domain:au$/) {
+ if (exists($env{'environment.editors'})) {
+ if (grep(/^daxe$/,split(/,/,$env{'environment.editors'}))) {
+ $hasdaxe = 1;
+ last;
+ }
+ }
+ } else {
+ my ($auname,$audom) = ($key =~ /^($LONCAPA::match_username):($LONCAPA::match_domain):(ca|aa)$/);
+ if (exists($env{"environment.internal.editors./$audom/$auname"})) {
+ if (grep(/^daxe$/,split(/,/,$env{"environment.internal.editors./$audom/$auname"}))) {
+ $hasdaxe = 1;
+ last;
+ }
+ }
+ }
+ }
+ }
+ return $hasdaxe;
+}
+
sub lockednameschanger {
my $r = shift;
my %userenv = &Apache::lonnet::get('environment',['lockedname']);
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1426 loncom/interface/loncommon.pm:1.1427
--- loncom/interface/loncommon.pm:1.1426 Wed Jan 10 20:07:37 2024
+++ loncom/interface/loncommon.pm Sun Mar 3 00:08:37 2024
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1426 2024/01/10 20:07:37 raeburn Exp $
+# $Id: loncommon.pm,v 1.1427 2024/03/03 00:08:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -6950,21 +6950,33 @@
$bodytag .= Apache::lonhtmlcommon::scripttag(
Apache::lonmenu::utilityfunctions($httphost), 'start');
+ my $collapsible;
if ($args->{'collapsible_header'} ne '') {
- my $alttext = &mt('menu state: collapsed');
- my $tooltip = &mt('display standard menus');
+ $collapsible = 1;
+ my ($menustate,$tiptext,$divclass);
+ if ($args->{'start_collapsed'}) {
+ $menustate = 'collapsed';
+ $tiptext = 'display';
+ $divclass = 'hidden';
+ } else {
+ $menustate = 'expanded';
+ $tiptext = 'hide';
+ $divclass = 'shown';
+ }
+ my $alttext = &mt('menu state: '.$menustate);
+ my $tooltip = &mt($tiptext.' standard menus');
$bodytag .= <<"END";
<div id="LC_expandingContainer" style="display:inline;">
<div id="LC_collapsible" class="LC_collapse_trigger" style="position: absolute;top: -5px;left: 0px; z-index:101; display:inline;">
-<a href="#" style="text-decoration:none;"><img class="LC_collapsible_indicator" alt="$alttext" title="$tooltip" src="/res/adm/pages/collapsed.png" style="border:0;margin:0;padding:0;max-width:100%;height:auto" /></a></div>
-<div class="LC_menus_content hidden">
+<a href="#" style="text-decoration:none;"><img class="LC_collapsible_indicator" alt="$alttext" title="$tooltip" src="/res/adm/pages/$menustate.png" style="border:0;margin:0;padding:0;max-width:100%;height:auto" /></a></div>
+<div class="LC_menus_content $divclass">
END
}
unless ($args->{'no_primary_menu'}) {
my ($left,$right) = Apache::lonmenu::primary_menu($crstype,$ltimenu,$menucoll,$menuref,
$args->{'links_disabled'},
$args->{'links_target'},
- $args->{'collapsible_header'});
+ $collapsible);
if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) {
if ($dc_info) {
Index: loncom/homework/daxepage.pm
diff -u loncom/homework/daxepage.pm:1.9 loncom/homework/daxepage.pm:1.10
--- loncom/homework/daxepage.pm:1.9 Mon Nov 27 23:24:04 2023
+++ loncom/homework/daxepage.pm Sun Mar 3 00:08:37 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.9 2023/11/27 23:24:04 raeburn Exp $
+# $Id: daxepage.pm,v 1.10 2024/03/03 00:08:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -31,6 +31,7 @@
use strict;
use Apache::loncommon();
+use Apache::lonnet();
use Apache::lonhtmlcommon();
use Apache::lonxml();
use Apache::edit();
@@ -117,8 +118,10 @@
'</td></tr></table>';
}
$editheader .= '</div></form>'."\n";
+ my $start_collapsed = &collapsible_std_LCmenus();
my $args = {
'collapsible_header' => $editheader,
+ 'start_collapsed' => $start_collapsed,
};
my $startpage = &Apache::loncommon::start_page('Daxe: '.$name,$headjs,$args).
&Apache::lonmenu::constspaceform();
@@ -203,5 +206,19 @@
return;
}
+sub collapsible_std_LCmenus {
+ my $daxecollapse = $Apache::lonnet::env{'environment.daxecollapse'};
+ unless ($daxecollapse) {
+ my %domdefs = &Apache::lonnet::get_domain_defaults($Apache::lonnet::env{'user.domain'});
+ if ($domdefs{'daxecollapse'}) {
+ $daxecollapse = 'yes';
+ }
+ }
+ if ($daxecollapse eq 'yes') {
+ return 1;
+ }
+ return;
+}
+
1;
__END__
More information about the LON-CAPA-cvs
mailing list