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

matthew lon-capa-cvs@mail.lon-capa.org
Thu, 29 May 2003 21:38:32 -0000


This is a MIME encoded message

--matthew1054244312
Content-Type: text/plain

matthew		Thu May 29 17:38:32 2003 EDT

  Modified files:              
    /loncom/interface	lonstatistics.pm 
    /loncom/interface/statistics	lonstudentassessment.pm 
  Log:
  Bug 1470 - reimplement single student view in chart.
  lonstatistics.pm:
    Changed handling of $curr_student, $prev_student, and $next_student.  Now
    assumed to be undef when they are not appropriate.
    Renamed 'StudentAssessmentStudent' form parameter to 'SelectedStudent'.
  lonstudentassessment.pm:
    Added package variable $single_student_mode to flag the single student mode.
    Added hidden form parameter 'sort', to maintain sort key.
    Added &next_and_previous_buttons to present the user with 3 buttons:
  	"previous student", "all students", and "next student"
    Added &SingleStudentTotal to output an html table with some statistics about
          the students performance.
    Modified &html_finish to call &SingleStudentTotal instead of 
  	&StudentAverageTotal if in $single_student_mode
  
  
--matthew1054244312
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20030529173832.txt"

Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.71 loncom/interface/lonstatistics.pm:1.72
--- loncom/interface/lonstatistics.pm:1.71	Tue May 27 10:51:24 2003
+++ loncom/interface/lonstatistics.pm	Thu May 29 17:38:32 2003
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstatistics.pm,v 1.71 2003/05/27 14:51:24 matthew Exp $
+# $Id: lonstatistics.pm,v 1.72 2003/05/29 21:38:32 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -300,9 +300,10 @@
     @Students = @TmpStudents;
     # 
     # Now deal with that current student thing....
