[LON-CAPA-cvs] cvs: loncom / lonmap.pm /homework grades.pm /interface lonnavmaps.pm lonprintout.pm

raeburn raeburn at source.lon-capa.org
Thu May 30 01:04:33 EDT 2013


raeburn		Thu May 30 05:04:33 2013 EDT

  Modified files:              
    /loncom	lonmap.pm 
    /loncom/interface	lonnavmaps.pm lonprintout.pm 
    /loncom/homework	grades.pm 
  Log:
  - When users with pav and vgr priv (e.g., Course Coordinators)  print a 
    folder of resources for anonymous CODE(s) or for named student(s), e.g.,
    for a bubblesheet exam, parameter in map for hiddenresource will be
    ignored when retrieving resources for folder in random order.
  - Supports use case where CC sets hidden for exam folder while printing
    bubblesheet exam, and also while grading exam. 
  
  
-------------- next part --------------
Index: loncom/lonmap.pm
diff -u loncom/lonmap.pm:1.10 loncom/lonmap.pm:1.11
--- loncom/lonmap.pm:1.10	Thu May 30 04:02:02 2013
+++ loncom/lonmap.pm	Thu May 30 05:04:16 2013
@@ -2,7 +2,7 @@
 #
 #  Read maps into a 'big hash'.
 #
-# $Id: lonmap.pm,v 1.10 2013/05/30 04:02:02 raeburn Exp $
+# $Id: lonmap.pm,v 1.11 2013/05/30 05:04:16 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -617,7 +617,16 @@
 	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});
@@ -782,7 +791,6 @@
 	    $hiddenurl{$referid}=1;
 	}
     }
-
 }
 
 
@@ -970,6 +978,14 @@
     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'};
@@ -1399,6 +1415,7 @@
 #    $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.
@@ -1407,7 +1424,7 @@
 #
 #  
 sub loadmap {
-    my ($cnum, $cdom, $uname, $udom, $code, $target_hash) = @_;
+    my ($cnum, $cdom, $uname, $udom, $code, $nohideurl, $target_hash) = @_;
 
 
 
@@ -1426,7 +1443,7 @@
     %mapalias_cache = ();
     %cenv           = ();
     $map_number     =  0;
-
+    
     # 
 
     $username   = $uname;
@@ -1477,12 +1494,13 @@
 	$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);
@@ -1561,28 +1579,39 @@
 
 =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
 
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.495 loncom/interface/lonnavmaps.pm:1.496
--- loncom/interface/lonnavmaps.pm:1.495	Sat May  4 23:58:00 2013
+++ loncom/interface/lonnavmaps.pm	Thu May 30 05:04:22 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.495 2013/05/04 23:58:00 raeburn Exp $
+# $Id: lonnavmaps.pm,v 1.496 2013/05/30 05:04:22 raeburn Exp $
 
 #
 # Copyright Michigan State University Board of Trustees
@@ -2020,6 +2020,7 @@
     $self->{USERNAME} = shift || $env{'user.name'};
     $self->{DOMAIN}   = shift || $env{'user.domain'};
     $self->{CODE}     = shift;
+    $self->{NOHIDE} = shift;
 
 
 
@@ -2059,7 +2060,7 @@
 	$self->{PARM_HASH} = \%parmhash;
 	$self->{PARM_CACHE} = {};
     } else {
-	$self->change_user($self->{USERNAME}, $self->{DOMAIN},  $self->{CODE});
+	$self->change_user($self->{USERNAME}, $self->{DOMAIN},  $self->{CODE}, $self->{NOHIDE});
     }
 
     return $self;
@@ -2080,6 +2081,7 @@
     $self->{USERNAME} = shift;
     $self->{DOMAIN}   = shift;
     $self->{CODE}     = shift;
+    $self->{NOHIDE}   = shift;
 
     # If the hashes are already tied make sure to break that bond:
 
@@ -2095,7 +2097,7 @@
     my ($cdom, $cnum) = split(/\_/, $env{'request.course.id'});
 
     my %big_hash;
