[LON-CAPA-cvs] cvs: loncom /homework chemresponse.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Thu, 26 May 2005 20:59:49 -0000
albertel Thu May 26 16:59:49 2005 EDT
Modified files:
/loncom/homework chemresponse.pm
Log:
- degraded more gracefully in view of an instructor not providing a jme version of the answer
Index: loncom/homework/chemresponse.pm
diff -u loncom/homework/chemresponse.pm:1.54 loncom/homework/chemresponse.pm:1.55
--- loncom/homework/chemresponse.pm:1.54 Thu May 26 16:49:23 2005
+++ loncom/homework/chemresponse.pm Thu May 26 16:59:47 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# chemical equation style response
#
-# $Id: chemresponse.pm,v 1.54 2005/05/26 20:49:23 albertel Exp $
+# $Id: chemresponse.pm,v 1.55 2005/05/26 20:59:47 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -30,6 +30,7 @@
use strict;
use Apache::lonxml;
use Apache::lonnet;
+use Apache::lonlocal;
BEGIN {
&Apache::lonxml::register('Apache::chemresponse',('organicresponse','organicstructure','reactionresponse','chem'));
@@ -63,7 +64,7 @@
}
sub separate_jme_window {
- my ($smile_input,$jme_input,$molecule,$options)=@_;
+ my ($smile_input,$jme_input,$molecule,$options,$shown_text)=@_;
my $smilesection;
if (defined($smile_input)) {
$smilesection=<<SMILESECTION;
@@ -123,8 +124,10 @@
$body=~s/\n/ /g;
my $nothing=&Apache::lonhtmlcommon::javascript_nothing();
my $docopen=&Apache::lonhtmlcommon::javascript_docopen();
+ my $display=&mt('Draw Molecule');
+ if (defined($shown_text)) { $display=&mt($shown_text); }
my $result=<<CHEMINPUT;
-<input type="button" value="Draw Molecule" onclick="javascript:editor=window.open($nothing,'jmeedit','width=500,height=500,menubar=yes,scrollbars=no,resizable=yes');editor.$docopen;editor.document.write('$body');editor.document.close();editor.focus()" />
+<input type="button" value="$display" onclick="javascript:editor=window.open($nothing,'jmeedit','width=500,height=500,menubar=yes,scrollbars=no,resizable=yes');editor.$docopen;editor.document.write('$body');editor.document.close();editor.focus()" />
CHEMINPUT
return $result;
}
@@ -137,9 +140,9 @@
if ($target eq 'meta') {
$result=&Apache::response::meta_package_write('organicresponse');
} elsif ($target eq 'web') {
- if ( &Apache::response::show_answer() ) {
- my $jmeanswer=&Apache::lonxml::get_param('jmeanswer',$parstack,
- $safeeval);
+ my $jmeanswer=&Apache::lonxml::get_param('jmeanswer',$parstack,
+ $safeeval);
+ if ( &Apache::response::show_answer() && $jmeanswer ne '') {
my $options=&Apache::lonxml::get_param('options',$parstack,
$safeeval);
my $width=&Apache::lonxml::get_param('width',$parstack,
@@ -162,7 +165,12 @@
}
my $options=&Apache::lonxml::get_param('options',$parstack,
$safeeval);
- $result=&separate_jme_window("HWVAL_$id","MOLECULE_$id",$molecule,$options);
+ my $shown_text;
+ if (&Apache::response::show_answer()) {
+ $shown_text="Show Your Last Answer";
+ }
+ $result=&separate_jme_window("HWVAL_$id","MOLECULE_$id",$molecule,
+ $options,$shown_text);
$result.= '<input type="hidden" name="MOLECULE_'.$id.'" value="" />';
}
} elsif ($target eq 'edit') {