--- loncom/homework/chemresponse.pm 2008/09/05 16:09:39 1.79
+++ loncom/homework/chemresponse.pm 2008/12/23 18:51:44 1.86
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# chemical equation style response
#
-# $Id: chemresponse.pm,v 1.79 2008/09/05 16:09:39 riegler 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 @@ CHEMPAGE
editor.focus();
}
-
CHEMINPUT
+ if ($shown_text eq '') {
+ $result .=<
+PENCIL
+ } else {
+ $result .= '';
+ }
return $result;
}
sub jme_img {
@@ -203,30 +209,19 @@ sub start_organicresponse {
} 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.= '';
}
} elsif ($target eq 'edit') {
@@ -234,7 +229,7 @@ sub start_organicresponse {
my $options=&Apache::lonxml::get_param('options',$parstack,
$safeeval);
if ($options !~ /multipart/) { $options.=',multipart'; }
- $result .=''.
+ $result .=''.
&Apache::edit::text_arg('Starting Molecule:','molecule',
$token,40);
my $molecule=&Apache::lonxml::get_param('molecule',$parstack,
@@ -242,11 +237,11 @@ sub start_organicresponse {
$result .=&separate_jme_window(undef,
&Apache::edit::html_element_name('molecule'),
$molecule,$options);
- $result .='
';
+ $result .='
';
$result .=&Apache::edit::text_arg('Correct Answer:','answer',
$token,40);
- $result .='
';
- $result .=&Apache::edit::text_arg('JME string of the answer (automatically updated when using the Draw Molecule button):',
+ $result .='
';
+ $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);
@@ -254,7 +249,7 @@ sub start_organicresponse {
&Apache::edit::html_element_name('answer'),
&Apache::edit::html_element_name('jmeanswer'),
$jmeanswer,$options);
- $result .='
';
+ $result .='
';
$result .=&Apache::edit::checked_arg('Options:','options',
[ ['autoez','Auto E,Z stereochemistry'],
['multipart','Multipart Structures'],
@@ -338,17 +333,25 @@ sub end_organicresponse {
"$partid.$id"); # part.response
if ($target eq 'analyze') {
$Apache::lonhomework::analyze{"$partid.$id.type"} = 'organicresponse';
+ push (@{ $Apache::lonhomework::analyze{"parts"} },"$partid.$id");
&Apache::lonhomework::set_bubble_lines();
}
}
- if (($target eq 'web' ) && ($Apache::lonhomework::type ne 'exam') && ($Apache::inputtags::status['-1'] eq 'CAN_ANSWER')){
-# hierher
- 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 @@ sub end_organicresponse {
$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;
@@ -411,7 +415,7 @@ sub start_organicstructure {
$result .=&Apache::edit::tag_start($target,$token);
$result .=&Apache::edit::text_arg('Width (pixels):','width',$token,5);
$result .=&Apache::edit::text_arg('TeXwidth (mm):','texwidth',$token,5);
- $result .='';
+ $result .='';
$result .=&Apache::edit::text_arg('Molecule:','molecule',$token,40);
my $molecule=&Apache::lonxml::get_param('molecule',$parstack,
$safeeval);
@@ -424,7 +428,7 @@ sub start_organicstructure {
$result .=&separate_jme_window(undef,
&Apache::edit::html_element_name('molecule'),
$molecule,$options);
- $result.="
";
+ $result.="
";
$result .=&Apache::edit::checked_arg('Options:','options',
[ ['reaction','Is a reaction'],
['border','Draw a border'] ],
@@ -455,6 +459,8 @@ sub edit_reaction_button {
my $field_es=&escape($field);
my $reaction_es=&escape($reaction);
my $docopen=&Apache::lonhtmlcommon::javascript_docopen();
+ my $iconpath=$Apache::lonnet::perlvar{'lonIconsURL'};
+ my $display=&mt('Edit Answer');
my $start_page =
&Apache::loncommon::start_page('LON-CAPA Reaction Editor',undef,
{'frameset' => 1,
@@ -476,7 +482,7 @@ sub edit_reaction_button {
}
// -->
-
+
EDITREACTION
return $result;
}
@@ -490,12 +496,6 @@ sub start_reactionresponse {
} elsif ($target eq 'web') {
my $partid = $Apache::inputtags::part;
my $id = $Apache::inputtags::response['-1'];
- my $reaction=$Apache::lonhomework::history{"resource.$partid.$id.submission"};
- if ($reaction eq '') { $reaction=&Apache::lonxml::get_param('initial',$parstack,$safeeval); }
- my $status=$Apache::inputtags::status['-1'];
- if ($status eq 'CAN_ANSWER') {
- $result.=&edit_reaction_button($id,"HWVAL_$id",$reaction);
- }
if ( &Apache::response::show_answer() ) {
my $ans=&Apache::lonxml::get_param('answer',$parstack,$safeeval);
if (!$Apache::lonxml::default_homework_loaded) {
@@ -508,14 +508,13 @@ sub start_reactionresponse {
$result .=&Apache::edit::tag_start($target,$token);
my $answer=&Apache::lonxml::get_param('answer',$parstack,
$safeeval);
- $result .=''.
+ $result .=''.
&Apache::edit::text_arg('Answer:','answer',$token,40);
- $result .=&edit_reaction_button($id,&Apache::edit::html_element_name('answer'),$answer).'';
+ $result .=&edit_reaction_button($id,&Apache::edit::html_element_name('answer'),$answer).'';
my $initial=&Apache::lonxml::get_param('initial',$parstack,$safeeval);
- $result.=''.
+ $result.=''.
&Apache::edit::text_arg('Initial Reaction:','initial',$token,40);
- $result .=&edit_reaction_button($id,&Apache::edit::html_element_name('initial'),$initial).'';
-
+ $result .=&edit_reaction_button($id,&Apache::edit::html_element_name('initial'),$initial).'';
$result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
} elsif ($target eq 'modified') {
my $constructtag=&Apache::edit::get_new_args($token,$parstack,
@@ -586,9 +585,16 @@ sub end_reactionresponse {
&Apache::lonxml::increment_counter(&Apache::response::repetition(), "$partid.$id");
if ($target eq 'analyze') {
$Apache::lonhomework::analyze{"$partid.$id.type"} = 'reactionresponse';
+ push (@{ $Apache::lonhomework::analyze{"parts"} },"$partid.$id");
&Apache::lonhomework::set_bubble_lines();
}
}
+ my $status=$Apache::inputtags::status['-1'];
+ if (($target eq 'web') && ($Apache::lonhomework::type ne 'exam') && ($status eq 'CAN_ANSWER')) {
+ my $reaction=$Apache::lonhomework::history{"resource.$partid.$id.submission"};
+ if ($reaction eq '') { $reaction=&Apache::lonxml::get_param('initial',$parstack,$safeeval); }
+ $result.=&edit_reaction_button($id,"HWVAL_$id",$reaction);
+ }
&Apache::response::end_response();
return $result;
}