--- loncom/interface/statistics/lonproblemanalysis.pm 2004/03/11 19:34:10 1.75 +++ loncom/interface/statistics/lonproblemanalysis.pm 2004/03/11 20:06:50 1.76 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonproblemanalysis.pm,v 1.75 2004/03/11 19:34:10 matthew Exp $ +# $Id: lonproblemanalysis.pm,v 1.76 2004/03/11 20:06:50 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -570,34 +570,37 @@ sub OR_Tries_Foil_Analysis { my @PlotData; foreach my $concept (@$Concepts) { foreach my $foilid (@{$concept->{'foils'}}) { - for (my $i=$mintries;$i<=$maxtries;$i++) { - if ($ResponseData{$foilid}->[$i]->{'_total'} == 0) { - push(@{$PlotData[$i]->{'_correct'}},0); + for (my $try=$mintries;$try<=$maxtries;$try++) { + if ($ResponseData{$foilid}->[$try]->{'_total'} == 0) { + push(@{$PlotData[$try]->{'_correct'}},0); } else { - push(@{$PlotData[$i]->{'_correct'}}, - 100*$ResponseData{$foilid}->[$i]->{'_correct'}/ - $ResponseData{$foilid}->[$i]->{'_total'}); + push(@{$PlotData[$try]->{'_correct'}}, + 100*$ResponseData{$foilid}->[$try]->{'_correct'}/ + $ResponseData{$foilid}->[$try]->{'_total'}); } foreach my $option (@{$ORdata->{'_Options'}}) { - push(@{$PlotData[$i]->{'_total'}}, - $ResponseData{$foilid}->[$i]->{'_total'}); - if ($ResponseData{$foilid}->[$i]->{'_total'} == 0) { - push (@{$PlotData[$i]->{$option}},0); + push(@{$PlotData[$try]->{'_total'}}, + $ResponseData{$foilid}->[$try]->{'_total'}); + if ($ResponseData{$foilid}->[$try]->{'_total'} == 0) { + push (@{$PlotData[$try]->{$option}},0); } else { - if ($ResponseData{$foilid}->[$i]->{'_total'} == - $ResponseData{$foilid}->[$i]->{'_correct'}) { - push(@{$PlotData[$i]->{$option}},0); + if ($ResponseData{$foilid}->[$try]->{'_total'} == + $ResponseData{$foilid}->[$try]->{'_correct'}) { + push(@{$PlotData[$try]->{$option}},0); } else { - push (@{$PlotData[$i]->{$option}}, - 100 * $ResponseData{$foilid}->[$i]->{$option} / - ($ResponseData{$foilid}->[$i]->{'_total'} - - $ResponseData{$foilid}->[$i]->{'_correct'})); + push (@{$PlotData[$try]->{$option}}, + 100 * + $ResponseData{$foilid}->[$try]->{$option} / + ($ResponseData{$foilid}->[$try]->{'_total'} + - + $ResponseData{$foilid}->[$try]->{'_correct'} + )); } } - } + } # End of foreach my $option } - } - } + } # End of foreach my $foilid + } # End of foreach my $concept # # Build a table for the plots my $analysis_html = "\n"; @@ -617,9 +620,34 @@ sub OR_Tries_Foil_Analysis { next if (! exists($PlotData[$try]->{$option})); push(@Datasets,$PlotData[$try]->{$option}); } + # + # Put a blank in the data set between concepts + for (my $set =0;$set<=$#Datasets;$set++) { + my @Data = @{$Datasets[$set]}; + my $idx = 0; + foreach my $concept (@{$Concepts}) { + foreach my $foilid (@{$concept->{'foils'}}) { + $Datasets[$set]->[$idx++]=shift(@Data); + } + if ($concept->{'name'} ne $Concepts->[-1]->{'name'}) { + $Datasets[$set]->[$idx++] = 0; + } + } + } + # + # Set up the labels needed for the bar graph + my @Labels; + my $idx = 1; + foreach my $concept (@{$Concepts}) { + foreach my $foilid (@{$concept->{'foils'}}) { + push(@Labels,$idx++); + } + push(@Labels,''); + } + # my $correctgraph = &Apache::loncommon::DrawBarGraph ($title,'Foil Number','Percent Correct', - 100,$plotcolors,undef,$Datasets[0]); + 100,$plotcolors,\@Labels,$Datasets[0]); $analysis_html.= ''; # @@ -640,7 +668,7 @@ sub OR_Tries_Foil_Analysis { $title = 'Attempt '.$try.', '.$count; my $incorrectgraph = &Apache::loncommon::DrawBarGraph ($title,'Foil Number','% Option Chosen Incorrectly', - 100,$plotcolors,undef,@Datasets); + 100,$plotcolors,\@Labels,@Datasets); $analysis_html.= ''; $analysis_html.= '\n"; }
'.$correctgraph.''.$incorrectgraph.''.$optionkey."