From raeburn at source.lon-capa.org Tue May 1 08:40:06 2018 From: raeburn at source.lon-capa.org (raeburn) Date: Tue, 01 May 2018 12:40:06 -0000 Subject: [LON-CAPA-cvs] cvs: loncom /interface mydesk.tab Message-ID: raeburn Tue May 1 12:40:06 2018 EDT Modified files: /loncom/interface mydesk.tab Log: - Add Spreadsheet and Content Grading items to "Grades" drop-down in inline menu (vgr priv required). Index: loncom/interface/mydesk.tab diff -u loncom/interface/mydesk.tab:1.179 loncom/interface/mydesk.tab:1.180 --- loncom/interface/mydesk.tab:1.179 Fri Apr 27 23:01:05 2018 +++ loncom/interface/mydesk.tab Tue May 1 12:40:06 2018 @@ -1,4 +1,4 @@ -# $Id: mydesk.tab,v 1.179 2018/04/27 23:01:05 raeburn Exp $ +# $Id: mydesk.tab,v 1.180 2018/05/01 12:40:06 raeburn Exp $ # primary menu links # Apache::lonmenu::primary_menu() generates a menu from these elements # prim: item belongs to primary menu @@ -117,6 +117,8 @@ # scndsub:parent:link:text:condition scndsub:Grades:/adm/statistics?reportSelected=student_assessment:Assessment Chart:vgr scndsub:Grades:/adm/statistics:Statistics and Reports:vgr +scndsub:Grades:/adm/classcalc:Spreadsheet:vgr +scndsub:Grades:/adm/grades:Content Grading:vgr scndsub:Settings:/adm/courseprefs:Course Settings:params scndsub:Settings:/adm/parmset:Content Settings:params scndsub:Settings:/adm/slotrequest?command=showslots:Slots:vgr From raeburn at source.lon-capa.org Tue May 1 09:30:50 2018 From: raeburn at source.lon-capa.org (raeburn) Date: Tue, 01 May 2018 13:30:50 -0000 Subject: [LON-CAPA-cvs] cvs: loncom /interface loncommon.pm Message-ID: raeburn Tue May 1 13:30:50 2018 EDT Modified files: /loncom/interface loncommon.pm Log: - Use three-argument open() to separate file mode from the filename. Index: loncom/interface/loncommon.pm diff -u loncom/interface/loncommon.pm:1.1316 loncom/interface/loncommon.pm:1.1317 --- loncom/interface/loncommon.pm:1.1316 Fri Apr 27 23:01:05 2018 +++ loncom/interface/loncommon.pm Tue May 1 13:30:49 2018 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1316 2018/04/27 23:01:05 raeburn Exp $ +# $Id: loncommon.pm,v 1.1317 2018/05/01 13:30:49 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -203,7 +203,7 @@ { my $langtabfile = $Apache::lonnet::perlvar{'lonTabDir'}. '/language.tab'; - if ( open(my $fh,"<$langtabfile") ) { + if ( open(my $fh,'<',$langtabfile) ) { while (my $line = <$fh>) { next if ($line=~/^\#/); chomp($line); @@ -225,7 +225,7 @@ { my $copyrightfile = $Apache::lonnet::perlvar{'lonIncludes'}. '/copyright.tab'; - if ( open (my $fh,"<$copyrightfile") ) { + if ( open (my $fh,'<',$copyrightfile) ) { while (my $line = <$fh>) { next if ($line=~/^\#/); chomp($line); @@ -239,7 +239,7 @@ { my $sourcecopyrightfile = $Apache::lonnet::perlvar{'lonIncludes'}. '/source_copyright.tab'; - if ( open (my $fh,"<$sourcecopyrightfile") ) { + if ( open (my $fh,'<',$sourcecopyrightfile) ) { while (my $line = <$fh>) { next if ($line =~ /^\#/); chomp($line); @@ -253,7 +253,7 @@ # -------------------------------------------------------------- default domain designs my $designdir=$Apache::lonnet::perlvar{'lonTabDir'}.'/lonDomColors'; my $designfile = $designdir.'/default.tab'; - if ( open (my $fh,"<$designfile") ) { + if ( open (my $fh,'<',$designfile) ) { while (my $line = <$fh>) { next if ($line =~ /^\#/); chomp($line); @@ -267,7 +267,7 @@ { my $categoryfile = $Apache::lonnet::perlvar{'lonTabDir'}. '/filecategories.tab'; - if ( open (my $fh,"<$categoryfile") ) { + if ( open (my $fh,'<',$categoryfile) ) { while (my $line = <$fh>) { next if ($line =~ /^\#/); chomp($line); @@ -282,7 +282,7 @@ { my $typesfile = $Apache::lonnet::perlvar{'lonTabDir'}. '/filetypes.tab'; - if ( open (my $fh,"<$typesfile") ) { + if ( open (my $fh,'<',$typesfile) ) { while (my $line = <$fh>) { next if ($line =~ /^\#/); chomp($line); @@ -5650,7 +5650,7 @@ my $designdir=$Apache::lonnet::perlvar{'lonTabDir'}.'/lonDomColors'; my $designfile = $designdir.'/'.$udom.'.tab'; if (-e $designfile) { - if ( open (my $fh,"<$designfile") ) { + if ( open (my $fh,'<',$designfile) ) { while (my $line = <$fh>) { next if ($line =~ /^\#/); chomp($line); @@ -12163,7 +12163,7 @@ return; } } - if (open(my $fh,"<$container")) { + if (open(my $fh,'<',$container)) { $content = join('', <$fh>); close($fh); } else { @@ -12228,7 +12228,7 @@ } } } else { - if (open(my $fh,">$container")) { + if (open(my $fh,'>',$container)) { print $fh $content; close($fh); $output = '

