+ '.$/;
+ }
+
+ 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.=''.$description.'';
+ }
+ }
+ if ($codechoice eq '') {
+ $codechoice='Default';
+ }
+ 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)
@@ -457,7 +588,9 @@ sub generate_format_selector {
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 = 'Each PDF contains exactly one section';
}
return <>$Apache::lonnet::perlvar{'lonPrtDir'}/$env{'user.name'}_$env{'user.domain'}_printout.dat");
+ open(FILE,">>","$Apache::lonnet::perlvar{'lonPrtDir'}/$env{'user.name'}_$env{'user.domain'}_printout.dat");
print FILE ("$file\n");
close (FILE);
@@ -921,13 +1058,13 @@ sub include_pdf {
sub collect_languages {
my $doc = shift;
my %languages;
- while ($doc =~ /\\selectlanguage{(\w+)}/mg) {
+ while ($doc =~ /\\selectlanguage\{(\w+)}/mg) {
$languages{$1} = 1; # allows us to request each language exactly once.
}
my @lang_list = (keys(%languages)); # List of unique languages
if (scalar @lang_list) {
my $babel_header = '\usepackage[' . join(',', @lang_list) .']{babel}'. "\n";
- $doc =~ s/\\begin{document}/$babel_header\\begin{document}/;
+ $doc =~ s/\\begin\{document}/$babel_header\\begin{document}/;
}
return $doc;
}
@@ -1229,8 +1366,9 @@ sub is_valid_alpha_code {
sub is_code_valid {
my ($code_value, $code_option) = @_;
my ($code_type, $code_length) = ('letter', 6); # defaults.
- my @lines = &Apache::grades::get_scantronformat_file();
+ my @lines = &Apache::lonnet::get_scantronformat_file();
foreach my $line (@lines) {
+ next if (($line =~ /^\#/) || ($line eq ''));
my ($name, $type, $length) = (split(/:/, $line))[0,2,4];
if($name eq $code_option) {
$code_length = $length;
@@ -1324,8 +1462,8 @@ sub compare_names {
sub latex_header_footer_remove {
my $text = shift;
- $text =~ s/\\end{document}//;
- $text =~ s/\\documentclass([^&]*)\\begin{document}//;
+ $text =~ s/\\end\{document}//;
+ $text =~ s/\\documentclass([^&]*)\\begin\{document}//;
return $text;
}
#
@@ -1334,8 +1472,8 @@ sub latex_header_footer_remove {
# necessity is determined by the problem_split param.
#
sub encapsulate_minipage {
- my ($text) = @_;
- if (!($env{'form.problem.split'} =~ /yes/i)) {
+ my ($text,$problem_split) = @_;
+ if (!($problem_split =~ /yes/i)) {
$text = '\begin{minipage}{\textwidth}'.$text.'\end{minipage}';
}
return $text;
@@ -1875,12 +2013,12 @@ sub page_format_transformation {
$fancypagestatement="\\rhead{}\\chead{}\\lhead{$header_text}";
}
if ($layout eq 'album') {
- $text =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}$topmargintoinsert\n\\setlength{\\textwidth}{$textwidth}\\setlength{\\textheight}{$textheight}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt}\n\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\usepackage{fancyhdr}\\addtolength{\\headheight}{\\baselineskip}\n\\pagestyle{fancy}$fancypagestatement\\usepackage{booktabs}\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1}\n /;
+ $text =~ s/\\begin\{document}/\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}$topmargintoinsert\n\\setlength{\\textwidth}{$textwidth}\\setlength{\\textheight}{$textheight}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt}\n\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\usepackage{fancyhdr}\\addtolength{\\headheight}{\\baselineskip}\n\\pagestyle{fancy}$fancypagestatement\\usepackage{booktabs}\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1}\n /;
} elsif ($layout eq 'book') {
if ($choice ne 'All class print') {
- $text =~ s/\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset $topmargintoinsert\n\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\n\\renewcommand{\\ref}{\\keephidden\}\\usepackage{fancyhdr}\\addtolength{\\headheight}{\\baselineskip}\\pagestyle{fancy}$fancypagestatement\\usepackage{booktabs}\\begin{document}\n\\voffset=-0\.8 cm\\setcounter{page}{1}\n/;
+ $text =~ s/\\begin\{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset $topmargintoinsert\n\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\n\\renewcommand{\\ref}{\\keephidden\}\\usepackage{fancyhdr}\\addtolength{\\headheight}{\\baselineskip}\\pagestyle{fancy}$fancypagestatement\\usepackage{booktabs}\\begin{document}\n\\voffset=-0\.8 cm\\setcounter{page}{1}\n/;
} else {
- $text =~ s/\\pagestyle{fancy}\\rhead{}\\chead{}\s*\\begin{document}/\\textheight = $textheight\\oddsidemargin = $evenoffset\n\\evensidemargin = $evenoffset $topmargintoinsert\\textwidth= $textwidth\\newlength{\\minipagewidth}\n\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\pagestyle{fancy}\\rhead{}\\chead{}\\usepackage{booktabs}\\begin{document}\\voffset=-0\.8cm\n\\setcounter{page}{1} \\vskip 5 mm\n /;
+ $text =~ s/\\pagestyle\{fancy}\\rhead\{}\\chead\{}\s*\\begin\{document}/\\textheight = $textheight\\oddsidemargin = $evenoffset\n\\evensidemargin = $evenoffset $topmargintoinsert\\textwidth= $textwidth\\newlength{\\minipagewidth}\n\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\pagestyle{fancy}\\rhead{}\\chead{}\\usepackage{booktabs}\\begin{document}\\voffset=-0\.8cm\n\\setcounter{page}{1} \\vskip 5 mm\n /;
}
if ($papersize eq 'a4') {
my $papersize_text;
@@ -1889,13 +2027,13 @@ sub page_format_transformation {
} else {
$papersize_text = '\special{papersize=210mm,297mm}';
}
- $text =~ s/(\\begin{document})/$1$papersize_text/;
+ $text =~ s/(\\begin\{document})/$1$papersize_text/;
}
}
if ($tableofcontents eq 'yes') {$text=~s/(\\setcounter\{page\}\{1\})/$1 \\tableofcontents\\newpage /;}
if ($indexlist eq 'yes') {
- $text=~s/(\\begin{document})/\\makeindex $1/;
- $text=~s/(\\end{document})/\\strut\\\\\\strut\\printindex $1/;
+ $text=~s/(\\begin\{document})/\\makeindex $1/;
+ $text=~s/(\\end\{document})/\\strut\\\\\\strut\\printindex $1/;
}
return $text;
}
@@ -1904,12 +2042,12 @@ sub page_format_transformation {
sub page_cleanup {
my $result = shift;
- $result =~ m/\\end{document}(\d*)$/;
+ $result =~ m/\\end\{document}(\d*)$/;
my $number_of_columns = $1;
my $insert = '{';
for (my $id=1;$id<=$number_of_columns;$id++) { $insert .='l'; }
$insert .= '}';
- $result =~ s/(\\begin{longtable})INSERTTHEHEADOFLONGTABLE\\endfirsthead\\endhead/$1$insert/g;
+ $result =~ s/(\\begin\{longtable})INSERTTHEHEADOFLONGTABLE\\endfirsthead\\endhead/$1$insert/g;
$result =~ s/&\s*REMOVETHEHEADOFLONGTABLE\\\\/\\\\/g;
return $result,$number_of_columns;
}
@@ -1945,16 +2083,16 @@ my $end_of_student = "\n".'\special{ps:E
sub latex_corrections {
my ($number_of_columns,$result,$selectionmade,$answer_mode) = @_;
-# $result =~ s/\\includegraphics{/\\includegraphics\[width=\\minipagewidth\]{/g;
+# $result =~ s/\\includegraphics\{/\\includegraphics\[width=\\minipagewidth\]{/g;
my $copyright = ©right_line();
if ($selectionmade eq '1' || $answer_mode eq 'only') {
- $result =~ s/(\\end{document})/\\strut\\vskip 0 mm $copyright $end_of_student $1/;
+ $result =~ s/(\\end\{document})/\\strut\\vskip 0 mm $copyright $end_of_student $1/;
} else {
- $result =~ s/(\\end{document})/\\strut\\vspace\*{-4 mm}\\newline $copyright $end_of_student $1/;
+ $result =~ s/(\\end\{document})/\\strut\\vspace\*{-4 mm}\\newline $copyright $end_of_student $1/;
}
$result =~ s/\$number_of_columns/$number_of_columns/g;
- $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;
+ $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;
#-- LaTeX corrections
my $first_comment = index($result,' |