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

raeburn raeburn at source.lon-capa.org
Sat Dec 8 15:10:32 EST 2012


raeburn		Sat Dec  8 20:10:32 2012 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm lonprintout.pm 
    /loncom	lonmap.pm 
  Log:
  - Printing Problems/Resources from folder for CODEd assignments:
    - If randomorder parameter set for folder, seed used for ordering of
      resources is set in lonnet::rndseed() based on CODE.
  
  
-------------- next part --------------
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.490 loncom/interface/lonnavmaps.pm:1.491
--- loncom/interface/lonnavmaps.pm:1.490	Sat Dec  1 13:14:56 2012
+++ loncom/interface/lonnavmaps.pm	Sat Dec  8 20:10:26 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.490 2012/12/01 13:14:56 raeburn Exp $
+# $Id: lonnavmaps.pm,v 1.491 2012/12/08 20:10:26 raeburn Exp $
 
 #
 # Copyright Michigan State University Board of Trustees
@@ -2011,6 +2011,7 @@
 
     $self->{USERNAME} = shift || $env{'user.name'};
     $self->{DOMAIN}   = shift || $env{'user.domain'};
+    $self->{CODE}     = shift;
 
 
 
@@ -2027,7 +2028,7 @@
     # assume there are course hashes for the specific requested user at domamin:
     #
 
-    if (($self->{USERNAME} eq $env{'user.name'}) && ($self->{DOMAIN} eq $env{'user.domain'})) {
+    if (($self->{USERNAME} eq $env{'user.name'}) && ($self->{DOMAIN} eq $env{'user.domain'}) && !$self->{CODE}) {
 	
 	# tie the nav hash
 	
@@ -2050,7 +2051,7 @@
 	$self->{PARM_HASH} = \%parmhash;
 	$self->{PARM_CACHE} = {};
     } else {
-	$self->change_user($self->{USERNAME}, $self->{DOMAIN});
+	$self->change_user($self->{USERNAME}, $self->{DOMAIN},  $self->{CODE});
     }
 
     return $self;
@@ -2063,12 +2064,14 @@
 # Parameters:
 #    user  - New user.
 #    domain- Domain the user belongs to.
+#    code  - Anonymous CODE in use.
 # Implicit inputs:
 #   
 sub change_user {
     my $self = shift;
     $self->{USERNAME} = shift;
     $self->{DOMAIN}   = shift;
+    $self->{CODE}     = shift;
 
     # If the hashes are already tied make sure to break that bond:
 
@@ -2084,7 +2087,7 @@
     my ($cdom, $cnum) = split(/\_/, $env{'request.course.id'});
 
     my %big_hash;
-    &Apache::lonmap::loadmap($cnum, $cdom, $self->{USERNAME}, $self->{DOMAIN}, \%big_hash);
+    &Apache::lonmap::loadmap($cnum, $cdom, $self->{USERNAME}, $self->{DOMAIN}, $self->{CODE}, \%big_hash);
     $self->{NAV_HASH} = \%big_hash;
 
 
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.624 loncom/interface/lonprintout.pm:1.625
--- loncom/interface/lonprintout.pm:1.624	Fri Nov 30 20:48:27 2012
+++ loncom/interface/lonprintout.pm	Sat Dec  8 20:10:26 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.624 2012/11/30 20:48:27 raeburn Exp $
+# $Id: lonprintout.pm,v 1.625 2012/12/08 20:10:26 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -718,7 +718,7 @@
 #   print_resources.
 # 
 sub master_seq_to_person_seq {
-    my ($helper, $seq, $who) = @_;
+    my ($helper, $seq, $who, $code) = @_;
 
 
     my ($username, $userdomain, $usersection) = split(/:/, $who);
@@ -732,7 +732,8 @@
     my @output_seq;
     
     my ($map, $id, $url) = &Apache::lonnet::decode_symb($helper->{VARS}->{'symb'});
-    my $navmap           = Apache::lonnavmaps::navmap->new($username, $userdomain);
+    my $navmap           = Apache::lonnavmaps::navmap->new($username, $userdomain,
+                                                           $code);
     my $iterator         = $navmap->getIterator($navmap->firstResource(),
 						$navmap->finishResource(),
 						{}, 1);
@@ -3204,7 +3205,6 @@
 	 my $old_name=$helper->{'VARS'}->{'REUSE_OLD_CODES'};
 	 my $single_code = $helper->{'VARS'}->{'SINGLE_CODE'};
 	 my $selected_code = $helper->{'VARS'}->{'CODE_SELECTED_FROM_LIST'};
-
 	 my $code_option=$helper->{'VARS'}->{'CODE_OPTION'};
          my @lines = &Apache::grades::get_scantronformat_file();
 	 my ($code_type,$code_length,$bubbles_per_row)=('letter',6,10);
@@ -3221,6 +3221,19 @@
                  }
 	     }
 	 }
+         my ($randomorder,$randompick);
+         if ($helper->{VARS}{'symb'}) {
+             my $navmap = Apache::lonnavmaps::navmap->new();
+             if (defined($navmap)) {
+                 my ($map,$id,$resource) = 
+                     &Apache::lonnet::decode_symb($helper->{VARS}{'symb'});
+                 if ($map) {
+                     my $res = $navmap->getResourceByUrl($map);
+                     $randomorder = $res->randomorder();
+                     $randompick = $res->randompick();
+                 }
+             }
+         }
 	 my %moreenv = ('textwidth' => &get_textwidth($helper,$LaTeXwidth));
 	 $moreenv{'problem_split'}    = $parmhash{'problem_stream_switch'};
          $moreenv{'instructor_comments'}='hide';
@@ -3282,9 +3295,16 @@
 	     } else {
 		 $moreenv{'CODE'}=&num_to_letters($code);
 	     }
+             my $actual_seq = \@master_seq;
+             if ($randomorder) {
+                 $env{'form.CODE'} = $moreenv{'CODE'};
+                 $actual_seq = master_seq_to_person_seq($helper,\@master_seq,undef,
+                                                        $moreenv{'CODE'});
+                 delete($env{'form.CODE'});
+             }
 	     my ($output,$fullname, $printed)=
 		 &print_resources($r,$helper,'anonymous',$type,\%moreenv,
-				  \@master_seq,$flag_latex_header_remove,
+				  $actual_seq,$flag_latex_header_remove,
 				  $LaTeXwidth);
 	     $resources_printed .= ":";
 	     $print_array[$file_num].=$output;
Index: loncom/lonmap.pm
diff -u loncom/lonmap.pm:1.6 loncom/lonmap.pm:1.7
--- loncom/lonmap.pm:1.6	Tue Nov 29 11:50:53 2011
+++ loncom/lonmap.pm	Sat Dec  8 20:10:32 2012
@@ -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 @@
 #    $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_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 @@
     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 @@
 #   $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 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 @@
 	# 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 @@
     # 
 
     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 @@
 #    $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 loadmap {
-    my ($cnum, $cdom, $uname, $udom,  $target_hash) = @_;
+    my ($cnum, $cdom, $uname, $udom, $code, $target_hash) = @_;
 
 
 
@@ -1477,7 +1480,7 @@
 	$target_hash->{'context.courseid'} = $course_id;
 
 
-        &read_map($course_uri, '0.0', $target_hash);
+        &read_map($course_uri, '0.0', $code, $target_hash);
 
 	# 
 


More information about the LON-CAPA-cvs mailing list