[LON-CAPA-cvs] cvs: loncom /homework grades.pm

raeburn raeburn at source.lon-capa.org
Tue Jan 5 16:25:47 EST 2021


raeburn		Tue Jan  5 21:25:47 2021 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  - "Send Messages" and "Grading Increments" rows only shown in display options
    table, if user has mgr priv.
  - Save button on "Grading table" and "Grade page/folder for one student" screens
    grayed out unless user has mgr priv.
  - "Upload Scores", "Process Clicker", and "Grade/Manage/Review Bubblesheets"
    items only included in "Automated Grading" panel if user has mgr priv.
  
  
-------------- next part --------------
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.779 loncom/homework/grades.pm:1.780
--- loncom/homework/grades.pm:1.779	Tue Nov 10 17:17:54 2020
+++ loncom/homework/grades.pm	Tue Jan  5 21:25:47 2021
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.779 2020/11/10 17:17:54 raeburn Exp $
+# $Id: grades.pm,v 1.780 2021/01/05 21:25:47 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1166,8 +1166,31 @@
         $nocompmsg = '';
     }
     $gradeTable .= &Apache::lonhtmlcommon::row_title($viewtitle)
-                  .$submission_options
-                  .&Apache::lonhtmlcommon::row_closure()
+                  .$submission_options;
+# Check if any gradable
+    my $showmore;
+    if ($perm{'mgr'}) {
+        my @sections;
+        if ($env{'request.course.sec'} ne '') {
+            @sections = ($env{'request.course.sec'});
+        } else {
+            @sections = &Apache::loncommon::get_env_multiple('form.section');
+        }
+        if (grep(/^all$/, at sections)) {
+            $showmore = 1;
+        } else {
+            foreach my $sec (@sections) {
+                if (&canmodify($sec)) {
+                    $showmore = 1;
+                    last;
+                }
+            }
+        }
+    }
+
+    if ($showmore) {
+        $gradeTable .=
+                   &Apache::lonhtmlcommon::row_closure()
                   .&Apache::lonhtmlcommon::row_title(&mt('Send Messages'))
                   .'<span class="LC_nobreak">'
                   .'<label><input type="radio" name="compmsg" value="0"'.$nocompmsg.' />'
@@ -1176,13 +1199,15 @@
                   .&mt('Yes').(' 'x2).'</label>'
                   .&Apache::lonhtmlcommon::row_closure();
 
-    $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('Grading Increments'))
+        $gradeTable .= 
+                   &Apache::lonhtmlcommon::row_title(&mt('Grading Increments'))
                   .'<select name="increment">'
                   .'<option value="1">'.&mt('Whole Points').'</option>'
                   .'<option value=".5">'.&mt('Half Points').'</option>'
                   .'<option value=".25">'.&mt('Quarter Points').'</option>'
                   .'<option value=".1">'.&mt('Tenths of a Point').'</option>'
                   .'</select>';
+    }
     $gradeTable .= 
         &build_section_inputs().
 	'<input type="hidden" name="submitonly"  value="'.$submitonly.'" />'."\n".
@@ -3977,7 +4002,26 @@
     }
 
     my ($common_header,$specific_header, at sections,$section_display);
-    @sections = &Apache::loncommon::get_env_multiple('form.section');
+    if ($env{'request.course.sec'} ne '') {
+        @sections = ($env{'request.course.sec'});
+    } else {
+        @sections = &Apache::loncommon::get_env_multiple('form.section');
+    }
+
+# Check if Save button should be usable
+    my $disabled = ' disabled="disabled"';
+    if ($perm{'mgr'}) {
+        if (grep(/^all$/, at sections)) {
+            undef($disabled);
+        } else {
+            foreach my $sec (@sections) {
+                if (&canmodify($sec)) {
+                    undef($disabled);
+                    last;
+                }
+            }
+        }
+    }
     if (grep(/^all$/, at sections)) {
         @sections = ('all');
         if ($group_display) {
@@ -4169,7 +4213,7 @@
     }
     $result.=&Apache::loncommon::end_data_table();
     $result.='<input type="hidden" name="total" value="'.$ctr.'" />'."\n";
-    $result.='<input type="button" value="'.&mt('Save').'" '.
+    $result.='<input type="button" value="'.&mt('Save').'"'.$disabled.' '.
 	'onclick="javascript:submit();" target="_self" /></form>'."\n";
     if ($ctr == 0) {
         my $stu_status = join(' or ',&Apache::loncommon::get_env_multiple('form.Status'));
@@ -5409,10 +5453,14 @@
 	}
         $curRes = $iterator->next();
     }
