--- loncom/interface/statistics/lonstudentassessment.pm 2002/10/23 21:04:26 1.16 +++ loncom/interface/statistics/lonstudentassessment.pm 2002/11/08 22:16:47 1.18 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # (Publication Handler # -# $Id: lonstudentassessment.pm,v 1.16 2002/10/23 21:04:26 minaeibi Exp $ +# $Id: lonstudentassessment.pm,v 1.18 2002/11/08 22:16:47 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -104,13 +104,13 @@ sub BuildStudentAssessmentPage { $r->print('
'."\n");
     foreach (@$students) {
         if($c->aborted()) { return $Str; }
-        next if ($_ ne $selectedName && 
+        next if ($_ ne $selectedName &&
                  $selectedName ne 'All Students');
         $selected = 1;
 
         my @who = ($_);
-        next if(&Apache::loncoursedata::DownloadStudentCourseData(\@who, 'true', 
-                                                             $cacheDB, 'true', 
+        next if(&Apache::loncoursedata::DownloadStudentCourseData(\@who, 'true',
+                                                             $cacheDB, 'true',
                                                              'false', $courseID,
                                                              $r, $c) ne 'OK');
         next if($c->aborted());
@@ -166,7 +166,8 @@ sub BuildStudentAssessmentPage {
     }
 
 
-    $r->print(&StudentReport(\%cache, "AvgTotal", $spacing, $sequenceKeys));
+#    $r->print("AverageTtal");
+    $r->print(&StudentAverageTotal(\%cache, $spacing, $sequenceKeys));
     $r->print("\n");
     $r->rflush();
     untie(%cache);
@@ -193,7 +194,7 @@ sub CreateInterface {
     $Str .= ''."\n";
-    $Str .= &Apache::lonhtmlcommon::CreateHeadings($cache, 
+    $Str .= &Apache::lonhtmlcommon::CreateHeadings($cache,
                                                    $infoKeys,
                                                    $infoHeadings,
                                                    $displayString,
@@ -264,7 +276,7 @@ sub CreateTableHeadings {
 =item &FormatStudentData()
 
 First, FormatStudentInformation is called and prefixes the course information.
-This function produces a formatted string of the student's course information.
+This function produces a formatted string of the student\'s course information.
 Each column of data represents all the problems for a given sequence.  For
 valid grade data, a link is created for that problem to a submission record
 for that problem.
@@ -326,10 +338,99 @@ sub StudentReport {
                 }
                 $hasVersion = 'true';
                 $hasData = 'true';
+                if (lc($ENV{'form.displaymode'}) ne 'display without links') {
+                    $Str .= ''; 
+                }
+                my $code = $cache->{$name.':'.$problemID.':'.$_.':code'};
+                my $tries = $cache->{$name.':'.$problemID.':'.$_.':tries'};
+                if($code eq '*' && $tries < 10 && $tries ne '') {
+                    $code = $tries;
+                }
+                $Str .= $code;
+                if (lc($ENV{'form.displaymode'}) ne 'display without links') {
+                    $Str .= '';
+                }
+                $characterCount++;
+            }
+        }
+
+        # Output the number of correct answers for the current sequence.
+        # This part takes up 6 character slots, but is formated right
+        # justified.
+        my $spacesNeeded=$cache->{$sequence.':columnWidth'}-$characterCount;
+        $spacesNeeded -= 3;
+        $Str .= (' 'x$spacesNeeded);
+
+#        my $outputProblemsCorrect = sprintf("%3d", $cache->{$name.':'.$sequence.
+#							    ':problemsCorrect'});
+
+	my $outputProblemsCorrect = sprintf("%2d/%2d", $cache->{$name.':'.$sequence.
+                                            ':problemsCorrect'},
+                                            $characterCount);
+        if($hasData eq 'true') {
+            $Str .= ''.$outputProblemsCorrect.'';
+            $hasFinalData = 'true';
+        } else {
+            $Str .= '     ';
+        }
+        $Str .= $spacing;
+    }
+
+    # Output the total correct problems over the total number of problems.
+    # I don't like this type of formatting, but it is a solution.  Need
+    # a way to dynamically determine the space requirements.
+    my $outputProblemsSolved = sprintf("%4d", $cache->{$name.':problemsSolved'});
+    my $outputTotalProblems  = sprintf("%4d", $cache->{$name.':totalProblems'});
+    if($hasFinalData eq 'true') {
+        $Str .= ''.$outputProblemsSolved.
+	    ' / '.$outputTotalProblems.'';
+    } else {
+        $Str .= '           ';
+    }
+
+    if($hasVersion eq 'false') {
+        $Str = 'No course data.';
+    }
+
+    return $Str;
+}
+
+
+sub StudentAverageTotal {
+    
+    return "";
+
+    my ($cache,$name,$spacing,$showSequences)=@_;
+    my $username = $name;
+    my $Str = '';
+    my $hasVersion = 'false';
+    my $hasFinalData = 'false';
+    foreach my $sequence (@$showSequences) {
+        my $hasData = 'false';
+        my $characterCount=0;
+        foreach my $problemID (split(':', $cache->{$sequence.':problems'})) {
+            my $problem = $cache->{$problemID.':problem'};
+            # All grades (except for versionless parts) are displayed as links
+            # to their submission record.  Loop through all the parts for the
+            # current problem in the correct order and prepare the output links
+            foreach(split(/\:/,$cache->{$sequence.':'.$problemID.
+                                        ':parts'})) {
+                if($cache->{$name.':'.$problemID.':NoVersion'} eq 'true' ||
+                   $cache->{$name.':'.$problemID.':'.$_.':code'} eq ' ' ||
+                   $cache->{$name.':'.$problemID.':'.$_.':code'} eq '') {
+                    $Str .= ' ';
+                    $characterCount++;
+                    next;
+                }
+                $hasVersion = 'true';
+                $hasData = 'true';
                 $Str .= ''; 
+                $Str .= '&student= Average &domain= Total';
+                $Str .= '&command=submission">';
                 my $code = $cache->{$name.':'.$problemID.':'.$_.':code'};
                 my $tries = $cache->{$name.':'.$problemID.':'.$_.':tries'};
                 if($code eq '*' && $tries < 10 && $tries ne '') {
@@ -342,7 +443,7 @@ sub StudentReport {
         }
 
         # Output the number of correct answers for the current sequence.
-        # This part takes up 6 character slots, but is formated right 
+        # This part takes up 6 character slots, but is formated right
         # justified.
         my $spacesNeeded=$cache->{$sequence.':columnWidth'}-$characterCount;
         $spacesNeeded -= 3;
@@ -352,7 +453,7 @@ sub StudentReport {
 #							    ':problemsCorrect'});
 
 	my $outputProblemsCorrect = sprintf("%2d/%2d", $cache->{$name.':'.$sequence.
-                                            ':problemsCorrect'}, 
+                                            ':problemsCorrect'},
                                             $characterCount);
         if($hasData eq 'true') {
             $Str .= ''.$outputProblemsCorrect.'';
@@ -382,6 +483,8 @@ sub StudentReport {
     return $Str;
 }
 
+
+
 =pod
 
 =item &CreateLegend()
@@ -403,7 +506,7 @@ sub CreateLegend {
 	      "   #  ungraded attempted\n".
               "      not attempted (blank field)\n".
 	      "   x  excused".
-              "

"; + "

"; return $Str; } @@ -412,7 +515,7 @@ sub CreateLegend { =item &CreateColumnSelectionBox() If there are columns not being displayed then this selection box is created -with a list of those columns. When selections are made and the page +with a list of those columns. When selections are made and the page refreshed, the columns will be removed from this box and the column is put back in the chart. If there is no columns to select, no row is added to the interface table. @@ -423,13 +526,13 @@ Input: $CacheData, $headings $CacheData: A pointer to a hash tied to the cached data -$headings: An array of the names of the columns for the student information. +$headings: An array of the names of the columns for the student information. They are used for displaying which columns are missing. Output: $notThere -$notThere: The string contains one row of a table. The first column has the -name of the selection box. The second contains the selection box +$notThere: The string contains one row of a table. The first column has the +name of the selection box. The second contains the selection box which has a size of four. =back @@ -459,7 +562,7 @@ sub CreateColumnSelectionBox { =item &CreateColumnSelectors() -This function generates the checkboxes above the column headings. The +This function generates the checkboxes above the column headings. The column will be removed if the checkbox is unchecked. =over 4 @@ -509,7 +612,7 @@ sub CreateColumnSelectors { sub FindSelectedStudent { my($cache, $selectedName, $students)=@_; - if($selectedName eq 'All Students' || + if($selectedName eq 'All Students' || $selectedName eq 'No Student Selected') { return $selectedName; }