'.&mt('Updated [quant,_1,reference] in [_2].', @@ -13857,7 +13857,7 @@ { my $datafile = $r->dir_config('lonDaemons'). '/tmp/'.$datatoken.'.tmp'; - if ( open(my $fh,">$datafile") ) { + if ( open(my $fh,'>',$datafile) ) { print $fh $env{'form.upfile'}; close($fh); } @@ -13882,7 +13882,7 @@ { my $studentfile = $r->dir_config('lonDaemons'). '/tmp/'.$datatoken.'.tmp'; - if ( open(my $fh,"<$studentfile") ) { + if ( open(my $fh,'<',$studentfile) ) { @studentdata=<$fh>; close($fh); } From raeburn at source.lon-capa.org Tue May 1 09:47:53 2018 From: raeburn at source.lon-capa.org (raeburn) Date: Tue, 01 May 2018 13:47:53 -0000 Subject: [LON-CAPA-cvs] cvs: loncom /auth lonlogout.pm Message-ID: raeburn Tue May 1 13:47:53 2018 EDT Modified files: /loncom/auth lonlogout.pm Log: - Use three-argument open() to separate file mode from the filename. Index: loncom/auth/lonlogout.pm diff -u loncom/auth/lonlogout.pm:1.52 loncom/auth/lonlogout.pm:1.53 --- loncom/auth/lonlogout.pm:1.52 Thu Nov 30 03:35:08 2017 +++ loncom/auth/lonlogout.pm Tue May 1 13:47:53 2018 @@ -1,7 +1,7 @@ # The LearningOnline Network # Logout Handler # -# $Id: lonlogout.pm,v 1.52 2017/11/30 03:35:08 raeburn Exp $ +# $Id: lonlogout.pm,v 1.53 2018/05/01 13:47:53 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -130,7 +130,7 @@ $ssofile = '/'.&Apache::loncommon::clean_path($r->dir_config("lonSSOUserLogoutHeadFile_$domain")); if ($ssofile eq $r->dir_config("lonSSOUserLogoutHeadFile_$domain")) { if ($ssofile =~ /^\Q$londocroot\E/) { - if (open(my $fh,"<$ssofile")) { + if (open(my $fh,'<',$ssofile)) { $headextra = join('',<$fh>); close($fh); } @@ -142,7 +142,7 @@ $ssofile = '/'.&Apache::loncommon::clean_path($r->dir_config('lonSSOUserLogoutHeadFile')); if ($ssofile eq $r->dir_config('lonSSOUserLogoutHeadFile')) { if ($ssofile =~ /^\Q$londocroot\E/) { - if (open(my $fh,"<$ssofile")) { + if (open(my $fh,'<',$ssofile)) { $headextra.= join('',<$fh>); close($fh); } @@ -210,14 +210,14 @@ } if ($env{'request.sso.login'} && defined($r->dir_config("lonSSOUserLogoutMessageFile_$domain"))) { - if (open(my $fh,$r->dir_config("lonSSOUserLogoutMessageFile_$domain"))) { + if (open(my $fh,'<',$r->dir_config("lonSSOUserLogoutMessageFile_$domain"))) { $relogmessage.= join('',<$fh>); close($fh); } } if ($env{'request.sso.login'} && defined($r->dir_config('lonSSOUserLogoutMessageFile'))) { - if (open(my $fh,$r->dir_config('lonSSOUserLogoutMessageFile'))) { + if (open(my $fh,'<',$r->dir_config('lonSSOUserLogoutMessageFile'))) { $relogmessage.= join('',<$fh>); close($fh); } From raeburn at source.lon-capa.org Tue May 1 10:28:42 2018 From: raeburn at source.lon-capa.org (raeburn) Date: Tue, 01 May 2018 14:28:42 -0000 Subject: [LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm Message-ID: raeburn Tue May 1 14:28:42 2018 EDT Modified files: /loncom/lonnet/perl lonnet.pm Log: - Sanity checking Index: loncom/lonnet/perl/lonnet.pm diff -u loncom/lonnet/perl/lonnet.pm:1.1375 loncom/lonnet/perl/lonnet.pm:1.1376 --- loncom/lonnet/perl/lonnet.pm:1.1375 Sat Apr 14 02:30:01 2018 +++ loncom/lonnet/perl/lonnet.pm Tue May 1 14:28:41 2018 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.1375 2018/04/14 02:30:01 raeburn Exp $ +# $Id: lonnet.pm,v 1.1376 2018/05/01 14:28:41 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -762,16 +762,19 @@ $env{$key}=$newenv->{$key}; } } - my $opened = open(my $env_file,'+<',$env{'user.environment'}); - if ($opened - && &timed_flock($env_file,LOCK_EX) - && - tie(my %disk_env,'GDBM_File',$env{'user.environment'}, - (&GDBM_WRITER()|&GDBM_NOLOCK()),0640)) { - while (my ($key,$value) = each(%{$newenv})) { - $disk_env{$key} = $value; - } - untie(%disk_env); + my $lonids = $perlvar{'lonIDsDir'}; + if ($env{'user.environment'} =~ m{^\Q$lonids/\E$match_username\_\d+\_$match_domain\_[\w\-.]+\.id$}) { + my $opened = open(my $env_file,'+<',$env{'user.environment'}); + if ($opened + && &timed_flock($env_file,LOCK_EX) + && + tie(my %disk_env,'GDBM_File',$env{'user.environment'}, + (&GDBM_WRITER()|&GDBM_NOLOCK()),0640)) { + while (my ($key,$value) = each(%{$newenv})) { + $disk_env{$key} = $value; + } + untie(%disk_env); + } } } return 'ok'; From raeburn at source.lon-capa.org Wed May 2 12:59:44 2018 From: raeburn at source.lon-capa.org (raeburn) Date: Wed, 02 May 2018 16:59:44 -0000 Subject: [LON-CAPA-cvs] cvs: loncom /interface multidownload.pl Message-ID: raeburn Wed May 2 16:59:44 2018 EDT Modified files: /loncom/interface multidownload.pl Log: - Use three-argument open() to separate file mode from the filename. Index: loncom/interface/multidownload.pl diff -u loncom/interface/multidownload.pl:1.41 loncom/interface/multidownload.pl:1.42 --- loncom/interface/multidownload.pl:1.41 Sun Nov 5 18:19:41 2017 +++ loncom/interface/multidownload.pl Wed May 2 16:59:44 2018 @@ -2,7 +2,7 @@ # CGI-script to allow download of all essay submissions of # multiple students. # -# $Id: multidownload.pl,v 1.41 2017/11/05 18:19:41 raeburn Exp $ +# $Id: multidownload.pl,v 1.42 2018/05/02 16:59:44 raeburn Exp $ # Copyright Michigan State University Board of Trustees # # This file is part of the LearningOnline Network with CAPA (LON-CAPA). @@ -135,7 +135,7 @@ unless (-d "$doc_zip_root/zipdir/$unique_user/$unique_path") { &File::Path::mkpath($doc_zip_root."/zipdir/$unique_user/$unique_path",0,0700); } - if (open(MANIFEST, ">$doc_zip_root/zipdir/$unique_user/$unique_path/manifest.txt")) { + if (open(MANIFEST,'>',"$doc_zip_root/zipdir/$unique_user/$unique_path/manifest.txt")) { $manifest = 1; print MANIFEST (&mt("Zip file generated on [_1]",&Apache::lonlocal::locallocaltime(time()))."\n"); print MANIFEST (&mt("Course: [_1]",$env{"course.$courseid.description"})."\n"); From raeburn at source.lon-capa.org Wed May 2 13:06:46 2018 From: raeburn at source.lon-capa.org (raeburn) Date: Wed, 02 May 2018 17:06:46 -0000 Subject: [LON-CAPA-cvs] cvs: loncom /imspackages imsimportdocs.pm Message-ID: raeburn Wed May 2 17:06:46 2018 EDT Modified files: /loncom/imspackages imsimportdocs.pm Log: - Bug 6754 LON-CAPA as LTI Provider - LTI launch of LON-CAPA may be for display within an iframe. Index: loncom/imspackages/imsimportdocs.pm diff -u loncom/imspackages/imsimportdocs.pm:1.36 loncom/imspackages/imsimportdocs.pm:1.37 --- loncom/imspackages/imsimportdocs.pm:1.36 Sun Nov 5 20:04:30 2017 +++ loncom/imspackages/imsimportdocs.pm Wed May 2 17:06:45 2018 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: imsimportdocs.pm,v 1.36 2017/11/05 20:04:30 raeburn Exp $ +# $Id: imsimportdocs.pm,v 1.37 2018/05/02 17:06:45 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -559,8 +559,12 @@ ''; + my $windowname = 'loncapaclient'; + if ($env{'request.lti.login'}) { + $windowname .= 'lti'; + } $r->print( - '

