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

matthew lon-capa-cvs@mail.lon-capa.org
Fri, 25 Feb 2005 02:37:50 -0000


This is a MIME encoded message

--matthew1109299070
Content-Type: text/plain

matthew		Thu Feb 24 21:37:50 2005 EDT

  Modified files:              
    /loncom/interface	lonstatistics.pm 
    /loncom/interface/statistics	lonstudentassessment.pm 
  Log:
  Reworking to use navmaps directly.  It compiles.  Most statistics pages
  will not load. chart works for html output only, although the columns are
  off and all sequences are selected regardless of what you say.  In short,
  it needs work.  A lot of work.  Guess I'll be busy tomorrow.
  
  
--matthew1109299070
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20050224213750.txt"

Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.114 loncom/interface/lonstatistics.pm:1.115
--- loncom/interface/lonstatistics.pm:1.114	Thu Feb 17 03:29:43 2005
+++ loncom/interface/lonstatistics.pm	Thu Feb 24 21:37:49 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstatistics.pm,v 1.114 2005/02/17 08:29:43 albertel Exp $
+# $Id: lonstatistics.pm,v 1.115 2005/02/25 02:37:49 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -54,10 +54,6 @@
     %StudentData
     @StudentDataOrder
     @SelectedStudentData
-    $top_map 
-    @Sequences 
-    @SelectedMaps
-    @Assessments
     $enrollment_status);
 
 use Apache::lonnet();
@@ -413,173 +409,6 @@
     return $next_student;
 }
 
-#######################################################
-#######################################################
-
-=pod
-
-=item &clear_sequence_variables()
-
-=cut
-
-#######################################################
-#######################################################
-sub clear_sequence_variables {
-    undef($top_map);
-    undef(@Sequences);
-    undef(@Assessments);
-}
-
-#######################################################
-#######################################################
-
-=pod
-
-=item &SetSelectedMaps($elementname)
-
-Sets the @SelectedMaps array from $ENV{'form.'.$elementname};
-
-=cut
-
-#######################################################
-#######################################################
-sub SetSelectedMaps {
-    my $elementname = shift;
-    if (exists($ENV{'form.'.$elementname})) {
-        if (ref($ENV{'form.'.$elementname})) {
-            @SelectedMaps = @{$ENV{'form.'.$elementname}};
-        } else {
-            @SelectedMaps = ($ENV{'form.'.$elementname});
-        }
-    } else {
-        @SelectedMaps = ('all');
-    }
-}
-
-
-#######################################################
-#######################################################
-
-=pod
-
-=item &Sequences_with_Assess()
-
-Returns an array containing the subset of @Sequences which contain
-assessments.
-
-=cut
-
-#######################################################
-#######################################################
-sub Sequences_with_Assess {
-    my ($mode) = @_;
-    $mode = 'selected' if (! defined($mode));
-    my @Sequences_to_Show;
-    foreach my $sequence (@Sequences) {
-        next if ($sequence->{'num_assess'} < 1);
-        if ($mode eq 'all') {
-            push (@Sequences_to_Show,$sequence);
-        } elsif ($mode eq 'selected') {
-            foreach my $map_symb (@SelectedMaps) {
-                if ($sequence->{'symb'} eq $map_symb || $map_symb eq 'all'){
-                    push (@Sequences_to_Show,$sequence);
-                    last; # Only put it in once
-                }
-            }
-        }
-
-    }
-    return @Sequences_to_Show;
-}
-
-#######################################################
-#######################################################
-
-=pod
-
-=item &PrepareCourseData($r)
-
-=cut
-
-#######################################################
-#######################################################
-sub PrepareCourseData {
-    my ($r) = @_;
-    &clear_sequence_variables();
-    my ($top,$sequences,$assessments) = 
-        &Apache::loncoursedata::get_sequence_assessment_data();
-    if (! defined($top) || ! ref($top)) {
-        # There has been an error, better report it
-        &Apache::lonnet::logthis('top is undefined');
-        return;
-    }
-    $top_map = $top if (ref($top));
-    @Sequences = @{$sequences} if (ref($sequences) eq 'ARRAY');
-    @Assessments = @{$assessments} if (ref($assessments) eq 'ARRAY');
-    return;
-}
-
-#######################################################
-#######################################################
-
-=pod
-
-=item &log_sequence($sequence,$recursive,$padding)
-
-Write data about the sequence to a logfile.  If $recursive is not
-undef the data is written recursively.  $padding is used for recursive
-calls.
-
-=cut
-
-#######################################################
-#######################################################
-sub log_sequence {
-    my ($seq,$recursive,$padding) = @_;
-    $padding = '' if (! defined($padding));
-    if (ref($seq) ne 'HASH') {
-        &Apache::lonnet::logthis('log_sequence passed bad sequnce');
-        return;
-    }
-    &Apache::lonnet::logthis($padding.'sequence '.$seq->{'title'});
-    while (my($key,$value) = each(%$seq)) {
-        next if ($key eq 'contents');
-        if (ref($value) eq 'ARRAY') {
-            for (my $i=0;$i< scalar(@$value);$i++) {
-                &Apache::lonnet::logthis($padding.$key.'['.$i.']='.
-                                         $value->[$i]);
-            }
-        } else {
-            &Apache::lonnet::logthis($padding.$key.'='.$value);
-        }
-    }
-    if (defined($recursive)) {
-        &Apache::lonnet::logthis($padding.'-'x20);
-        &Apache::lonnet::logthis($padding.'contains:');
-        foreach my $item (@{$seq->{'contents'}}) {
-            if ($item->{'type'} eq 'container') {
-                &log_sequence($item,$recursive,$padding.'    ');
-            } else {
-                &Apache::lonnet::logthis($padding.'title = '.$item->{'title'});
-                while (my($key,$value) = each(%$item)) {
-                    next if ($key eq 'title');
-                    if (ref($value) eq 'ARRAY') {
-                        for (my $i=0;$i< scalar(@$value);$i++) {
-                            &Apache::lonnet::logthis($padding.$key.'['.$i.']='.
-                                                     $value->[$i]);
-                        }
-                    } else {
-                        &Apache::lonnet::logthis($padding.$key.'='.$value);
-                    }
-                }
-            }
-        }
-        &Apache::lonnet::logthis($padding.'end contents of '.$seq->{'title'});
-        &Apache::lonnet::logthis($padding.'-'x20);
-    }
-    return;
-}
-
 ##############################################
 ##############################################
 
