[LON-CAPA-cvs] cvs: loncom /html/res/adm/pages printout.gif /interface loncommon.pm lonhelper.pm lonnavmaps.pm lonprintout.pm doc/loncapafiles loncapafiles.lpml

raeburn raeburn at source.lon-capa.org
Sat Jun 11 10:51:50 EDT 2022


raeburn		Sat Jun 11 14:51:50 2022 EDT

  Added files:                 
    /loncom/html/res/adm/pages	printout.gif 

  Modified files:              
    /loncom/interface	loncommon.pm lonhelper.pm lonnavmaps.pm 
                     	lonprintout.pm 
    /doc/loncapafiles	loncapafiles.lpml 
  Log:
  - Include printout icon in "Tools" above listing of course contents unless
    course is empty. Options include:
    - Print items not in a folder (if any exist)
    - Print items in a selected folder 
    Privileged users can also print selected folder for selected users or CODEs. 
  - When displaying list of resources to select exlude any /adm/navmaps items
    themselves. 
  
  
-------------- next part --------------
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1383 loncom/interface/loncommon.pm:1.1384
--- loncom/interface/loncommon.pm:1.1383	Tue May 31 22:07:15 2022
+++ loncom/interface/loncommon.pm	Sat Jun 11 14:51:49 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1383 2022/05/31 22:07:15 raeburn Exp $
+# $Id: loncommon.pm,v 1.1384 2022/06/11 14:51:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -8524,6 +8524,10 @@
   background-image:url(/res/adm/pages/edittoplevel.gif);
 }
 
+a#LC_content_toolbar_printout {
+  background-image:url(/res/adm/pages/printout.gif);
+}
+
 ul#LC_toolbar li a:hover {
   background-position: bottom center;
 }
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.202 loncom/interface/lonhelper.pm:1.203
--- loncom/interface/lonhelper.pm:1.202	Mon Sep  3 16:43:47 2018
+++ loncom/interface/lonhelper.pm	Sat Jun 11 14:51:49 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.202 2018/09/03 16:43:47 raeburn Exp $
+# $Id: lonhelper.pm,v 1.203 2022/06/11 14:51:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2162,6 +2162,8 @@
     $paramHash->{'addstatus'} = $token->[2]{'addstatus'};
     $paramHash->{'addparts'} = $token->[2]{'addparts'};
     $paramHash->{'modalLink'} = $token->[2]{'modallink'};
+    $paramHash->{'nocurrloc'} = $token->[2]{'nocurrloc'};
+    $paramHash->{'suppressNavmap'} = $token->[2]{'suppressNavmap'};
     if ($paramHash->{'addparts'}) {
 	$helper->declareVar($paramHash->{'variable'}.'_part');
     }
@@ -2554,7 +2556,9 @@
 				       'include_top_level_map' => $self->{'include_top_level_map'},
                                        'iterator_map' => $mapUrl,
                                        'map_no_edit_link' => 1,
-                                       'modalLink' => $modalLink, }
+                                       'modalLink' => $modalLink,
+                                       'nocurrloc' => $self->{'nocurrloc'},
+                                       'suppressNavmap' => $self->{'suppressNavmap'}, }
                                        );
 
     $result .= $buttons;
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.557 loncom/interface/lonnavmaps.pm:1.558
--- loncom/interface/lonnavmaps.pm:1.557	Sat Jun 11 04:57:08 2022
+++ loncom/interface/lonnavmaps.pm	Sat Jun 11 14:51:49 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.557 2022/06/11 04:57:08 raeburn Exp $
+# $Id: lonnavmaps.pm,v 1.558 2022/06/11 14:51:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1425,7 +1425,7 @@
         $condition = 1;
     }
 
