--- rat/lonuserstate.pm 2006/05/30 19:11:37 1.115 +++ rat/lonuserstate.pm 2006/05/30 19:47:40 1.116 @@ -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.115 2006/05/30 19:11:37 raeburn Exp $ +# $Id: lonuserstate.pm,v 1.116 2006/05/30 19:47:40 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,7 +42,6 @@ use Safe::Hole; use Opcode; use Apache::lonenc; use Fcntl qw(:flock); -use lib '/home/httpd/lib/perl/'; use LONCAPA; @@ -53,7 +52,8 @@ my %hash; # The big tied hash my %parmhash;# The hash with the parameters my @cond; # Array with all of the conditions my $errtext; # variable with all errors -my $retfurl; # variable with the very first URL in the course +my $retfrid; # variable with the very first RID in the course +my $retfurl; # first URL my %randompick; # randomly picked resources my %randompickseed; # optional seed for randomly picking resources my %encurl; # URLs in this folder are supposed to be encrypted @@ -363,10 +363,9 @@ sub traceroute { my $encrypt=&Apache::lonnet::EXT('resource.0.encrypturl',$symb); if ($encflag || lc($encrypt) eq 'yes') { $encurl{$rid}=1; } - if (($retfurl eq '') && ($hash{'src_'.$rid}) + if (($retfrid eq '') && ($hash{'src_'.$rid}) && ($hash{'src_'.$rid}!~/\.sequence$/)) { - $retfurl=$hash{'src_'.$rid}.(($hash{'src_'.$rid}=~/\?/)?'&':'?'). - 'symb='.$symb; + $retfrid=$rid; } if (defined($hash{'conditions_'.$rid})) { $hash{'conditions_'.$rid}=simplify( @@ -573,7 +572,7 @@ sub readmap { undef %randompick; undef %hiddenurl; undef %encurl; - $retfurl=''; + $retfrid=''; if ($lock && (tie(%hash,'GDBM_File',"$fn.db",&GDBM_WRCREAT(),0640)) && (tie(%parmhash,'GDBM_File',$fn.'_parms.db',&GDBM_WRCREAT(),0640))) { %hash=(); @@ -591,6 +590,7 @@ sub readmap { &Apache::lonnet::appenv("request.course.id" => $short, "request.course.fn" => $fn, "request.course.uri" => $uri); + $env{'request.course.id'}=$short; &traceroute('0',$hash{'map_start_'.$uri},'&'); &accinit($uri,$short,$fn); &hiddenurls(); @@ -612,6 +612,14 @@ sub readmap { } # ----------------------------------------------- Close hashes to finally store # --------------------------------- Routine must pass this point, no early outs + $hash{'first_rid'}=$retfrid; + my ($mapid,$resid)=split(/\./,$retfrid); + $hash{'first_mapurl'}=$hash{'map_id_'.$mapid}; + my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$hash{'src_'.$retfrid}); + $retfurl=&add_get_param($hash{'src_'.$retfrid},{ 'symb' => $symb }); + if ($hash{'encrypted_'.$retfrid}) { + $retfurl=&Apache::lonenc::encrypted($retfurl,(&Apache::lonnet::allowed('adv') ne 'F')); + } $hash{'first_url'}=$retfurl; unless ((untie(%hash)) && (untie(%parmhash))) { &Apache::lonnet::logthis("WARNING: ".