--- loncom/homework/chemresponse.pm 2005/07/01 19:48:46 1.61 +++ 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.61 2005/07/01 19:48:46 albertel Exp $ +# $Id: chemresponse.pm,v 1.64 2006/03/09 01:12:05 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -251,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; @@ -294,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; } @@ -317,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); @@ -445,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; @@ -482,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; }