--- loncom/homework/grades.pm	2020/11/08 22:23:52	1.777
+++ loncom/homework/grades.pm	2020/11/10 17:17:54	1.779
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.777 2020/11/08 22:23:52 raeburn Exp $
+# $Id: grades.pm,v 1.779 2020/11/10 17:17:54 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -11337,61 +11337,6 @@ sub select_problem {
     $r->print('<input type="submit" value="'.&mt('Next').' &rarr;" /></form>');
 }
 
-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 .= '<link rel="stylesheet" type="text/css" href="'.$css_href.'" />'."\n";
-        }
-    }
-    return $links;
-}
-
 sub handler {
     my $request=$_[0];
     &reset_caches();
@@ -11457,8 +11402,13 @@ sub handler {
             } else {
                 $divforres = 1;
             }
-            my $csslinks = &css_links($symb);
-            my $head_extra = $js."\n".$csslinks;
+            my $head_extra = $js;
+            unless ($env{'form.vProb'} eq 'no') {
+                my $csslinks = &Apache::loncommon::css_links($symb);
+                if ($csslinks) {
+                    $head_extra .= "\n$csslinks";
+                }
+            }
             &startpage($request,$symb,[{href=>"", text=>"Student Submissions"}],undef,undef,
                        $stuvcurrent,$stuvdisp,undef,$head_extra,$onload,$divforres);
             if ($versionform) {
@@ -11473,8 +11423,13 @@ sub handler {
                 &choose_task_version_form($symb,$env{'form.student'},
                                           $env{'form.userdom'},
                                           $env{'form.inhibitmenu'});
-            my $csslinks = &css_links($symb);
-            my $head_extra = $js."\n".$csslinks;
+            my $head_extra = $js;
+            unless ($env{'form.vProb'} eq 'no') {
+                my $csslinks = &Apache::loncommon::css_links($symb);
+                if ($csslinks) {
+                    $head_extra .= "\n$csslinks";
+                }
+            }
             &startpage($request,$symb,[{href=>"", text=>"Previous Student Version"}],undef,undef,
                        $stuvcurrent,$stuvdisp,$env{'form.inhibitmenu'},$head_extra);
             if ($versionform) {
@@ -11487,7 +11442,10 @@ sub handler {
                                        {href=>'',text=>'Select student'}],1,1);
 	    &pickStudentPage($request,$symb);
 	} elsif ($command eq 'displayPage' && $perm{'vgr'}) {
-            my $csslinks = &css_links($symb,'map');
+            my $csslinks;
+            unless ($env{'form.vProb'} eq 'no') {
+                $csslinks = &Apache::loncommon::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'},
@@ -11500,7 +11458,10 @@ sub handler {
                                        {href=>'',text=>'Store grades'}],1,1);
 	    &updateGradeByPage($request,$symb);
 	} elsif ($command eq 'processGroup' && $perm{'vgr'}) {
-            my $csslinks = &css_links($symb);
+            my $csslinks;
+            unless ($env{'form.vProb'} eq 'no') {
+                $csslinks = &Apache::loncommon::css_links($symb);
+            }
             &startpage($request,$symb,[{href=>'',text=>'...'},
                                        {href=>'',text=>'Modify grades'}],undef,undef,undef,undef,undef,$csslinks,undef,1);
 	    &processGroup($request,$symb);