[LON-CAPA-cvs] cvs: loncom /homework lonsimpleproblemedit.pm
raeburn
raeburn at source.lon-capa.org
Thu Nov 8 22:28:01 EST 2012
raeburn Fri Nov 9 03:28:01 2012 EDT
Modified files:
/loncom/homework lonsimpleproblemedit.pm
Log:
- Choice of "Save and Edit" or "Save and View" buttons when saving changes
to a simpleproblem.problem.
- If changes were not stored report the error.
Index: loncom/homework/lonsimpleproblemedit.pm
diff -u loncom/homework/lonsimpleproblemedit.pm:1.33 loncom/homework/lonsimpleproblemedit.pm:1.34
--- loncom/homework/lonsimpleproblemedit.pm:1.33 Thu Nov 8 21:55:11 2012
+++ loncom/homework/lonsimpleproblemedit.pm Fri Nov 9 03:28:01 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Simple Problem Parameter Setting "Editor"
#
-# $Id: lonsimpleproblemedit.pm,v 1.33 2012/11/08 21:55:11 raeburn Exp $
+# $Id: lonsimpleproblemedit.pm,v 1.34 2012/11/09 03:28:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -205,7 +205,7 @@
my $weightprefix=$env{'request.course.id'}.'.'.$symb.'.';
# ---------------------------------------------------------- Anything to store?
-
+ my $storeresult;
if (($symb) && (defined($env{'form.questiontype'}))) {
my %storecontent=();
undef %storecontent;
@@ -247,7 +247,16 @@
&Apache::lonnet::devalidatecourseresdata(
$env{'course.'.$env{'request.course.id'}.'.num'},
$env{'course.'.$env{'request.course.id'}.'.domain'});
-
+ if ($reply eq 'ok') {
+ if ($env{'form.forceview'}) {
+ my $dest = &get_parent_uri($symb);
+ if ($dest) {
+ $r->internal_redirect($dest);
+ }
+ }
+ } else {
+ $storeresult = $reply;
+ }
}
# ------------------------------------------------------------------- Read Data
@@ -256,14 +265,34 @@
$env{'course.'.$env{'request.course.id'}.'.num'},
$env{'request.course.id'}.'.'.$symb);
+ my $js = <<"ENDJS";
+
+<script type="text/javascript">
+// <![CDATA[
+
+function setForceView() {
+ if (document.getElementById('spview')) {
+ document.getElementById('spview').value = 1;
+ }
+ return true;
+}
+// END LON-CAPA Internal -->
+// ]]>
+</script>
+
+ENDJS
+
# ------------------------------------------------------------ Print the screen
my $spell_header=&Apache::lonhtmlcommon::spellheader();
$r->print(&Apache::loncommon::start_page('Simple Problem Editor',
- $spell_header));
+ $spell_header.$js));
if ($symb) {
my $title='<h1>'.&Apache::lonnet::gettitle($symb).'</h1>';
if (&get_parent_uri($symb)) {
$r->print($title);
+ if ($storeresult) {
+ $r->print('<p class="LC_error">'.&mt('An error: [_1] occurred saving your changes',$storeresult).'</p>');
+ }
} else {
$r->print($title
.'<p class="LC_error">'
@@ -307,7 +336,10 @@
);
$r->print(
'<p>'
+ .'<input type="hidden" name="forceview" value="" id="spview" />'
.'<input type="submit" value="'.&mt('Save and Edit').'" />'
+ .(' ' x3)
+ .'<input type="submit" value="'.&mt('Save and View').'" onclick="javascript:setForceView();" />'
.'</p>'
);
# Script
@@ -407,7 +439,10 @@
}
# Store Button
$r->print(
- '<input type="submit" value="'.&mt('Save and Edit').'" /></form>');
+ '<input type="submit" value="'.&mt('Save and Edit').'" />'.
+ (' ' x3).
+ '<input type="submit" value="'.&mt('Save and View').'" onclick="javascript:setForceView();" />'.
+ '</form>');
} else {
$r->print(&mt('Could not identify problem.'));
}
More information about the LON-CAPA-cvs
mailing list