--- loncom/homework/grades.pm	2021/01/05 21:25:47	1.780
+++ loncom/homework/grades.pm	2021/01/25 14:21:17	1.784
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.780 2021/01/05 21:25:47 raeburn Exp $
+# $Id: grades.pm,v 1.784 2021/01/25 14:21:17 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1173,6 +1173,8 @@ LISTJAVASCRIPT
         my @sections;
         if ($env{'request.course.sec'} ne '') {
             @sections = ($env{'request.course.sec'});
+        } elsif ($env{'form.section'} eq '') {
+            @sections = ('all');
         } else {
             @sections = &Apache::loncommon::get_env_multiple('form.section');
         }
@@ -1214,7 +1216,7 @@ LISTJAVASCRIPT
 	'<input type="hidden" name="symb" value="'.&Apache::lonenc::check_encrypt($symb).'" />'."\n".
 	'<input type="hidden" name="saveStatusOld" value="'.$saveStatus.'" />'."\n";
     if (exists($env{'form.Status'})) {
-	$gradeTable .= '<input type="hidden" name="Status" value="'.$stu_status.'" />'."\n";
+	$gradeTable .= '<input type="hidden" name="Status" value="'.$env{'form.Status'}.'" />'."\n";
     } else {
         $gradeTable .= &Apache::lonhtmlcommon::row_closure()
                       .&Apache::lonhtmlcommon::row_title(&mt('Student Status'))
@@ -10445,32 +10447,32 @@ sub grading_menu {
             items =>[
                         {	linktext => 'Select individual students to grade',
                     		url => $url1a,
-                    		permission => $permissions{'either'}
+                    		permission => $permissions{'either'},
                     		icon => 'grade_students.png',
                     		linktitle => 'Grade current resource for a selection of students.'
                         }, 
                         {       linktext => 'Grade ungraded submissions',
                                 url => $url1b,
-                                permission => $permissions{'either'}
+                                permission => $permissions{'either'},
                                 icon => 'ungrade_sub.png',
                                 linktitle => 'Grade all submissions that have not been graded yet.'
                         },
 
                         {       linktext => 'Grading table',
                                 url => $url1c,
-                                permission => $permissions{'either'}
+                                permission => $permissions{'either'},
                                 icon => 'grading_table.png',
                                 linktitle => 'Grade current resource for all students.'
                         },
                         {       linktext => 'Grade page/folder for one student',
                                 url => $url1d,
-                                permission => $permissions{'either'}
+                                permission => $permissions{'either'},
                                 icon => 'grade_PageFolder.png',
                                 linktitle => 'Grade all resources in current page/sequence/folder for one student.'
                         },
                         {       linktext => 'Download submissions',
                                 url => $url1e,
-                                permission => $permissions{'either'}
+                                permission => $permissions{'either'},
                                 icon => 'download_sub.png',
                                 linktitle => 'Download all students submissions.'
                         }]},
@@ -10632,6 +10634,14 @@ sub selectfield {
            (&substatus_options,
             'select_form_order' => ['yes','queued','graded','incorrect','all']);
    }
+
+  #
+  # PrepareClasslist() needs to be called to avoid getting a sections list
+  # for a different course from the @Sections global in lonstatistics.pm, 
+  # populated by an earlier request.
+  #
+   &Apache::lonstatistics::PrepareClasslist();
+
    my $result='<div class="LC_columnSection">
   
     <fieldset>