--- rat/lonuserstate.pm 2022/05/29 12:35:02 1.149.2.5.2.2 +++ rat/lonuserstate.pm 2021/07/19 15:48:25 1.164 @@ -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.5.2.2 2022/05/29 12:35:02 raeburn Exp $ +# $Id: lonuserstate.pm,v 1.164 2021/07/19 15:48:25 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,7 +42,7 @@ use Safe::Hole; use Opcode; use Apache::lonenc; use Fcntl qw(:flock); -use LONCAPA qw(:DEFAULT :match); +use LONCAPA qw(:DEFAULT :match); use File::Basename; @@ -256,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) { @@ -950,7 +950,8 @@ sub traceroute { @deeplink = &Apache::lonnet::EXT('resource.0.deeplink',$symb,'','','','',$cid,\@recurseup); } unless (@deeplink < 2) { - $hash{'deeplinkonly_'.$rid}=join(':',map { &escape($_); } @deeplink); + my ($listed,$scope,$access) = split(/,/,$deeplink[0]); + $hash{'deeplinkonly_'.$rid}=join(':',@deeplink); } if (defined($hash{'conditions_'.$rid})) { @@ -1495,7 +1496,7 @@ sub readmap { if ($redirect) { $retfurl = $url; } - } + } return ($retfurl,$errtext); } @@ -1613,73 +1614,51 @@ sub build_tmp_hashes { } my $deeplink; if ($hash{'deeplinkonly_'.$loginrid} ne '') { - my @deeplinkinfo = map { &unescape($_); } split(/:/,$hash{'deeplinkonly_'.$loginrid}); - unless (@deeplinkinfo < 2) { - $deeplink = $deeplinkinfo[0]; - } + $deeplink = $hash{'deeplinkonly_'.$loginrid}; } if ($deeplink) { - my $disallow; - my ($state,$others,$listed,$scope,$protect) = split(/,/,$deeplink); - if (($protect ne 'none') && ($protect ne '')) { - my ($acctype,$item) = split(/:/,$protect); - if ($acctype =~ /lti(c|d)$/) { - unless ($env{'request.linkprot'} eq $item.$1.':'.$env{'request.deeplink.login'}) { - $disallow = 1; - } - } elsif ($acctype eq 'key') { - unless ($env{'request.linkkey'} eq $item) { - $disallow = 1; - } - } - } - if ($disallow) { - &Apache::lonnet::delenv('request.deeplink.login'); - if ($env{'request.deeplink.target'} ne '') { - &Apache::lonnet::delenv('request.deeplink.target'); - } - } else { - if ($others eq 'hide') { - my @recfolders; - if ($scope eq 'rec') { - foreach my $key (keys(%hash)) { - if ($key=~/^map_hierarchy_(\d+)$/) { - my $mpc = $1; - my @ids = split(/,/,$hash{$key}); - if (grep(/^$deeplink_login_pc$/,@ids)) { - my $idx; - foreach my $mapid (@ids) { - if ($idx) { - push(@recfolders,$mapid); - } elsif ($mapid == $deeplink_login_pc) { - push(@recfolders,$mapid); - $idx = $mapid; - } + my ($listed,$scope,$access) = split(/,/,$deeplink); + my $exclude = 1; + if ($exclude) { + my @recfolders; + if ($scope eq 'rec') { + foreach my $key (keys(%hash)) { + if ($key=~/^map_hierarchy_(\d+)$/) { + my $mpc = $1; + my @ids = split(/,/,$hash{$key}); + if (grep(/^$deeplink_login_pc$/,@ids)) { + my $idx; + foreach my $mapid (@ids) { + if ($idx) { + push(@recfolders,$mapid); + } elsif ($mapid == $deeplink_login_pc) { + push(@recfolders,$mapid); + $idx = $mapid; } - push(@recfolders,$mpc); } + push(@recfolders,$mpc); } } } - foreach my $key (keys(%hash)) { - if ($key=~/^src_(.+)$/) { - my $rid = $1; - next if ($rid eq '0.0'); - next if ($rid eq $loginrid); - if ($scope ne 'res') { - my $mapid = (split(/\./,$rid))[0]; - next if ($mapid eq $deeplink_login_pc); - if ($scope eq 'rec') { - next if (grep(/^$mapid$/,@recfolders)); - } + } + foreach my $key (keys(%hash)) { + if ($key=~/^src_(.+)$/) { + my $rid = $1; + next if ($rid eq '0.0'); + next if ($rid eq $loginrid); + if ($scope ne 'res') { + my $mapid = (split(/\./,$rid))[0]; + next if ($mapid eq $deeplink_login_pc); + if ($scope eq 'rec') { + next if (grep(/^$mapid$/,@recfolders)); } - $deeplinkout{$rid} = 1; } + $deeplinkout{$rid} = 1; } } } - &deeplinkouts(); } + &deeplinkouts(); } } &mapcrumbs(); @@ -1812,6 +1791,10 @@ sub get_mapparam { last; } } + my $recursechk=$usercourseprefix.'.'.$item.'___(rec).'.$what; + if (defined($$useropt{$recursechk})) { + return $$useropt{$recursechk}; + } } } @@ -1833,6 +1816,10 @@ sub get_mapparam { last; } } + my $recursechk=$usercourseprefix.'.['.$cgroup.'].'.$item.'___(rec).'.$what; + if (defined($$courseopt{$recursechk})) { + return $$courseopt{$recursechk}; + } } } @@ -1854,6 +1841,10 @@ sub get_mapparam { last; } } + my $recursechk=$usercourseprefix.'.['.$csec.'].'.$item.'___(rec).'.$what; + if (defined($$courseopt{$recursechk})) { + return $$courseopt{$recursechk}; + } } } @@ -1897,6 +1888,10 @@ sub get_mapparam { last; } } + my $recursechk=$usercourseprefix.'.'.$item.'___(rec).'.$what; + if (defined($$courseopt{$recursechk})) { + return $$courseopt{$recursechk}; + } } } }