--- loncom/homework/chemresponse.pm 2005/06/27 14:27:25 1.59 +++ 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.59 2005/06/27 14:27:25 albertel Exp $ +# $Id: chemresponse.pm,v 1.64 2006/03/09 01:12:05 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -105,17 +105,40 @@ function submitSmiles() { function openHelpWindow() { window.open("/adm/jme/jme_help.html","","scrollbars=yes,resizable=yes,width=500,height=600"); } +function substituent(r) {document.applets.JME.setSubstituent(r);}
- +
+ + + +
+ +
+ You have to enable Java and JavaScript on your machine. $molecule
JME Editor courtesy of Peter Ertl, Novartis - +
$insert_answer
@@ -133,7 +156,7 @@ CHEMPAGE my $display=&mt('Draw Molecule'); if (defined($shown_text)) { $display=&mt($shown_text); } my $result=< + CHEMINPUT return $result; } @@ -228,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; @@ -271,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; } @@ -294,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); @@ -422,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; @@ -459,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; }