--- rat/lonuserstate.pm 2020/07/19 15:24:11 1.149.2.2.2.3 +++ rat/lonuserstate.pm 2020/03/03 01:16:31 1.158 @@ -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.158 2020/03/03 01:16:31 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -62,6 +62,7 @@ my %randomorder; # maps to order content my %randomizationcode; # code used to grade folder for bubblesheet exam my %encurl; # URLs in this folder are supposed to be encrypted my %hiddenurl; # this URL (or complete folder) is supposed to be hidden +my %deeplinkonly; # this URL (or complete folder) is deep-link only my %rescount; # count of unhidden items in each map my %mapcount; # count of unhidden maps in each map @@ -255,9 +256,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 +293,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 +384,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 # @@ -569,9 +566,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'}; } @@ -927,6 +922,14 @@ sub traceroute { && ($hash{'src_'.$rid}!~/\.sequence$/)) { $retfrid=$rid; } + my @deeplink=&Apache::lonnet::EXT('resource.0.deeplink',$symb); + unless ((@deeplink == 0) || ($deeplink[0] eq 'full')) { + $deeplinkonly{$rid}=join(':',@deeplink); + if ($deeplink[1] eq 'map') { + my $parent = (split(/\,/,$hash{'map_hierarchy_'.$mapid}))[-1]; + $deeplinkonly{"$parent.$mapid"}=$deeplinkonly{$rid}; + } + } if (defined($hash{'conditions_'.$rid})) { $hash{'conditions_'.$rid}=simplify( @@ -1242,6 +1245,7 @@ sub readmap { undef %randomizationcode; undef %hiddenurl; undef %encurl; + undef %deeplinkonly; undef %rescount; undef %mapcount; $retfrid=''; @@ -1390,6 +1394,7 @@ sub readmap { undef %randomizationcode; undef %hiddenurl; undef %encurl; + undef %deeplinkonly; undef %rescount; undef %mapcount; $errtext=''; @@ -1528,6 +1533,10 @@ sub build_tmp_hashes { # $hash{'src_'.$id}=&Apache::lonenc::encrypted($hash{'src_'.$id}); $hash{'encrypted_'.$id}=1; } +# ------------------------------------------------------------ Deep-linked URLs + foreach my $id (keys(%deeplinkonly)) { + $hash{'deeplinkonly_'.$id}=$deeplinkonly{$id}; + } # ----------------------------------------------- Close hashes to finally store # --------------------------------- Routine must pass this point, no early outs $hash{'first_rid'}=$retfrid;