--- loncom/lonmap.pm 2011/11/29 11:50:53 1.6 +++ loncom/lonmap.pm 2012/12/08 20:10:32 1.7 @@ -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.7 2012/12/08 20:10:32 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -801,6 +801,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 +824,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 +971,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 +1179,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 +1190,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 +1291,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 +1315,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 +1399,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,7 +1408,7 @@ sub read_map { # # sub loadmap { - my ($cnum, $cdom, $uname, $udom, $target_hash) = @_; + my ($cnum, $cdom, $uname, $udom, $code, $target_hash) = @_; @@ -1477,7 +1480,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); #