--- loncom/interface/lonprintout.pm 2012/10/12 13:48:08 1.620 +++ loncom/interface/lonprintout.pm 2013/06/01 00:22:37 1.632 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.620 2012/10/12 13:48:08 raeburn Exp $ +# $Id: lonprintout.pm,v 1.632 2013/06/01 00:22:37 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -149,8 +149,7 @@ sub printable_sequence { # Return: # XML that can be parsed by the helper to drive the state machine. # -sub create_incomplete_folder_selstud_helper($helper) -{ +sub create_incomplete_folder_selstud_helper { my ($helper, $map) = @_; @@ -705,11 +704,14 @@ sub incomplete { # to only those that are in the original set selcted to be printed. # # Parameters: -# $helper - The helper we need $helper->{'VARS'}->{'symb'} -# to construct the navmap and the iteration. -# $seq - The original set of resources to print +# $map - The URL of the folder being printed. +# Used to determine which startResource and finishResource +# to use when using the navmap's getIterator method. +# $seq - The original set of resources to print. # (really an array of resource names (array of symb's). # $who - Student/domain for whome the sequence will be generated. +# $code - CODE being printed when printing Problems/Resources +# from folder for CODEd assignments # # Implicit inputs: # $ @@ -718,33 +720,40 @@ sub incomplete { # print_resources. # sub master_seq_to_person_seq { - my ($helper, $seq, $who) = @_; + my ($map, $seq, $who, $code, $nohidemap) = @_; my ($username, $userdomain, $usersection) = split(/:/, $who); - # Toss the sequence up into a hash so that we have O(1) lookup time. # on the items that come out of the user's list of resources. # - + my %seq_hash = map {$_ => 1} @$seq; my @output_seq; + + my $unhidden; + if ($perm{'pav'} && $perm{'vgr'} && $nohidemap) { + $unhidden = &Apache::lonnet::clutter($map); + } - my ($map, $id, $url) = &Apache::lonnet::decode_symb($helper->{VARS}->{'symb'}); - my $navmap = Apache::lonnavmaps::navmap->new($username, $userdomain); - my $iterator = $navmap->getIterator($navmap->firstResource(), - $navmap->finishResource(), - {}, 1); - my %nonResourceItems = ( - $iterator->BEGIN_MAP => 1, - $iterator->BEGIN_BRANCH => 1, - $iterator->END_BRANCH => 1, - $iterator->END_MAP => 1, - $iterator->FORWARD => 1, - $iterator->BACKWARD => 1 + my $navmap = Apache::lonnavmaps::navmap->new($username, $userdomain, + $code, $unhidden); + my ($start,$finish); + + if ($map) { + my $mapres = $navmap->getResourceByUrl($map); + if ($mapres->is_map()) { + $start = $mapres->map_start(); + $finish = $mapres->map_finish(); + } + } + unless ($start && $finish) { + $start = $navmap->firstResource(); + $finish = $navmap->finishResource(); + } - ); # These items are not resources but appear in the midst of iteration. + my $iterator = $navmap->getIterator($start,$finish,{},1); # Iterate on the resource..select the items that are randomly selected # and that are in the seq_has. Presumably the iterator will take care @@ -756,15 +765,13 @@ sub master_seq_to_person_seq { # Only process resources..that are not removed by randomout... # and are selected for printint as well. # - - if (! exists $nonResourceItems{$curres} && ! $curres->randomout()) { - my $symb = $curres->symb(); - if (exists $seq_hash{$symb}) { - push(@output_seq, $symb); + if (ref($curres) && ! $curres->randomout()) { + my $currsymb = $curres->symb(); + if (exists($seq_hash{$currsymb})) { + push(@output_seq, $currsymb); } } } - return \@output_seq; # for now. @@ -2060,6 +2067,7 @@ sub unsupported { my $result.= &print_latex_header($mode); if ($currentURL=~m|^(/adm/wrapper/)?ext/|) { $currentURL=~s|^(/adm/wrapper/)?ext/|http://|; + $currentURL=~s|^http://https://|https://|; my $title=&Apache::lonnet::gettitle($symb); $title = &Apache::lonxml::latex_special_symbols($title); $result.=' \strut \\\\ '.$title.' \strut \\\\ '.$currentURL.' '; @@ -2139,6 +2147,8 @@ sub print_page_in_course { my @page_resources = $navmap->retrieveResources($resource_src); $result .= &print_page_in_course($helper, $rparmhash, $resource_src, \@page_resources); + } elsif ($resource->ext()) { + $result .= &unsupported($currentURL,$mode,$symb); } # these resources go through the XML transformer: @@ -2605,6 +2615,7 @@ sub print_construction_sequence { # For item 100, filtering was done at the helper level. sub output_data { + my ($r,$helper,$rparmhash) = @_; my %parmhash = %$rparmhash; $ssi_error = 0; # This will be set nonzero by failing ssi's. @@ -2878,7 +2889,6 @@ ENDPART ($print_type eq 'select_sequences') or ($print_type eq 'map_incomplete_problems_seq') ) { - #-- produce an output string if (($print_type eq 'map_problems') or @@ -3141,6 +3151,12 @@ ENDPART } my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; + my $map; + if ($helper->{VARS}->{'symb'}) { + ($map, my $id, my $resource) = + &Apache::lonnet::decode_symb($helper->{VARS}->{'symb'}); + } + #loop over students my $flag_latex_header_remove = 'NO'; @@ -3175,7 +3191,8 @@ ENDPART } else { $i=int($student_counter/$helper->{'VARS'}{'NUMBER_TO_PRINT'}); } - my $actual_seq = master_seq_to_person_seq($helper, \@master_seq, $person); + my $actual_seq = master_seq_to_person_seq($map, \@master_seq, + $person, undef, 1); my ($output,$fullname, $printed)=&print_resources($r,$helper, $person,$type, \%moreenv, $actual_seq, @@ -3201,7 +3218,6 @@ ENDPART 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); @@ -3218,6 +3234,19 @@ ENDPART } } } + my ($randomorder,$randompick,$map); + if ($helper->{VARS}{'symb'}) { + ($map, my $id, my $resource) = + &Apache::lonnet::decode_symb($helper->{VARS}{'symb'}); + my $navmap = Apache::lonnavmaps::navmap->new(); + if (defined($navmap)) { + if ($map) { + my $mapres = $navmap->getResourceByUrl($map); + $randomorder = $mapres->randomorder(); + $randompick = $mapres->randompick(); + } + } + } my %moreenv = ('textwidth' => &get_textwidth($helper,$LaTeXwidth)); $moreenv{'problem_split'} = $parmhash{'problem_stream_switch'}; $moreenv{'instructor_comments'}='hide'; @@ -3279,9 +3308,17 @@ ENDPART } else { $moreenv{'CODE'}=&num_to_letters($code); } + my $actual_seq = \@master_seq; + if ($randomorder || $randompick) { + $env{'form.CODE'} = $moreenv{'CODE'}; + $actual_seq = master_seq_to_person_seq($map, \@master_seq, + undef, + $moreenv{'CODE'}, 1); + 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; @@ -3533,7 +3570,6 @@ sub print_resources { my $namepostfix = "\\\\"; # Both anon and not anon should get the same vspace. - # # Figure out if we need to filter the output by # the incomplete problems for that person @@ -3800,7 +3836,6 @@ sub handler { } &init_perm(); - my $helper = printHelper($r); if (!ref($helper)) { return $helper; @@ -4219,7 +4254,7 @@ sub printHelper { 'RESOURCES', 'PAGESIZE', $map, - ! $isProblem, '', + $isProblem, '', $symbFilter, $start_new_option); $helperFragment .= &generate_resource_chooser('CHOOSE_PROBLEMS_HTML', @@ -4627,8 +4662,9 @@ CHOOSE_FROM_ANY_SEQUENCE if (!$res_printable) { $paramHash = Apache::lonhelper::getParamHash(); $paramHash->{MESSAGE_TEXT} = - &mt('

Printing for current resource is only possible between [_1] and [_1]

', - $res_printstartdate, $res_printenddate); + '

' + .&mt('Printing for current resource is only possible between [_1] and [_2]', + $res_printstartdate, $res_printenddate).'

'; Apache::lonhelper::message->new(); } $paramHash = Apache::lonhelper::getParamHash(); @@ -4853,7 +4889,7 @@ FONT_SELECTION return "$helper->{VARS}->{'probstatus'}"; Homework Problem - Exam Problem + Bubblesheet Exam Problem Survey question ,choice computer="anonsurvey"Anonymous survey question