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

bowersj2 lon-capa-cvs@mail.lon-capa.org
Thu, 19 Jun 2003 20:15:31 -0000


bowersj2		Thu Jun 19 16:15:31 2003 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  Fixes bug 1841, non-advanced users should not be able to print resources 
  that aren't randomly selected for them in randomout maps.
  
  Hooks into Apache::lonnavmaps::advancedUser; fixing that function will 
  fix both lonprintout and lonnavmaps.
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.191 loncom/interface/lonprintout.pm:1.192
--- loncom/interface/lonprintout.pm:1.191	Thu Jun 19 11:46:42 2003
+++ loncom/interface/lonprintout.pm	Thu Jun 19 16:15:30 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.191 2003/06/19 15:46:42 bowersj2 Exp $
+# $Id: lonprintout.pm,v 1.192 2003/06/19 20:15:30 bowersj2 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -899,6 +899,8 @@
         $subdir = &Apache::lonnet::filelocation("", $url);
     }
 
+    my $userCanSeeHidden = Apache::lonnavmaps::advancedUser();
+
     Apache::lonhelper::registerHelperTags();
 
     # "Delete everything after the last slash."
@@ -936,18 +938,20 @@
         # Allow all resources from sequence
         push @{$printChoices}, ["Everything (problem(s), page(s), html/xml file(s)) from <b>$sequenceTitle</b>", 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML'];
 
-        my $isProblem = '$res->is_problem();';
+        my $isProblem = '$res->is_problem()';
+	$isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden;
         my $isProblemOrMap = '$res->is_problem() || $res->is_map()';
-        my $isNotMap = '!$res->is_map();';
-        my $symb = '$res->symb();';
+        my $isNotMap = '!$res->is_map()';
+	$isNotMap .= ' && !$res->randomout()' if !$userCanSeeHidden;
+        my $symb = '$res->symb()';
         my $helperFragment = <<HELPERFRAGMENT;
   <state name="CHOOSE_PROBLEMS" title="Select Problem(s) to print">
     <message>(mark them then click "next" button) <br /></message>
     <resource variable="RESOURCES" multichoice="1" toponly='1'>
       <nextstate>PAGESIZE</nextstate>
-      <filterfunc>return $isProblem</filterfunc>
+      <filterfunc>return $isProblem;</filterfunc>
       <mapurl>$map</mapurl>
-      <valuefunc>return $symb</valuefunc>
+      <valuefunc>return $symb;</valuefunc>
       </resource>
     </state>
 
@@ -957,7 +961,7 @@
       <nextstate>PAGESIZE</nextstate>
       <filterfunc>return $isNotMap;</filterfunc>
       <mapurl>$map</mapurl>
-      <valuefunc>return $symb</valuefunc>
+      <valuefunc>return $symb;</valuefunc>
       </resource>
     </state>
 HELPERFRAGMENT
@@ -971,17 +975,19 @@
         push @{$printChoices}, ['<b>Problems</b> in this course', 'all_problems', 'ALL_PROBLEMS'];
         push @{$printChoices}, ["Problems from <b>$sequenceTitle</b> for selected students", 'problems_for_students', 'CHOOSE_STUDENTS'];
 
-        my $isProblem = '$res->is_problem();';
-        my $isProblemOrMap = '$res->is_problem() || $res->is_map()';
-        my $symb = '$res->symb();';
+        my $isProblem = '$res->is_problem()';
+	$isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden;
+        my $isProblemOrMap = '($res->is_problem() || $res->is_map())';
+	$isProblemOrMap .= ' && !$res->randomout()' if !$userCanSeeHidden;
+        my $symb = '$res->symb()';
         &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS);
   <state name="ALL_PROBLEMS" title="Select Problem(s) to print">
     <message>(mark them then click "next" button) <br /></message>
     <resource variable="RESOURCES" multichoice="1" suppressEmptySequences='1'>
       <nextstate>PAGESIZE</nextstate>
-      <filterfunc>return $isProblemOrMap</filterfunc>
-      <choicefunc>return $isProblem</choicefunc>
-      <valuefunc>return $symb</valuefunc>
+      <filterfunc>return $isProblemOrMap;</filterfunc>
+      <choicefunc>return $isProblem;</choicefunc>
+      <valuefunc>return $symb;</valuefunc>
       </resource>
     </state>