--- loncom/interface/statistics/loncorrectproblemplot.pm 2004/10/06 14:21:57 1.12 +++ loncom/interface/statistics/loncorrectproblemplot.pm 2005/03/14 20:28:22 1.17 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: loncorrectproblemplot.pm,v 1.12 2004/10/06 14:21:57 matthew Exp $ +# $Id: loncorrectproblemplot.pm,v 1.17 2005/03/14 20:28:22 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -92,25 +92,39 @@ sub BuildCorrectProblemsPage { # Determine which problem symbs we are to sum over if (exists($ENV{'form.CreatePlot'})) { my @ProblemSymbs; - my $total_parts = 0; + my $total_weights = 0; my $title = ''; - if ($Apache::lonstatistics::SelectedMaps[0] ne 'all') { - foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()){ + my @maps = &Apache::lonstatistics::get_selected_maps('Maps'); + my ($navmap,@sequences) = + &Apache::lonstatistics::selected_sequences_with_assessments(); + if ($maps[0] ne 'all') { + foreach my $seq (@sequences) { if ($title eq '') { - $title = $seq->{'title'}; + $title = $seq->compTitle; } else { $title = 'Multiple Sequences'; } - foreach my $res (@{$seq->{'contents'}}) { - next if ($res->{'type'} ne 'assessment'); - foreach my $part (@{$res->{'parts'}}) { - $total_parts++; - push(@ProblemSymbs,{symb=>$res->{'symb'}, - part=>$part}); - } + } + } else { + $title = 'All Problems'; + } + foreach my $seq (@sequences) { + my @resources = + &Apache::lonstathelpers::get_resources($navmap,$seq); + foreach my $res (@resources) { + foreach my $partid (@{$res->parts}) { + push(@ProblemSymbs,{symb=>$res->symb, + part=>$partid}); + $total_weights += + &Apache::lonnet::EXT('resource.'.$partid.'.weight', + $res->symb, + undef,undef,undef); } } } + $r->print('

'. + &Apache::lonstatistics::section_and_enrollment_description(). + '

'); my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits(); if (defined($starttime) || defined($endtime)) { # Inform the user what the time limits on the data are. @@ -118,12 +132,13 @@ sub BuildCorrectProblemsPage { &Apache::lonlocal::locallocaltime($starttime), &Apache::lonlocal::locallocaltime($endtime))); } + &Apache::loncoursedata::populate_weight_table(); my $score_data = &Apache::loncoursedata::get_student_scores - (\@Apache::lonstatistics::SelectedSections, + ([&Apache::lonstatistics::get_selected_sections()], \@ProblemSymbs, $Apache::lonstatistics::enrollment_status,undef, $starttime,$endtime); - $r->print(&AnalyzeScoreData($score_data,$title,$total_parts)); + $r->print(&AnalyzeScoreData($score_data,$title,$total_weights)); } else { $r->print('

'.&mt('Make a sequence selection from the "Sequences and Folders" menu and hit "Create Plot" to begin').'

'); } @@ -145,7 +160,7 @@ return html with a plot of the data and ######################################################### ######################################################### sub AnalyzeScoreData { - my ($score_data,$title,$total_parts) = @_; + my ($score_data,$title,$maximum) = @_; # # Basic check first if (ref($score_data) ne 'ARRAY' || @$score_data < 1) { @@ -156,7 +171,6 @@ sub AnalyzeScoreData { my $lowest = $score_data->[0]->[0]; $lowest = 0; my $highest = $score_data->[-1]->[0]; - &Apache::lonnet::logthis('highest = '.$highest); my $binsize = 1; if ($highest > 50) { $binsize = 2; } if ($highest > 100) { $binsize = 5; } @@ -169,6 +183,9 @@ sub AnalyzeScoreData { my @Bins = &bin_data($score_data,$binsize,$lowest,$highest); my @Xdata; my @Ydata; my $max; my $Str = + '

'. + &mt('Problem weights do not reflect individual student settings.') + .'

'. ''."\n".''."\n"; my $sum = 0; while (my $bin = shift(@Bins)) { @@ -185,14 +202,13 @@ sub AnalyzeScoreData { $max = 5*(int($max/5)+1); $Str .= "
RangeCount

\n"; $title = &HTML::Entities::decode($title); - $Str = "\n

".&Apache::loncommon::DrawBarGraph($title.' N = '.$sum, - 'Num Correct Problems (max:'.$total_parts.')', - 'Number of students', - $max, - undef, # colors - \@Xdata, - \@Ydata). - "\n
\n".$Str; + $Str = "\n

". + &Apache::loncommon::DrawBarGraph($title.' ('.$sum.' students)', + 'Correct Problems (max possible = '.$maximum.')', + 'Number of students', + $max,undef, # colors + \@Xdata,\@Ydata). + "\n
\n".$Str; $Str .= '

'."\n"; return $Str; } @@ -272,8 +288,7 @@ sub CreateInterface { ## ## Environment variable initialization my $Str; - $Str .= &Apache::lonhtmlcommon::breadcrumbs - (undef,'Correct Problems Plot'); + $Str .= &Apache::lonhtmlcommon::breadcrumbs(undef,'Correct Problems Plot'); $Str .= '

'; # $Str .= ''."\n"; @@ -293,16 +308,7 @@ sub CreateInterface { $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5); $Str .= ''; # $Str .= ''."\n";
'."\n"; # - my $only_seq_with_assessments = sub { - my $s=shift; - if ($s->{'num_assess'} < 1) { - return 0; - } else { - return 1; - } - }; - $Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5, - $only_seq_with_assessments); + $Str .= &Apache::lonstatistics::map_select('Maps','multiple,all',5); $Str .= '