@@ -643,12 +472,97 @@
     return $Str;
 }
 
+#######################################################
+#######################################################
+
+=pod
+
+=item &get_selected_maps($elementname)
+
+Input: Name of the <select> form element used to specify the maps.
+
+Returns: Array of symbs of selected maps or the description 'all'.
+   If form.$elementname does not exist, 'all' is returned.
+
+=cut
+
+#######################################################
+#######################################################
+sub get_selected_maps {
+    my ($elementname) = @_;
+    my @selected_maps;
+    if (exists($ENV{'form.'.$elementname})) {
+        if (ref($ENV{'form.'.$elementname})) {
+            @selected_maps = @{$ENV{'form.'.$elementname}};
+        } else {
+            @selected_maps = ($ENV{'form.'.$elementname});
+        }
+    } else {
+        @selected_maps = ('all');
+    }
+    return @selected_maps;
+}
+
+
+#######################################################
+#######################################################
+
+=pod
+
+=item &sequences_with_assessments
+
+Retrieve the sequences which were selected by the user to show.  
+
+Input: $mode: scalar.  Either 'selected' or 'all'.  If not specified,
+    'selected' is used.
+
+Returns: an array containing a navmap object and navmap resources, 
+    or an array containing a scalar with an error message.
+
+=cut
+
+#######################################################
+#######################################################
+sub sequences_with_assessments {
+    my ($mode) = @_;
+    $mode = 'selected' if (! defined($mode));
+    my $navmap = Apache::lonnavmaps::navmap->new();
+    if (!defined($navmap)) {
+        return ('Can not open Coursemap');
+    }
+    #
+    my @sequences = $navmap->retrieveResources(undef,
+                                               sub { shift->is_map(); },1,0,1);
+    my @sequences_with_assessments;
+    for my $sequence ($navmap->getById('0.0'), @sequences) {
+	if ($navmap->hasResource($sequence,sub { shift->is_problem(); }, 0)){
+            push(@sequences_with_assessments,$sequence);
+        }
+    }
+    #
+    my @sequences_to_show;
+    foreach my $sequence (@sequences_with_assessments) {
+        if ($mode eq 'all') {
+            push (@sequences_to_show,$sequence);
+        } elsif ($mode eq 'selected') {
+            foreach my $map_symb (&get_selected_maps()) {
+                if ($sequence->symb eq $map_symb || $map_symb eq 'all'){
+                    push (@sequences_to_show,$sequence);
+                    last; # Only put it in once
+                }
+            }
+        }
+
+    }
+    return $navmap,@sequences_to_show;
+}
+
 ##############################################
 ##############################################
 
 =pod 
 