-    if (!$env{'form.folderManip'} && !defined($args->{'iterator'})) {
+    if (!$env{'form.folderManip'} && !defined($args->{'iterator'}) && !$args->{'nocurrloc'}) {
         # Step 1: Check to see if we have a navmap
         if (!defined($navmap)) {
             $navmap = Apache::lonnavmaps::navmap->new();
@@ -1632,16 +1632,22 @@
 	}
 	$result.='</form>';
     }
-    if (($args->{'caller'} eq 'navmapsdisplay') &&
-        ((&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) ||
-         (&Apache::lonnet::allowed('cev',$env{'request.course.id'})))) {
+    if (($args->{'caller'} eq 'navmapsdisplay') && ($env{'request.course.id'})) {
         my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
         my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
-        if ($env{'course.'.$env{'request.course.id'}.'.url'} eq 
+        if ($env{'course.'.$env{'request.course.id'}.'.url'} eq
             "uploaded/$cdom/$cnum/default.sequence") {
-            &add_linkitem($args->{'linkitems'},'edittoplevel',
-                          "javascript:gocmd('/adm/coursedocs','editdocs');",
-                          'Content Editor');
+            if ((&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) ||
+                (&Apache::lonnet::allowed('cev',$env{'request.course.id'}))) {
+                &add_linkitem($args->{'linkitems'},'edittoplevel',
+                              "javascript:gocmd('/adm/coursedocs','editdocs');",
+                              'Content Editor');
+            }
+            if ($counter) {
+                &add_linkitem($args->{'linkitems'},'printout',
+                              "javascript:gopost('/adm/printout','/adm/navmaps');",
+                              'Prepare a printable document');
+            }
         }
     }
 
@@ -2088,7 +2094,7 @@
             $result .= '<td align="left">'."\n".
                        '<ul id="LC_toolbar">';
             my @linkorder = ('firsthomework','everything','uncompleted',
-                             'changefolder','clearbubbles','edittoplevel');
+                             'changefolder','clearbubbles','printout','edittoplevel');
             foreach my $link (@linkorder) {
                 if (ref($args->{'linkitems'}{$link}) eq 'HASH') {
                     if ($args->{'linkitems'}{$link}{'text'} ne '') {
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.678 loncom/interface/lonprintout.pm:1.679
--- loncom/interface/lonprintout.pm:1.678	Sat Jun 11 14:38:27 2022
+++ loncom/interface/lonprintout.pm	Sat Jun 11 14:51:49 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.678 2022/06/11 14:38:27 raeburn Exp $
+# $Id: lonprintout.pm,v 1.679 2022/06/11 14:51:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -143,12 +143,13 @@
 # Parameters:
 #    helper - the helper which already contains info about the current folder we can
 #             purloin.
-#    url    - Top url of the sequence
+#    map    - the map for which incomplete problems are to be printed
+#    nocurrloc - True if printout called from icon/link in Tools in /adm/navmaps
 # Return:
 #     XML that can be parsed by the helper to drive the state machine.
 #
 sub create_incomplete_folder_selstud_helper {
-    my ($helper, $map)  = @_;
+    my ($helper, $map, $nocurrloc)  = @_;
 
 
     my $symbFilter = '$res->shown_symb()';
@@ -157,7 +158,7 @@
 
     my $resource_chooser = &generate_resource_chooser('CHOOSE_INCOMPLETE_PEOPLE_SEQ',
 						      'Select problem(s) to print',
-						      'multichoice="1" toponly="1" addstatus="1" closeallpages="1" modallink="1"',
+						      'multichoice="1" toponly="1" addstatus="1" closeallpages="1" modallink="1" nocurrloc="'.$nocurrloc.'"',
 						      'RESOURCES',
 						      'CHOOSE_STUDENTS_INCOMPLETE',
 						      $map,
@@ -235,6 +236,7 @@
 # Parameters:
 #   $helper - helper we are generating states for.
 #   $map    - The map for which the student wants incomplete problems.
+#   $nocurrloc - True if printout called from icon/link in Tools in /adm/navmaps
 # Returns:
 #   XML that defines the helper states being created.
 #
@@ -242,7 +244,7 @@
 #   CHOOSE_INCOMPLETE_SEQ  - Resource selector.
 #
 sub create_incomplete_folder_helper {
-    my ($helper, $map) = @_;
+    my ($helper, $map, $nocurrloc) = @_;
 
     my $filter    = '$res->is_problem()';
     $filter      .= ' && $res->resprintable() ';
@@ -252,7 +254,7 @@
 
     my $resource_chooser = &generate_resource_chooser('CHOOSE_INCOMPLETE_SEQ',
 						      'Select problem(s) to print',
-						      'multichoice="1", toponly ="1", addstatus="1", closeallpages="1" modallink="1"',
+						      'multichoice="1", toponly ="1", addstatus="1", closeallpages="1" modallink="1" nocurrloc="'.$nocurrloc.'"',
 						      'RESOURCES',
 						      'PAGESIZE',
 						      $map,
@@ -444,6 +446,134 @@
    return $result;
 }
 
+sub generate_common_choosers {
+    my ($r,$helper,$map,$url,$isProblem,$symbFilter,$start_new_option) = @_;
+
+    my $randomly_ordered_warning =
+        &get_randomly_ordered_warning($helper, $map);
+
+    # code for a few states used for printout launched from both 
+    # /adm/navmpas and from a resource by a privileged user:
+    #   - To allow resources to be selected for printing.
+    #   - To determine pagination between assignments.
+    #   - To determine how many assignments should be bundled into a single PDF.
+
+    my $resource_selector= &generate_resource_chooser('SELECT_PROBLEMS',
+                                                      'Select resources to print',
+                                                      'multichoice="1" addstatus="1" closeallpages="1" modallink="1" suppressNavmap="1"',
+                                                      'RESOURCES',
+                                                      'PRINT_FORMATTING',
+                                                      $map,
+                                                      $isProblem, '', $symbFilter,
+                                                      $start_new_option);
+    $resource_selector .=  &generate_format_selector($helper,
+                                                     'How should results be printed?',
+                                                     'PRINT_FORMATTING').
+                           &generate_resource_chooser('CHOOSE_STUDENTS_PAGE',
+                                                      'Select Problem(s) to print',
+                                                      "multichoice='1' addstatus='1' closeallpages ='1' modallink='1'",
+                                                      'RESOURCES',
+                                                      'PRINT_FORMATTING',
+                                                      $url,
+                                                      $isProblem, '',  $symbFilter,
+                                                      $start_new_option);
+
+# Generate student choosers.
+
+    &Apache::lonxml::xmlparse($r, 'helper',
+                              &generate_student_chooser('CHOOSE_TGT_STUDENTS_PAGE',
+                                                        'student_sort',
+                                                        'STUDENTS',
+                                                        'CHOOSE_STUDENTS_PAGE'));
+    &Apache::lonxml::xmlparse($r, 'helper',
+                              &generate_student_chooser('CHOOSE_STUDENTS',
+                                                        'student_sort',
+                                                        'STUDENTS',
+                                                        'SELECT_PROBLEMS'));
+    &Apache::lonxml::xmlparse($r, 'helper', $resource_selector);
+
+    my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+    my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+    my @names=&Apache::lonnet::getkeys('CODEs',$cdom,$cnum);
+    my $namechoice='<choice></choice>';
+    foreach my $name (sort {uc($a) cmp uc($b)} @names) {
+        if ($name =~ /^error: 2 /) { next; }
+        if ($name =~ /^type\0/) { next; }
+        $namechoice.='<choice computer="'.$name.'">'.$name.'</choice>';
+    }
+
+    my %code_values;
+    my %codes_to_print;
+    foreach my $key (@names) {
+        %code_values = &Apache::grades::get_codes($key, $cdom, $cnum);
+        foreach my $key (keys(%code_values)) {
+            $codes_to_print{$key} = 1;
+        }
+    }
+
+    my $code_selection;
+    foreach my $code (sort {uc($a) cmp uc($b)} (keys(%codes_to_print))) {
+        my $choice  = $code;
+        if ($code =~ /^[A-Z]+$/) { # Alpha code
+            $choice = &letters_to_num($code);
+        }
+        push(@{$helper->{DATA}{ALL_CODE_CHOICES}},[$code,$choice]);
+    }
+    if (%codes_to_print) {
+        $code_selection .='
+        <message><b>Choose single CODE from list:</b></message>
+        <message></td><td></message>
+            <dropdown variable="CODE_SELECTED_FROM_LIST" multichoice="0" allowempty="0">
+              <choice></choice>
+              <exec>
+                 push(@{$state->{CHOICES}},@{$helper->{DATA}{ALL_CODE_CHOICES}});
+              </exec>
+            </dropdown>
+        <message></td></tr><tr><td></message>
+        '.$/;
+    }
+
+    my @lines = &Apache::lonnet::get_scantronformat_file();
+    my $codechoice='';
+    foreach my $line (@lines) {
+        next if (($line =~ /^\#/) || ($line eq ''));
+        my ($name,$description,$code_type,$code_length)=
+            (split(/:/,$line))[0,1,2,4];
+        if ($code_length > 0 &&
+            $code_type =~/^(letter|number|-1)/) {
+            $codechoice.='<choice computer="'.$name.'">'.$description.'</choice>';
+        }
+    }
+    if ($codechoice eq '') {
+        $codechoice='<choice computer="default">Default</choice>';
+    }
+    my $anon1 = &generate_code_selector($helper,
+                                        'CHOOSE_ANON1',
+                                        'SELECT_PROBLEMS',
+                                        $codechoice,
+                                        $code_selection,
+                                        $namechoice) . $resource_selector;
+
+    &Apache::lonxml::xmlparse($r, 'helper',$anon1);
+
+    my $anon_page = &generate_code_selector($helper,
+                                            'CHOOSE_ANON1_PAGE',
+                                            'SELECT_PROBLEMS_PAGE',
+                                            $codechoice,
+                                            $code_selection,
+                                            $namechoice) .
+                    &generate_resource_chooser('SELECT_PROBLEMS_PAGE',
+                                               'Select Problem(s) to print',
+                                               "multichoice='1' addstatus='1' closeallpages ='1' modallink='1'",
+                                               'RESOURCES',
+                                               'PRINT_FORMATTING',
+                                               $url,
+                                               $isProblem, '',  $symbFilter,
+                                               $start_new_option);
+    &Apache::lonxml::xmlparse($r, 'helper', $anon_page);
+    return ($randomly_ordered_warning,$codechoice,$code_selection,$namechoice);
+}
+
 #  Returns the XML for choosing how assignments are to be formatted 
 #  that text must still be parsed by the helper xml parser.
 # Parameters: 3 (required)
@@ -458,7 +588,9 @@
     my $secpdfoption;
     unless (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon')     ||
             ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon_page') ||
-            ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_anon')  ) {
+            ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_anon') ||
+            ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences_problems_for_anon') ||
+            ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences_resources_for_anon')) {
         $secpdfoption =  '<choice computer="sections">Each PDF contains exactly one section</choice>';
     }
     return <<RESOURCE_SELECTOR;
@@ -3117,7 +3249,9 @@
 	      ($print_type eq 'all_problems_students')           ||
 	      ($print_type eq 'resources_for_students')          ||
 	      ($print_type eq 'incomplete_problems_selpeople_course') ||
-	      ($print_type eq 'map_incomplete_problems_people_seq')){
+	      ($print_type eq 'map_incomplete_problems_people_seq') ||
+              ($print_type eq 'select_sequences_problems_for_students') ||
+              ($print_type eq 'select_sequences_resources_for_students')) {
 
 
      #-- prints assignments for whole class or for selected students  
@@ -3126,10 +3260,12 @@
 	     ($print_type eq 'problems_for_students_from_page') ||
 	     ($print_type eq 'all_problems_students')           ||
 	     ($print_type eq 'incomplete_problems_selpeople_course') ||
-	     ($print_type eq 'map_incomplete_problems_people_seq')) {
+	     ($print_type eq 'map_incomplete_problems_people_seq') ||
+             ($print_type eq 'select_sequences_problems_for_students')) {
 	     $selectionmade=5;
 	     $type='problems';
-	 } elsif ($print_type eq 'resources_for_students') {
+	 } elsif (($print_type eq 'resources_for_students') ||
+                  ($print_type eq 'select_sequences_resources_for_students')) {
 	     $selectionmade=8;
 	     $type='resources';
 	 }
@@ -3229,7 +3365,9 @@
 	 $result .= $print_array[0].'  \end{document}';
      } elsif (($print_type eq 'problems_for_anon')      ||
 	      ($print_type eq 'problems_for_anon_page') ||
-	      ($print_type eq 'resources_for_anon')  ) {
+	      ($print_type eq 'resources_for_anon')     ||
+              ($print_type eq 'select_sequences_problems_for_anon') ||
+              ($print_type eq 'select_sequences_resources_for_anon')) {
 	 my $cdom =$env{'course.'.$env{'request.course.id'}.'.domain'};
 	 my $cnum =$env{'course.'.$env{'request.course.id'}.'.num'};
 	 my $num_todo=$helper->{'VARS'}->{'NUMBER_TO_PRINT_TOTAL'};
@@ -3478,6 +3616,9 @@
                 $URLback .= (($URLback =~ /\?/) ? '&':'?').'symb='.&escape($symb.$anchor);
             }
         }
+    } elsif (($helper->{VARS}->{'postdata'} eq '/adm/navmaps') &&
+             ($env{'request.course.id'})) {
+        $URLback=$helper->{VARS}->{'postdata'};
     }
     #
     # Final adjustment of the font size:
@@ -4060,7 +4201,9 @@
         $helper->{VARS}->{'construction'} = 1;
     } else {
         if ($env{'form.postdata'}) {
-            $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($env{'form.postdata'});
+            unless ($env{'form.postdata'} eq '/adm/navmaps') {
+                $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($env{'form.postdata'});
+            }
 	    if ( $helper->{VARS}->{'symb'} eq '') {
 		$helper->{VARS}->{'postdata'} = $env{'form.postdata'};
 	    }
@@ -4078,13 +4221,40 @@
         $helper->{VARS}->{'symb'} = $env{'form.symb'};
     }
     if ($env{'form.url'}) {
-        $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'});
+        unless ($env{'form.url'} eq '/adm/navmaps') {
+            $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'});
+        }
     }
     if ($helper->{VARS}->{'symb'} ne '') {
         $helper->{VARS}->{'symb'}=
 	    &Apache::lonenc::check_encrypt($helper->{VARS}->{'symb'});
     }
-    my ($resourceTitle,$sequenceTitle,$mapTitle) = &details_for_menu($helper);
+    my ($resourceTitle,$sequenceTitle,$mapTitle,$cdom,$cnum);
+    if ($helper->{VARS}->{'postdata'} eq '/adm/navmaps') {
+        $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+        $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+        if ($env{'course.'.$env{'request.course.id'}.'.url'} eq
+            "uploaded/$cdom/$cnum/default.sequence") {
+            my $navmap = Apache::lonnavmaps::navmap->new();
+            if (ref($navmap)) {
+                my @toplevelres = $navmap->retrieveResources('',sub { !(($_[0]->is_map()) || ($_[0]->src =~ /^\/adm\/navmaps/)) },0,0);
+                if (@toplevelres) {
+                    my @printable;
+                    if ($perm{'pav'} || $perm{'pfo'}) {
+                        @printable = @toplevelres;
+                    } else {
+                        @printable = $navmap->retrieveResources(undef,sub { $_[0]->resprintable() },0,1);
+                    }
+                    if (@printable) {
+                        $sequenceTitle = 'Main Content';
+                        $mapTitle = $sequenceTitle;
+                    }
+                }
+            }
+        }
+    } else {
+        ($resourceTitle,$sequenceTitle,$mapTitle) = &details_for_menu($helper);
+    }
     if ($sequenceTitle ne '') {$helper->{VARS}->{'assignment'}=$sequenceTitle;}
 
     
@@ -4116,10 +4286,24 @@
 	    ($map, $id, $url) = &Apache::lonnet::decode_symb($symb);
 	    $helper->{VARS}->{'postdata'} = 
 		&Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($url));
+        } elsif (($helper->{VARS}->{'postdata'} eq '/adm/navmaps') &&
+                ($env{'request.course.id'} ne '')) {
+            if ($env{'course.'.$env{'request.course.id'}.'.url'} eq
+                "uploaded/$cdom/$cnum/default.sequence") {
+                $map = $env{'course.'.$env{'request.course.id'}.'.url'};
+                $url = $helper->{VARS}->{'postdata'};
+            }
+        }
+        if (($symb ne '') || ($map ne '')) {
             if (!$userCanPrint) {
 	        my $navmap = Apache::lonnavmaps::navmap->new();
                 if (ref($navmap)) {
-	            my $res = $navmap->getBySymb($symb);
+                    my $res;
+                    if ($symb ne '') {
+	                $res = $navmap->getBySymb($symb);
+                    } elsif ($map ne '') {
+                        $res = $navmap->getResourceByUrl($map);
+                    }
                     if (ref($res)) {
 	                $res_printable = $res->resprintable(); #printability in course context
 	                ($res_printstartdate, $res_printenddate) = &get_print_dates($res);
@@ -4143,7 +4327,11 @@
             my $postdata = $helper->{VARS}->{'postdata'};
             $resourceTitle = substr($postdata, rindex($postdata, '/') + 1);
         }
-        $subdir = &Apache::lonnet::filelocation("", $url);
+        if (($url eq '/adm/navmaps') && ($map eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
+            $res_printable=0;
+        } else {
+            $subdir = &Apache::lonnet::filelocation("", $url);
+        }
 
 
     }
@@ -4257,14 +4445,14 @@
 
       $helperFragment .= &generate_resource_chooser('CHOOSE_RESOURCES_PAGE',
 						    'Select Resource(s) to print',
-						    'multichoice="1" toponly="1" addstatus="1" closeallpages="1" modallink="1"',
+						    'multichoice="1" toponly="1" addstatus="1" closeallpages="1" modallink="1" suppressNavmap="1"',
 						    'RESOURCES',
 						    'PAGESIZE',
 						    $url,
 						    $isNotMap, '', $symbFilter,
 						    $start_new_option);
 
-						    
+
 
 
 
@@ -4282,20 +4470,25 @@
 	# the exact form of this depends on whether or not we are privileged or a mere
 	# plebe of s student:
 
+        my $optionText    = '';
 	my $printSelector = 'map_incomplete_problems_seq';
 	my $nextState     = 'CHOOSE_INCOMPLETE_SEQ';
 	my $textSuffix    = '';
+        my $nocurrloc = '';
+        if ($helper->{VARS}->{'postdata'} eq '/adm/navmaps') {
+            $nocurrloc = 1;
+        }
 
 	if ($userCanPrint)  {
 	    $printSelector = 'map_incomplete_problems_people_seq';
 	    $nextState     = 'CHOOSE_INCOMPLETE_PEOPLE_SEQ';
 	    $textSuffix    = ' for selected students';
 	    my $helperStates =
-		&create_incomplete_folder_selstud_helper($helper, $map); 
+		&create_incomplete_folder_selstud_helper($helper, $map, $nocurrloc); 
 	    &Apache::lonxml::xmlparse($r, 'helper', $helperStates);
 	} else {
 	    if (&printable($map_open, $map_close)) {
-		my $helperStates = &create_incomplete_folder_helper($helper, $map); # Create needed states for student.
+		my $helperStates = &create_incomplete_folder_helper($helper, $map, $nocurrloc); # Create needed states for student.
 		&Apache::lonxml::xmlparse($r, 'helper', $helperStates);
 	    } else {
 		# TODO: Figure out how to break the news...this folder is not printable.
@@ -4303,26 +4496,41 @@
 	}
 
 	if ($userCanPrint || &printable($map_open, $map_close)) {
+            if ($helper->{VARS}->{'postdata'} eq '/adm/navmaps') {
+                $optionText = &mt('Selected [_1]Incomplete Problems[_2] [_3]not in a folder[_4]' . $textSuffix,
+                                  '<b>','</b>','<i>','</i>');
+            } else {
+                $optionText = &mt('Selected  [_1]Incomplete Problems[_2] from folder [_3]' . $textSuffix,
+                                  '<b>','</b>','<b><i>'.$sequenceTitle.'</b></i>');
+            }
 	    push(@{$printChoices},
-		 [&mt('Selected  [_1]Incomplete Problems[_2] from folder [_3]' . $textSuffix,
-		      '<b>', '</b>',
-		      '<b><i>'. $sequenceTitle . '</b></i>'),
+		 [$optionText,
 		  $printSelector,
 		  $nextState]);
 	}
         # Allow problems from sequence
 	if ($userCanPrint || &printable($map_open, $map_close)) {
+            if ($helper->{VARS}->{'postdata'} eq '/adm/navmaps') {
+                $optionText = &mt('Selected [_1]Problems[_2] [_3]not in a folder[_4]','<b>','</b>','<i>','</i>');
+            } else {
+                $optionText = &mt('Selected [_1]Problems[_2] from folder [_3]','<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>');
+            }
 	    push @{$printChoices}, 
-	    [&mt('Selected [_1]Problems[_2] from folder [_3]','<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>'), 
+	    [$optionText, 
 	     'map_problems', 
 	     'CHOOSE_PROBLEMS'];
 	    # Allow all resources from sequence
-	    push @{$printChoices}, [&mt('Selected [_1]Resources[_2] from folder [_3]','<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>'), 
+            if ($helper->{VARS}->{'postdata'} eq '/adm/navmaps') {
+                $optionText = &mt('Selected [_1]Resources[_2] [_3]not in a folder[_4]','<b>','</b>','<i>','</i>');
+            } else {
+                $optionText = &mt('Selected [_1]Resources[_2] from folder [_3]','<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>');
+            }
+	    push @{$printChoices}, [$optionText, 
 				    'map_problems_pages', 
 				    'CHOOSE_PROBLEMS_HTML'];
 	    my $helperFragment = &generate_resource_chooser('CHOOSE_PROBLEMS',
 							    'Select Problem(s) to print',
-							    'multichoice="1" toponly="1" addstatus="1" closeallpages="1" modallink="1"',
+							    'multichoice="1" toponly="1" addstatus="1" closeallpages="1" modallink="1" nocurrloc="'.$nocurrloc.'"',
 							    'RESOURCES',
 							    'PAGESIZE',
 							    $map,
@@ -4331,7 +4539,7 @@
 							    $start_new_option);
 	    $helperFragment .= &generate_resource_chooser('CHOOSE_PROBLEMS_HTML',
 							  'Select Resource(s) to print',
-							  'multichoice="1" toponly="1" addstatus="1" closeallpages="1" modallink="1"',
+							  'multichoice="1" toponly="1" addstatus="1" closeallpages="1" modallink="1" nocurrloc="'.$nocurrloc.'" suppressNavmap="1"',
 							  'RESOURCES',
 							  'PAGESIZE',
 							  $map,
@@ -4349,7 +4557,7 @@
 	my $post_data = $helper->{VARS}->{'postdata'};
     
     if ($perm{'pfo'} &&  !$is_published  &&
-        ($post_data=~/\/res\// || $post_data =~/\/(syllabus|smppg|aboutme|bulletinboard)$/)) { 
+        ($post_data=~/\/res\// || $post_data =~/\/(syllabus|smppg|aboutme|bulletinboard)$/)) {
 
 	# BZ 5209 - incomplete problems from entire course:
 
@@ -4388,7 +4596,7 @@
 							      $start_new_option) .
 				   &generate_resource_chooser('ALL_RESOURCES',
 							      'Select Resource(s) to print',
-							      " toponly='0' multichoice='1' suppressEmptySequences='0' addstatus='1' closeallpages='1' modallink='1'",
+							      'toponly="0" multichoice="1" suppressEmptySequences="0" addstatus="1" closeallpages="1" modallink="1" suppressNavmap="1"',
 							      'RESOURCES',
 							      'PAGESIZE',
 							      '',
@@ -4426,138 +4634,8 @@
 				    '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.
-	#   - Determine how many assignments should be bundled into a single PDF.
-        # TODO:
-	#    Probably good to do things like separate this up into several vars, each
-	#    with one state, and use REGEXPs at inclusion time to set state names
-	#    and next states for better mix and match capability
-	#
-	my $resource_selector= &generate_resource_chooser('SELECT_PROBLEMS',
-							  'Select resources to print',
-							  'multichoice="1" addstatus="1" closeallpages="1" modallink="1"',
-							  'RESOURCES', 
-							  'PRINT_FORMATTING',
-							  $map,
-							  $isProblem, '', $symbFilter,
-							  $start_new_option);
-	$resource_selector .=  &generate_format_selector($helper,
-                                                         'How should results be printed?',
-                                                         'PRINT_FORMATTING').
-                               &generate_resource_chooser('CHOOSE_STUDENTS_PAGE',
-							'Select Problem(s) to print',
-							"multichoice='1' addstatus='1' closeallpages ='1' modallink='1'",
-							'RESOURCES',
-							'PRINT_FORMATTING',
-							$url,
-							$isProblem, '',  $symbFilter,
-							$start_new_option);
-
-
-# Generate student choosers.
-
-
-
-        &Apache::lonxml::xmlparse($r, 'helper',
-				  &generate_student_chooser('CHOOSE_TGT_STUDENTS_PAGE',
-							    'student_sort',
-							    'STUDENTS',
-							    'CHOOSE_STUDENTS_PAGE'));
-	&Apache::lonxml::xmlparse($r, 'helper', 
-				  &generate_student_chooser('CHOOSE_STUDENTS',
-							    'student_sort',
-							    'STUDENTS',
-							    'SELECT_PROBLEMS'));
-	&Apache::lonxml::xmlparse($r, 'helper', $resource_selector);
-
-	my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
-	my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
-        my @names=&Apache::lonnet::getkeys('CODEs',$cdom,$cnum);
-	my $namechoice='<choice></choice>';
-	foreach my $name (sort {uc($a) cmp uc($b)} @names) {
-	    if ($name =~ /^error: 2 /) { next; }
-	    if ($name =~ /^type\0/) { next; }
-	    $namechoice.='<choice computer="'.$name.'">'.$name.'</choice>';
-	}
-
-
-	my %code_values;
-	my %codes_to_print;
-	foreach my $key (@names) {
-	    %code_values = &Apache::grades::get_codes($key, $cdom, $cnum);
-	    foreach my $key (keys(%code_values)) {
-		$codes_to_print{$key} = 1;
-	    }
-	}
-
-	my $code_selection;
-	foreach my $code (sort {uc($a) cmp uc($b)} (keys(%codes_to_print))) {
-	    my $choice  = $code;
-	    if ($code =~ /^[A-Z]+$/) { # Alpha code
-		$choice = &letters_to_num($code);
-	    }
-	    push(@{$helper->{DATA}{ALL_CODE_CHOICES}},[$code,$choice]);
-	}
-	if (%codes_to_print) {
-	    $code_selection .='   
-	    <message><b>Choose single CODE from list:</b></message>
-		<message></td><td></message>
-		<dropdown variable="CODE_SELECTED_FROM_LIST" multichoice="0" allowempty="0">
-                  <choice></choice>
-                  <exec>
-                     push(@{$state->{CHOICES}},@{$helper->{DATA}{ALL_CODE_CHOICES}});
-                  </exec>
-		</dropdown>
-	    <message></td></tr><tr><td></message>
-            '.$/;
-
-	}
-
-        my @lines = &Apache::lonnet::get_scantronformat_file();
-	my $codechoice='';
-	foreach my $line (@lines) {
-            next if (($line =~ /^\#/) || ($line eq ''));
-	    my ($name,$description,$code_type,$code_length)=
-		(split(/:/,$line))[0,1,2,4];
-	    if ($code_length > 0 && 
-		$code_type =~/^(letter|number|-1)/) {
-		$codechoice.='<choice computer="'.$name.'">'.$description.'</choice>';
-	    }
-	}
-	if ($codechoice eq '') {
-	    $codechoice='<choice computer="default">Default</choice>';
-	}
-	my $anon1 = &generate_code_selector($helper, 
-					    'CHOOSE_ANON1',
-					    'SELECT_PROBLEMS',
-					    $codechoice,
-					    $code_selection,
-					    $namechoice) . $resource_selector;
-					    
-					    
-        &Apache::lonxml::xmlparse($r, 'helper',$anon1);
-
-	my $anon_page = &generate_code_selector($helper,
-						'CHOOSE_ANON1_PAGE',
-						'SELECT_PROBLEMS_PAGE',
-						$codechoice,
-						$code_selection,
-						$namechoice) .
-			&generate_resource_chooser('SELECT_PROBLEMS_PAGE',
-						   'Select Problem(s) to print',
-						   "multichoice='1' addstatus='1' closeallpages ='1' modallink='1'",
-						   'RESOURCES',
-						   'PRINT_FORMATTING',
-						   $url,
-						   $isProblem, '',  $symbFilter,
-						   $start_new_option);
-	&Apache::lonxml::xmlparse($r, 'helper', $anon_page);
-
+        my ($randomly_ordered_warning,$codechoice,$code_selection,$namechoice) =
+            &generate_common_choosers($r,$helper,$map,$url,$isProblem,$symbFilter,$start_new_option);
 
 	if ($helper->{VARS}->{'assignment'}) {
 
@@ -4566,9 +4644,18 @@
 	    push @{$printChoices}, [&mt('Selected [_1]Resources[_2] from folder [_3] for [_4]selected people[_5]','<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>','<b>','</b>'), 'resources_for_students', 'CHOOSE_STUDENTS1'];
 	    push @{$printChoices}, [&mt('Selected [_1]Resources[_2] from folder [_3] for [_4]CODEd assignments[_5]','<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>','<b>','</b>'), 'resources_for_anon', 'CHOOSE_ANON2'];
 	}
-	    
 
-	$resource_selector=<<RESOURCE_SELECTOR;
+        # resource_selector will hold a few states that:
+        #   - Allow resources to be selected for printing.
+        #   - Determine pagination between assignments.
+        #   - Determine how many assignments should be bundled into a single PDF.
+        # TODO:
+        #    Probably good to do things like separate this up into several vars, each
+        #    with one state, and use REGEXPs at inclusion time to set state names
+        #    and next states for better mix and match capability
+        #
+
+	my $resource_selector=<<RESOURCE_SELECTOR;
     <state name="SELECT_RESOURCES" title="Select Resources">
     $randomly_ordered_warning
     <nextstate>PRINT_FORMATTING</nextstate>
@@ -4665,6 +4752,7 @@
 
     # FIXME: That RE should come from a library somewhere.
     if (($perm{'pav'} 
+        && ($subdir ne '') 
 	&& $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/'
 	&& (defined($helper->{'VARS'}->{'construction'})
 	    ||
@@ -4698,14 +4786,118 @@
 
     # Allow the user to select any sequence in the course, feed it to
     # another resource selector for that sequence
-    if (!$helper->{VARS}->{'construction'} && !$is_published) {
-	push @$printChoices, [&mtn("Selected <b>Resources</b> from <b>selected folder</b> in course"),
-			      'select_sequences', 'CHOOSE_SEQUENCE'];
-	my $escapedSequenceName = $helper->{VARS}->{'SEQUENCE'};
-	#Escape apostrophes and backslashes for Perl
-	$escapedSequenceName =~ s/\\/\\\\/g;
-	$escapedSequenceName =~ s/'/\\'/g;
-	&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_FROM_ANY_SEQUENCE);
+    if ((!$helper->{VARS}->{'construction'}) &&
+        (!$is_published || (($subdir eq '') && ($url eq '/adm/navmaps')))) {
+        push @$printChoices, [&mtn("Selected <b>Resources</b> from <b>selected folder</b> in course"),
+                              'select_sequences', 'CHOOSE_SEQUENCE'];
+        my $escapedSequenceName;
+        if ($helper->{VARS}->{'SEQUENCE'} ne '') {
+            $escapedSequenceName = $helper->{VARS}->{'SEQUENCE'};
+        } elsif (($subdir eq '') && ($url eq '/adm/navmaps')) {
+            my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+            my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+            if ($env{'course.'.$env{'request.course.id'}.'.url'} eq
+                "uploaded/$cdom/$cnum/default.sequence") {
+                $escapedSequenceName = $env{'course.'.$env{'request.course.id'}.'.url'};
+            }
+        }
+        #Escape apostrophes and backslashes for Perl
+        $escapedSequenceName =~ s/\\/\\\\/g;
+        $escapedSequenceName =~ s/'/\\'/g;
+        if (($subdir eq '') && ($url eq '/adm/navmaps')) {
+            if ($perm{'pfo'})) {
+                push(@{$printChoices},
+                    [&mt('Selected [_1]Problems[_2] from [_3]selected folder[_4] in course for [_5]selected people[_6]',
+                         '<b>','</b>','<b>','</b>','<b>','</b>'),
+                         'select_sequences_problems_for_students','CHOOSE_SEQUENCE_STUDENTS'],
+                    [&mt('Selected [_1]Problems[_2] from [_3]selected folder[_4] in course  for [_5]CODEd assignments[_6]',
+                         '<b>','</b>','<b>','</b>','<b>','</b>'),
+                         'select_sequences_problems_for_anon','CHOOSE_SEQUENCE_ANON1'],
+                    [&mt('Selected [_1]Resources[_2] from [_3]selected folder[_4] in course for [_5]selected people[_6]',
+                         '<b>','</b>','<b>','</b>','<b>','</b>'),
+                         'select_sequences_resources_for_students','CHOOSE_SEQUENCE_STUDENTS1'],
+                    [&mt('Selected [_1]Resources[_2] from [_3]selected folder[_4] in course for [_5]CODEd assignments[_6]',
+                         '<b>','</b>','<b>','</b>','<b>','</b>'),
+                         'select_sequences_resources_for_anon','CHOOSE_SEQUENCE_ANON2'],
+                    [&mt('Selected [_1]Resources[_2] from [_3]selected folder[_4] in course',
+                         '<b>','</b>','<b>','</b>'),
+                         'select_sequences','CHOOSE_SEQUENCE']);
+                if ($escapedSequenceName) {
+                    &generate_common_choosers($r,$helper,$escapedSequenceName,$escapedSequenceName,$isProblem,$symbFilter,$start_new_option);
+                }
+            } else {
+                push(@{$printChoices},
+                [&mt('Selected [_1]Resources[_2] from [_3]selected folder[_4] in course',
+                     '<b>','</b>','<b>','</b>'),
+                     'select_sequences','CHOOSE_SEQUENCE']);
+            }
+        }
+        if (($subdir eq '') && ($url eq '/adm/navmaps') && ($perm{'pfo'})) {
+           &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_FROM_ANY_SEQUENCE);
+  <state name="CHOOSE_SEQUENCE" title="Select Sequence To Print From">
+    <message>Select the sequence to print resources from:</message>
+    <resource variable="SEQUENCE">
+      <nextstate>CHOOSE_FROM_ANY_SEQUENCE</nextstate>
+      <filterfunc>return &Apache::lonprintout::printable_sequence(\$res);</filterfunc>
+      <valuefunc>return $urlValue;</valuefunc>
+      <choicefunc>return \$res->hasResource(\$res,sub { return !\$_[0]->is_sequence() },0,0);
+        </choicefunc>
+      </resource>
+    </state>
+  <state name="CHOOSE_SEQUENCE_STUDENTS" title="Select Sequence To Print From">
+    <message>Select the sequence to print resources from:</message>
+    <resource variable="SEQUENCE">
+      <nextstate>CHOOSE_STUDENTS</nextstate>
+      <filterfunc>return &Apache::lonprintout::printable_sequence(\$res);</filterfunc>
+      <valuefunc>return $urlValue;</valuefunc>
+      <choicefunc>return \$res->hasResource(\$res,sub { return !\$_[0]->is_sequence() },0,0);
+        </choicefunc>
+      </resource>
+    </state>
+  <state name="CHOOSE_SEQUENCE_ANON1" title="Select Sequence To Print From">
+    <message>Select the sequence to print resources from:</message>
+    <resource variable="SEQUENCE">
+      <nextstate>CHOOSE_ANON1</nextstate>
+      <filterfunc>return &Apache::lonprintout::printable_sequence(\$res);</filterfunc>
+      <valuefunc>return $urlValue;</valuefunc>
+      <choicefunc>return \$res->hasResource(\$res,sub { return !\$_[0]->is_sequence() },0,0);
+        </choicefunc>
+      </resource>
+    </state>
+  <state name="CHOOSE_SEQUENCE_STUDENTS1" title="Select Sequence To Print From">
+    <message>Select the sequence to print resources from:</message>
+    <resource variable="SEQUENCE">
+      <nextstate>CHOOSE_STUDENTS</nextstate>
+      <filterfunc>return &Apache::lonprintout::printable_sequence(\$res);</filterfunc>
+      <valuefunc>return $urlValue;</valuefunc>
+      <choicefunc>return \$res->hasResource(\$res,sub { return !\$_[0]->is_sequence() },0,0);
+        </choicefunc>
+      </resource>
+    </state>
+  <state name="CHOOSE_SEQUENCE_ANON2" title="Select Sequence To Print From">
+    <message>Select the sequence to print resources from:</message>
+    <resource variable="SEQUENCE">
+      <nextstate>CHOOSE_ANON1</nextstate>
+      <filterfunc>return &Apache::lonprintout::printable_sequence(\$res);</filterfunc>
+      <valuefunc>return $urlValue;</valuefunc>
+      <choicefunc>return \$res->hasResource(\$res,sub { return !\$_[0]->is_sequence() },0,0);
+        </choicefunc>
+      </resource>
+    </state>
+  <state name="CHOOSE_FROM_ANY_SEQUENCE" title="Select Resources To Print">
+    <message>(mark desired resources then click "next" button) <br /></message>
+    <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"
+              closeallpages="1" modallink="1">
+      <nextstate>PAGESIZE</nextstate>
+      <filterfunc>return $isNotMap</filterfunc>
+      <mapurl evaluate='1'>return '$escapedSequenceName';</mapurl>
+      <valuefunc>return $symbFilter;</valuefunc>
+      $start_new_option
+      </resource>
+    </state>
+CHOOSE_FROM_ANY_SEQUENCE
+        } else {
+	    &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_FROM_ANY_SEQUENCE);
   <state name="CHOOSE_SEQUENCE" title="Select Sequence To Print From">
     <message>Select the sequence to print resources from:</message>
     <resource variable="SEQUENCE">
@@ -4728,8 +4920,8 @@
       </resource>
     </state>
 CHOOSE_FROM_ANY_SEQUENCE
-}
-
+        }
+    }
     my $numchoices = 0;
     if (ref($printChoices) eq 'ARRAY') {
         $numchoices = @{$printChoices};
Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.1028 doc/loncapafiles/loncapafiles.lpml:1.1029
--- doc/loncapafiles/loncapafiles.lpml:1.1028	Fri May  6 19:36:10 2022
+++ doc/loncapafiles/loncapafiles.lpml	Sat Jun 11 14:51:49 2022
@@ -2,7 +2,7 @@
  "http://lpml.sourceforge.net/DTD/lpml.dtd">
 <!-- loncapafiles.lpml -->
 
-<!-- $Id: loncapafiles.lpml,v 1.1028 2022/05/06 19:36:10 raeburn Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.1029 2022/06/11 14:51:49 raeburn Exp $ -->
 
 <!--
 
@@ -8347,6 +8347,7 @@
 nothumb.gif;
 open-all-folders.gif;
 open-first-problem.gif;
+printout.gif;
 qempty.gif;
 refresh.gif;
 show-all.gif;


More information about the LON-CAPA-cvs mailing list