--- loncom/interface/lonprintout.pm 2004/03/23 01:34:17 1.284 +++ loncom/interface/lonprintout.pm 2004/05/27 17:30:48 1.304 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.284 2004/03/23 01:34:17 albertel Exp $ +# $Id: lonprintout.pm,v 1.304 2004/05/27 17:30:48 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -421,13 +421,13 @@ sub page_format { } elsif($papersize eq '6') { if ($layout eq 'book') { if ($numberofcolumns == 1) { - $textwidth = '18 cm'; - $textheight = '28 cm'; + $textwidth = '176 mm'; + $textheight = '254 mm'; $oddoffset = '-0.57 in'; $evenoffset = '-0.57 in'; } elsif ($numberofcolumns == 2) { - $textwidth = '96 mm'; - $textheight = '2 cm'; + $textwidth = '91 mm'; + $textheight = '254 mm'; $oddoffset = '-0.57 in'; $evenoffset = '-0.57 in'; } @@ -661,6 +661,31 @@ sub recalcto_mm { return $LaTeXwidth; } +sub get_textwidth { + my ($helper,$LaTeXwidth)=@_; + my $textwidth=$LaTeXwidth; + if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ && + $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) { + $textwidth=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '. + $helper->{'VARS'}->{'pagesize.widthunit'}); + } + return $textwidth; +} + + +sub unsupported { + my $currentURL=shift; + my $result.='\documentclass[letterpaper]{article}\usepackage{calc}\begin{document}Printout of this type of document is currently not supported: '; + if ($currentURL=~/\/ext\//) { + $result.=' \strut \\\\ THIS IS EXTERNAL RESOURCE WITH URL \strut \\\\ '.$currentURL.' '; + } else { + $result.=$currentURL; + } + $result.= '\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill} \end{document}'; + return $result; +} + + sub output_data { my ($r,$helper,$rparmhash) = @_; my %parmhash = %$rparmhash; @@ -739,13 +764,9 @@ ENDPART my $put_result = &Apache::lonnet::put('environment',{'construct.style'=>$helper->{'VARS'}->{'style_file'}},$dom,$user); } my %form; + if ($helper->{'VARS'}->{'probstatus'} eq 'exam') {$form{'problemtype'}='exam';} $form{'grade_target'}='tex'; - if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ && - $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) { - $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'}); - } else { - $form{'textwidth'}=$LaTeXwidth; - } + $form{'textwidth'}=&get_textwidth($helper,$LaTeXwidth); $form{'problem_split'}=$parmhash{'problem_stream_switch'}; $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; if ($helper->{'VARS'}->{'curseed'}) { @@ -810,12 +831,7 @@ ENDPART if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') { my %form; $form{'grade_target'}='tex'; - if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ && - $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) { - $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'}); - } else { - $form{'textwidth'}=$LaTeXwidth; - } + $form{'textwidth'}=&get_textwidth($helper,$LaTeXwidth); $form{'problem_split'}=$parmhash{'problem_stream_switch'}; $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; $form{'rndseed'}=$rndseed; @@ -858,42 +874,34 @@ ENDPART } if ($helper->{VARS}->{'construction'} eq '1') {$result=~s/(\\begin{document})/$1 \\fbox\{RANDOM SEED IS $rndseed\} /;} $result .= '\end{document}'; - } elsif ($currentURL=~/\/smppg$/) { + } elsif ($currentURL=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { my %form; $form{'grade_target'}='tex'; - if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ && - $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) { - $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'}); - } else { - $form{'textwidth'}=$LaTeXwidth; - } + $form{'textwidth'}=&get_textwidth($helper,$LaTeXwidth); $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; + if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;} my $texversion=&Apache::lonnet::ssi($currentURL,%form); $result .= $texversion; } else { - $result.='\documentclass[letterpaper]{article}\usepackage{calc}\begin{document}Printout of this type of document is currently not supported: '; - if ($currentURL=~/\/(aboutme|syllabus|bulletinboard|smppg)$/) { - $result.=$1; - } elsif ($currentURL=~/\/ext\//) { - $result.=' \strut \\\\ THIS IS EXTERNAL RESOURCE WITH URL \strut \\\\ '.$currentURL.' '; - } else { - $result.=$currentURL; - } - $result.=' \end{document}' + $result.=&unsupported($currentURL); } } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') or ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') or ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') or ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences')) { #-- produce an output string + if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') { + $selectionmade = 2; + } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') { + $selectionmade = 3; + } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') { + $selectionmade = 4; + } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences') { + $selectionmade = 7; + } my %form=(); $form{'grade_target'}='tex'; - if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ && - $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) { - $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'}); - } else { - $form{'textwidth'}=$LaTeXwidth; - } + $form{'textwidth'}=&get_textwidth($helper,$LaTeXwidth); $form{'problem_split'}=$parmhash{'problem_stream_switch'}; $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; my $flag_latex_header_remove = 'NO'; @@ -905,71 +913,88 @@ ENDPART for (my $i=0;$i<=$#master_seq;$i++) { my (undef,undef,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]); $urlp=&Apache::lonnet::clutter($urlp); - if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') { - $selectionmade = 2; - } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') { - $selectionmade = 3; - } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') { - $selectionmade = 4; - } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences') { - $selectionmade = 7; - } $form{'symb'}=$master_seq[$i]; my ($sequence)=&Apache::lonnet::decode_symb($master_seq[$i]); my $assignment=&Apache::lonxml::latex_special_symbols(&Apache::lonnet::gettitle($sequence),'header'); #tittle of the assignment which contains this problem if ($selectionmade==7) {$helper->{VARS}->{'assignment'}=$assignment;} if ($i==0) {$prevassignment=$assignment;} #&Apache::lonnet::logthis("Trying to get $urlp with symb $master_seq[$i]"); - my $texversion.=&Apache::lonnet::ssi($urlp,%form); - if ($urlp=~/\.page$/) { - ($texversion,my $number_of_columns_page) = &page_cleanup($texversion); - if ($number_of_columns_page > $number_of_columns) {$number_of_columns=$number_of_columns_page;} - $texversion =~ s/\\end{document}\d*/\\end{document}/; - $flag_page_in_sequence = 'YES'; - } - my $lonidsdir=$r->dir_config('lonIDsDir'); - my $envfile=$ENV{'user.environment'}; - $envfile=~/\/([^\/]+)\.id$/; - $envfile=$1; - &Apache::lonnet::transfer_profile_to_env($lonidsdir,$envfile); - my $current_counter=$ENV{'form.counter'}; - if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || - ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) { - my %form; - $form{'grade_target'}='answer'; - $form{'answer_output_mode'}='tex'; - my $answer=&Apache::lonnet::ssi($urlp,%form); - &Apache::lonnet::appenv(('form.counter' => $current_counter)); - if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { - $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; - } else { - if ($urlp=~/\.(problem|exam|quiz|library)$/) { - $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); - $texversion.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($urlp).'}\vskip 0 mm '; - $texversion.=&path_to_problem ($urlp,$LaTeXwidth); - $texversion.='\vskip 1 mm '.$answer; + my $texversion=''; + if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { + $texversion.=&Apache::lonnet::ssi($urlp,%form); + if ($urlp=~/\.page$/) { + ($texversion,my $number_of_columns_page) = &page_cleanup($texversion); + if ($number_of_columns_page > $number_of_columns) {$number_of_columns=$number_of_columns_page;} + $texversion =~ s/\\end{document}\d*/\\end{document}/; + $flag_page_in_sequence = 'YES'; + } + my $lonidsdir=$r->dir_config('lonIDsDir'); + my $envfile=$ENV{'user.environment'}; + $envfile=~/\/([^\/]+)\.id$/; + $envfile=$1; + &Apache::lonnet::transfer_profile_to_env($lonidsdir,$envfile); + my $current_counter=$ENV{'form.counter'}; + if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || + ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) { + my %form; + $form{'grade_target'}='answer'; + $form{'answer_output_mode'}='tex'; + my $answer=&Apache::lonnet::ssi($urlp,%form); + &Apache::lonnet::appenv(('form.counter' => $current_counter)); + if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { + $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; } else { - $texversion=''; + if ($urlp=~/\.(problem|exam|quiz|library)$/) { + $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); + $texversion.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($urlp).'}\vskip 0 mm '; + $texversion.=&path_to_problem ($urlp,$LaTeXwidth); + $texversion.='\vskip 1 mm '.$answer; + } else { + $texversion=''; + } } } - } - if ($flag_latex_header_remove ne 'NO') { - $texversion = &latex_header_footer_remove($texversion); + if ($flag_latex_header_remove ne 'NO') { + $texversion = &latex_header_footer_remove($texversion); + } else { + $texversion =~ s/\\end{document}//; + } + if ($helper->{'VARS'}->{'TABLE_INDEX'} eq 'yes') { + $texversion=&IndexCreation($texversion,$urlp); + } + if (($selectionmade == 4) and ($assignment ne $prevassignment)) { + my $name = &get_name(); + my $courseidinfo = &get_course(); + if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } + $prevassignment=$assignment; + $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$name.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$assignment.'}}} \vskip -5 mm '; + } + $result .= $texversion; + $flag_latex_header_remove = 'YES'; + } elsif ($urlp=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { + my %form; + $form{'grade_target'}='tex'; + $form{'textwidth'}=&get_textwidth($helper,$LaTeXwidth); + $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; + if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;} + my $texversion=&Apache::lonnet::ssi($urlp,%form); + if ($flag_latex_header_remove ne 'NO') { + $texversion = &latex_header_footer_remove($texversion); + } else { + $texversion =~ s/\\end{document}/\\vskip 0\.5mm\\noindent\\makebox\[\\textwidth\/\$number_of_columns\]\[b\]\{\\hrulefill\}/; + } + $result .= $texversion; + $flag_latex_header_remove = 'YES'; } else { - $texversion =~ s/\\end{document}//; - } - if ($helper->{'VARS'}->{'TABLE_INDEX'} eq 'yes') { - $texversion=&IndexCreation($texversion,$urlp); - } - if (($selectionmade == 4) and ($assignment ne $prevassignment)) { - my $name = &get_name(); - my $courseidinfo = &get_course(); - if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } - $prevassignment=$assignment; - $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$name.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$assignment.'}}} \vskip -5 mm '; - } - $result .= $texversion; - $flag_latex_header_remove = 'YES'; + $texversion=&unsupported($urlp); + if ($flag_latex_header_remove ne 'NO') { + $texversion = &latex_header_footer_remove($texversion); + } else { + $texversion =~ s/\\end{document}//; + } + $result .= $texversion; + $flag_latex_header_remove = 'YES'; + } } &Apache::lonnet::delenv('form.counter'); if ($flag_page_in_sequence eq 'YES') {$result =~ s/\\usepackage{calc}/\\usepackage{calc}\\usepackage{longtable}/;} @@ -994,12 +1019,7 @@ ENDPART #loop over students my $flag_latex_header_remove = 'NO'; my %moreenv; - if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ && - $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) { - $moreenv{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'}); - } else { - $moreenv{'textwidth'}=$LaTeXwidth; - } + $moreenv{'textwidth'}=&get_textwidth($helper,$LaTeXwidth); my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1); my $student_counter=-1; foreach my $person (@students) { @@ -1015,10 +1035,54 @@ ENDPART $result .= $print_array[0].' \end{document}'; } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon') || ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_anon') ) { - $selectionmade="Seems to be useless"; + 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'}; + my $code_name=$helper->{'VARS'}->{'ANON_CODE_STORAGE_NAME'}; + my $old_name=$helper->{'VARS'}->{'REUSE_OLD_CODES'}; my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; - - } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_from_directory') { + my ($type) = split(/_/,$helper->{'VARS'}->{'PRINT_TYPE'}); + my $number_per_page=$helper->{'VARS'}->{'NUMBER_TO_PRINT'}; + if ($number_per_page eq '0' || $number_per_page eq 'all') { + $number_per_page=$num_todo; + } + my $flag_latex_header_remove = 'NO'; + my %moreenv = ('textwidth' => &get_textwidth($helper,$LaTeXwidth)); + my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$num_todo,'inline','75'); + my $seed=time+($$<<16)+($$); + my @allcodes; + if ($old_name) { + my %result=&Apache::lonnet::get('CODEs',[$old_name],$cdom,$cnum); + @allcodes=split(',',$result{$old_name}); + } else { + my %allcodes; + srand($seed); + for (my $i=0;$i<$num_todo;$i++) { + $moreenv{'CODE'}=&get_CODE(\%allcodes,$i,$seed,'6'); + } + if ($code_name) { + &Apache::lonnet::put('CODEs', + {$code_name =>join(',',keys(%allcodes))}, + $cdom,$cnum); + } + @allcodes=keys(%allcodes); + } + my $count=0; + foreach my $code (sort(@allcodes)) { + my $file_num=int($count/$number_per_page); + $moreenv{'CODE'}=&num_to_letters($code); + my ($output,$fullname)= + &print_resources($r,$helper,'anonymous',$type,\%moreenv, + \@master_seq,$flag_latex_header_remove); + $print_array[$file_num].=$output; + &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, + &mt('last assignment').' '.$fullname); + $flag_latex_header_remove = 'YES'; + $count++; + } + &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); + $result .= $print_array[0].' \end{document}'; + } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_from_directory') { #prints selected problems from the subdirectory $selectionmade = 6; my @list_of_files=split /\|\|\|/, $helper->{'VARS'}->{'FILES'}; @@ -1034,17 +1098,12 @@ ENDPART if ($urlp=~/\//) { my %form; $form{'grade_target'}='tex'; - if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ && - $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) { - $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'}); - } else { - $form{'textwidth'}=$LaTeXwidth; - } + $form{'textwidth'}=&get_textwidth($helper,$LaTeXwidth); $form{'rndseed'}=$rndseed; if ($urlp =~ m|/home/([^/]+)/public_html|) { $urlp =~ s|/home/([^/]*)/public_html|/~$1|; } else { - $urlp =~ s|^/home/httpd/html||; + $urlp =~ s|^$Apache::lonnet::perlvar{'lonDocRoot'}||; } my $texversion=&Apache::lonnet::ssi($urlp,%form); if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || @@ -1172,6 +1231,7 @@ ENDPART &Apache::lonnet::appenv('cgi.'.$identifier.'.file' => $filename, 'cgi.'.$identifier.'.layout' => $laystyle, 'cgi.'.$identifier.'.numcol' => $numberofcolumns, + 'cgi.'.$identifier.'.paper' => $papersize, 'cgi.'.$identifier.'.selection' => $selectionmade, 'cgi.'.$identifier.'tableofcontents' => $helper->{'VARS'}->{'TABLE_CONTENTS'}, 'cgi.'.$identifier.'tableofindex' => $helper->{'VARS'}->{'TABLE_INDEX'}, @@ -1181,19 +1241,42 @@ ENDPART 'cgi.'.$identifier.'backref' => $URLback,); $r->print(< + FINALEND } +sub num_to_letters { + my ($num) = @_; + my @nums= split('',$num); + my @num_to_let=('A'..'Z'); + my $word; + foreach my $digit (@nums) { $word.=$num_to_let[$digit]; } + return $word; +} + +sub get_CODE { + my ($all_codes,$num,$seed,$size)=@_; + my $max='1'.'0'x$size; + my $newcode; + while(1) { + $newcode=sprintf("%06d",int(rand($max))); + if (!exists($$all_codes{$newcode})) { + $$all_codes{$newcode}=1; + return &num_to_letters($newcode); + } + } +} sub print_resources { my ($r,$helper,$person,$type,$moreenv,$master_seq,$remove_latex_header)=@_; my $current_output = ''; my ($username,$userdomain,$usersection) = split /:/,$person; my $fullname = &get_name($username,$userdomain); - + if ($person =~ 'anon') { + $fullname = "CODE - ".$moreenv->{'CODE'}; + } #goes through all resources, checks if they are available for #current student, and produces output &Apache::lonnet::delenv('form.counter'); @@ -1337,7 +1420,8 @@ sub printHelper { my $helper = Apache::lonhelper::helper->new("Printing Helper"); $helper->declareVar('symb'); $helper->declareVar('postdata'); - $helper->declareVar('curseed'); + $helper->declareVar('curseed'); + $helper->declareVar('probstatus'); $helper->declareVar('filename'); $helper->declareVar('construction'); $helper->declareVar('assignment'); @@ -1397,6 +1481,9 @@ sub printHelper { if (!$helper->{VARS}->{'curseed'} && $ENV{'form.curseed'}) { $helper->{VARS}->{'curseed'}=$ENV{'form.curseed'}; } + if (!$helper->{VARS}->{'probstatus'} && $ENV{'form.problemtype'}) { + $helper->{VARS}->{'probstatus'}=$ENV{'form.problemtype'}; + } my $userCanSeeHidden = Apache::lonnavmaps::advancedUser(); my $userPriviledged = ($ENV{'request.role'}=~m/^cc\./ or @@ -1408,7 +1495,7 @@ sub printHelper { # "Delete everything after the last slash." $subdir =~ s|/[^/]+$||; if (not $helper->{VARS}->{'construction'}) { - $subdir='/home/httpd/html/res/'.$subdir; + $subdir=$Apache::lonnet::perlvar{'lonDocRoot'}.'/res/'.$subdir; } # "Remove all duplicate slashes." $subdir =~ s|/+|/|g; @@ -1428,16 +1515,14 @@ sub printHelper { my $paramHash; if ($resourceTitle) { - push @{$printChoices}, ["$resourceTitle (what you just saw on the screen)", 'current_document', 'PAGESIZE']; + push @{$printChoices}, ["$resourceTitle (".&mt('what you just saw on the screen').")", 'current_document', 'PAGESIZE']; } -# $r->print($helper->{VARS}->{'postdata'}); - # Useful filter strings - my $isProblem = '$res->is_problem()'; + my $isProblem = '($res->is_problem()||$res->contains_problem) '; $isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden; - my $isProblemOrMap = '$res->is_problem() || $res->is_map()'; - my $isNotMap = '!$res->is_map()'; + my $isProblemOrMap = '$res->is_problem() || $res->contains_problem() || $res->is_sequence()'; + my $isNotMap = '!$res->is_sequence()'; $isNotMap .= ' && !$res->randomout()' if !$userCanSeeHidden; my $isMap = '$res->is_map()'; my $symbFilter = '$res->symb()'; @@ -1454,14 +1539,15 @@ sub printHelper { $helper->{VARS}->{'postdata'} && $helper->{VARS}->{'assignment'}) { # Allow problems from sequence - push @{$printChoices}, ["Problems in $sequenceTitle", 'map_problems', 'CHOOSE_PROBLEMS']; + push @{$printChoices}, ["".&mt('Problems')." ".&mt('in')." $sequenceTitle", 'map_problems', 'CHOOSE_PROBLEMS']; # Allow all resources from sequence - push @{$printChoices}, ["Resources in $sequenceTitle", 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML']; + push @{$printChoices}, ["".&mt('Resources')." ".&mt('in')." $sequenceTitle", 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML']; my $helperFragment = < (mark them then click "next" button)
- + PAGESIZE return $isProblem; $map @@ -1471,7 +1557,8 @@ sub printHelper { (mark them then click "next" button)
- + PAGESIZE return $isNotMap; $map @@ -1490,23 +1577,24 @@ HELPERFRAGMENT &Apache::lonxml::xmlparse($r, 'helper', < (mark them then click "next" button)
- + PAGESIZE return $isProblemOrMap; - return $isProblem; + return $isNotMap; return $symbFilter;
ALL_PROBLEMS if ($helper->{VARS}->{'assignment'}) { - push @{$printChoices}, ["Problems from $sequenceTitle for selected students", 'problems_for_students', 'CHOOSE_STUDENTS']; - push @{$printChoices}, ["Problems from $sequenceTitle for anonymous students", 'problems_for_anonymous', 'CHOOSE_ANON1']; + push @{$printChoices}, ["".&mt('Problems')." ".&mt('from')." $sequenceTitle ".&mt('for')." ".&mt('selected students')."", 'problems_for_students', 'CHOOSE_STUDENTS']; + push @{$printChoices}, ["".&mt('Problems')." ".&mt('from')." $sequenceTitle ".&mt('for')." ".&mt('anonymous students')."", 'problems_for_anon', 'CHOOSE_ANON1']; } my $resource_selector=<
Select resources for the assignment
- + return $isProblem; $map return $symbFilter; @@ -1528,10 +1616,27 @@ RESOURCE_SELECTOR $resource_selector CHOOSE_STUDENTS + + 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=''; + foreach my $name (@names) { + if ($name =~ /^error: 2 /) { next; } + $namechoice.=''.$name.''; + } &Apache::lonxml::xmlparse($r, 'helper', < -
How many Anonymous exams to print?
+ PAGESIZE +
Number of anonymous assignments to print?
+
Names to store the CODEs under for later:
+ +
+ Reprint a set of saved CODEs: + + $namechoice +
$resource_selector @@ -1539,14 +1644,15 @@ CHOOSE_ANON1 if ($helper->{VARS}->{'assignment'}) { - push @{$printChoices}, ["Resources from $sequenceTitle for selected students", 'resources_for_students', 'CHOOSE_STUDENTS1']; - push @{$printChoices}, ["Resources from $sequenceTitle for anonymous students", 'resources_for_anonymous', 'CHOOSE_ANON2']; + push @{$printChoices}, ["".&mt('Resources')." ".&mt('from')." $sequenceTitle ".&mt('for')." ".&mt('selected students')."", 'resources_for_students', 'CHOOSE_STUDENTS1']; + push @{$printChoices}, ["".&mt('Resources')." ".&mt('from')." $sequenceTitle ".&mt('for')." ".&mt('anonymous students')."", 'resources_for_anon', 'CHOOSE_ANON2']; } $resource_selector=<
Select resources for the assignment
- + return $isNotMap; $map return $symbFilter; @@ -1571,8 +1677,16 @@ CHOOSE_STUDENTS1 &Apache::lonxml::xmlparse($r, 'helper', < -
How many Anonymous exams to print?
+ PAGESIZE +
Number of anonymous assignments to print?
+
Names to store the CODEs under for later:
+ +
+ Reprint a set of saved CODEs: + + $namechoice +
$resource_selector @@ -1580,8 +1694,8 @@ CHOOSE_ANON2 } # FIXME: That RE should come from a library somewhere. - if ((((&Apache::lonnet::allowed('bre',$subdir) eq 'F') and ($helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)) or defined $helper->{'VARS'}->{'construction'}) and $ENV{'request.role.adv'} and $subdir ne '/home/httpd/html/res/') { - push @{$printChoices}, ["Problems from current subdirectory $subdir", 'problems_from_directory', 'CHOOSE_FROM_SUBDIR']; + if ((((&Apache::lonnet::allowed('bre',$subdir) eq 'F') and ($helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)) or defined $helper->{'VARS'}->{'construction'}) and $ENV{'request.role.adv'} and $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/') { + push @{$printChoices}, ["".&mt('Problems')." ".&mt('from current subdirectory')." $subdir", 'problems_from_directory', 'CHOOSE_FROM_SUBDIR']; my $f = '$filename'; my $xmlfrag = < (mark desired resources then click "next" button)
- + PAGESIZE return $isProblem return '$escapedSequenceName'; @@ -1657,7 +1772,9 @@ CHOOSE_FROM_ANY_SEQUENCE $paramHash->{CHOICES} = [ ['Without Answers', 'yes'], ['With Answers', 'no'], - ['Only Answers', 'only'] ]; + ['Only Answers', 'only'], + ['As Exam Problem', 'exam'] + ]; Apache::lonhelper::dropdown->new(); addMessage(""); $startedTable = 1; @@ -1709,7 +1826,7 @@ CHOOSE_FROM_ANY_SEQUENCE if ($helper->{'VARS'}->{'construction'}) { my $stylevalue=$ENV{'construct.style'}; my $xmlfrag .= <<"RNDSEED"; - Use random seed: + Use random seed: return $helper->{VARS}->{'curseed'}; @@ -1850,9 +1967,12 @@ STATEHTML $result .= "\n"; $result .= "