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

albertel lon-capa-cvs-allow@mail.lon-capa.org
Wed, 29 Aug 2007 00:55:38 -0000


albertel		Tue Aug 28 20:55:38 2007 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm lonprintout.pm 
  Log:
  - add randomly ordered notices to 
     - nav maps (on display of folders)
     - printout (when printing for Students or Anon that it will not be
                 randomly ordered)
  (BUG#3960)
  
  
  
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.399 loncom/interface/lonnavmaps.pm:1.400
--- loncom/interface/lonnavmaps.pm:1.399	Wed May 23 16:46:29 2007
+++ loncom/interface/lonnavmaps.pm	Tue Aug 28 20:55:37 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.399 2007/05/23 20:46:29 albertel Exp $
+# $Id: lonnavmaps.pm,v 1.400 2007/08/29 00:55:37 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -991,7 +991,10 @@
         if ($color) {$result .= "</b></font>"; }
     }
     if ($resource->is_map() && advancedUser() && $resource->randompick()) {
-        $result .= '(randomly select ' . $resource->randompick() .')';
+        $result .= &mt('(randomly select [_1])', $resource->randompick());
+    }
+    if ($resource->is_map() && &advancedUser() && $resource->randomorder()) {
+        $result .= &mt('(randomly ordered)');
     }
 
     # Debugging code
@@ -2511,6 +2514,10 @@
 
     my @resources = ();
 
+    if (&$filterFunc($map)) {
+	push(@resources, $map);
+    }
+
     # Run down the iterator and collect the resources.
     my $curRes;
 
@@ -2520,7 +2527,7 @@
                 next;
             }
 
-            push @resources, $curRes;
+            push(@resources, $curRes);
 
             if ($bailout) {
                 return @resources;
@@ -3364,8 +3371,13 @@
 
 =item * B<randompick>:
 
-Returns true for a map if the randompick feature is being used on the
-map. (?)
+Returns the number of randomly picked items for a map if the randompick
+feature is being used on the map. 
+
+=item * B<randomorder>:
+
+Returns true for a map if the randomorder feature is being used on the
+map.
 
 =item * B<src>:
 
@@ -3397,6 +3409,10 @@
     my $self = shift;
     return $self->parmval('randompick');
 }
+sub randomorder { 
+    my $self = shift;
+    return ($self->parmval('randomorder') =~ /^yes$/i);
+}
 sub link {
     my $self=shift;
     if ($self->encrypted()) { return &Apache::lonenc::encrypted($self->src); }
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.506 loncom/interface/lonprintout.pm:1.507
--- loncom/interface/lonprintout.pm:1.506	Wed Jul 25 19:20:38 2007
+++ loncom/interface/lonprintout.pm	Tue Aug 28 20:55:37 2007
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.506 2007/07/25 23:20:38 albertel Exp $
+# $Id: lonprintout.pm,v 1.507 2007/08/29 00:55:37 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2222,6 +2222,28 @@
     }
 }
 
+sub get_randomly_ordered_warning {
+    my ($helper,$map) = @_;
+
+    my $message;
+
+    my $postdata = $env{'form.postdata'} || $helper->{VARS}{'postdata'};
+    my $navmap = Apache::lonnavmaps::navmap->new();
+    my $res = $navmap->getResourceByUrl($map);
+    if ($res) {
+	my $func = 
+	    sub { return ($_[0]->is_map() && $_[0]->randomorder); };
+	my @matches = $navmap->retrieveResources($res, $func,1,1,1);
+	if (@matches) {
+	    $message = "Some folders are set to be randomly ordered. When printing the contents of these folders will be printed in the original order for all students.";
+	}
+    }
+    if ($message) {
+	return '<message type="warning">'.$message.'</message>';
+    }
+    return;
+}
+
 sub printHelper {
     my $r = shift;
 
@@ -2477,6 +2499,9 @@
 	    push @{$printChoices}, [&mt("Selected <b>Problems</b> from folder <b><i>[_1]</i></b> for <b>CODEd assignments</b>",$sequenceTitle), 'problems_for_anon', 'CHOOSE_ANON1'];
 	}
 
+	my $randomly_ordered_warning = 
+	    &get_randomly_ordered_warning($helper,$map);
+
 	# resource_selector will hold a few states that:
 	#   - Allow resources to be selected for printing.
 	#   - Determine pagination between assignments.
@@ -2488,6 +2513,8 @@
 	#
 	my $resource_selector=<<RESOURCE_SELECTOR;
     <state name="SELECT_PROBLEMS" title="Select resources to print">
+    $randomly_ordered_warning
+
    <nextstate>PRINT_FORMATTING</nextstate> 
    <message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message>
     <resource variable="RESOURCES" multichoice="1" addstatus="1" 
@@ -2655,6 +2682,8 @@
 
 	$resource_selector=<<RESOURCE_SELECTOR;
     <state name="SELECT_RESOURCES" title="Select Resources">
+    $randomly_ordered_warning
+
     <nextstate>PRINT_FORMATTING</nextstate>
     <message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message>
     <resource variable="RESOURCES" multichoice="1" addstatus="1"