+    my $disabled;
+    unless (&canmodify($usec)) {
+        $disabled = ' disabled="disabled"';
+    }
 
     $studentTable.=
         '</table>'."\n".
-        '<input type="button" value="'.&mt('Save').'" '.
+        '<input type="button" value="'.&mt('Save').'"'.$disabled.' '.
         'onclick="javascript:checkSubmitPage(this.form,'.$question.');" />'.
         '</form>'."\n";
     $request->print($studentTable);
@@ -10382,37 +10430,47 @@
 
     $fields{'command'} = 'initialverifyreceipt';
     my $url5 = &Apache::lonhtmlcommon::build_url('grades/',\%fields);
-    
+
+    my %permissions;
+    if ($perm{'mgr'}) {
+        $permissions{'either'} = 'F';
+        $permissions{'mgr'} = 'F';
+    }
+    if ($perm{'vgr'}) {
+        $permissions{'either'} = 'F';
+        $permissions{'vgr'} = 'F';
+    }
+
     my @menu = ({	categorytitle=>'Hand Grading',
             items =>[
                         {	linktext => 'Select individual students to grade',
                     		url => $url1a,
-                    		permission => 'F',
+                    		permission => $permissions{'either'}
                     		icon => 'grade_students.png',
                     		linktitle => 'Grade current resource for a selection of students.'
                         }, 
                         {       linktext => 'Grade ungraded submissions',
                                 url => $url1b,
-                                permission => 'F',
+                                permission => $permissions{'either'}
                                 icon => 'ungrade_sub.png',
                                 linktitle => 'Grade all submissions that have not been graded yet.'
                         },
 
                         {       linktext => 'Grading table',
                                 url => $url1c,
-                                permission => 'F',
+                                permission => $permissions{'either'}
                                 icon => 'grading_table.png',
                                 linktitle => 'Grade current resource for all students.'
                         },
                         {       linktext => 'Grade page/folder for one student',
                                 url => $url1d,
-                                permission => 'F',
+                                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 => 'F',
+                                permission => $permissions{'either'}
                                 icon => 'download_sub.png',
                                 linktitle => 'Download all students submissions.'
                         }]},
@@ -10421,25 +10479,25 @@
 
                 	    {	linktext => 'Upload Scores',
                     		url => $url2,
-                    		permission => 'F',
+                    		permission => $permissions{'mgr'},
                     		icon => 'uploadscores.png',
                     		linktitle => 'Specify a file containing the class scores for current resource.'
                 	    },
                 	    {	linktext => 'Process Clicker',
                     		url => $url3,
-                    		permission => 'F',
+                    		permission => $permissions{'mgr'},
                     		icon => 'addClickerInfoFile.png',
                     		linktitle => 'Specify a file containing the clicker information for this resource.'
                 	    },
                 	    {	linktext => 'Grade/Manage/Review Bubblesheets',
                     		url => $url4,
-                    		permission => 'F',
+                    		permission => $permissions{'mgr'},
                     		icon => 'bubblesheet.png',
                     		linktitle => 'Grade bubblesheet exams, upload/download bubblesheet data files, and review previously graded bubblesheet exams.'
                 	    },
                             {   linktext => 'Verify Receipt Number',
                                 url => $url5,
-                                permission => 'F',
+                                permission => $permissions{'either'},
                                 icon => 'receipt_number.png',
                                 linktitle => 'Verify a system-generated receipt number for correct problem solution.'
                             }


More information about the LON-CAPA-cvs mailing list