--- loncom/interface/statistics/lonstathelpers.pm 2006/05/30 12:46:50 1.53 +++ loncom/interface/statistics/lonstathelpers.pm 2006/12/29 21:47:11 1.54 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonstathelpers.pm,v 1.53 2006/05/30 12:46:50 www Exp $ +# $Id: lonstathelpers.pm,v 1.54 2006/12/29 21:47:11 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -736,11 +736,16 @@ sub get_answer { my ($prefix,$key,%Answer) = @_; my $returnvalue; if (exists($Answer{$key})) { - my $student_answer = $Answer{$key}->[0]; - if (! defined($student_answer)) { - $student_answer = $Answer{$key}->[1]; - } - $returnvalue = $student_answer; + if (ref($Answer{$key}) eq 'HASH') { + my $which = 'INTERNAL'; + if (!exists($Answer{$key}{$which})) { + $which = (sort(keys(%{ $Answer{$key} })))[0]; + } + my $student_answer = $Answer{$key}{$which}[0][0]; + $returnvalue = $student_answer; + } else { + &Apache::lonnet::logthis("error analyzing problem. got a answer of type ".ref($Answer{$key})); + } } else { if (exists($Answer{$prefix.'.shown'})) { # The response has foils