--- rat/lonuserstate.pm 2020/07/19 15:24:11 1.149.2.2.2.3 +++ rat/lonuserstate.pm 2018/03/29 21:12:57 1.156 @@ -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.149.2.2.2.3 2020/07/19 15:24:11 raeburn Exp $ +# $Id: lonuserstate.pm,v 1.156 2018/03/29 21:12:57 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -255,9 +255,9 @@ sub loadmap { push(@map_ids, $resource_id); if ($hash{'src_'.$lpc.'.'.$resource_id}) { $rescount{$lpc} ++; - if (($hash{'src_'.$lpc.'.'.$resource_id}=~/\.sequence$/) || + if (($hash{'src_'.$lpc.'.'.$resource_id}=~/\.sequence$/) || ($hash{'src_'.$lpc.'.'.$resource_id}=~/\.page$/)) { - $mapcount{$lpc} ++; + $mapcount{$lpc} ++; } } unless ($codechecked) { @@ -292,7 +292,15 @@ sub loadmap { # Handle randomization and random selection if ($randomize) { - unless (&is_advanced($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'} = ''; + } + unless ($advanced) { # Order of resources is not randomized if user has and advanced role in the course. my $seed; @@ -375,18 +383,6 @@ sub loadmap { } } -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 # @@ -473,11 +469,7 @@ sub parse_resource { # is not a page. If the resource is a page then it must be # assembled (at fetch time?). - if ($ispage) { - if ($token->[2]->{'external'} eq 'true') { # external - $turi=~s{^http\://}{/ext/}; - } - } else { + unless ($ispage) { $turi=~/\.(\w+)$/; my $embstyle=&Apache::loncommon::fileembstyle($1); if ($token->[2]->{'external'} eq 'true') { # external @@ -569,9 +561,7 @@ sub parse_resource { if (($turi=~/\.sequence$/) || ($turi=~/\.page$/)) { $hash{'is_map_'.$rid}=1; - if ((!$hiddenurl{$rid}) || (&is_advanced($courseid))) { - &loadmap($turi,$rid,$courseid); - } + &loadmap($turi,$rid,$courseid); } return $token->[2]->{'id'}; }