-=item &MapSelect($elementname,$status,$numvisible,$restriction) 
+=item &map_select($elementname,$status,$numvisible,$restriction) 
 
 Returns html for a selection box allowing the user to choose one (or more) 
 of the sequences in the course.  The values of the sequences are the symbs.
@@ -662,69 +576,67 @@
 
 =item $numvisible The number of options to be visible
 
-=item $restriction Code reference to subroutine which returns true or 
-false.  The code must expect a reference to a sequence data structure.
-
 =back
 
 =cut
 
 ##############################################
 ##############################################
-sub MapSelect {
-    my ($elementname,$status,$numvisible,$restriction)=@_;
+sub map_select {
+    my ($elementname,$status,$numvisible)=@_;
     if ($numvisible < 1) {
         return;
     }
     #
     # Set up array of selected items
-    &SetSelectedMaps($elementname);
-    #
-    # Set up the restriction call
-    if (! defined($restriction)) {
-        $restriction = sub { 1; };
-    }
+    my @selected_maps = &get_selected_maps($elementname);
     #
     # Build the form element
-    my $Str = "\n";
-    $Str .= '<select name="'.$elementname.'" ';
+    my $form = "\n";
+    $form .= '<select name="'.$elementname.'" ';
     if ($status ne 'single') {
-        $Str .= 'multiple="true" ';
+        $form .= 'multiple="true" ';
     }
-    $Str .= 'size="'.$numvisible.'" >'."\n";
+    $form .= 'size="'.$numvisible.'" >'."\n";
     #
     # Deal with 'all'
-    foreach (@SelectedMaps) {
+    foreach (@selected_maps) {
         if ($_ eq 'all') {
-            @SelectedMaps = ('all');
+            @selected_maps = ('all');
             last;
         }
     }
     #
     # Put in option for 'all'
-    $Str .= '    <option value="all" ';
-    foreach (@SelectedMaps) {
+    $form .= '    <option value="all" ';
+    foreach (@selected_maps) {
         if ($_ eq 'all') {
-            $Str .= 'selected ';
+            $form .= 'selected ';
             last;
         }
     }
-    $Str .= ">all</option>\n";
+    $form .= ">all</option>\n";
     #
     # Loop through the sequences
-    foreach my $seq (@Sequences) {
-        next if (! $restriction->($seq));
-        $Str .= '    <option value="'.$seq->{'symb'}.'" ';
-        foreach (@SelectedMaps) {
-            if ($seq->{'symb'} eq $_) {
-                $Str .= 'selected ';
+    my @sequences = &sequences_with_assessments();
+    my $navmap;
+    if (!ref($sequences[0])) {
+        return $sequences[0];
+    } else {
+        $navmap = shift(@sequences);
+    }
+    foreach my $seq (@sequences){
+        $form .= '    <option value="'.$seq->symb.'" ';
+        foreach (@selected_maps) {
+            if ($seq->symb eq $_) {
+                $form .= 'selected ';
                 last;
             }
         }
-        $Str .= '>'.$seq->{'title'}."</option>\n";
+        $form .= '>'.$seq->compTitle."</option>\n";
     }
-    $Str .= "</select>\n";
-    return $Str;
+    $form .= "</select>\n";
+    return $form;
 }
 
 ##############################################
@@ -1063,9 +975,6 @@
         #
         my $GoToPage = $ENV{'form.reportSelected'};
         #
-        # Set up the statistics and chart environment
-        &PrepareCourseData($r);
-        #
         $r->print('<input type="hidden" name="reportSelected" value="'.
                   $GoToPage.'">');
         if($GoToPage eq 'activitylog') {
Index: loncom/interface/statistics/lonstudentassessment.pm
diff -u loncom/interface/statistics/lonstudentassessment.pm:1.111 loncom/interface/statistics/lonstudentassessment.pm:1.112
--- loncom/interface/statistics/lonstudentassessment.pm:1.111	Fri Feb 11 16:25:53 2005
+++ loncom/interface/statistics/lonstudentassessment.pm	Thu Feb 24 21:37:49 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstudentassessment.pm,v 1.111 2005/02/11 21:25:53 matthew Exp $
+# $Id: lonstudentassessment.pm,v 1.112 2005/02/25 02:37:49 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -56,6 +56,7 @@
 use Apache::loncoursedata;
 use Apache::lonnet; # for logging porpoises
 use Apache::lonlocal;
+use Time::HiRes;
 use Spreadsheet::WriteExcel;
 use Spreadsheet::WriteExcel::Utility();
 
@@ -176,6 +177,7 @@
     my $initialize     = \&html_initialize;
     my $output_student = \&html_outputstudent;
     my $finish         = \&html_finish;
+    &Apache::lonnet::logthis('got here! 1');
     #
     if ($output_mode eq 'excel') {
         $initialize     = \&excel_initialize;
@@ -187,6 +189,7 @@
         $finish         = \&csv_finish;
     }
     #
+    &Apache::lonnet::logthis('got here! 2');
     if($c->aborted()) {  return ; }
     #
     # Determine which students we want to look at
@@ -211,6 +214,7 @@
     #
     # Call the initialize routine selected above
     $initialize->($r);
+    &Apache::lonnet::logthis('got here! 3');
     foreach my $student (@Students) {
         if($c->aborted()) { 
             $finish->($r);
@@ -327,21 +331,12 @@
     $Str .= '<tr><td align="center">'."\n";
     $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
     $Str .= '</td><td align="center">';
-    my $only_seq_with_assessments = sub { 
-        my $s=shift;
-        if ($s->{'num_assess'} < 1) { 
-            return 0;
-        } else { 
-            return 1;
-        }
-    };
     $Str .= &Apache::lonstatistics::StudentDataSelect('StudentData','multiple',
                                                       5,undef);
     $Str .= '</td><td>'."\n";
     $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
     $Str .= '</td><td>'."\n";
-    $Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5,
-                                              $only_seq_with_assessments);
+    $Str .= &Apache::lonstatistics::map_select('Maps','multiple,all',5);
     $Str .= '</td><td>'."\n";
     $Str .= &CreateAndParseOutputSelector();
     $Str .= '</td><td>'."\n";
@@ -613,6 +608,10 @@
     my %prog_state;   # progress state used by loncommon PrgWin routines
     my $total_sum_width;
 
+    my %width; # Holds sequence width information
+    my @sequences;
+    my $navmap; # Have to keep this around since weakref is a bit zealous
+
 sub html_initialize {
     my ($r) = @_;
     #
@@ -620,10 +619,14 @@
     $count = 0;
     $nodata_count = 0;
     undef(%prog_state);
+    undef(%width);
+    undef($navmap);
+    undef(@sequences);
+    &Apache::lonnet::logthis('called html_initialize');
     #
     $r->print("<h3>".$ENV{'course.'.$ENV{'request.course.id'}.'.description'}.
               "&nbsp;&nbsp;".localtime(time)."</h3>");
-
+    #
     if ($chosen_output->{'base'} !~ /^final table/) {
         $r->print("<h3>".$chosen_output->{'shortdesc'}."</h3>");        
     }
@@ -639,45 +642,68 @@
     #
     # Compute the column widths and output the sequence titles
     my $total_count;
-    foreach my $sequence (&Apache::lonstatistics::Sequences_with_Assess()){
-        #
-        # Comptue column widths
-        $sequence->{'width_sum'} = 0;
+    ($navmap,@sequences) = 
+        &Apache::lonstatistics::sequences_with_assessments();
+    if (! ref($navmap)) {
+        # Unable to get data, so bail out
+        $r->print("<h3>".
+                  &mt('Unable to retrieve course information.').
+                  '</h3>');
+    }
+    #
+    # Compute sequence widths
+    my $starttime = Time::HiRes::time;
+    foreach my $seq (@sequences) {
+        my $symb = $seq->symb;
+        my $title = $seq->compTitle;
+        $width{$symb}->{'width_sum'} = 0;
+        # Compute width of sum
         if ($chosen_output->{'sequence_sum'}) {
             if ($chosen_output->{'every_problem'}) {
                 # Use 1 digit for a space
-                $sequence->{'width_sum'} += 1;            
+                $width{$symb}->{'width_sum'} += 1;            
             }
-	    $total_count += $sequence->{'num_assess_parts'};
+	    $total_count += $width{$symb}->{'num_assess_parts'};
             # Use 3 digits for the sum
-            $sequence->{'width_sum'} += 3;
+            $width{$symb}->{'width_sum'} += 3;
         }
+        # Compute width of maximum
         if ($chosen_output->{'sequence_max'}) {
-            if ($sequence->{'width_sum'}>0) {
+            if ($width{$symb}->{'width_sum'}>0) {
                 # One digit for the '/'
-                $sequence->{'width_sum'} +=1;
+                $width{$symb}->{'width_sum'} +=1;
             }
             # Use 3 digits for the total
-            $sequence->{'width_sum'}+=3;
+            $width{$symb}->{'width_sum'}+=3;
         }
 	#
         if ($chosen_output->{'every_problem'}) {
             # one problem per digit
-            $sequence->{'width_problem'} = $sequence->{'num_assess_parts'};
+            $width{$symb}->{'width_parts'}=0;
+            $starttime = Time::HiRes::time;
+            my @resources = 
+                $navmap->retrieveResources($seq,sub { shift->is_problem(); },
+                                           0,0,0);
+            $starttime = Time::HiRes::time;
+            foreach my $res (@resources) {
+                my @parts = $res->parts;
+                $width{$symb}->{'width_parts'} += scalar(@parts);
+            } 
+            &Apache::lonnet::logthis('2elapsed:'.(Time::HiRes::time-$starttime));            $width{$symb}->{'width_problem'} += 
+                $width{$symb}->{'width_parts'};
         } else {
-            $sequence->{'width_problem'} = 0;
+            $width{$symb}->{'width_problem'} = 0;
         }
-        $sequence->{'width_total'} = $sequence->{'width_problem'} + 
-                                     $sequence->{'width_sum'};
-        if ($sequence->{'width_total'} < length(&HTML::Entities::decode($sequence->{'title'}))) {
-            $sequence->{'width_total'} = length(&HTML::Entities::decode($sequence->{'title'}));
+        $width{$symb}->{'width_total'} = $width{$symb}->{'width_problem'} + 
+                                     $width{$symb}->{'width_sum'};
+        if ($width{$symb}->{'width_total'} < length(&HTML::Entities::decode($title))) {
+            $width{$symb}->{'width_total'} = length(&HTML::Entities::decode($title));
         }
         #
         # Output the sequence titles
-        $Str .= 
-            $sequence->{'title'}.' 'x($sequence->{'width_total'}-
-                                      length($sequence->{'title'})
-                                      ).$padding;
+        $Str .= $title.(' 'x($width{$symb}->{'width_total'}-
+                            length($title)
+                            )).$padding;
     }
     $total_sum_width = length($total_count)+1;
     $Str .= "    total</pre>\n";
@@ -690,6 +716,7 @@
 sub html_outputstudent {
     my ($r,$student) = @_;
     my $Str = '';
+    return if (! defined($navmap));
     #
     if($count++ % 5 == 0 && $count > 0) {
         $r->print("</pre><pre>");
@@ -725,16 +752,17 @@
     # By sequence build up the data
     my $studentstats;
     my $PerformanceStr = '';
-    foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
+    foreach my $seq (@sequences) {
+        &Apache::lonnet::logthis('computing student data for '.$seq->compTitle);
         my ($performance,$performance_length,$score,$seq_max,$rawdata);
         if ($chosen_output->{'tries'}) {
             ($performance,$performance_length,$score,$seq_max,$rawdata) =
-                &StudentTriesOnSequence($student,\%StudentsData,
-                                        $seq,$show_links);
+                &student_tries_on_sequence($student,\%StudentsData,
+                                           $navmap,$seq,$show_links);
         } else {
             ($performance,$performance_length,$score,$seq_max,$rawdata) =
-                &StudentPerformanceOnSequence($student,\%StudentsData,
-                                              $seq,$show_links);
+                &student_performance_on_sequence($student,\%StudentsData,
+                                                 $navmap,$seq,$show_links);
         }
         my $ratio='';
         if ($chosen_output->{'every_problem'}) {
@@ -756,13 +784,15 @@
             $performance = '';
 	    $performance_length=0;
         }
-        $performance .= ' 'x($seq->{'width_total'}-$performance_length-$seq->{'width_sum'}).
+        $performance .= ' 'x($width{$seq->symb}->{'width_total'} -
+                             $performance_length -
+                             $width{$seq->symb}->{'width_sum'}).
             $ratio;
         #
         $Str .= $performance.$padding;
         #
-        $studentstats->{$seq->{'symb'}}->{'score'}= $score;
-        $studentstats->{$seq->{'symb'}}->{'max'}  = $seq_max;
+        $studentstats->{$seq->symb}->{'score'}= $score;
+        $studentstats->{$seq->symb}->{'max'}  = $seq_max;
     }
     #
     # Total it up and store the statistics info.
@@ -794,6 +824,7 @@
 
 sub html_finish {
     my ($r) = @_;
+    return if (! defined($navmap));
     #
     # Check for suppressed output and close the progress window if so
     $r->print("</pre>\n"); 
@@ -805,6 +836,7 @@
         }
     }
     $r->rflush();
+    undef($navmap);
     return;
 }
 
@@ -816,19 +848,20 @@
         '<th>'.&mt('Average').'</th>'.
         '<th>'.&mt('Maximum').'</th>'.
         '</tr>'.$/;
-    foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
+    foreach my $seq (@sequences) {
+        my $symb = $seq->symb;
         my $ave;
-        my $num_students = $Statistics->{$seq->{'symb'}}->{'num_students'};
+        my $num_students = $Statistics->{$symb}->{'num_students'};
         if ($num_students > 0) {
             $ave = int(100*
-                       ($Statistics->{$seq->{'symb'}}->{'score'}/$num_students)
+                       ($Statistics->{$symb}->{'score'}/$num_students)
                        )/100;
         } else {
             $ave = 0;
         }
-        my $max = $Statistics->{$seq->{'symb'}}->{'max'};
+        my $max = $Statistics->{$symb}->{'max'};
         $ave = sprintf("%.2f",$ave);
-        $Str .= '<tr><td>'.$seq->{'title'}.'</td>'.
+        $Str .= '<tr><td>'.$seq->compTitle.'</td>'.
             '<td align="right">'.$ave.'&nbsp;</td>'.
             '<td align="right">'.$max.'&nbsp;'.'</td></tr>'."\n";
     }
@@ -855,9 +888,9 @@
     my $total = 0;
     my $total_max = 0;
     foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
-        my $value = $Statistics->{$seq->{'symb'}}->{'score'};
-        my $max = $Statistics->{$seq->{'symb'}}->{'max'};
-        $Str .= '<tr><td>'.$seq->{'title'}.'</td>'.
+        my $value = $Statistics->{$seq->symb}->{'score'};
+        my $max = $Statistics->{$seq->symb}->{'max'};
+        $Str .= '<tr><td>'.&HTML::Entities::encode($seq->compTitle).'</td>'.
             '<td align="right">'.$value.'</td>'.
                 '<td align="right">'.$max.'</td></tr>'."\n";
         $total += $value;
@@ -1706,8 +1739,8 @@
 
 #######################################################
 #######################################################
-sub StudentTriesOnSequence {
-    my ($student,$studentdata,$seq,$links) = @_;
+sub student_tries_on_sequence {
+    my ($student,$studentdata,$navmap,$seq,$links) = @_;
     $links = 'no' if (! defined($links));
     my $Str = '';
     my ($sum,$max) = (0,0);
@@ -1715,11 +1748,12 @@
     my @TriesData = ();
     my $tries;
     my $hasdata = 0; # flag - true if the student has any data on the sequence
-    foreach my $resource (@{$seq->{'contents'}}) {
-        next if ($resource->{'type'} ne 'assessment');
-        my $resource_data = $studentdata->{$resource->{'symb'}};
+    my @resources = 
+        $navmap->retrieveResources($seq,sub { shift->is_problem(); },0,0,0);
+    foreach my $resource (@resources) {
+        my $resource_data = $studentdata->{$resource->symb};
         my $value = '';
-        foreach my $partnum (@{$resource->{'parts'}}) {
+        foreach my $partnum (@{$resource->parts()}) {
             $tries = undef;
             $max++;
             $performance_length++;
@@ -1796,7 +1830,7 @@
                     &Apache::lonnet::logthis('length of symbol "'.$symbol.'" > 1');
                 }
                 $symbol = '<a href="/adm/grades'.
-                    '?symb='.&Apache::lonnet::escape($resource->{'symb'}).
+                    '?symb='.&Apache::lonnet::escape($resource->symb).
                         '&student='.$student->{'username'}.
                             '&userdom='.$student->{'domain'}.
                                 '&command=submission">'.$symbol.'</a>';
@@ -1805,8 +1839,8 @@
         }
         $Str .= $value;
     }
-    if ($seq->{'randompick'}) {
-        $max = $seq->{'randompick'};
+    if ($seq->randompick()) {
+        $max = $seq->randompick();
     }
     if (! $hasdata && $sum == 0) {
         $sum = ' ';
@@ -1839,8 +1873,8 @@
 
 #######################################################
 #######################################################
-sub StudentPerformanceOnSequence {
-    my ($student,$studentdata,$seq,$links) = @_;
+sub student_performance_on_sequence {
+    my ($student,$studentdata,$navmap,$seq,$links) = @_;
     $links = 'no' if (! defined($links));
     my $Str = ''; # final result string
     my ($score,$max) = (0,0);
@@ -1849,13 +1883,15 @@
     my @ScoreData = ();
     my $partscore;
     my $hasdata = 0; # flag, 0 if there were no submissions on the sequence
-    foreach my $resource (@{$seq->{'contents'}}) {
-        next if ($resource->{'type'} ne 'assessment');
-        my $resource_data = $studentdata->{$resource->{'symb'}};
-        foreach my $part (@{$resource->{'parts'}}) {
+    my @resources = 
+        $navmap->retrieveResources($seq,sub { shift->is_problem(); },0,0,0);
+    foreach my $resource (@resources) {
+        my $symb = $resource->symb;
+        my $resource_data = $studentdata->{$symb};
+        foreach my $part (@{$resource->parts()}) {
             $partscore = undef;
             my $weight = &Apache::lonnet::EXT('resource.'.$part.'.weight',
-                                              $resource->{'symb'},
+                                              $symb,
                                               $student->{'domain'},
                                               $student->{'username'},
                                               $student->{'section'});
@@ -1910,7 +1946,7 @@
             #
             if ( ($links eq 'yes' && $symbol ne ' ') || ($links eq 'all')) {
                 $symbol = '<a href="/adm/grades'.
-                    '?symb='.&Apache::lonnet::escape($resource->{'symb'}).
+                    '?symb='.&Apache::lonnet::escape($symb).
                     '&student='.$student->{'username'}.
                     '&userdom='.$student->{'domain'}.
                     '&command=submission">'.$symbol.'</a>';

--matthew1109299070--