--- loncom/homework/chemresponse.pm 2004/03/08 17:31:37 1.30 +++ loncom/homework/chemresponse.pm 2004/06/07 21:17:42 1.33 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # chemical equation style response # -# $Id: chemresponse.pm,v 1.30 2004/03/08 17:31:37 www Exp $ +# $Id: chemresponse.pm,v 1.33 2004/06/07 21:17:42 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -92,7 +92,7 @@ $molecule CHEMPAGE - $body=&HTML::Entities::encode($body); + $body=&HTML::Entities::encode($body,'<>&"'); $body=~s/\n/ /g; my $result=< @@ -165,7 +165,7 @@ sub end_organicresponse { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; my $result; if ($target eq 'grade' && defined($ENV{'form.submitted'})) { - &Apache::response::setup_params($$tagstack[-1]); + &Apache::response::setup_params($$tagstack[-1],$safeeval); my $response = &Apache::response::getresponse(); if ( $response =~ /[^\s]/) { my $partid = $Apache::inputtags::part; @@ -304,7 +304,15 @@ sub start_reactionresponse { my $partid = $Apache::inputtags::part; my $id = $Apache::inputtags::response['-1']; my $reaction=$Apache::lonhomework::history{"resource.$partid.$id.submission"}; - $result.=&edit_reaction_button($id,"HWVAL_$id",$reaction); + 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); + $ans=~s/(\\|\')/\\$1/g; + $Apache::inputtags::answertxt{$id}=&Apache::run::run("return &chemparse('$ans');",$safeeval); + } } elsif ($target eq "edit") { $result .=&Apache::edit::tag_start($target,$token); my $answer=&Apache::lonxml::get_param('answer',$parstack, @@ -326,7 +334,7 @@ sub end_reactionresponse { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; my $result; if ($target eq 'grade' && defined($ENV{'form.submitted'})) { - &Apache::response::setup_params($$tagstack[-1]); + &Apache::response::setup_params($$tagstack[-1],$safeeval); my $response = &Apache::response::getresponse(); if ( $response =~ /[^\s]/) { my $partid = $Apache::inputtags::part;