--- loncom/homework/chemresponse.pm 2005/06/30 18:56:35 1.60
+++ loncom/homework/chemresponse.pm 2006/03/09 01:12:05 1.64
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# chemical equation style response
#
-# $Id: chemresponse.pm,v 1.60 2005/06/30 18:56:35 albertel Exp $
+# $Id: chemresponse.pm,v 1.64 2006/03/09 01:12:05 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -138,6 +138,7 @@ $molecule
JME Editor courtesy of Peter Ertl, Novartis
+
$insert_answer
@@ -155,7 +156,7 @@ CHEMPAGE
my $display=&mt('Draw Molecule');
if (defined($shown_text)) { $display=&mt($shown_text); }
my $result=<
+
CHEMINPUT
return $result;
}
@@ -250,18 +251,30 @@ sub start_organicresponse {
'options','width');
if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
}
+
return $result;
}
sub end_organicresponse {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $result;
- if ($target eq 'grade' && &Apache::response::submitted()) {
+
+ my $partid = $Apache::inputtags::part;
+ my $id = $Apache::inputtags::response['-1'];
+
+ if ($target eq 'grade'
+ && &Apache::response::submitted()
+ && $Apache::lonhomework::type eq 'exam') {
+
+ &Apache::response::scored_response($partid,$id);
+
+ } elsif ($target eq 'grade'
+ && &Apache::response::submitted()
+ && $Apache::lonhomework::type ne 'exam') {
+
&Apache::response::setup_params($$tagstack[-1],$safeeval);
my $response = &Apache::response::getresponse();
if ( $response =~ /[^\s]/) {
- my $partid = $Apache::inputtags::part;
- my $id = $Apache::inputtags::response['-1'];
my (@answers)=&Apache::lonxml::get_param_var('answer',$parstack,$safeeval);
my %previous = &Apache::response::check_for_previous($response,$partid,$id);
$Apache::lonhomework::results{"resource.$partid.$id.submission"}=$response;
@@ -293,7 +306,12 @@ sub end_organicresponse {
}
$result.=&Apache::response::answer_footer('organicresponse');
}
- &Apache::response::end_response;
+
+ if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
+ $target eq 'tex' || $target eq 'analyze') {
+ &Apache::lonxml::increment_counter(&Apache::response::repetition());
+ }
+ &Apache::response::end_response();
return $result;
}
@@ -316,7 +334,7 @@ sub start_organicstructure {
my $texwidth=&Apache::lonxml::get_param('texwidth',$parstack,$safeeval,undef,1);
my $webwidth=&Apache::lonxml::get_param('width', $parstack, $safeeval);
my $webheight=&Apache::lonxml::get_param('height', $parstack, $safeeval);
- if ($webheight) { $webheight = $webwidth; }
+ if (!$webheight) { $webheight = $webwidth; }
if (!$texwidth) { $texwidth='90'; }
$result = "%DYNAMICIMAGE:$webwidth:$webheight:$texwidth\n";
my $molecule=&Apache::lonxml::get_param('molecule',$parstack,$safeeval);
@@ -444,12 +462,23 @@ sub start_reactionresponse {
sub end_reactionresponse {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $result;
- if ($target eq 'grade' && &Apache::response::submitted()) {
+
+ my $partid = $Apache::inputtags::part;
+ my $id = $Apache::inputtags::response['-1'];
+
+ if ($target eq 'grade'
+ && &Apache::response::submitted()
+ && $Apache::lonhomework::type eq 'exam') {
+
+ &Apache::response::scored_response($partid,$id);
+
+ } elsif ($target eq 'grade'
+ && &Apache::response::submitted()
+ && $Apache::lonhomework::type ne 'exam') {
+
&Apache::response::setup_params($$tagstack[-1],$safeeval);
my $response = &Apache::response::getresponse();
if ( $response =~ /[^\s]/) {
- my $partid = $Apache::inputtags::part;
- my $id = $Apache::inputtags::response['-1'];
my (@answers)=&Apache::lonxml::get_param_var('answer',$parstack,$safeeval);
my %previous = &Apache::response::check_for_previous($response,$partid,$id);
$Apache::lonhomework::results{"resource.$partid.$id.submission"}=$response;
@@ -481,7 +510,12 @@ sub end_reactionresponse {
}
$result.=&Apache::response::answer_footer('reactionresponse');
}
- &Apache::response::end_response;
+
+ if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
+ $target eq 'tex' || $target eq 'analyze') {
+ &Apache::lonxml::increment_counter(&Apache::response::repetition());
+ }
+ &Apache::response::end_response();
return $result;
}