--- loncom/homework/chemresponse.pm 2004/09/27 20:59:21 1.39
+++ loncom/homework/chemresponse.pm 2005/01/21 22:10:59 1.44
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# chemical equation style response
#
-# $Id: chemresponse.pm,v 1.39 2004/09/27 20:59:21 www Exp $
+# $Id: chemresponse.pm,v 1.44 2005/01/21 22:10:59 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -121,9 +121,9 @@ $molecule
CHEMPAGE
$body=&HTML::Entities::encode($body,'<>&"');
$body=~s/\n/ /g;
- my $nothing= &Apache::lonhtmlcommon::javascript_nothing();
+ my $docopen=&Apache::lonhtmlcommon::javascript_docopen();
my $result=<
+
CHEMINPUT
return $result;
}
@@ -136,17 +136,34 @@ sub start_organicresponse {
if ($target eq 'meta') {
$result=&Apache::response::meta_package_write('organicresponse');
} elsif ($target eq 'web') {
- my $molecule;
- if (defined($Apache::lonhomework::history{"resource.$partid.$id.molecule"})) {
- $molecule=$Apache::lonhomework::history{"resource.$partid.$id.molecule"};
+ if ( &Apache::response::show_answer() ) {
+ my $jmeanswer=&Apache::lonxml::get_param('jmeanswer',$parstack,
+ $safeeval);
+ my $options=&Apache::lonxml::get_param('options',$parstack,
+ $safeeval);
+ my $width=&Apache::lonxml::get_param('width',$parstack,
+ $safeeval);
+ my $id=&Apache::loncommon::get_cgi_id();
+ $result="
';
+ &Apache::lonnet::appenv('cgi.'.$id.'.JME' =>
+ &Apache::lonnet::escape($jmeanswer),
+ 'cgi.'.$id.'.PNG' => 1,
+ 'cgi.'.$id.'.WIDTH' => $width);
} else {
- $molecule=&Apache::lonxml::get_param('molecule',$parstack,
- $safeeval);
+ 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,
+ $safeeval);
+ }
+ my $options=&Apache::lonxml::get_param('options',$parstack,
+ $safeeval);
+ $result=&separate_jme_window("HWVAL_$id","MOLECULE_$id",$molecule,$options);
+ $result.= '';
}
- my $options=&Apache::lonxml::get_param('options',$parstack,
- $safeeval);
- $result=&separate_jme_window("HWVAL_$id","MOLECULE_$id",$molecule,$options);
- $result.= '';
} elsif ($target eq 'edit') {
$result .=&Apache::edit::tag_start($target,$token);
my $options=&Apache::lonxml::get_param('options',$parstack,
@@ -178,12 +195,14 @@ sub start_organicresponse {
['reaction','Is a reaction'],
['number','Able to number atoms'] ],
,$token);
+ $result .=&Apache::edit::text_arg('Width of correct answer image:',
+ 'width',$token,10);
$result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
} elsif ($target eq 'modified') {
my $constructtag=&Apache::edit::get_new_args($token,$parstack,
$safeeval,'molecule',
'answer','jmeanswer',
- 'options');
+ 'options','width');
if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
}
return $result;
@@ -211,6 +230,9 @@ sub end_organicresponse {
$ad='INCORRECT';
}
}
+ if ($ad && $Apache::lonhomework::type eq 'survey') {
+ $ad='SUBMITTED';
+ }
&Apache::response::handle_previous(\%previous,$ad);
$Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad;
$Apache::lonhomework::results{"resource.$partid.$id.molecule"}=$ENV{"form.MOLECULE_$id"};
@@ -309,12 +331,12 @@ sub edit_reaction_button {
my $id_es=&Apache::lonnet::escape($id);
my $field_es=&Apache::lonnet::escape($field);
my $reaction_es=&Apache::lonnet::escape($reaction);
- my $nothing= &Apache::lonhtmlcommon::javascript_nothing();
+ my $docopen=&Apache::lonhtmlcommon::javascript_docopen();
my $result=<
function create_reaction_window_${id}_${field} () {
editor=window.open('','','width=500,height=270,scrollbars=no,resizable=yes');
- editor.document.open($nothing,'replace');
+ editor.$docopen;
editor.document.writeln(' LON-CAPA Reaction Editor ');
}
@@ -352,7 +374,7 @@ sub start_reactionresponse {
$result .=&edit_reaction_button($id,&Apache::edit::html_element_name('answer'),$answer).'';
my $initial=&Apache::lonxml::get_param('initial',$parstack,$safeeval);
$result.=''.
- &Apache::edit::text_arg('Initial Reation:','initial',$token,40);
+ &Apache::edit::text_arg('Initial Reaction:','initial',$token,40);
$result .=&edit_reaction_button($id,&Apache::edit::html_element_name('initial'),$initial).'';
$result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
@@ -387,6 +409,9 @@ sub end_reactionresponse {
$ad='INCORRECT';
}
}
+ if ($ad && $Apache::lonhomework::type eq 'survey') {
+ $ad='SUBMITTED';
+ }
&Apache::response::handle_previous(\%previous,$ad);
$Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad;
}