--- loncom/interface/statistics/lonstudentsubmissions.pm	2010/09/11 19:08:22	1.54.10.1
+++ loncom/interface/statistics/lonstudentsubmissions.pm	2011/11/18 22:35:33	1.54.10.4
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstudentsubmissions.pm,v 1.54.10.1 2010/09/11 19:08:22 raeburn Exp $
+# $Id: lonstudentsubmissions.pm,v 1.54.10.4 2011/11/18 22:35:33 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -77,7 +77,7 @@ sub BuildStudentSubmissionsPage {
                                    '<div class="LC_info">'.&mt('Loading student data...').'</div>');
     $r->rflush();
     #
-    if (exists($env{'form.problemchoice'}) && 
+    if ((exists($env{'form.problemchoice'}) || (exists($env{'form.allproblems'}))) && 
         ! exists($env{'form.SelectAnother'})) {
         foreach my $button (@SubmitButtons) {
             if ($button->{'name'} eq 'break') {
@@ -95,16 +95,32 @@ sub BuildStudentSubmissionsPage {
         $r->print('<hr />'.$/);
         $r->rflush();
         #
+
+        #
+        # Get resource objects
+        my $navmap = Apache::lonnavmaps::navmap->new();
+
         # Determine which problems we are to analyze
         my @Symbs = 
             &Apache::lonstathelpers::get_selected_symbs('problemchoice');
+        if (defined($navmap)) {
+            if ($env{'form.allproblems'}) {
+                my $iterator = $navmap->getIterator(undef, undef, undef, 1);
+                while (my $curRes = $iterator->next()) {
+                    next if (! ref($curRes));
+                    if ($curRes->is_problem) {
+                        my $symb = $curRes->symb;
+                        unless(grep(/^\Q$symb\E$/,@Symbs)) {
+                            push(@Symbs,$symb);
+                        }
+                    }
+                }
+            }
+        }
         foreach my $selected (@Symbs) {
             $r->print('<input type="hidden" name="problemchoice" value="'.
                       $selected.'" />'.$/);
         }
-        #
-        # Get resource objects
-        my $navmap = Apache::lonnavmaps::navmap->new();
         if (!defined($navmap)) {
             $r->print('<div class="LC_error">'.&mt("Internal error").'</div>');
             return;
@@ -112,7 +128,9 @@ sub BuildStudentSubmissionsPage {
         my %already_seen;
         my (@Problems,$show_named);
         unless (&Apache::loncommon::needs_gci_custom()) {
-            $show_named = 1;  
+            unless ($env{'form.anonymized'} eq 'true') {
+                $show_named = 1;
+            }
         }
         foreach my $symb (@Symbs) {
             my $resource = $navmap->getBySymb($symb);
@@ -136,6 +154,9 @@ sub BuildStudentSubmissionsPage {
                 $threshold = 10;
             }
         }
+        unless (&Apache::loncommon::needs_gci_custom()) {
+            $threshold = 0;
+        }
         # 
         $r->print('<h4>'.
                   &Apache::lonstatistics::section_and_enrollment_description().
@@ -143,7 +164,7 @@ sub BuildStudentSubmissionsPage {
         if (! scalar(@Problems) || ! defined($Problems[0])) {
             $r->print('resource is undefined');
         } elsif (!$show_named && @Students < $threshold) {
-            $r->print(&mt('The number of students matching the selection criteria is too few for display of submission data for anonymous surveys.').'<br />'.&mt('There must be at least [quant,_1,student].',$threshold).' '.&mt('Contact a Domain Coordinator if you need the threshold to be changed for this course.'));
+            $r->print(&mt('The number of students matching the selection criteria is too few for display of submission data for anonymous surveys.').'<br />'.&mt('There must be at least [quant,_1,student].',$threshold).' '.&mt('Contact the LON-CAPA [_1]Helpdesk[_2] if you need the threshold to be changed for this course.','<a href="/adm/helpdesk?origurl=%2fadm%2fstatistics>','</a>'));
         } else {
             if (scalar(@Problems) == 1) {
                 my $resource = $Problems[0];
@@ -341,6 +362,9 @@ sub prepare_html_output {
             $prob_span += $part_span;
         }
         my $title = $prob->compTitle;
+        unless (&Apache::loncommon::needs_gci_custom()) {
+            ($title) = ($prob->src =~ m{/([^/]+)$});
+        }
         if ($prob_span > 0) {
             $headers{'problem'}.= qq{<th colspan="$prob_span">$title</th>};
         } elsif ($single_response) {
@@ -774,14 +798,13 @@ sub prepare_excel_output {
         $worksheet->write($header_row,$cols_output++,ucfirst($_),
                           $format->{'bold'});
     }
-    foreach (@StudentColumns) {
-        $worksheet->write($header_row,$cols_output++,ucfirst($_),
-                          $format->{'bold'});
-    }
     # Problem headers
     my %start_col;
     foreach my $prob (@$Problems) {
         my $title = $prob->compTitle;
+        unless (&Apache::loncommon::needs_gci_custom()) {
+            ($title) = ($prob->src =~ m{/([^/]+)$});
+        }
         $worksheet->write($title_row,$cols_output,
                           $title,$format->{'h3'});
         foreach my $partid (@{$prob->parts}) {
@@ -823,16 +846,6 @@ sub prepare_excel_output {
         my $anonid = &Crypt::PasswdMD5::unix_md5_crypt($student->{'username'},
                                                        $salt);
         $anonid = substr($anonid,length($salt)+1);
-        foreach my $field (@StudentColumns) {
-            if ($show_named) {
-                $worksheet->write($student_row,$cols_output++,
-                                  $student->{$field});
-            } else {
-                $worksheet->write($student_row,$cols_output++,
-                                      $anonid);
-            }
-        }
-        my $last_student_col = $cols_output-1;
         foreach my $prob (@$Problems) {
             foreach my $partid (@{$prob->parts}) {
                 my @Response = $prob->responseIds($partid);
@@ -882,7 +895,7 @@ sub prepare_excel_output {
             }
         }
         # Fill in the remaining rows with the students data
-        for (my $row = $student_row+1;$row<$max_row;$row++) {
+        for (my $row = $student_row;$row<$max_row;$row++) {
             my $cols = 0;
             foreach my $field (@StudentColumns) {
                 if ($show_named) {
@@ -1056,7 +1069,11 @@ sub prepare_csv_output {
     foreach my $prob (@$problems) {
         my %analysis = &Apache::lonstathelpers::get_problem_data($prob->src);
         $problem_analysis{$prob->src}=\%analysis;
-        $headers{'problem'}->[$max_column] = $prob->compTitle;
+        my $title = $prob->compTitle;
+        unless (&Apache::loncommon::needs_gci_custom()) {
+            ($title) = ($prob->src =~ m{/([^/]+)$});
+        }
+        $headers{'problem'}->[$max_column] = $title;
         foreach my $partid (@{$prob->parts}) {
             $headers{'part'}->[$max_column] = $prob->part_display($partid);
             my $responses = [$prob->responseIds($partid)];
@@ -1248,7 +1265,19 @@ sub CreateInterface {
         $prob_status_checkbox .= 'checked="checked" ';
     }
     $prob_status_checkbox .= 'value="true" />';
-    #
+    my $anon_checkbox;
+    unless (&Apache::loncommon::needs_gci_custom()) {
+        #
+        # anonymized checkbox
+        #
+        $anon_checkbox = '<input type="checkbox" name="anonymized" ';
+        if (exists($env{'form.anonymized'}) &&
+            $env{'form.anonymized'} eq 'true') {
+            $anon_checkbox .= 'checked="checked" ';
+        }
+        $anon_checkbox .= ' value="true" />';
+    }
+
     $Str .= '<td align="right" valign="top">'.
         '<label><b>'.
         &mt('Show problem').' '.$prob_checkbox.'</b></label><br />'.
@@ -1259,8 +1288,14 @@ sub CreateInterface {
         '</b></label><br />'.
         '<label><b>'.
         &mt('Show problem grading').' '.$prob_status_checkbox.
-        '</b></label><br />'.
-        '</td>';
+        '</b></label><br />';
+
+    unless (&Apache::loncommon::needs_gci_custom()) {
+        $Str .= '<label><b>'.
+                &mt('Anonymized').' '.$anon_checkbox.
+                '</b></label><br />';
+    }
+    $Str .= '</td>';
     #
     $Str .= '<td align="center" valign="top">'.$output_selector.'</td>';
     #