--- loncom/homework/caparesponse/caparesponse.pm 2008/07/26 15:06:43 1.227 +++ loncom/homework/caparesponse/caparesponse.pm 2008/09/23 19:22:58 1.227.2.4 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # caparesponse definition # -# $Id: caparesponse.pm,v 1.227 2008/07/26 15:06:43 raeburn Exp $ +# $Id: caparesponse.pm,v 1.227.2.4 2008/09/23 19:22:58 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -310,10 +310,6 @@ sub start_numericalresponse { $safeeval); if ($unit =~ /\S/) { $result.=" (in $unit) "; } } - if (($token->[1] eq 'formularesponse') && - ($Apache::inputtags::status['-1'] eq 'CAN_ANSWER')) { - $result.=&edit_formula_button($id,"HWVAL_$id"); - } if ( &Apache::response::show_answer() ) { &set_answertext($tag_internal_answer_name,$target,$token,$tagstack, $parstack,$parser,$safeeval,-1); @@ -322,22 +318,6 @@ sub start_numericalresponse { return $result; } -sub edit_formula_button { - my ($id,$field)=@_; - my $button=&mt('Edit Answer'); - my $helplink=&Apache::loncommon::help_open_topic('Formula_Editor'); - return(< -function edit_${id}_${field} (textarea) { - thenumber = textarea; - thedata = document.forms['lonhomework'].elements[textarea].value; - newwin = window.open("/adm/dragmath/applet/MaximaPopup.html","","width=565,height=400,resizable"); -} - -$helplink -ENDFORMULABUTTON -} - sub set_answertext { my ($name,$target,$token,$tagstack,$parstack,$parser,$safeeval, $response_level) = @_; @@ -447,8 +427,12 @@ sub check_submission { } } elsif ($tag eq 'numericalresponse') { $$args_ref{'type'}='float'; + } elsif ($tag eq 'stringresponse') { + if ($$args_ref{'type'} eq '') { + $$args_ref{'type'} = 'ci'; + } } - + &add_in_tag_answer($parstack,$safeeval); if (!%answer) { @@ -622,6 +606,12 @@ sub end_numericalresponse { } } } + if (($target eq 'web') && ($tag eq 'formularesponse') + && ($Apache::lonhomework::type ne 'exam') && ($Apache::inputtags::status['-1'] eq 'CAN_ANSWER') + && (&Apache::lonnet::EXT('resource.'.$partid.'_'.$id.'.turnoffeditor') ne 'yes')) { + $result.=&Apache::response::edit_mathresponse_button($id,"HWVAL_$id"); + } + &Apache::response::setup_prior_tries_hash(\&format_prior_response_numerical); } elsif ($target eq 'edit') { $result.=''.&Apache::edit::end_table; @@ -1171,7 +1161,9 @@ sub end_stringresponse { my @args = ('type'); my $args_ref = &setup_capa_args($safeeval,$parstack, \@args,$response); - + if ($$args_ref{'type'} eq '') { + $$args_ref{'type'} = 'ci'; + } &add_in_tag_answer($parstack,$safeeval); my (@final_awards,@final_msgs,@names); foreach my $name (keys(%answer)) {