version 1.79, 2004/10/26 15:10:42
|
version 1.82, 2004/11/10 21:30:48
|
Line 332 sub simplify {
|
Line 332 sub simplify {
|
|
|
sub traceroute { |
sub traceroute { |
my ($sofar,$rid,$beenhere,$encflag,$hdnflag)=@_; |
my ($sofar,$rid,$beenhere,$encflag,$hdnflag)=@_; |
$sofar=simplify($sofar); |
my $newsofar=$sofar=simplify($sofar); |
unless ($beenhere=~/\&$rid\&/) { |
unless ($beenhere=~/\&$rid\&/) { |
$beenhere.=$rid.'&'; |
$beenhere.=$rid.'&'; |
my ($mapid,$resid)=split(/\./,$rid); |
my ($mapid,$resid)=split(/\./,$rid); |
my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$hash{'src_'.$rid}); |
my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$hash{'src_'.$rid}); |
my $encrypt=&Apache::lonnet::EXT('resource.0.hiddenresource',$symb); |
my $hidden=&Apache::lonnet::EXT('resource.0.hiddenresource',$symb); |
if ($hdnflag || lc($encrypt) eq 'yes') { $hiddenurl{$rid}=1; } |
if ($hdnflag || lc($hidden) eq 'yes') { $hiddenurl{$rid}=1; } |
my $encrypt=&Apache::lonnet::EXT('resource.0.encrypturl',$symb); |
my $encrypt=&Apache::lonnet::EXT('resource.0.encrypturl',$symb); |
if ($encflag || lc($encrypt) eq 'yes') { $encurl{$rid}=1; } |
if ($encflag || lc($encrypt) eq 'yes') { $encurl{$rid}=1; } |
if (($retfurl eq '') && ($hash{'src_'.$rid}) |
if (($retfurl eq '') && ($hash{'src_'.$rid}) |
Line 352 sub traceroute {
|
Line 352 sub traceroute {
|
} else { |
} else { |
$hash{'conditions_'.$rid}=$sofar; |
$hash{'conditions_'.$rid}=$sofar; |
} |
} |
|
$newsofar=$hash{'conditions_'.$rid}; |
if (defined($hash{'is_map_'.$rid})) { |
if (defined($hash{'is_map_'.$rid})) { |
if (defined($hash{'map_start_'.$hash{'src_'.$rid}})) { |
if (defined($hash{'map_start_'.$hash{'src_'.$rid}})) { |
&traceroute($sofar,$hash{'map_start_'.$hash{'src_'.$rid}},'&', |
$sofar=$newsofar= |
$encflag || $encurl{$rid}, |
&traceroute($sofar, |
$hdnflag || $hiddenurl{$rid}); |
$hash{'map_start_'.$hash{'src_'.$rid}},'&', |
if (defined($hash{'map_finish_'.$hash{'src_'.$rid}})) { |
$encflag || $encurl{$rid}, |
$sofar= |
$hdnflag || $hiddenurl{$rid}); |
$hash{'conditions_'.$hash{'map_finish_'.$hash{'src_'.$rid}}}; |
|
} |
|
} |
} |
} |
} |
if (defined($hash{'to_'.$rid})) { |
if (defined($hash{'to_'.$rid})) { |
Line 375 sub traceroute {
|
Line 374 sub traceroute {
|
.$hash{'undercond_'.$_}.'. '; |
.$hash{'undercond_'.$_}.'. '; |
} |
} |
} |
} |
&traceroute($further,$hash{'goesto_'.$_},$beenhere,$encflag,$hdnflag); |
$newsofar=&traceroute($further,$hash{'goesto_'.$_},$beenhere, |
|
$encflag,$hdnflag); |
} |
} |
} |
} |
} |
} |
|
return $newsofar; |
} |
} |
|
|
# ------------------------------ Cascading conditions, quick access, parameters |
# ------------------------------ Cascading conditions, quick access, parameters |
Line 579 sub readmap {
|
Line 580 sub readmap {
|
} |
} |
# ---------------------------------------------------------------- Encrypt URLs |
# ---------------------------------------------------------------- Encrypt URLs |
foreach (keys %encurl) { |
foreach (keys %encurl) { |
$hash{'src_'.$_}=&Apache::lonenc::encrypted($hash{'src_'.$_}); |
# $hash{'src_'.$_}=&Apache::lonenc::encrypted($hash{'src_'.$_}); |
|
$hash{'encrypted_'.$_}=1; |
} |
} |
# ----------------------------------------------- Close hashes to finally store |
# ----------------------------------------------- Close hashes to finally store |
# --------------------------------- Routine must pass this point, no early outs |
# --------------------------------- Routine must pass this point, no early outs |
Line 617 sub readmap {
|
Line 619 sub readmap {
|
# ------------------------------------------------------- Evaluate state string |
# ------------------------------------------------------- Evaluate state string |
|
|
sub evalstate { |
sub evalstate { |
|
|
my $fn=$ENV{'request.course.fn'}.'.state'; |
my $fn=$ENV{'request.course.fn'}.'.state'; |
my $state='2'; |
my $state=''; |
if (-e $fn) { |
if (-e $fn) { |
my @conditions=(); |
my @conditions=(); |
{ |
{ |
my $fh=Apache::File->new($fn); |
my $fh=Apache::File->new($fn); |
@conditions=<$fh>; |
@conditions=<$fh>; |
} |
} |
my $safeeval = new Safe; |
my $safeeval = new Safe; |
my $safehole = new Safe::Hole; |
my $safehole = new Safe::Hole; |
$safeeval->permit("entereval"); |
$safeeval->permit("entereval"); |
$safeeval->permit(":base_math"); |
$safeeval->permit(":base_math"); |
$safeeval->deny(":base_io"); |
$safeeval->deny(":base_io"); |
$safehole->wrap(\&Apache::lonnet::EXT,$safeeval,'&EXT'); |
$safehole->wrap(\&Apache::lonnet::EXT,$safeeval,'&EXT'); |
foreach (@conditions) { |
foreach my $line (@conditions) { |
my $line=$_; |
chomp($line); |
chomp($line); |
my ($condition,$weight)=split(/\:/,$line); |
my ($condition,$weight)=split(/\:/,$_); |
if ($safeeval->reval($condition)) { |
if ($safeeval->reval($condition)) { |
if ($weight eq 'force') { |
if ($weight eq 'force') { |
$state.='3'; |
$state.='3'; |
} else { |
} else { |
$state.='2'; |
$state.='2'; |
} |
} |
} else { |
} else { |
if ($weight eq 'stop') { |
if ($weight eq 'stop') { |
$state.='0'; |
$state.='0'; |
} else { |
} else { |
$state.='1'; |
$state.='1'; |
} |
} |
} |
} |
} |
} |
|
} |
} |
&Apache::lonnet::appenv('user.state.'.$ENV{'request.course.id'} => $state); |
&Apache::lonnet::appenv('user.state.'.$ENV{'request.course.id'} => $state); |
return $state; |
return $state; |