[LON-CAPA-cvs] cvs: loncom /interface lonnavmaps.pm rat lonuserstate.pm

raeburn raeburn at source.lon-capa.org
Wed Apr 22 10:53:03 EDT 2020


raeburn		Wed Apr 22 14:53:03 2020 EDT

  Modified files:              
    /rat	lonuserstate.pm 
    /loncom/interface	lonnavmaps.pm 
  Log:
  - Speed-up course loading and Course Contents display for users without adv
    priv if course contains several hidden folders and/or sub-folders.
  
  
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.158 rat/lonuserstate.pm:1.159
--- rat/lonuserstate.pm:1.158	Tue Mar  3 01:16:31 2020
+++ rat/lonuserstate.pm	Wed Apr 22 14:52:56 2020
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construct and maintain state and binary representation of course for user
 #
-# $Id: lonuserstate.pm,v 1.158 2020/03/03 01:16:31 raeburn Exp $
+# $Id: lonuserstate.pm,v 1.159 2020/04/22 14:52:56 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -293,15 +293,7 @@
     # Handle randomization and random selection
 
     if ($randomize) {
-        my $advanced;
-        if ($env{'request.course.id'}) {
-            $advanced = (&Apache::lonnet::allowed('adv') eq 'F');
-        } else {
-            $env{'request.course.id'} = $courseid;
-            $advanced = (&Apache::lonnet::allowed('adv') eq 'F');
-            $env{'request.course.id'} = '';
-        }
-        unless ($advanced) {
+        unless (&is_advanced($courseid)) {
             # Order of resources is not randomized if user has and advanced role in the course.
 	    my $seed;
 
@@ -384,6 +376,18 @@
     }
 }
 
+sub is_advanced {
+    my ($courseid) = @_;
+    my $advanced;
+    if ($env{'request.course.id'}) {
+        $advanced = (&Apache::lonnet::allowed('adv') eq 'F');
+    } else {
+        $env{'request.course.id'} = $courseid;
+        $advanced = (&Apache::lonnet::allowed('adv') eq 'F');
+        $env{'request.course.id'} = '';
+    }
+    return $advanced;
+}
 
 # -------------------------------------------------------------------- Resource
 #
@@ -566,7 +570,9 @@
     if (($turi=~/\.sequence$/) ||
 	($turi=~/\.page$/)) {
 	$hash{'is_map_'.$rid}=1;
-	&loadmap($turi,$rid,$courseid);
+	if ((&is_advanced($courseid)) || (!$hiddenurl{$rid})) {
+	    &loadmap($turi,$rid,$courseid);
+	}
     } 
     return $token->[2]->{'id'};
 }
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.549 loncom/interface/lonnavmaps.pm:1.550
--- loncom/interface/lonnavmaps.pm:1.549	Thu Mar  5 16:45:36 2020
+++ loncom/interface/lonnavmaps.pm	Wed Apr 22 14:53:03 2020
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.549 2020/03/05 16:45:36 raeburn Exp $
+# $Id: lonnavmaps.pm,v 1.550 2020/04/22 14:53:03 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4021,7 +4021,8 @@
     # That ends the main iterator logic. Now, do we want to recurse
     # down this map (if this resource is a map)?
     if ( ($self->{HERE}->is_sequence() || (!$closeAllPages && $self->{HERE}->is_page())) &&
-        (defined($self->{FILTER}->{$self->{HERE}->map_pc()}) xor $self->{CONDITION})) {
+        (defined($self->{FILTER}->{$self->{HERE}->map_pc()}) xor $self->{CONDITION}) &&
+        ($env{'request.role.adv'} || !$self->{HERE}->randomout())) {
         $self->{RECURSIVE_ITERATOR_FLAG} = 1;
         my $firstResource = $self->{HERE}->map_start();
         my $finishResource = $self->{HERE}->map_finish();




More information about the LON-CAPA-cvs mailing list