--- loncom/homework/caparesponse/caparesponse.pm 2007/04/16 23:25:12 1.211 +++ loncom/homework/caparesponse/caparesponse.pm 2007/04/17 23:25:24 1.212 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # caparesponse definition # -# $Id: caparesponse.pm,v 1.211 2007/04/16 23:25:12 albertel Exp $ +# $Id: caparesponse.pm,v 1.212 2007/04/17 23:25:24 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -601,7 +601,7 @@ sub end_numericalresponse { } } } - &setup_prior_tries_hash(); + &Apache::response::setup_prior_tries_hash(\&format_prior_response_numerical); } elsif ($target eq 'edit') { $result.=''.&Apache::edit::end_table; } elsif ($target eq 'answer' || $target eq 'analyze') { @@ -792,18 +792,12 @@ sub end_numericalresponse { return $result; } -sub setup_prior_tries_hash { - #FIXME support multi answer numericals/formula - my $part=$Apache::inputtags::part; - my $id=$Apache::inputtags::response[-1]; - foreach my $i (1..$Apache::lonhomework::history{'version'}) { - my $key = "$i:resource.$part.$id.submission"; - next if (!exists($Apache::lonhomework::history{"$key"})); - $Apache::inputtags::submission_display{$key} = - ''. - &HTML::Entities::encode($Apache::lonhomework::history{$key}, - '"<>&').''; - } +sub format_prior_response_numerical { + my ($mode,$answer) = @_; + #FIXME needs to support multianswer modes + return ''. + &HTML::Entities::encode($answer,'"<>&').''; + } sub check_for_answer_errors { @@ -1025,17 +1019,10 @@ sub get_sigrange { return ($sig_ubound,$sig_lbound); } -sub setup_prior_tries_hash_string { - my $part=$Apache::inputtags::part; - my $id=$Apache::inputtags::response[-1]; - foreach my $i (1..$Apache::lonhomework::history{'version'}) { - my $key = "$i:resource.$part.$id.submission"; - next if (!exists($Apache::lonhomework::history{"$key"})); - $Apache::inputtags::submission_display{$key} = - ''. - &HTML::Entities::encode($Apache::lonhomework::history{$key}, - '"<>&').''; - } +sub format_prior_response_string { + my ($mode,$answer) =@_; + return ''. + &HTML::Entities::encode($answer,'"<>&').''; } sub start_stringresponse { @@ -1216,7 +1203,7 @@ sub end_stringresponse { } elsif ($target eq 'edit') { $result.=''.&Apache::edit::end_table; } elsif ($target eq 'web' || $target eq 'tex') { - &setup_prior_tries_hash_string(); + &Apache::response::setup_prior_tries_hash(\&format_prior_response_string); } if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || $target eq 'tex' || $target eq 'analyze') {