-    if (exists($ENV{'form.StudentAssessmentStudent'})) {
+    $curr_student = undef;
+    if (exists($ENV{'form.SelectedStudent'})) {
         my ($current_uname,$current_dom) = 
-            split(':',$ENV{'form.StudentAssessmentStudent'});
+            split(':',$ENV{'form.SelectedStudent'});
         my $i;
         for ($i = 0; $i<=$#Students; $i++) {
             next if (($Students[$i]->{'username'} ne $current_uname) || 
@@ -310,15 +311,17 @@
             $curr_student = $Students[$i];
             last; # If we get here, we have our student.
         }
-        if ($i == 0) {
-            $prev_student = 'none';
-        } else {
-            $prev_student = $Students[$i-1];
-        }
-        if ($i == $#Students) {
-            $next_student = 'none';
-        } else {
-            $next_student = $Students[$i+1];
+        if (defined($curr_student)) {
+            if ($i == 0) {
+                $prev_student = undef;
+            } else {
+                $prev_student = $Students[$i-1];
+            }
+            if ($i == $#Students) {
+                $next_student = undef;
+            } else {
+                $next_student = $Students[$i+1];
+            }
         }
     }
     #
@@ -329,7 +332,7 @@
             @SelectedStudentData = ($ENV{'form.StudentData'});
         }
     } else {
-        @SelectedStudentData = ('fullname');
+        @SelectedStudentData = ('username');
     }
     foreach (@SelectedStudentData) {
         if ($_ eq 'all') {
@@ -377,11 +380,7 @@
 #######################################################
 #######################################################
 sub current_student { 
-    if (defined($curr_student)) {
-        return $curr_student;
-    } else {
-        return 'All Students';
-    }
+    return $curr_student;
 }
 
 #######################################################
@@ -399,11 +398,7 @@
 #######################################################
 #######################################################
 sub previous_student { 
-    if (defined($prev_student)) {
-        return $prev_student;
-    } else {
-        return 'No Student Selected';
-    }
+    return $prev_student;
 }
 
 #######################################################
@@ -421,11 +416,7 @@
 #######################################################
 #######################################################
 sub next_student { 
-    if (defined($next_student)) {
-        return $next_student;
-    } else {
-        return 'No Student Selected';
-    }
+    return $next_student;
 }
 
 #######################################################
@@ -839,7 +830,8 @@
             if ($field eq 'fullname') {
                 $Str .= '<a href="/adm/statistics?reportSelected=';
                 $Str .= &Apache::lonnet::escape('student_assessment');
-                $Str .= '&StudentAssessmentStudent=';
+                $Str .= '&sort='.&Apache::lonnet::escape($ENV{'form.sort'});
+                $Str .= '&SelectedStudent=';
                 $Str .= &Apache::lonnet::escape($sname).'">';
                 $Str .= $student->{$field}.'&nbsp';
                 $Str .= '</a>';
@@ -940,7 +932,7 @@
     # Extract form elements from query string
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['sort','reportSelected',
-                                             'StudentAssessmentStudent']);
+                                             'SelectedStudent']);
     if (! exists($ENV{'form.reportSelected'})) {
         $ENV{'form.reportSelected'} = 'student_assessment';
     }
Index: loncom/interface/statistics/lonstudentassessment.pm
diff -u loncom/interface/statistics/lonstudentassessment.pm:1.48 loncom/interface/statistics/lonstudentassessment.pm:1.49
--- loncom/interface/statistics/lonstudentassessment.pm:1.48	Wed May 21 10:43:01 2003
+++ loncom/interface/statistics/lonstudentassessment.pm	Thu May 29 17:38:32 2003
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstudentassessment.pm,v 1.48 2003/05/21 14:43:01 matthew Exp $
+# $Id: lonstudentassessment.pm,v 1.49 2003/05/29 21:38:32 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -85,6 +85,9 @@
 
 =item $show 'all', 'totals', or 'scores' determines how much data is output
 
+=item $single_student_mode evaluates to true if we are showing only one
+student.
+
 =cut
 
 #######################################################
@@ -92,6 +95,7 @@
 my $show_links;
 my $output_mode;
 my $show;
+my $single_student_mode;
 
 #######################################################
 #######################################################
@@ -127,14 +131,17 @@
 sub BuildStudentAssessmentPage {
     my ($r,$c)=@_;
     undef($Statistics);
+    $single_student_mode = 1 if ($ENV{'form.SelectedStudent'});
     #
     # Print out the HTML headers for the interface
     #    This also parses the output mode selector
     #    This step must always be done.
     $r->print(&CreateInterface());
     $r->print('<input type="hidden" name="notfirstrun" value="true" />');
+    $r->print('<input type="hidden" name="sort" value="'.
+              $ENV{'form.sort'}.'" />');
     $r->rflush();
-    if (! exists($ENV{'form.notfirstrun'})) {
+    if (! exists($ENV{'form.notfirstrun'}) && ! $single_student_mode) {
         $r->print(<<ENDMSG);
 <p>
 <font size="+2">
@@ -168,9 +175,19 @@
     #
     if($c->aborted()) {  return ; }
     #
+    # Determine which students we want to look at
+    my @Students;
+    if ($single_student_mode) {
+        @Students = (&Apache::lonstatistics::current_student());
+        $r->print(&next_and_previous_buttons());
+        $r->rflush();
+    } else {
+        @Students = @Apache::lonstatistics::Students;
+    }
+    #
     # Call the initialize routine selected above
     $initialize->($r);
-    foreach my $student (@Apache::lonstatistics::Students) {
+    foreach my $student (@Students) {
         if($c->aborted()) { 
             $finish->($r);
             return ; 
@@ -186,6 +203,54 @@
 
 #######################################################
 #######################################################
+sub next_and_previous_buttons {
+    my $Str = '';
+    $Str .= '<input type="hidden" name="SelectedStudent" value="'.
+        $ENV{'form.SelectedStudent'}.'" />';
+    #
+    # Build the previous student link
+    my $previous = &Apache::lonstatistics::previous_student();
+    my $previousbutton = '';
+    if (defined($previous)) {
+        my $sname = $previous->{'username'}.':'.$previous->{'domain'};
+        $previousbutton .= '<input type="button" value="'.
+            'Previous Student ('.
+            $previous->{'username'}.'@'.$previous->{'domain'}.')'.
+            '" onclick="document.Statistics.SelectedStudent.value='.
+            "'".$sname."'".';'.
+            'document.Statistics.submit();" />';
+    } else {
+        $previousbutton .= '<input type="button" value="'.
+            'Previous student (none)'.'" />';
+    }
+    #
+    # Build the next student link
+    my $next = &Apache::lonstatistics::next_student();
+    my $nextbutton = '';
+    if (defined($next)) {
+        my $sname = $next->{'username'}.':'.$next->{'domain'};
+        $nextbutton .= '<input type="button" value="'.
+            'Next Student ('.
+            $next->{'username'}.'@'.$next->{'domain'}.')'.
+            '" onclick="document.Statistics.SelectedStudent.value='.
+            "'".$sname."'".';'.
+            'document.Statistics.submit();" />';
+    } else {
+        $nextbutton .= '<input type="button" value="'.
+            'Next student (none)'.'" />';
+    }
+    #
+    # Build the 'all students' button
+    my $all = '';
+    $all .= '<input type="button" value="All Students" '.
+            '" onclick="document.Statistics.SelectedStudent.value='.
+            "''".';'.'document.Statistics.submit();" />';
+    $Str .= $previousbutton.('&nbsp;'x5).$all.('&nbsp;'x5).$nextbutton;
+    return $Str;
+}
+
+#######################################################
+#######################################################
 
 sub get_student_fields_to_show {
     my @to_show = @Apache::lonstatistics::SelectedStudentData;
@@ -595,7 +660,11 @@
     } else {
         $r->print("</pre>\n"); 
     }
-    $r->print(&StudentAverageTotal());
+    if ($single_student_mode) {
+        $r->print(&SingleStudentTotal());
+    } else {
+        $r->print(&StudentAverageTotal());
+    }
     $r->rflush();
     return;
 }
@@ -638,6 +707,31 @@
     return $Str;
 }
 
+sub SingleStudentTotal {
+    my $student = &Apache::lonstatistics::current_student();
+    my $Str = "<h3>Summary Table For ".$student->{'username'}.'@'.
+        $student->{'domain'}."</h3>\n";
+    $Str .= '<table border=2 cellspacing="1">'."\n";
+    $Str .= 
+        "<tr><th>Sequence or Folder</th><th>Score</th><th>Maximum</th></tr>\n";
+    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>'.
+            '<td align="right">'.$value.'</td>'.
+                '<td align="right">'.$max.'</td></tr>'."\n";
+        $total += $value;
+        $total_max +=$max;
+    }
+    $Str .= '<tr><td><b>Total</b></td>'.
+        '<td align="right">'.$total.'</td>'.
+        '<td align="right">'.$total_max."</td></tr>\n";
+    $Str .= "</table>\n";
+    return $Str;
+}
+
 }
 
 #######################################################
@@ -1175,6 +1269,9 @@
             #
             if ( ($links eq 'yes' && $symbol ne ' ') ||
                  ($links eq 'all')) {
+                if (length($symbol) > 1) {
+                    &Apache::lonnet::logthis('length of symbol "'.$symbol.'" > 1');
+                }
                 $symbol = '<a href="/adm/grades'.
                     '?symb='.&Apache::lonnet::escape($resource->{'symb'}).
                         '&student='.$student->{'username'}.

--matthew1054244312--