[LON-CAPA-cvs] cvs: loncom /homework chemresponse.pm
raeburn
raeburn@source.lon-capa.org
Tue, 23 Dec 2008 18:51:44 -0000
raeburn Tue Dec 23 18:51:44 2008 EDT
Modified files:
/loncom/homework chemresponse.pm
Log:
- Restore pre-2.7.1 functionality: "Show Your Last Answer" button displayed if after answer date, but no jmeanswer (for display of computer's answer) provided in problem.
- Remove code no longer used from start_organicresponse() following changes in 1.79 and 1.80 which replaced "Draw Molecule" button before input textbox with pencil icon after textbox.
- Change wording in CSTR for textbox entry for JME string of the answer, now pencil icon is used instead of "Draw Molecule" button.
Index: loncom/homework/chemresponse.pm
diff -u loncom/homework/chemresponse.pm:1.85 loncom/homework/chemresponse.pm:1.86
--- loncom/homework/chemresponse.pm:1.85 Mon Dec 22 15:05:49 2008
+++ loncom/homework/chemresponse.pm Tue Dec 23 18:51:44 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# chemical equation style response
#
-# $Id: chemresponse.pm,v 1.85 2008/12/22 15:05:49 raeburn Exp $
+# $Id: chemresponse.pm,v 1.86 2008/12/23 18:51:44 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -176,8 +176,14 @@
editor.focus();
}
</script>
-<a href="javascript:$function();void(0);"><img class="stift" src='$iconpath/stift.gif' alt='$display' title='$display' /></a>
CHEMINPUT
+ if ($shown_text eq '') {
+ $result .=<<PENCIL;
+<a href="javascript:$function();void(0);"><img class="stift" src='$iconpath/stift.gif' alt='$display' title='$display' /></a>
+PENCIL
+ } else {
+ $result .= '<input type="button" value="'.&mt($shown_text).'" onclick="javascript:'.$function.'();void(0);" />';
+ }
return $result;
}
sub jme_img {
@@ -203,30 +209,19 @@
} elsif ($target eq 'web') {
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,
- $safeeval);
- my (@answers)=&Apache::lonxml::get_param_var('answer',$parstack,
- $safeeval);
- $result.=&jme_img($jmeanswer,$answers[0],$width,$options);
- } else {
- my $molecule;
- if (defined($Apache::lonhomework::history{"resource.$partid.$id.molecule"})) {
- $molecule=$Apache::lonhomework::history{"resource.$partid.$id.molecule"};
- } else {
- $molecule=&Apache::lonxml::get_param('molecule',$parstack,
+ if (&Apache::response::show_answer()) {
+ my $jmeanswer=&Apache::lonxml::get_param('jmeanswer',$parstack,
+ $safeeval);
+ if ($jmeanswer ne '') {
+ my $options=&Apache::lonxml::get_param('options',$parstack,
+ $safeeval);
+ my $width=&Apache::lonxml::get_param('width',$parstack,
$safeeval);
- }
- my $options=&Apache::lonxml::get_param('options',$parstack,
- $safeeval);
- my $shown_text;
- if (&Apache::response::show_answer()) {
- $shown_text="Show Your Last Answer";
- }
- #stift $result=&separate_jme_window("HWVAL_$id","MOLECULE_$id",$molecule,
-# $options,$shown_text);
+ my (@answers)=&Apache::lonxml::get_param_var('answer',$parstack,
+ $safeeval);
+ $result.=&jme_img($jmeanswer,$answers[0],$width,$options);
+ }
+ } else {
$result.= '<input type="hidden" name="MOLECULE_'.$id.'" value="" />';
}
} elsif ($target eq 'edit') {
@@ -246,7 +241,7 @@
$result .=&Apache::edit::text_arg('Correct Answer:','answer',
$token,40);
$result .='</span><br /><span class="LC_nobreak">';
- $result .=&Apache::edit::text_arg('JME string of the answer (automatically updated when using the Draw Molecule button):',
+ $result .=&Apache::edit::text_arg('JME string of the answer - automatically updated by "Insert Answer" in the JME pop-up (click pencil):',
'jmeanswer',$token);
my $jmeanswer=&Apache::lonxml::get_param('jmeanswer',$parstack,
$safeeval);
@@ -342,13 +337,21 @@
&Apache::lonhomework::set_bubble_lines();
}
}
- if (($target eq 'web' ) && ($Apache::lonhomework::type ne 'exam') && ($Apache::inputtags::status['-1'] eq 'CAN_ANSWER')){
- my $options=&Apache::lonxml::get_param('options',$parstack,
- $safeeval);
- my $shown_text;
- if (&Apache::response::show_answer()) {
+ if ($target eq 'web' ) {
+ my ($showpencil,$shown_text);
+ if ($Apache::inputtags::status['-1'] eq 'CAN_ANSWER') {
+ $showpencil = 1;
+ } elsif (&Apache::response::show_answer()) {
+ my $jmeanswer=&Apache::lonxml::get_param('jmeanswer',$parstack, $safeeval);
+ if ($jmeanswer eq '') {
+ $showpencil = 1;
$shown_text="Show Your Last Answer";
}
+ }
+ if ($showpencil) {
+ my $options=&Apache::lonxml::get_param('options',$parstack,
+ $safeeval);
+
my $molecule;
if (defined($Apache::lonhomework::history{"resource.$partid.$id.molecule"})) {
$molecule=$Apache::lonhomework::history{"resource.$partid.$id.molecule"};
@@ -356,8 +359,9 @@
$molecule=&Apache::lonxml::get_param('molecule',$parstack,
$safeeval);
}
- $result.=&separate_jme_window("HWVAL_$id","MOLECULE_$id",$molecule,
- $options,$shown_text);
+ $result.=&separate_jme_window("HWVAL_$id","MOLECULE_$id",$molecule,
+ $options,$shown_text);
+ }
}
&Apache::response::end_response();
return $result;