--- loncom/lonmap.pm 2012/12/20 16:10:57 1.8
+++ loncom/lonmap.pm 2013/07/19 18:24:13 1.12
@@ -2,7 +2,7 @@
#
# Read maps into a 'big hash'.
#
-# $Id: lonmap.pm,v 1.8 2012/12/20 16:10:57 raeburn Exp $
+# $Id: lonmap.pm,v 1.12 2013/07/19 18:24:13 bisitz 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).'
';
@@ -618,7 +617,16 @@ sub traceroute {
my $hidden=&Apache::lonnet::EXT('resource.0.hiddenresource',$symb);
if ($hdnflag || lc($hidden) eq 'yes') {
- $hiddenurl{$rid}=1;
+ my $ignorehidden;
+ if (defined($hash->{'is_map_'.$rid})) {
+ if (($hash->{'context.nohideurl'}) && ($hash->{'context.nohideurl'} eq $hash->{'src_'.$rid})) {
+ $ignorehidden = 1; # Hidden parameter explicitly deleted
+ # if printing/grading bubblesheet exam
+ }
+ }
+ unless ($ignorehidden) {
+ $hiddenurl{$rid}=1;
+ }
}
if (!$hdnflag && lc($hidden) eq 'no') {
delete($hiddenurl{$rid});
@@ -673,7 +681,7 @@ sub traceroute {
$further=simplify('('.'_'.$rid.')&('.
$hash->{'condid_'.$hash->{'undercond_'.$id}}.')');
} else {
- my $errtext.=&mt('
Undefined condition ID: [_1]',$hash->{'undercond_'.$id});
+ my $errtext.='
'.&mt('Undefined condition ID: [_1]',$hash->{'undercond_'.$id});
throw Error::Simple($errtext);
}
}
@@ -783,7 +791,6 @@ sub parse_param {
$hiddenurl{$referid}=1;
}
}
-
}
@@ -971,6 +978,14 @@ sub parse_resource {
if (($turi=~/\.sequence$/) ||
($turi=~/\.page$/)) {
$hash->{'is_map_'.$rid}='1'; # String in lonuserstate.
+ if ($hiddenurl{$rid}) {
+ if (($hash->{'context.nohideurl'}) &&
+ ($hash->{'context.nohideurl'} eq $hash->{'src_'.$rid})) {
+ delete($hiddenurl{$rid}); # Hidden parameter explicitly deleted
+ # if printing/grading bubblesheet exam
+ }
+ }
+
&read_map($turi,$rid,$code,$hash);
}
return $token->[2]->{'id'};
@@ -1237,7 +1252,7 @@ sub read_map {
my $ispage = ($filename =~/\.page$/);
unless ($ispage || ($filename =~ /\.sequence$/)) {
&Apache::lonnet::logthis("invalid: $filename : $uri");
- throw Error::Simple(&mt("
Invalid map: [_1]", $filename));
+ throw Error::Simple('
'.&mt('Invalid map: [_1]',''.$filename.''));
}
$filename =~ /\.(\w+)$/;
@@ -1248,8 +1263,8 @@ sub read_map {
my $contents = &Apache::lonnet::getfile($filename);
if($contents eq -1) {
- throw Error::Simple(&mt('
Map not loaded: The file [_1] does not exist.',
- $filename));
+ throw Error::Simple('
'.&mt('Map not loaded: The file [_1] does not exist.',
+ ''.$filename.''));
}
# Now that we succesfully retrieved the file we can make our parsing passes over it:
# parsing is done in passes:
@@ -1400,6 +1415,7 @@ sub read_map {
# $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)
+# $nohideurl - URL for an exam folder for which hidden state is to be ignored.
# $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.
@@ -1408,7 +1424,7 @@ sub read_map {
#
#
sub loadmap {
- my ($cnum, $cdom, $uname, $udom, $code, $target_hash) = @_;
+ my ($cnum, $cdom, $uname, $udom, $code, $nohideurl, $target_hash) = @_;
@@ -1426,7 +1442,7 @@ sub loadmap {
$userdomain = '';
%mapalias_cache = ();
%cenv = ();
-
+ $map_number = 0;
#
@@ -1446,7 +1462,7 @@ sub loadmap {
{'freshen_cache' => 1,
'user' => $uname});
- unless ($cenv{'url'}) {
+ unless ($cenv{'url'}) {
&Apache::lonnet::logthis("lonmap::loadmap failed: $cnum/$cdom - did not get url");
return;
}
@@ -1478,12 +1494,13 @@ sub loadmap {
$target_hash->{'context.username'} = $username;
$target_hash->{'context.userdom'} = $userdomain;
$target_hash->{'context.courseid'} = $course_id;
-
+
+ # When grading or printing a bubblesheet exam ignore
+ # "hidden" parameter set in the map containing the exam folder.
+ $target_hash->{'context.nohideurl'} = $nohideurl;
&read_map($course_uri, '0.0', $code, $target_hash);
- #
-
if (defined($target_hash->{'map_start_'.$map_uri})) {
&traceroute('0',$target_hash->{'map_start_'.$course_uri},'&', 0, 0, $target_hash);
@@ -1532,7 +1549,7 @@ sub loadmap {
&merge_hash($target_hash, 'randompick', \%randompick);
- &merge_hash($target_hash, 'randompickseed', \%randompick);
+ &merge_hash($target_hash, 'randompickseed', \%randompickseed);
&merge_hash($target_hash, 'randomorder', \%randomorder);
&merge_hash($target_hash, 'encurl', \%encurl);
&merge_hash($target_hash, 'hiddenurl', \%hiddenurl);
@@ -1562,28 +1579,39 @@ Apache::lonmap - Construct a hash that r
=head1 SYNOPSIS
-&Apache::lonmap::loadmap($filepath, \%target_hash);
+&Apache::lonmap::loadmap($cnum, $cdom, $uname, $udom, $code, $nohideurl, \%target_hash);
=head1 INTRODUCTION
This module reads a course filename into a hash reference. It's up to the caller
-to to things like decide the has should be tied to some external file and handle the locking
-if this file should be shared amongst several Apache children.
+to do things like decide that the hash should be tied to some external file and handle the
+the locking if this file should be shared amongst several Apache children.
=head1 SUBROUTINES
=over
-=item loadmap($filepath, $targethash)
+=item loadmap($cnum, $cdom, $uname, $udom, $code, $nohideurl, $targethash)
-Reads the map file into a target hash.
+Reads the top-level map file into a target hash. This is done by first parsing the
+map file into local hashes and then unrolling those hashes into the big hash.
=over
-=item $filepath - The path to the map file to read.
+=item $cnum - number of course being read.
+
+=item $cdom - domain in which the course is evaluated.
+
+=item $uname - name of the user for whom the course is being read.
+
+=item $udom - name of the domain of the user for whom the course is being read.
+
+=item $code - CODE for which course is being read (CODEd assignments).
+
+=item $nohideurl - URL for an exam folder for which hidden state is to be ignored.
-=item $targethash - A reference to hash into which the course is read.
+=item $targethash - A reference to hash into which the course is read
=back