[LON-CAPA-cvs] cvs: loncom /xml lonxml.pm
raeburn
raeburn at source.lon-capa.org
Mon Nov 27 21:39:01 EST 2023
raeburn Tue Nov 28 02:39:01 2023 EDT
Modified files:
/loncom/xml lonxml.pm
Log:
- Changes in handle_save_or_undo() in lonhomework.pm rev. 1.323 caused the
"undo" button to have no effect for html file editing. Change input items
to button and add onclick call to setmode() to reinstate.
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.565 loncom/xml/lonxml.pm:1.566
--- loncom/xml/lonxml.pm:1.565 Tue Nov 28 01:33:14 2023
+++ loncom/xml/lonxml.pm Tue Nov 28 02:39:01 2023
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.565 2023/11/28 01:33:14 raeburn Exp $
+# $Id: lonxml.pm,v 1.566 2023/11/28 02:39:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1630,14 +1630,23 @@
}
}
}
- my $undo;
+ my ($undo,%onclick);
+ foreach my $item ('discard','undo') {
+ $onclick{$item} = 'onclick="still_ask=true;setmode(this.form,'."'$item'".')"';
+ }
+ foreach my $item ('saveedit','saveview') {
+ $onclick{$item} = 'onclick="is_submit=true;setmode(this.form,'."'$item'".')"';
+ }
unless ($uri =~ m{^/uploaded/}) {
- $undo = '<input type="submit" name="Undo" accesskey="u" value="'.$lt{'un'}.'" />'."\n";
+ $undo = '<input type="button" name="Undo" accesskey="u" value="'.$lt{'un'}.'" '.
+ $onclick{'undo'}.' />'."\n";
}
+ $initialize .= &setmode_javascript();
my $editfooter=(<<ENDFOOTER);
$initialize
<a name="editsection" />
<form $form_events method="post" name="xmledit" action="$action">
+ <input type="hidden" name="problemmode" value="edit" />
<div class="LC_edit_problem_editxml_header">
<table class="LC_edit_problem_header_title"><tr><td>
$filename
@@ -1646,11 +1655,11 @@
</td></tr>
</table>
<div style="float:right">
- <input type="submit" name="savethisfile" accesskey="s" value="$lt{'st'}" />
- <input type="submit" name="viewmode" accesskey="v" value="$lt{'vi'}" />
+ <input type="button" name="savethisfile" accesskey="s" value="$lt{'st'}" $onclick{'saveedit'} />
+ <input type="button" name="viewmode" accesskey="v" value="$lt{'vi'}" $onclick{'saveview'} />
</div>
<div>
- <input type="submit" name="discardview" accesskey="d" value="$lt{'dv'}" />
+ <input type="button" name="discardview" accesskey="d" value="$lt{'dv'}" $onclick{'discard'} />
$undo $htmlerror $deps_button $dragmath_button
</div>
</div>
@@ -1661,7 +1670,7 @@
</div>
</form>
ENDFOOTER
- return ($editfooter,$add_to_onload,$add_to_onresize);;
+ return ($editfooter,$add_to_onload,$add_to_onresize);
}
sub setmode_javascript {
@@ -1804,11 +1813,13 @@
# Edit action? Save file.
#
if (!($env{'request.state'} eq 'published')) {
- if ($env{'form.savethisfile'} || $env{'form.viewmode'} || $env{'form.Undo'}) {
+ if (($env{'form.problemmode'} eq 'saveedit') ||
+ ($env{'form.problemmode'} eq 'saveview') ||
+ ($env{'form.problemmode'} eq 'undo')) {
my $html_file=&Apache::lonnet::getfile($file);
my $error = &Apache::lonhomework::handle_save_or_undo($request, \$html_file, \$env{'form.filecont'});
- if ($env{'form.savethisfile'}) {
- $env{'form.editmode'}='Edit'; #force edit mode
+ if ($env{'form.problemmode'} eq 'saveedit') {
+ $env{'form.editmode'}='edit'; #force edit mode
}
}
}
@@ -1837,7 +1848,7 @@
} elsif ($filetype ne 'css' && $filetype ne 'txt' && $filetype ne 'tex') {
$filecontents=&createnewhtml();
}
- $env{'form.editmode'}='Edit'; #force edit mode
+ $env{'form.editmode'}='edit'; #force edit mode
}
} else {
unless ($env{'request.state'} eq 'published') {
@@ -1849,7 +1860,9 @@
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['editmode']);
}
- if (!$env{'form.editmode'} || $env{'form.viewmode'} || $env{'form.discardview'}) {
+ if ((!$env{'form.editmode'}) ||
+ ($env{'form.problemmode'} eq 'saveview') ||
+ ($env{'form.problemmode'} eq 'discard')) {
if ($filetype eq 'html' || $filetype eq 'sty') {
&Apache::structuretags::reset_problem_globals();
$result = &Apache::lonxml::xmlparse($request,$target,
@@ -1926,8 +1939,9 @@
# Edit action? Insert editing commands
#
unless (($env{'request.state'} eq 'published') || ($inhibit_menu)) {
- if ($env{'form.editmode'} && (!($env{'form.viewmode'})) && (!($env{'form.discardview'})))
- {
+ if (($env{'form.editmode'}) &&
+ (!($env{'form.problemmode'} eq 'saveview')) &&
+ (!($env{'form.problemmode'} eq 'discard'))) {
my ($displayfile,$url,$symb,$itemtitle,$action);
$displayfile=$request->uri;
if ($request->uri =~ m{^/uploaded/}) {
More information about the LON-CAPA-cvs
mailing list