--- loncom/homework/caparesponse/caparesponse.pm 2006/02/06 23:02:50 1.187 +++ loncom/homework/caparesponse/caparesponse.pm 2006/07/03 14:21:45 1.193 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # caparesponse definition # -# $Id: caparesponse.pm,v 1.187 2006/02/06 23:02:50 albertel Exp $ +# $Id: caparesponse.pm,v 1.193 2006/07/03 14:21:45 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -29,6 +29,8 @@ package Apache::caparesponse; use strict; use capa; +use Safe::Hole; +use Apache::lonmaxima(); use Apache::lonlocal; use Apache::lonnet; @@ -247,7 +249,11 @@ sub check_submission { } if ($tag eq 'formularesponse') { - $$args_ref{'type'}='fml'; +# if ($$args_ref{'samples'}) { + $$args_ref{'type'}='fml'; +# } else { +# $$args_ref{'type'}='math'; +# } } elsif ($tag eq 'numericalresponse') { $$args_ref{'type'}='float'; } @@ -290,12 +296,15 @@ sub end_numericalresponse { my $partid = $Apache::inputtags::part; my $id = $Apache::inputtags::response[-1]; my $tag; + my $safehole = new Safe::Hole; $safeeval->share_from('capa',['&caparesponse_capa_check_answer']); + $safehole->wrap(\&Apache::lonmaxima::maxima_check,$safeeval,'&maxima_check'); + if (scalar(@$tagstack)) { $tag=$$tagstack[-1]; } if ( $target eq 'grade' && &Apache::response::submitted() ) { &Apache::response::setup_params($tag,$safeeval); if ($Apache::lonhomework::type eq 'exam' && - $tag eq 'formularesponse') { + (($tag eq 'formularesponse') || ($tag eq 'mathresponse'))) { $increment=&Apache::response::scored_response($partid,$id); } else { my $response = &Apache::response::getresponse(); @@ -362,10 +371,6 @@ sub end_numericalresponse { $bubble_display->[$ind].''; } $result.=''; - } elsif ($tag eq 'formularesponse') { - $result.= '

-

'; } } elsif ($target eq 'tex') { if ((defined $unit) and ($unit=~/\S/) and ($Apache::lonhomework::type eq 'exam')) { @@ -393,14 +398,7 @@ sub end_numericalresponse { } $result.='\end{enumerate}'; } else { - $result.='\fbox{\fbox{\parbox{\textwidth-5mm}{\strut\\\\\strut\\\\\strut\\\\\strut\\\\}}}'; - my $repetition = &Apache::response::repetition(); - $result.='\begin{enumerate}'; - for (my $i=0;$i<$repetition;$i++) { - $result.='\item[\textbf{'.($Apache::lonxml::counter+$i).'}.]\textit{Leave blank on scoring form}\vskip 0 mm'; - } - $increment=$repetition; - $result.= '\end{enumerate}'; + $increment = &Apache::response::repetition(); } } } @@ -787,7 +785,7 @@ sub start_stringresponse { sub end_stringresponse { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; - my $increment=1; + my $result = ''; my $part=$Apache::inputtags::part; my $id=$Apache::inputtags::response[-1]; @@ -803,7 +801,8 @@ sub end_stringresponse { $safeeval->share_from('capa',['&caparesponse_capa_check_answer']); if ($Apache::lonhomework::type eq 'exam' || &Apache::response::submitted('scantron')) { - $increment=&Apache::response::scored_response($part,$id); + &Apache::response::scored_response($part,$id); + } else { my $response = &Apache::response::getresponse(); if ( $response =~ /[^\s]/) { @@ -856,19 +855,6 @@ sub end_stringresponse { $Apache::lonhomework::results{"resource.$part.$id.awardmsg"}=$msg; } } - } elsif ($target eq 'web' || $target eq 'tex') { - my $award = $Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"}; - my $status = $Apache::inputtags::status['-1']; - if ($Apache::lonhomework::type eq 'exam' && $target eq 'tex') { - $result.='\fbox{\fbox{\parbox{\textwidth-5mm}{\strut\\\\\strut\\\\\strut\\\\\strut\\\\}}}'; - $increment = &Apache::response::repetition(); - $result.='\begin{enumerate}'; - for (my $i=0;$i<$increment;$i++) { - $result.='\item[\textbf{'.($Apache::lonxml::counter+$i). - '}.]\textit{Leave blank on scoring form}\vskip 0 mm'; - } - $result.= '\end{enumerate}'; - } } elsif ($target eq 'answer' || $target eq 'analyze') { if ($target eq 'analyze') { push (@{ $Apache::lonhomework::analyze{"parts"} },"$part.$id"); @@ -922,7 +908,7 @@ sub end_stringresponse { } if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || $target eq 'tex' || $target eq 'analyze') { - &Apache::lonxml::increment_counter($increment); + &Apache::lonxml::increment_counter(&Apache::response::repetition()); } &Apache::response::end_response; return $result;