--- loncom/homework/grades.pm 2020/08/30 20:30:21 1.773 +++ loncom/homework/grades.pm 2020/11/08 22:23:52 1.777 @@ -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.777 2020/11/08 22:23:52 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; } @@ -2576,8 +2587,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 +2652,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 +2663,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 +2674,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 +2686,7 @@ sub submission { } $lastsubonly.=$subval."\n"; } - if ($similar) {$lastsubonly.="

$similar\n";} + if ($similar) {$lastsubonly.="

$similar\n";} $lastsubonly.=''; } } @@ -3242,7 +3252,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'}; @@ -9462,7 +9472,7 @@ END if ($count > 1) { $formatextra = ''; $onclick = ' onclick="toggleScantab(this.form);"'; $formatjs = <<"END"; @@ -11295,7 +11305,7 @@ sub navmap_errormsg { } sub startpage { - my ($r,$symb,$crumbs,$onlyfolderflag,$nodisplayflag,$stuvcurrent,$stuvdisp,$nomenu,$js,$onload,$divforres) = @_; + my ($r,$symb,$crumbs,$onlyfolderflag,$nodisplayflag,$stuvcurrent,$stuvdisp,$nomenu,$head_extra,$onload,$divforres) = @_; my %args; if ($onload) { my %loaditems = ( @@ -11305,11 +11315,11 @@ sub startpage { } if ($nomenu) { $args{'only_body'} = 1; - $r->print(&Apache::loncommon::start_page("Student's Version",$js,\%args)); + $r->print(&Apache::loncommon::start_page("Student's Version",$head_extra,\%args)); } else { unshift(@$crumbs,{href=>&href_symb_cmd($symb,'gradingmenu'),text=>"Grading"}); $args{'bread_crumbs'} = $crumbs; - $r->print(&Apache::loncommon::start_page('Grading',$js,\%args)); + $r->print(&Apache::loncommon::start_page('Grading',$head_extra,\%args)); if ($env{'request.course.id'}) { &Apache::lonquickgrades::startGradeScreen($r,($env{'form.symb'}?'probgrading':'grading')); } @@ -11327,6 +11337,61 @@ sub select_problem { $r->print(''); } +sub css_links { + my ($currsymb,$level) = @_; + my ($links,@symbs,%cssrefs,%httpref); + if ($level eq 'map') { + my $navmap = Apache::lonnavmaps::navmap->new(); + if (ref($navmap)) { + my ($map,undef,$url)=&Apache::lonnet::decode_symb($currsymb); + my @resources = $navmap->retrieveResources($map,sub { $_[0]->is_problem() },0,0); + foreach my $res (@resources) { + if (ref($res)) { + if ($res->symb()) { + push(@symbs,$res->symb()); + } + } + } + } + } else { + @symbs = ($currsymb); + } + foreach my $symb (@symbs) { + my $css_href = &Apache::lonnet::EXT('resource.0.cssfile',$symb); + if ($css_href =~ /\S/) { + unless ($css_href =~ m{https?://}) { + my ($map,undef,$url)=&Apache::lonnet::decode_symb($symb); + my $proburl = &Apache::lonnet::clutter($url); + my ($probdir) = ($proburl =~ m{(.+)/[^/]+$}); + unless ($css_href =~ m{^/}) { + $css_href = &Apache::lonnet::hreflocation($probdir,$css_href); + } + if ($css_href =~ m{^/(res|uploaded)/}) { + unless (($httpref{'httpref.'.$css_href}) | + (&Apache::lonnet::is_on_map($css_href))) { + my $thisurl = $proburl; + if ($env{'httpref.'.$proburl}) { + $thisurl = $env{'httpref.'.$proburl}; + } + $httpref{'httpref.'.$css_href} = $thisurl; + } + } + } + $cssrefs{$css_href} = 1; + } + } + if (keys(%httpref)) { + &Apache::lonnet::appenv(\%httpref); + } + if (keys(%cssrefs)) { + foreach my $css_href (keys(%cssrefs)) { + next unless ($css_href =~ m{^(/res/|/uploaded/|https?://)}); + $links .= ''."\n"; + } + } + return $links; +} + sub handler { my $request=$_[0]; &reset_caches(); @@ -11392,8 +11457,14 @@ sub handler { } else { $divforres = 1; } - &startpage($request,$symb,[{href=>"", text=>"Student Submissions"}],undef,undef,$stuvcurrent,$stuvdisp,undef,$js,$onload,$divforres); + my $csslinks = &css_links($symb); + my $head_extra = $js."\n".$csslinks; + &startpage($request,$symb,[{href=>"", text=>"Student Submissions"}],undef,undef, + $stuvcurrent,$stuvdisp,undef,$head_extra,$onload,$divforres); if ($versionform) { + if ($divforres) { + $request->print('
'); + } $request->print($versionform); } ($env{'form.student'} eq '' ? &listStudents($request,$symb,'',$divforres) : &submission($request,0,0,$symb,$divforres,$command)); @@ -11402,7 +11473,10 @@ sub handler { &choose_task_version_form($symb,$env{'form.student'}, $env{'form.userdom'}, $env{'form.inhibitmenu'}); - &startpage($request,$symb,[{href=>"", text=>"Previous Student Version"}],undef,undef,$stuvcurrent,$stuvdisp,$env{'form.inhibitmenu'},$js); + my $csslinks = &css_links($symb); + my $head_extra = $js."\n".$csslinks; + &startpage($request,$symb,[{href=>"", text=>"Previous Student Version"}],undef,undef, + $stuvcurrent,$stuvdisp,$env{'form.inhibitmenu'},$head_extra); if ($versionform) { $request->print($versionform); } @@ -11413,10 +11487,11 @@ sub handler { {href=>'',text=>'Select student'}],1,1); &pickStudentPage($request,$symb); } elsif ($command eq 'displayPage' && $perm{'vgr'}) { + my $csslinks = &css_links($symb,'map'); &startpage($request,$symb, [{href=>&href_symb_cmd($symb,'all_for_one'),text=>'Grade page/folder for one student'}, {href=>'',text=>'Select student'}, - {href=>'',text=>'Grade student'}],1,1); + {href=>'',text=>'Grade student'}],1,1,undef,undef,undef,$csslinks); &displayPage($request,$symb); } elsif ($command eq 'gradeByPage' && $perm{'mgr'}) { &startpage($request,$symb,[{href=>&href_symb_cmd($symb,'all_for_one'),text=>'Grade page/folder for one student'}, @@ -11425,8 +11500,9 @@ sub handler { {href=>'',text=>'Store grades'}],1,1); &updateGradeByPage($request,$symb); } elsif ($command eq 'processGroup' && $perm{'vgr'}) { + my $csslinks = &css_links($symb); &startpage($request,$symb,[{href=>'',text=>'...'}, - {href=>'',text=>'Modify grades'}],undef,undef,undef,undef,undef,undef,undef,1); + {href=>'',text=>'Modify grades'}],undef,undef,undef,undef,undef,$csslinks,undef,1); &processGroup($request,$symb); } elsif ($command eq 'gradingmenu' && $perm{'vgr'}) { &startpage($request,$symb); @@ -11546,6 +11622,7 @@ sub handler { [{href=>&href_symb_cmd($symb,'downloadfilesselect'), text=>'Select which submissions to download'}, {href=>'', text=>'Download submitted files'}], undef,undef,undef,undef,undef,undef,undef,1); + $request->print('
'); &submit_download_link($request,$symb); } elsif ($command) { &startpage($request,$symb,[{href=>'', text=>'Access denied'}]);