[LON-CAPA-cvs] cvs: loncom /homework daxepage.pm /interface loncommon.pm /xml lonxml.pm
raeburn
raeburn at source.lon-capa.org
Mon Nov 27 18:24:05 EST 2023
raeburn Mon Nov 27 23:24:05 2023 EDT
Modified files:
/loncom/homework daxepage.pm
/loncom/xml lonxml.pm
/loncom/interface loncommon.pm
Log:
- Include file path with colored background in collapsible header used for
Daxe Editor page. Buttons to access other available editors at far right.
Index: loncom/homework/daxepage.pm
diff -u loncom/homework/daxepage.pm:1.8 loncom/homework/daxepage.pm:1.9
--- loncom/homework/daxepage.pm:1.8 Sun Nov 26 02:15:29 2023
+++ loncom/homework/daxepage.pm Mon Nov 27 23:24:04 2023
@@ -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.8 2023/11/26 02:15:29 raeburn Exp $
+# $Id: daxepage.pm,v 1.9 2023/11/27 23:24:04 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -32,9 +32,12 @@
use Apache::loncommon();
use Apache::lonhtmlcommon();
+use Apache::lonxml();
+use Apache::edit();
use Apache::lonmenu();
use Apache::lonlocal;
use Apache::Constants qw(:common);
+use LONCAPA qw(:DEFAULT :match);
use HTML::Entities();
sub handler {
@@ -42,7 +45,15 @@
my $uri = $request->uri;
$uri =~ s{^/daxepage}{};
&Apache::loncommon::content_type($request,'text/html');
- if ($uri !~ /\.(task|problem|exam|quiz|assess|survey|library|xml|html|htm|xhtml|xhtm)$/) {
+ my ($is_not_assess,$is_assess);
+ if ($uri =~/\.(xml|html|htm|xhtml|xhtm)$/) {
+ $is_not_assess = 1;
+ } elsif ($uri =~ /$LONCAPA::assess_re/) {
+ unless ($uri =~ /\.form$/) {
+ $is_assess = 1;
+ }
+ }
+ unless ($is_not_assess || $is_assess) {
$request->status(406);
return OK;
}
@@ -53,18 +64,61 @@
&do_redirect($request,$uri,$msg);
return OK;
}
+ if ($is_not_assess) {
+ delete($editors{'xml'});
+ $editors{'edit'} = 1;
+ }
my %lt = &Apache::lonlocal::texthash(
'noif' => 'No iframe support.',
'show' => 'Show content in pop-up window',
+ 'oeds' => 'other editors',
+ 'othe' => 'other editor',
+ 'edit' => 'Edit',
);
my $name = $uri;
$name =~ s/^.*\/([^\/]+)$/$1/;
my $daxeurl = '/adm/daxe/daxe.html?config=config/loncapa_config.xml&save=/daxesave'.
'&file=/daxeopen'.$uri;
my $headjs = &Apache::loncommon::iframe_wrapper_headjs().
- &toggle_LCmenus_js();
+ &toggle_LCmenus_js().
+ &Apache::edit::js_change_detection();
+ if ($is_assess) {
+ $headjs .= &Apache::lonxml::setmode_javascript();
+ } else {
+ $headjs .= &Apache::lonxml::seteditor_javascript();
+ }
+ 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";
+ if ($editors{'edit'} || $editors{'xml'}) {
+ my $other = (($editors{'edit'} && $editors{'xml'})? $lt{'oeds'} : $lt{'othe'});
+ $editheader .= '<table class="LC_edit_problem_header_title"><tr><td>'.
+ $uri.
+ '</td><td align="right"><span class="LC_nobreak">'.$other.': ';
+ if ($is_not_assess) {
+ $editheader .= '<input type="hidden" name="editmode" value="" />'."\n".
+ '<input type="button" name="editordefault" value="'.$lt{'edit'}.
+ '" onclick="seteditmode(this.form,'."'edit'".');" />'."\n";
+ } else {
+ if ($editors{'edit'}) {
+ $editheader .= '<input type="button" name="submitmode" accesskey="e" value="'.&mt('Edit').'" '.
+ 'onclick="javascript:setmode(this.form,'."'edit'".')" />'."\n";
+ }
+ if ($editors{'xml'}) {
+ $editheader .= '<input type="button" name="submitmode" accesskey="x" value="'.&mt('EditXML').'" '.
+ 'onclick="javascript:setmode(this.form,'."'editxml'".')" />'."\n";
+ }
+ }
+ $editheader .= '</span></td></tr></table>';
+ } else {
+ $editheader .= '<table class="LC_edit_problem_header_title"><tr><td>'.
+ $uri.
+ '</td></tr></table>';
+ }
+ $editheader .= '</div></form>'."\n";
my $args = {
- 'collapsible_header' => 1,
+ 'collapsible_header' => $editheader,
};
my $startpage = &Apache::loncommon::start_page('Daxe: '.$name,$headjs,$args).
&Apache::lonmenu::constspaceform();
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.563 loncom/xml/lonxml.pm:1.564
--- loncom/xml/lonxml.pm:1.563 Mon Nov 27 22:44:21 2023
+++ loncom/xml/lonxml.pm Mon Nov 27 23:24:05 2023
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.563 2023/11/27 22:44:21 raeburn Exp $
+# $Id: lonxml.pm,v 1.564 2023/11/27 23:24:05 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1684,6 +1684,24 @@
ENDSCRIPT
}
+sub seteditor_javascript {
+ return <<"ENDSCRIPT";
+<script type="text/javascript">
+// <![CDATA[
+function seteditmode(form,editor) {
+ if (editor == 'daxe') {
+ var url = new URL(document.location.href);
+ window.location = url.protocol+'//'+url.hostname+'/daxepage'+url.pathname;
+ } else {
+ form.editmode.value = editor;
+ form.submit();
+ }
+}
+// ]]>
+</script>
+ENDSCRIPT
+}
+
sub get_target {
my $viewgrades=&Apache::lonnet::allowed('vgr',$env{'request.course.id'});
if ( $env{'request.state'} eq 'published') {
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1422 loncom/interface/loncommon.pm:1.1423
--- loncom/interface/loncommon.pm:1.1422 Sun Nov 26 20:47:16 2023
+++ loncom/interface/loncommon.pm Mon Nov 27 23:24:05 2023
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1422 2023/11/26 20:47:16 raeburn Exp $
+# $Id: loncommon.pm,v 1.1423 2023/11/27 23:24:05 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2501,7 +2501,7 @@
if (\$('div.LC_menus_content:first').length) {
if (\$('div.LC_menus_content:first').hasClass ("shown")) {
header = \$('div.LC_menus_content:first');
- offset = 9;
+ offset = 12;
}
} else if (\$('div.LC_head_subbox:first').length) {
header = \$('div.LC_head_subbox:first');
@@ -6887,7 +6887,7 @@
$bodytag .= Apache::lonhtmlcommon::scripttag(
Apache::lonmenu::utilityfunctions($httphost), 'start');
- if ($args->{'collapsible_header'}) {
+ if ($args->{'collapsible_header'} ne '') {
my $alttext = &mt('menu state: collapsed');
my $tooltip = &mt('display standard menus');
$bodytag .= <<"END";
@@ -6960,8 +6960,9 @@
$bodytag .= '<hr style="clear:both" />';
$bodytag .= Apache::lonhtmlcommon::scripttag('', 'end');
}
- if ($args->{'collapsible_header'}) {
- $bodytag .= '<div id="LC_collapsible_separator"></div>'.
+ if ($args->{'collapsible_header'} ne '') {
+ $bodytag .= $args->{'collapsible_header'}.
+ '<div id="LC_collapsible_separator"></div>'.
'</div></div>';
}
return $bodytag;
More information about the LON-CAPA-cvs
mailing list