--- loncom/lonmap.pm 2011/11/29 11:50:53 1.6 +++ loncom/lonmap.pm 2013/01/03 20:32:40 1.9 @@ -2,7 +2,7 @@ # # Read maps into a 'big hash'. # -# $Id: lonmap.pm,v 1.6 2011/11/29 11:50:53 foxr Exp $ +# $Id: lonmap.pm,v 1.9 2013/01/03 20:32:40 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -295,7 +295,6 @@ sub process_versions { # sub versionerror { my ($uri, $used, $unused) = @_; - my ($uri,$usedversion,$unusedversion)=@_; return '
'. &mt('Version discrepancy: resource [_1] included in both version [_2] and version [_3]. Using version [_2].', $uri,$used,$unused).'
'; @@ -801,6 +800,7 @@ sub parse_param { # $lpc - Map nesting level (?) # $ispage - True if this resource is encapsulated in a .page (assembled resourcde). # $uri - URI of the enclosing resource. +# $code - CODE for which resource is being parsed (CODEd assignments). # $hash - Reference to the hash we are building. # # Returns: @@ -823,7 +823,7 @@ sub parse_param { # sub parse_resource { - my ($token,$lpc,$ispage,$uri, $hash) = @_; + my ($token,$lpc,$ispage,$uri,$code,$hash) = @_; # I refuse to countenance code like this that has # such a dirty side effect (and forcing this sub to be called within a loop). @@ -970,7 +970,7 @@ sub parse_resource { if (($turi=~/\.sequence$/) || ($turi=~/\.page$/)) { $hash->{'is_map_'.$rid}='1'; # String in lonuserstate. - &read_map($turi,$rid, $hash); + &read_map($turi,$rid,$code,$hash); } return $token->[2]->{'id'}; } @@ -1178,7 +1178,8 @@ sub parse_mapalias_param { # $parent_rid - map number qualified id of the parent of the map being read. # For the top level course map this is 0.0. For the first nested # map 1.n where n is the id of the resource within the -# top level map and so on. +# top level map and so on. +# $code - CODE for which map is being read (CODEd assignments). # $hash - Reference to a hash that will become the big hash for the course # This hash is modified as per the map description. # Side-effects: @@ -1188,7 +1189,7 @@ sub parse_mapalias_param { # # sub read_map { - my ($uri, $parent_rid, $hash) = @_; + my ($uri, $parent_rid, $code, $hash) = @_; # Check for duplication: A map may only be included once. @@ -1289,7 +1290,7 @@ sub read_map { # Resource if ($token->[1] eq 'resource') { - my $resource_id = &parse_resource($token,$lmap_no,$ispage,$uri, $hash); + my $resource_id = &parse_resource($token,$lmap_no,$ispage,$uri,$code,$hash); if (defined $resource_id) { push(@map_ids, $resource_id); } @@ -1313,7 +1314,7 @@ sub read_map { # if ($randomize) { - if (!&has_advanced_role($username, $userdomain) ) { + if (!&has_advanced_role($username, $userdomain) || $code) { my $seed; # In the advanced role, the map's random seed @@ -1397,6 +1398,7 @@ sub read_map { # $cdom - Domain in which the course is evaluated. # $uname - Name of the user for whom the course is being read # $udom - Name of the domain of the user for whom the course is being read. +# $code - CODE for which course is being read (CODEd assignments) # $target_hash- Reference to the target hash into which all of this is read. # Note tht some of the hash entries we need to build require knowledge of the # course URI.. these are expected to be filled in by the caller. @@ -1405,11 +1407,11 @@ sub read_map { # # sub loadmap { - my ($cnum, $cdom, $uname, $udom, $target_hash) = @_; + my ($cnum, $cdom, $uname, $udom, $code, $target_hash) = @_; - # Clear the auxillary hashes and the cond array. + # Clear the auxiliary hashes and the cond array. %randompick = (); @@ -1477,7 +1479,7 @@ sub loadmap { $target_hash->{'context.courseid'} = $course_id; - &read_map($course_uri, '0.0', $target_hash); + &read_map($course_uri, '0.0', $code, $target_hash); #