--- loncom/homework/caparesponse/caparesponse.pm 2007/04/26 23:15:43 1.213 +++ loncom/homework/caparesponse/caparesponse.pm 2007/08/29 10:09:56 1.217 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # caparesponse definition # -# $Id: caparesponse.pm,v 1.213 2007/04/26 23:15:43 albertel Exp $ +# $Id: caparesponse.pm,v 1.217 2007/08/29 10:09:56 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -392,9 +392,6 @@ sub setup_capa_args { sub setup_capa_response { my ($args_ref,$response) = @_; - use Data::Dumper; - &Apache::lonxml::debug("response dump is ".&Dumper($response)); - if (ref($response)) { $$args_ref{'response'}=dclone($response); } else { @@ -608,6 +605,7 @@ sub end_numericalresponse { my $part_id="$partid.$id"; if ($target eq 'analyze') { push (@{ $Apache::lonhomework::analyze{"parts"} },$part_id); + push (@{ $Apache::lonhomework::analyze{"$part_id.bubble_lines"} }, 1); $Apache::lonhomework::analyze{"$part_id.type"} = $tag; my (@incorrect)=&Apache::lonxml::get_param_var('incorrect',$parstack,$safeeval); if ($#incorrect eq 0) { @incorrect=(split(/,/,$incorrect[0])); } @@ -824,10 +822,9 @@ sub check_for_answer_errors { } (sort(keys(%counts)))); &Apache::lonxml::error(&mt("All answers must have the same number of components. Varying numbers of answers were seen. ").$counts); } - use Data::Dumper; - &Apache::lonxml::debug("count dump is ".&Dumper(\%counts)); my $expected_number_of_inputs = (keys(%counts))[0]; - if ( $expected_number_of_inputs != scalar(@Apache::inputtags::inputlist)) { + if ( $expected_number_of_inputs > 0 + && $expected_number_of_inputs != scalar(@Apache::inputtags::inputlist)) { &Apache::lonxml::error(&mt("Expected [_1] input fields, but there were only [_2] seen.", $expected_number_of_inputs, scalar(@Apache::inputtags::inputlist))); @@ -863,7 +860,13 @@ sub get_table_sizes { my $bubbles_per_line=int($textwidth/$cell_width); if ($bubbles_per_line > $number_of_bubbles) { $bubbles_per_line=$number_of_bubbles; - }elsif (($bubbles_per_line > $number_of_bubbles/2) && ($number_of_bubbles % 2==0)) {$bubbles_per_line=$number_of_bubbles/2;} + } elsif (($bubbles_per_line > $number_of_bubbles/2) + && ($number_of_bubbles % 2==0)) { + $bubbles_per_line=$number_of_bubbles/2; + } + if ($bubbles_per_line < 1) { + $bubbles_per_line=1; + } my $number_of_tables = int($number_of_bubbles/$bubbles_per_line); my @table_range = (); for (my $i=0;$i<$number_of_tables;$i++) {push @table_range,$bubbles_per_line;} @@ -898,6 +901,11 @@ sub format_number { sub make_numerical_bubbles { my ($part,$id,$target,$parstack,$safeeval) =@_; + + if (!%answer) { + &Apache::lonxml::error(&mt("No answers defined for response [_1] in part [_2] to make bubbles for.",$id,$part)); + return ([],[],undef); + } my $number_of_bubbles = &Apache::response::get_response_param($part.'_'.$id,'numbubbles',8);