--- loncom/interface/lonprintout.pm 2005/12/06 16:23:26 1.403
+++ loncom/interface/lonprintout.pm 2005/12/19 23:27:28 1.410
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.403 2005/12/06 16:23:26 albertel Exp $
+# $Id: lonprintout.pm,v 1.410 2005/12/19 23:27:28 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -750,15 +750,14 @@ sub details_for_menu {
sub latex_corrections {
-
- my ($number_of_columns,$result,$selectionmade) = @_;
+ my ($number_of_columns,$result,$selectionmade,$answer_mode) = @_;
# $result =~ s/\\includegraphics{/\\includegraphics\[width=\\minipagewidth\]{/g;
$result =~ s/\$number_of_columns/$number_of_columns/g;
- if ($selectionmade ne '1') {
- $result =~ s/(\\end{document})/\\strut\\vspace\*{-4 mm}\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License $1/;
+ if ($selectionmade eq '1' || $answer_mode eq 'only') {
+ $result =~ s/(\\end{document})/\\strut\\vskip 0 mm\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License $1/;
} else {
- $result =~ s/(\\end{document})/\\strut\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License $1/;
+ $result =~ s/(\\end{document})/\\strut\\vspace\*{-4 mm}\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License $1/;
}
$result =~ s/(\\end{longtable}\s*)(\\strut\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill})/$2$1/g;
$result =~ s/(\\end{longtable}\s*)\\strut\\newline/$1/g;
@@ -817,11 +816,12 @@ sub IndexCreation {
sub print_latex_header {
my $mode=shift;
- my $output='\documentclass[letterpaper]{article}';
+ my $output='\documentclass[letterpaper,twoside]{article}';
if (($mode eq 'batchmode') || (!$perm{'pav'})) {
$output.='\batchmode';
}
$output.='\newcommand{\keephidden}[1]{}\renewcommand{\deg}{$^{\circ}$}'."\n".
+ '\usepackage{multirow}'."\n".
'\usepackage{longtable}\usepackage{textcomp}\usepackage{makeidx}'."\n".
'\usepackage[dvips]{graphicx}\usepackage{epsfig}'."\n".
'\usepackage{wrapfig}'.
@@ -844,16 +844,19 @@ sub print_latex_header {
sub path_to_problem {
my ($urlp,$colwidth)=@_;
+ $urlp=&Apache::lonnet::clutter($urlp);
+
my $newurlp = '';
$colwidth=~s/\s*mm\s*$//;
#characters average about 2 mm in width
if (length($urlp)*2 > $colwidth) {
- my @elements = split '/',$urlp;
+ my @elements = split('/',$urlp);
my $curlength=0;
foreach my $element (@elements) {
+ if ($element eq '') { next; }
if ($curlength+(length($element)*2) > $colwidth) {
- $newurlp .= '|\vskip -1 mm \noindent \verb|';
- $curlength=0;
+ $newurlp .= '|\vskip -1 mm \verb|';
+ $curlength=length($element)*2;
} else {
$curlength+=length($element)*2;
}
@@ -1183,7 +1186,7 @@ ENDPART
} else {
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
$texversion.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}).'}\vskip 0 mm ';
- $texversion.=&path_to_problem ($currentURL,$LaTeXwidth);
+ $texversion.=&path_to_problem($urlp,$LaTeXwidth);
$texversion.='\vskip 1 mm '.$answer.'\end{document}';
}
}
@@ -1254,11 +1257,11 @@ ENDPART
$result.="\\newpage\n";
}
}
- my (undef,undef,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]);
+ my ($sequence,undef,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]);
$urlp=&Apache::lonnet::clutter($urlp);
$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
+
+ my $assignment=&Apache::lonxml::latex_special_symbols(&Apache::lonnet::gettitle($sequence),'header'); #title of the assignment which contains this problem
if ($selectionmade==7) {$helper->{VARS}->{'assignment'}=$assignment;}
if ($i==0) {$prevassignment=$assignment;}
my $texversion='';
@@ -1291,7 +1294,7 @@ ENDPART
} else {
if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library)$/) {
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
- $texversion.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($urlp).'}\vskip 0 mm ';
+ $texversion.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($master_seq[$i]).'}\vskip 0 mm ';
$texversion.=&path_to_problem ($urlp,$LaTeXwidth);
$texversion.='\vskip 1 mm '.$answer;
} else {
@@ -1399,7 +1402,8 @@ ENDPART
$person,$type,
\%moreenv,\@master_seq,
$flag_latex_header_remove,
- $LaTeXwidth);
+ $LaTeXwidth,
+ $number_of_columns);
$resources_printed .= ":";
$print_array[$i].=$output;
$student_names[$i].=$person.':'.$fullname.'_END_';
@@ -1575,8 +1579,14 @@ ENDPART
}
#-------------------------------------------------------- corrections for the different page formats
$result = &page_format_transformation($papersize,$laystyle,$numberofcolumns,$helper->{'VARS'}->{'PRINT_TYPE'},$result,$helper->{VARS}->{'assignment'},$helper->{'VARS'}->{'TABLE_CONTENTS'},$helper->{'VARS'}->{'TABLE_INDEX'},$selectionmade);
- $result = &latex_corrections($number_of_columns,$result,$selectionmade);
- for (my $i=1;$i<=$#print_array;$i++) {$print_array[$i] = &latex_corrections($number_of_columns,$print_array[$i],$selectionmade);}
+ $result = &latex_corrections($number_of_columns,$result,$selectionmade,
+ $helper->{'VARS'}->{'ANSWER_TYPE'});
+ for (my $i=1;$i<=$#print_array;$i++) {
+ $print_array[$i] =
+ &latex_corrections($number_of_columns,$print_array[$i],
+ $selectionmade,
+ $helper->{'VARS'}->{'ANSWER_TYPE'});
+ }
#changes page's parameters for the one column output
if ($numberofcolumns == 1) {
$result =~ s/\\textwidth\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textwidth= $helper->{'VARS'}->{'pagesize.width'} $helper->{'VARS'}->{'pagesize.widthunit'} /;
@@ -1698,7 +1708,7 @@ sub get_CODE {
sub print_resources {
my ($r,$helper,$person,$type,$moreenv,$master_seq,$remove_latex_header,
- $LaTeXwidth)=@_;
+ $LaTeXwidth,$number_of_columns)=@_;
my $current_output = '';
my $printed = '';
my ($username,$userdomain,$usersection) = split /:/,$person;
@@ -1750,7 +1760,7 @@ sub print_resources {
} else {
$rendered=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
$rendered.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($curresline).'}\vskip 0 mm ';
- $rendered.=&path_to_problem ($curresline,$LaTeXwidth);
+ $rendered.=&path_to_problem($res_url,$LaTeXwidth);
$rendered.='\vskip 1 mm '.$ansrendered;
}
}
@@ -1764,7 +1774,7 @@ sub print_resources {
$printed .= $curresline.':';
my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv);
my ($envfile) =
- ( $env{'user.environment'} = ~m|/([^/]+)\.id$| );
+ ( $env{'user.environment'} =~ m|/([^/]+)\.id$| );
&Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'),
$envfile);
my $current_counter=$env{'form.counter'};
@@ -1773,7 +1783,7 @@ sub print_resources {
} else {
$rendered =~ s/\\end{document}//;
}
- $current_output .= $rendered.'\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\strut \vskip 0 mm \strut ';
+ $current_output .= $rendered.'\vskip 0.5mm\noindent\makebox[\textwidth/'.$number_of_columns.'][b]{\hrulefill}\strut \vskip 0 mm \strut ';
} else {
my $rendered = &unsupported($res_url,$helper->{'VARS'}->{'LATEX_TYPE'});
if ($remove_latex_header ne 'NO') {
@@ -2169,16 +2179,16 @@ CHOOSE_STUDENTS
my %all_codes = &Apache::lonnet::get('CODEs',
\@names, $cdom,$cnum);
my %code_values;
- my @all_code_array;
- foreach my $key (keys %all_codes) {
+ my %codes_to_print;
+ foreach my $key (keys(%all_codes)) {
%code_values = &Apache::grades::get_codes($key, $cdom, $cnum);
- foreach my $key (keys %code_values) {
- push (@all_code_array, "$key");
+ foreach my $key (keys(%code_values)) {
+ $codes_to_print{$key} = 1;
}
}
my $code_selection = "\n";
- foreach my $code (sort {uc($a) cmp uc($b)} @all_code_array) {
+ 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);
@@ -2394,7 +2404,6 @@ CHOOSE_FROM_SUBDIR
return $urlValue;
return \$res->hasResource(\$res,sub { return !\$_[0]->is_sequence() },0,0);
-