[LON-CAPA-cvs] cvs: loncom /interface lonstatistics.pm /interface/statistics loncorrectproblemplot.pm

matthew lon-capa-cvs@mail.lon-capa.org
Tue, 01 Mar 2005 22:26:00 -0000


matthew		Tue Mar  1 17:26:00 2005 EDT

  Modified files:              
    /loncom/interface	lonstatistics.pm 
    /loncom/interface/statistics	loncorrectproblemplot.pm 
  Log:
  loncorrectproblemsplot: use navmaps.
  lonstatistics:&get_selected_maps: Now returns an array containing just 
     'all' if any one of the items in the array of selected maps is 'all'.
     simplified code in &map_select to take advantage of the new functionality
     in &get_selected_maps.
  
  
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.117 loncom/interface/lonstatistics.pm:1.118
--- loncom/interface/lonstatistics.pm:1.117	Fri Feb 25 18:23:47 2005
+++ loncom/interface/lonstatistics.pm	Tue Mar  1 17:25:59 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstatistics.pm,v 1.117 2005/02/25 23:23:47 matthew Exp $
+# $Id: lonstatistics.pm,v 1.118 2005/03/01 22:25:59 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -500,6 +500,12 @@
     } else {
         @selected_maps = ('all');
     }
+    foreach my $map (@selected_maps) {
+        if ($map eq 'all') {
+            @selected_maps = ('all');
+            last;
+        }
+    }
     return @selected_maps;
 }
 
@@ -599,21 +605,10 @@
     }
     $form .= 'size="'.$numvisible.'" >'."\n";
     #
-    # Deal with 'all'
-    foreach (@selected_maps) {
-        if ($_ eq 'all') {
-            @selected_maps = ('all');
-            last;
-        }
-    }
-    #
     # Put in option for 'all'
     $form .= '    <option value="all" ';
-    foreach (@selected_maps) {
-        if ($_ eq 'all') {
-            $form .= 'selected ';
-            last;
-        }
+    if ($selected_maps[0] eq 'all') {
+        $form .= 'selected ';
     }
     $form .= ">all</option>\n";
     #
Index: loncom/interface/statistics/loncorrectproblemplot.pm
diff -u loncom/interface/statistics/loncorrectproblemplot.pm:1.14 loncom/interface/statistics/loncorrectproblemplot.pm:1.15
--- loncom/interface/statistics/loncorrectproblemplot.pm:1.14	Fri Dec 10 15:41:39 2004
+++ loncom/interface/statistics/loncorrectproblemplot.pm	Tue Mar  1 17:25:59 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncorrectproblemplot.pm,v 1.14 2004/12/10 20:41:39 matthew Exp $
+# $Id: loncorrectproblemplot.pm,v 1.15 2005/03/01 22:25:59 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -94,28 +94,33 @@
         my @ProblemSymbs;
         my $total_parts = 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'}}) {
+                my @resources = 
+                    &Apache::lonstathelpers::get_resources($navmap,$seq);
+                foreach my $res (@resources) {
+                    foreach my $partid (@{$res->parts}) {
                         $total_parts++;
-                        push(@ProblemSymbs,{symb=>$res->{'symb'},
-                                            part=>$part});
+                        push(@ProblemSymbs,{symb=>$res->symb,
+                                            part=>$partid});
                     }
                 }
             }
         } else {
             $title = "All Problems";
-            foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()){
-                foreach my $res (@{$seq->{'contents'}}) {
-                    next if ($res->{'type'} ne 'assessment');
-                    $total_parts += scalar(@{$res->{'parts'}});
+            foreach my $seq (@sequences) {
+                my @resources = 
+                    &Apache::lonstathelpers::get_resources($navmap,$seq);
+                foreach my $res (@resources) {
+                    $total_parts += scalar(@{$res->parts});
                 }
             }
         }
@@ -279,8 +284,7 @@
     ##
     ## Environment variable initialization
     my $Str;
-    $Str .= &Apache::lonhtmlcommon::breadcrumbs
-        (undef,'Correct Problems Plot');
+    $Str .= &Apache::lonhtmlcommon::breadcrumbs(undef,'Correct Problems Plot');
     $Str .= '<p>';
     #
     $Str .= '<table cellspacing="5">'."\n";
@@ -300,16 +304,7 @@
     $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
     $Str .= '</td><td>'."\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 .= '</td>';
     #
     $Str .= '</tr>'."\n";