--- loncom/homework/grades.pm 2020/08/30 20:30:21 1.773
+++ loncom/homework/grades.pm 2021/01/23 20:32:17 1.783
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.773 2020/08/30 20:30:21 raeburn Exp $
+# $Id: grades.pm,v 1.783 2021/01/23 20:32:17 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -293,6 +293,17 @@ sub showResourceInfo {
$result .= '';
}
$result .= '
';
+ if (!keys(%partsseen)) {
+ $result = '';
+ if ($uploads) {
+ return ''.
+ ''.
+ &mt('No dropbox items or essayresponse items with uploadedfiletypes set.').
+ '
';
+ } else {
+ return '
';
+ }
+ }
return $result;
}
@@ -1155,8 +1166,33 @@ LISTJAVASCRIPT
$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'});
+ } elsif ($env{'form.section'} eq '') {
+ @sections = ('all');
+ } else {
+ @sections = &Apache::loncommon::get_env_multiple('form.section');
+ }
+ if (grep(/^all$/,@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'))
.''
.''
.&Apache::lonhtmlcommon::row_closure();
- $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('Grading Increments'))
+ $gradeTable .=
+ &Apache::lonhtmlcommon::row_title(&mt('Grading Increments'))
.'';
+ }
$gradeTable .=
&build_section_inputs().
''."\n".
@@ -2576,8 +2614,8 @@ sub submission {
$rndseed = $record{"resource.$partid.rndseed"};
}
if ($env{'form.checkPlag'}) {
- my ($oname,$odom,$ocrsid,$oessay,$osim)=
- &most_similar($uname,$udom,$symb,$subval);
+ my ($oname,$odom,$ocrsid,$oessay,$osim)=
+ &most_similar($uname,$udom,$symb,$subval);
if ($osim) {
$osim=int($osim*100.0);
if ($hide eq 'anon') {
@@ -2641,7 +2679,6 @@ sub submission {
'('.&mt('Response ID: [_1]',$respid).')'.
' ';
my $files=&get_submitted_files($udom,$uname,$partid,$respid,\%record);
-
if (@$files) {
if ($hide eq 'anon') {
$lastsubonly.='
'.&mt('[quant,_1,file] uploaded to this anonymous survey',scalar(@{$files}));
@@ -2653,7 +2690,7 @@ sub submission {
} else {
$lastsubonly .= &mt('Like all files provided by users, these files may contain viruses!');
}
- $lastsubonly .= '';
+ $lastsubonly .= '';
foreach my $file (@$files) {
&Apache::lonnet::allowuploaded('/adm/grades',$file);
$lastsubonly.='
'.$file.'';
@@ -2664,7 +2701,7 @@ sub submission {
if ($hide eq 'anon') {
$lastsubonly.='
'.&mt('Anonymous Survey').'';
} else {
- $lastsubonly.='
'.&mt('Submitted Answer:').' ';
+ $lastsubonly.='
'.&mt('Submitted Answer:').' ';
if ($draft) {
$lastsubonly.= ' '.&mt('Draft Copy').'';
}
@@ -2676,7 +2713,7 @@ sub submission {
}
$lastsubonly.=$subval."\n";
}
- if ($similar) {$lastsubonly.="
$similar\n";}
+ if ($similar) {$lastsubonly.="
$similar\n";}
$lastsubonly.='';
}
}
@@ -3242,7 +3279,7 @@ sub processHandGrade {
# Keywords sorted in alphabatical order
my $loginuser = $env{'user.name'}.':'.$env{'user.domain'};
$env{'form.keywords'} =~ s/,\s{0,}|\s+/ /g;
- $env{'form.keywords'} =~ s/^\s+|\s+$//;
+ $env{'form.keywords'} =~ s/^\s+|\s+$//g;
my (@keywords) = sort(split(/\s+/,$env{'form.keywords'}));
$env{'form.keywords'} = join(' ',@keywords);
$keyhash{$symb.'_keywords'} = $env{'form.keywords'};
@@ -3967,7 +4004,26 @@ sub viewgrades {
}
my ($common_header,$specific_header,@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$/,@sections)) {
+ undef($disabled);
+ } else {
+ foreach my $sec (@sections) {
+ if (&canmodify($sec)) {
+ undef($disabled);
+ last;
+ }
+ }
+ }
+ }
if (grep(/^all$/,@sections)) {
@sections = ('all');
if ($group_display) {
@@ -4159,7 +4215,7 @@ sub viewgrades {
}
$result.=&Apache::loncommon::end_data_table();
$result.=''."\n";
- $result.=''."\n";
if ($ctr == 0) {
my $stu_status = join(' or ',&Apache::loncommon::get_env_multiple('form.Status'));
@@ -5399,10 +5455,14 @@ sub displayPage {
}
$curRes = $iterator->next();
}
+ my $disabled;
+ unless (&canmodify($usec)) {
+ $disabled = ' disabled="disabled"';
+ }
$studentTable.=
''."\n".
- ''.
''."\n";
$request->print($studentTable);
@@ -9462,7 +9522,7 @@ END
if ($count > 1) {
$formatextra = ''.
''.
- &mt('Bubblesheet type:').' '.
+ &mt('Bubblesheet type').': '.
&scantron_scantab().'
';
$onclick = ' onclick="toggleScantab(this.form);"';
$formatjs = <<"END";
@@ -10372,37 +10432,47 @@ sub grading_menu {
$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.'
}]},
@@ -10411,25 +10481,25 @@ sub grading_menu {
{ 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.'
}
@@ -10564,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='