-    &Apache::lonmap::loadmap($cnum, $cdom, $self->{USERNAME}, $self->{DOMAIN}, $self->{CODE}, \%big_hash);
+    &Apache::lonmap::loadmap($cnum, $cdom, $self->{USERNAME}, $self->{DOMAIN}, $self->{CODE}, $self->{NOHIDE}, \%big_hash);
     $self->{NAV_HASH} = \%big_hash;
 
 
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.630 loncom/interface/lonprintout.pm:1.631
--- loncom/interface/lonprintout.pm:1.630	Thu Jan 31 17:31:05 2013
+++ loncom/interface/lonprintout.pm	Thu May 30 05:04:22 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.630 2013/01/31 17:31:05 bisitz Exp $
+# $Id: lonprintout.pm,v 1.631 2013/05/30 05:04:22 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -720,7 +720,7 @@
 #   print_resources.
 # 
 sub master_seq_to_person_seq {
-    my ($map, $seq, $who, $code) = @_;
+    my ($map, $seq, $who, $code, $nohidemap) = @_;
 
 
     my ($username, $userdomain, $usersection) = split(/:/, $who);
@@ -731,9 +731,14 @@
 
     my %seq_hash = map {$_  => 1} @$seq;
     my @output_seq;
+
+    my $unhidden;
+    if ($perm{'pav'} && $perm{'vgr'} && $nohidemap) {
+        $unhidden = &Apache::lonnet::clutter($map);
+    }
     
     my $navmap           = Apache::lonnavmaps::navmap->new($username, $userdomain,
-                                                           $code);
+                                                           $code, $unhidden);
     my ($start,$finish);
 
     if ($map) {
@@ -760,7 +765,6 @@
 	#  Only process resources..that are not removed by randomout...
 	#  and are selected for printint as well.
 	#
-
         if (ref($curres) && ! $curres->randomout()) {
             my $currsymb = $curres->symb();
             if (exists($seq_hash{$currsymb})) {
@@ -3188,7 +3192,7 @@
 		 $i=int($student_counter/$helper->{'VARS'}{'NUMBER_TO_PRINT'});
 	     }
 	     my $actual_seq = master_seq_to_person_seq($map, \@master_seq,
-                                                       $person);
+                                                       $person, undef, 1);
 	     my ($output,$fullname, $printed)=&print_resources($r,$helper,
 						     $person,$type,
 						     \%moreenv,  $actual_seq,
@@ -3309,7 +3313,7 @@
                  $env{'form.CODE'} = $moreenv{'CODE'};
                  $actual_seq = master_seq_to_person_seq($map, \@master_seq,
                                                         undef,
-                                                        $moreenv{'CODE'});
+                                                        $moreenv{'CODE'}, 1);
                  delete($env{'form.CODE'});
              }
 	     my ($output,$fullname, $printed)=
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.687 loncom/homework/grades.pm:1.688
--- loncom/homework/grades.pm:1.687	Fri May 10 12:48:48 2013
+++ loncom/homework/grades.pm	Thu May 30 05:04:31 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.687 2013/05/10 12:48:48 raeburn Exp $
+# $Id: grades.pm,v 1.688 2013/05/30 05:04:31 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -8214,7 +8214,7 @@
         my $actual_seq =
             &Apache::lonprintout::master_seq_to_person_seq($mapurl,
                                                            $master_seq,
-                                                           $user,$scancode);
+                                                           $user,$scancode,1);
         if (ref($actual_seq) eq 'ARRAY') {
             @{$ordered->{$scancode}} =
                 map { $symb_to_resource->{$_}; } @{$actual_seq};
@@ -8225,7 +8225,7 @@
         my $actual_seq =
             &Apache::lonprintout::master_seq_to_person_seq($mapurl,
                                                            $master_seq,
-                                                           $user);
+                                                           $user,undef,1);
         if (ref($actual_seq) eq 'ARRAY') {
             @mapresources = 
                 map { $symb_to_resource->{$_}; } @{$actual_seq};


More information about the LON-CAPA-cvs mailing list