--- rat/lonuserstate.pm 2017/09/03 18:52:23 1.153 +++ rat/lonuserstate.pm 2018/11/13 03:59:17 1.157 @@ -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.153 2017/09/03 18:52:23 raeburn Exp $ +# $Id: lonuserstate.pm,v 1.157 2018/11/13 03:59:17 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 @@ -917,6 +918,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( @@ -1209,7 +1218,7 @@ sub readmap { } @cond=('true:normal'); - unless (open(LOCKFILE,">$fn.db.lock")) { + unless (open(LOCKFILE,">","$fn.db.lock")) { # # Most likely a permissions problem on the lockfile or its directory. # @@ -1227,8 +1236,14 @@ sub readmap { &unlink_tmpfiles($fn); } undef %randompick; + undef %randompickseed; + undef %randomorder; + undef %randomizationcode; undef %hiddenurl; undef %encurl; + undef %deeplinkonly; + undef %rescount; + undef %mapcount; $retfrid=''; $errtext=''; my ($untiedhash,$untiedparmhash,$tiedhash,$tiedparmhash); # More state flags. @@ -1370,8 +1385,14 @@ sub readmap { $lock=1; } undef %randompick; + undef %randompickseed; + undef %randomorder; + undef %randomizationcode; undef %hiddenurl; undef %encurl; + undef %deeplinkonly; + undef %rescount; + undef %mapcount; $errtext=''; $retfrid=''; # @@ -1508,6 +1529,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; @@ -1522,7 +1547,7 @@ sub build_tmp_hashes { # ---------------------------------------------------- Store away initial state { my $cfh; - if (open($cfh,">$fn.state")) { + if (open($cfh,">","$fn.state")) { print $cfh join("\n",@cond); $gotstate = 1; } else { @@ -1559,7 +1584,7 @@ sub evalstate { if (-e $fn) { my @conditions=(); { - open(my $fh,"<$fn"); + open(my $fh,"<",$fn); @conditions=<$fh>; close($fh); }