' + '' .'' .'' .'' From raeburn at source.lon-capa.org Wed May 2 13:08:42 2018 From: raeburn at source.lon-capa.org (raeburn) Date: Wed, 02 May 2018 17:08:42 -0000 Subject: [LON-CAPA-cvs] cvs: loncom /imspackages imsprocessor.pm Message-ID: raeburn Wed May 2 17:08:42 2018 EDT Modified files: /loncom/imspackages imsprocessor.pm Log: - Use three-argument open() to separate file mode from the filename. Index: loncom/imspackages/imsprocessor.pm diff -u loncom/imspackages/imsprocessor.pm:1.56 loncom/imspackages/imsprocessor.pm:1.57 --- loncom/imspackages/imsprocessor.pm:1.56 Sun Nov 5 22:47:13 2017 +++ loncom/imspackages/imsprocessor.pm Wed May 2 17:08:40 2018 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Processor for IMS Packages # -# $Id: imsprocessor.pm,v 1.56 2017/11/05 22:47:13 raeburn Exp $ +# $Id: imsprocessor.pm,v 1.57 2018/05/02 17:08:40 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -140,7 +140,7 @@ unless ($fname) { return 'error: no uploaded file'; } # Save the file chomp($env{'form.uploadname'}); - open(my $fh,'>'.$tempdir.'/'.$fname); + open(my $fh,'>',"$tempdir/$fname"); print $fh $env{'form.uploadname'}; close($fh); } elsif ($context eq 'CSTR') { From raeburn at source.lon-capa.org Wed May 2 15:34:58 2018 From: raeburn at source.lon-capa.org (raeburn) Date: Wed, 02 May 2018 19:34:58 -0000 Subject: [LON-CAPA-cvs] cvs: loncom /imspackages imsprocessor.pm Message-ID: raeburn Wed May 2 19:34:58 2018 EDT Modified files: /loncom/imspackages imsprocessor.pm Log: - Use three-argument open() to separate file mode from the filename. Index: loncom/imspackages/imsprocessor.pm diff -u loncom/imspackages/imsprocessor.pm:1.57 loncom/imspackages/imsprocessor.pm:1.58 --- loncom/imspackages/imsprocessor.pm:1.57 Wed May 2 17:08:40 2018 +++ loncom/imspackages/imsprocessor.pm Wed May 2 19:34:58 2018 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Processor for IMS Packages # -# $Id: imsprocessor.pm,v 1.57 2018/05/02 17:08:40 raeburn Exp $ +# $Id: imsprocessor.pm,v 1.58 2018/05/02 19:34:58 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -994,10 +994,10 @@ $seqtext{$key} .= "\n"; if ($cms eq 'webctce4' && $key ne 'Top') { push @{$seqfiles}, "$seqtitle.sequence"; - open(LOCFILE,">$destdir/sequences/$seqtitle.sequence"); + open(LOCFILE,'>',"$destdir/sequences/$seqtitle.sequence"); } else { push @{$seqfiles}, "$key.sequence"; - open(LOCFILE,">$destdir/sequences/$key.sequence"); + open(LOCFILE,'>',"$destdir/sequences/$key.sequence"); } print LOCFILE $seqtext{$key}; close(LOCFILE); @@ -1027,7 +1027,7 @@ &process_specials($context,'pools',$pools,\$topnum,$$items{'Top'}{contentscount},$destdir,$udom,$uname,$cdom,$crs,$timenow,$newdir,$timestamp,$resinfo,\$seqtext{'Top'},$pagesfiles,$seqfiles,$topurls,$topnames); } $seqtext{'Top'} .= "\n"; - open(TOPFILE,">$destdir/sequences/Top.sequence"); + open(TOPFILE,'>',"$destdir/sequences/Top.sequence"); print TOPFILE $seqtext{'Top'}; close(TOPFILE); push @{$seqfiles}, 'Top.sequence'; @@ -1049,7 +1049,7 @@ if (grep/^$res$/,@{$packages}) { $resource = $filestem.'/resfiles/'.$res.'./index.html'; # should be entry_point } - open(PAGEFILE,">$filename"); + open(PAGEFILE,'>',$filename); print PAGEFILE qq| \n|; @@ -1238,10 +1238,10 @@ if ($type eq "announcements") { push @{$pagesfiles}, "$seqnames{$type}.page"; - open(ITEM,">$destdir/pages/$seqnames{$type}.page"); + open(ITEM,'>',"$destdir/pages/$seqnames{$type}.page"); } else { push @{$seqfiles}, "$seqnames{$type}.sequence"; - open(ITEM,">$destdir/sequences/$seqnames{$type}.sequence"); + open(ITEM,'>',"$destdir/sequences/$seqnames{$type}.sequence"); } if ($type eq 'boards') { @@ -1584,7 +1584,7 @@ |; - open(FILE,">$destdir/resfiles/$res.html"); + open(FILE,'>',"$destdir/resfiles/$res.html"); push @{$resrcfiles}, "$res.html"; print FILE qq| @@ -1663,7 +1663,7 @@ $linktag .= qq|>$$settings{title}|; } - open(FILE,">$destdir/resfiles/$res.html"); + open(FILE,'>',"$destdir/resfiles/$res.html"); push @{$resrcfiles}, "$res.html"; print FILE qq| @@ -3399,7 +3399,7 @@ my $curr_id = 0; my $next_id = 1; my $fh; - open($fh,">$destdir/sequences/question_database.sequence"); + open($fh,'>',"$destdir/sequences/question_database.sequence"); push @{$sequencesfiles},'question_database.sequence'; foreach my $category (sort(keys(%{$catinfo}))) { my $seqname; @@ -3465,7 +3465,7 @@ if (!-e "$seqdir") { mkdir("$seqdir",0770); } - open($fh,">$$containerdir"); + open($fh,'>',$$containerdir); $$total{seq} ++; push @{$sequencesfiles},$mapname.'.sequence'; } else { @@ -3473,7 +3473,7 @@ if (!-e "$pagedir") { mkdir("$pagedir",0770); } - open($fh,">$$containerdir"); + open($fh,'>',$$containerdir); $$total{page} ++; push @{$pagesfiles},$mapname.'.page'; } @@ -3931,7 +3931,7 @@ $title =~ s/\s/_/g; $title =~ s/\W//g; $title .= '_'.$id; - open(PROB,">$newdir/$title.problem"); + open(PROB,'>',"$newdir/$title.problem"); print PROB $output; close PROB; } else { @@ -4549,7 +4549,7 @@ $title =~ s/\s/_/g; $title =~ s/:/_/g; $title =~ s/\//_/g; - open(PROB,">$destdir/problems/$probdir/$title.problem"); + open(PROB,'>',"$destdir/problems/$probdir/$title.problem"); print PROB $output; close PROB; } else { @@ -4948,7 +4948,7 @@ $title =~ s/\s/_/g; $title =~ s/\W//g; $title .= '_'.$id; - open(PROB,">$newdir/$title.problem"); + open(PROB,'>',"$newdir/$title.problem"); print PROB $output; close PROB; } else { @@ -4974,7 +4974,7 @@ if (!-e "$docroot/$res/webimages") { mkdir("$docroot/$res/webimages",0755); } - open(my $fh,">$docroot/$res/webimages/$filename"); + open(my $fh,'>',"$docroot/$res/webimages/$filename"); print $fh $contents; close($fh); if ($context eq 'DOCS') { @@ -5067,7 +5067,7 @@ } } - open(FILE,">$destdir/resfiles/$res.html"); + open(FILE,'>',"$destdir/resfiles/$res.html"); push @{$resrcfiles}, "$res.html"; print FILE qq| @@ -5273,7 +5273,7 @@ } } - if (!open(FILE,">$destdir/resfiles/$res.html")) { + if (!open(FILE,'>',"$destdir/resfiles/$res.html")) { &Apache::lonnet::logthis("IMS import error: Cannot open file - $destdir/resfiles/$res.html - $!"); } else { push @{$resrcfiles}, "$res.html"; @@ -5466,7 +5466,7 @@ $p->parse_file($xmlfile); $p->eof; if ($type eq "PAGE") { - open(FILE,"<$xmlfile"); + open(FILE,'<',$xmlfile); @buffer = ; close(FILE); chomp(@buffer); @@ -5483,7 +5483,7 @@ } } } - open(FILE,">$destdir/resfiles/$res.html"); + open(FILE,'>',"$destdir/resfiles/$res.html"); push @{$resrcfiles}, "$res.html"; print FILE qq| @@ -5519,7 +5519,7 @@ sub webct4_content { my ($res,$docroot,$destdir,$settings,$dom,$user,$type,$title,$resrcfiles) = @_; if (defined($$settings{url})) { - if (!open(FILE,">$destdir/resfiles/$res.html")) { + if (!open(FILE,'>',"$destdir/resfiles/$res.html")) { &Apache::lonnet::logthis("IMS import error: Cannot open file - $destdir/resfiles/$res.html - $!"); } else { push(@{$resrcfiles}, "$res.html"); From raeburn at source.lon-capa.org Fri May 4 11:15:05 2018 From: raeburn at source.lon-capa.org (raeburn) Date: Fri, 04 May 2018 15:15:05 -0000 Subject: [LON-CAPA-cvs] cvs: loncom /homework grades.pm Message-ID: 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 @@ ''."\n"; $result.='

- '.&mt('Select Students for Which to Download Submissions').' + '.&mt('Select Students for whom to Download Submissions').'

'.&selectfield(1,$is_tool).' @@ -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'}]);