[LON-CAPA-cvs] cvs: loncom /homework grades.pm
raeburn
raeburn at source.lon-capa.org
Fri May 4 11:15:05 EDT 2018
raeburn Fri May 4 15:15:05 2018 EDT
Modified files:
/loncom/homework grades.pm
Log:
- Three new args added to &getclasslist() to support filtering by submission
status.
- Download Submissions selection for Sections, Groups, Access Status, and
Submission Status now used to populate list of students for use by
multidownload.pl
-------------- next part --------------
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.749 loncom/homework/grades.pm:1.750
--- loncom/homework/grades.pm:1.749 Sun Dec 31 14:00:41 2017
+++ loncom/homework/grades.pm Fri May 4 15:15:05 2018
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.749 2017/12/31 14:00:41 raeburn Exp $
+# $Id: grades.pm,v 1.750 2018/05/04 15:15:05 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -502,7 +502,7 @@
#--- Dumps the class list with usernames,list of sections,
#--- section, ids and fullnames for each user.
sub getclasslist {
- my ($getsec,$filterlist,$getgroup) = @_;
+ my ($getsec,$filterbyaccstatus,$getgroup,$symb,$submitonly,$filterbysubmstatus) = @_;
my @getsec;
my @getgroup;
my $stu_status = join(':',&Apache::loncommon::get_env_multiple('form.Status'));
@@ -530,6 +530,13 @@
#
my %sections;
my %fullnames;
+ my ($cdom,$cnum,$partlist);
+ if (($filterbysubmstatus) && ($submitonly ne 'all') && ($symb ne '')) {
+ $cdom = $env{"course.$env{'request.course.id'}.domain"};
+ $cnum = $env{"course.$env{'request.course.id'}.num"};
+ my $res_error;
+ ($partlist,my $handgrade,my $responseType) = &response_type($symb,\$res_error);
+ }
foreach my $student (keys(%$classlist)) {
my $end =
$classlist->{$student}->[&Apache::loncoursedata::CL_END()];
@@ -546,7 +553,7 @@
my $group =
$classlist->{$student}->[&Apache::loncoursedata::CL_GROUP()];
# filter students according to status selected
- if ($filterlist && (!($stu_status =~ /Any/))) {
+ if ($filterbyaccstatus && (!($stu_status =~ /Any/))) {
if (!($stu_status =~ $status)) {
delete($classlist->{$student});
next;
@@ -563,13 +570,58 @@
}
}
if (($grp eq 'none') && !$group) {
- $exclude = 0;
+ $exclude = 0;
}
}
if ($exclude) {
delete($classlist->{$student});
+ next;
}
}
+ if (($filterbysubmstatus) && ($submitonly ne 'all') && ($symb ne '')) {
+ my $udom =
+ $classlist->{$student}->[&Apache::loncoursedata::CL_SDOM()];
+ my $uname =
+ $classlist->{$student}->[&Apache::loncoursedata::CL_SNAME()];
+ if (($symb ne '') && ($udom ne '') && ($uname ne '')) {
+ if ($submitonly eq 'queued') {
+ my %queue_status =
+ &Apache::bridgetask::get_student_status($symb,$cdom,$cnum,
+ $udom,$uname);
+ if (!defined($queue_status{'gradingqueue'})) {
+ delete($classlist->{$student});
+ next;
+ }
+ } else {
+ my (%status) =&student_gradeStatus($symb,$udom,$uname,$partlist);
+ my $submitted = 0;
+ my $graded = 0;
+ my $incorrect = 0;
+ foreach (keys(%status)) {
+ $submitted = 1 if ($status{$_} ne 'nothing');
+ $graded = 1 if ($status{$_} =~ /^ungraded/);
+ $incorrect = 1 if ($status{$_} =~ /^incorrect/);
+
+ my ($foo,$partid,$foo1) = split(/\./,$_);
+ if ($status{'resource.'.$partid.'.submitted_by'} ne '') {
+ $submitted = 0;
+ }
+ }
+ if (!$submitted && ($submitonly eq 'yes' ||
+ $submitonly eq 'incorrect' ||
+ $submitonly eq 'graded')) {
+ delete($classlist->{$student});
+ next;
+ } elsif (!$graded && ($submitonly eq 'graded')) {
+ delete($classlist->{$student});
+ next;
+ } elsif (!$incorrect && $submitonly eq 'incorrect') {
+ delete($classlist->{$student});
+ next;
+ }
+ }
+ }
+ }
$section = ($section ne '' ? $section : 'none');
if (&canview($section)) {
if (!@getsec || grep(/^\Q$section\E$/, at getsec)) {
@@ -584,7 +636,6 @@
delete($classlist->{$student});
}
}
- my %seen = ();
my @sections = sort(keys(%sections));
return ($classlist,\@sections,\%fullnames);
}
@@ -1952,7 +2003,6 @@
sub files_exist {
my ($r, $symb) = @_;
my @students = &Apache::loncommon::get_env_multiple('form.stuinfo');
-
foreach my $student (@students) {
my ($uname,$udom,$fullname) = split(/:/,$student);
my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},
@@ -1975,7 +2025,6 @@
$r->print(&mt('There are currently no submitted documents.'));
return;
}
-
my $all_students =
join("\n", &Apache::loncommon::get_env_multiple('form.stuinfo'));
@@ -1995,7 +2044,55 @@
my ($request,$symb) = @_;
if (!$symb) { return ''; }
#FIXME: Figure out which type of problem this is and provide appropriate download
- &download_all_link($request,$symb);
+ my $res_error;
+ my ($partlist,$handgrade,$responseType) = &response_type($symb,$res_error);
+ if (ref($res_error)) {
+ if ($$res_error) {
+ $request->print(&mt('An error occurred retrieving response types'));
+ return;
+ }
+ }
+ my ($numupload,$numessay) = (0,0);
+ if (ref($responseType) eq 'HASH') {
+ foreach my $part (sort(keys(%$responseType))) {
+ foreach my $id (sort(keys(%{ $responseType->{$part} }))) {
+ my $responsetype = $responseType->{$part}->{$id};
+ if ($responsetype eq 'essay') {
+ my $uploadedfiletypes =
+ &Apache::lonnet::EXT("resource.$part".'_'."$id.uploadedfiletypes",$symb);
+ if ($uploadedfiletypes) {
+ $numupload++;
+ } else {
+ $numessay++;
+ }
+ }
+ }
+ }
+ }
+ if (($numupload) || ($numessay)) {
+ my $submitonly= $env{'form.submitonly'} eq '' ? 'all' : $env{'form.submitonly'};
+ my $getsec = $env{'form.section'} eq '' ? 'all' : $env{'form.section'};
+ my $getgroup = $env{'form.group'} eq '' ? 'all' : $env{'form.group'};
+ (undef,undef,my $fullname) = &getclasslist($getsec,1,$getgroup,$symb,$submitonly,1);
+ if (ref($fullname) eq 'HASH') {
+ my @students = map { $_.':'.$fullname->{$_} } (keys(%{$fullname}));
+ if (@students) {
+ @{$env{'form.stuinfo'}} = @students;
+ if ($numupload) {
+ &download_all_link($request,$symb);
+ }
+# FIXME Need to provide a mechanism to download essays, i.e., if $numessay > 0
+# Needs to omit user's identity if resource instance is for an anonymous survey.
+ } else {
+ $request->print(&mt('No students match the criteria you selected'));
+ }
+ } else {
+ $request->print(&mt('Could not retrieve student information'));
+ }
+ } else {
+ $request->print(&mt('No essayresponse items found'));
+ }
+ return;
}
sub build_section_inputs {
@@ -9811,7 +9908,7 @@
'<input type="hidden" name="symb" value="'.&Apache::lonenc::check_encrypt($symb).'" />'."\n";
$result.='
<h2>
- '.&mt('Select Students for Which to Download Submissions').'
+ '.&mt('Select Students for whom to Download Submissions').'
</h2>'.&selectfield(1,$is_tool).'
<input type="hidden" name="command" value="downloadfileslink" />
<input type="submit" value="'.&mt('Next').' →" />
@@ -10751,7 +10848,7 @@
} elsif ($command eq 'downloadfileslink' && $perm{'vgr'}) {
&startpage($request,$symb,
[{href=>&href_symb_cmd($symb,'downloadfilesselect'), text=>'Select which submissions to download'},
- {href=>'', text=>'Download submissions'}]);
+ {href=>'', text=>'Download submitted files'}]);
&submit_download_link($request,$symb);
} elsif ($command) {
&startpage($request,$symb,[{href=>'', text=>'Access denied'}]);
More information about the LON-CAPA-cvs
mailing list