--- loncom/interface/lonstatistics.pm	2005/04/07 06:56:23	1.123
+++ loncom/interface/lonstatistics.pm	2006/02/14 16:05:37	1.128
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstatistics.pm,v 1.123 2005/04/07 06:56:23 albertel Exp $
+# $Id: lonstatistics.pm,v 1.128 2006/02/14 16:05:37 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -73,6 +73,7 @@ use Apache::lonstudentassessment();
 use Apache::lonpercentage;
 use Apache::lonstudentsubmissions();
 use Apache::lonsurveyreports();
+use Apache::longradinganalysis();
 
 #######################################################
 #######################################################
@@ -197,8 +198,8 @@ sub PrepareClasslist {
     my $cid  = $env{'request.course.id'};
     my $cdom = $env{'course.'.$cid.'.domain'};
     my $cnum = $env{'course.'.$cid.'.num'};
-    my ($classlist,$field_names) = &Apache::loncoursedata::get_classlist($cid,
-                                                                  $cdom,$cnum);
+    my ($classlist,$field_names) = &Apache::loncoursedata::get_classlist($cdom,
+									$cnum);
     my @selected_sections = &get_selected_sections();
     #
     # Deal with instructors with restricted section access
@@ -267,8 +268,9 @@ sub PrepareClasslist {
     # Sort the Students
     my $sortby = 'fullname';
     $sortby = $env{'form.sort'} if (exists($env{'form.sort'}));
-    my @TmpStudents = sort { $a->{$sortby} cmp $b->{$sortby} ||
-                             $a->{'fullname'} cmp $b->{'fullname'} } @Students;
+    my @TmpStudents = sort { lc($a->{$sortby}) cmp lc($b->{$sortby}) ||
+                             lc($a->{'fullname'}) cmp lc($b->{'fullname'}) ||
+			     lc($a->{'username'}) cmp lc($b->{'username'}) } @Students;
     @Students = @TmpStudents;
     # 
     # Now deal with that current student thing....
@@ -298,11 +300,8 @@ sub PrepareClasslist {
     }
     #
     if (exists($env{'form.StudentData'})) {
-        if (ref($env{'form.StudentData'}) eq 'ARRAY') {
-            @SelectedStudentData = @{$env{'form.StudentData'}};
-        } else {
-            @SelectedStudentData = ($env{'form.StudentData'});
-        }
+	@SelectedStudentData = 
+	    &Apache::loncommon::get_env_multiple('form.StudentData');
     } else {
         @SelectedStudentData = ('username');
     }
@@ -330,14 +329,8 @@ Returns an array of the selected section
 #######################################################
 #######################################################
 sub get_selected_sections {
-    my @selected_sections;
-    if (exists($env{'form.Section'})) {
-        if (ref($env{'form.Section'})) {
-            @selected_sections = @{$env{'form.Section'}};
-        } elsif ($env{'form.Section'} !~ /^\s*$/) {
-            @selected_sections = ($env{'form.Section'});
-        }
-    }
+    my @selected_sections = 
+	&Apache::loncommon::get_env_multiple('form.Section');
     @selected_sections = ('all') if (! @selected_sections);
     foreach (@selected_sections) {
         if ($_ eq 'all') {
@@ -569,16 +562,9 @@ Returns: Array of symbs of selected maps
 #######################################################
 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');
-    }
+    my @selected_maps = 
+	&Apache::loncommon::get_env_multiple('form.'.$elementname);
+    @selected_maps = ('all') if (! @selected_maps);
     foreach my $map (@selected_maps) {
         if ($map eq 'all') {
             @selected_maps = ('all');
@@ -929,6 +915,11 @@ sub CreateMainMenu {
                      short_description => 
     &mt('Display a histogram of student performance in the course.'),
                  },
+#                   { internal_name => 'grading_analysis',
+#                     name => &mt('Detailed Grading Analysis'),
+#                     short_description => 
+#    &mt('Display statistics about who graded who.'),
+#                 },
 #                   { internal_name => 'student_assessment',
 #                     name => &mt('Problem Status Chart'),
 #                     short_description => 
@@ -1093,7 +1084,12 @@ ENDSTYLE
                 ({href=>'/adm/statistics?reportselected=student_assessment',
                   text=>'Chart'});
             &Apache::lonstudentassessment::BuildStudentAssessmentPage($r,$c);
-        }
+        } elsif($GoToPage eq 'grading_analysis') {
+            &Apache::lonhtmlcommon::add_breadcrumb
+                ({href=>'/adm/statistics?reportselected=grading_anaylsis',
+                  text=>'Grading Analysis'});
+            &Apache::longradinganalysis::build_grading_analysis_page($r,$c);
+	}
         #
         $r->print("</form>\n");
     }