version 1.268, 2004/01/15 16:38:48
|
version 1.272, 2004/02/03 21:38:18
|
Line 86 sub character_chart {
|
Line 86 sub character_chart {
|
$result =~ s/&\#0?55;/7/g; |
$result =~ s/&\#0?55;/7/g; |
$result =~ s/&\#0?56;/8/g; |
$result =~ s/&\#0?56;/8/g; |
$result =~ s/&\#0?57;/9/g; |
$result =~ s/&\#0?57;/9/g; |
$result =~ s/&(\#0?58|colon);/:/g; |
$result =~ s/&\#0?58;/:/g; |
$result =~ s/&\#0?59;/;/g; |
$result =~ s/&\#0?59;/;/g; |
$result =~ s/&(\#0?60|lt|\#139);/\$<\$/g; |
$result =~ s/&(\#0?60|lt|\#139);/\$<\$/g; |
$result =~ s/&\#0?61;/\$=\$/g; |
$result =~ s/&\#0?61;/\$=\$/g; |
Line 474 sub get_course {
|
Line 474 sub get_course {
|
sub page_format_transformation { |
sub page_format_transformation { |
my ($papersize,$layout,$numberofcolumns,$choice,$text,$assignment,$tableofcontents,$indexlist) = @_; |
my ($papersize,$layout,$numberofcolumns,$choice,$text,$assignment,$tableofcontents,$indexlist) = @_; |
my ($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin); |
my ($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin); |
$assignment=&character_chart($assignment); |
|
$assignment=&Apache::lonxml::latex_special_symbols($assignment,'header'); |
$assignment=&Apache::lonxml::latex_special_symbols($assignment,'header'); |
($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin) = &page_format($papersize,$layout,$numberofcolumns,$topmargin); |
($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin) = &page_format($papersize,$layout,$numberofcolumns,$topmargin); |
my $name = &get_name(); |
my $name = &get_name(); |
Line 516 sub page_cleanup {
|
Line 515 sub page_cleanup {
|
|
|
sub details_for_menu { |
sub details_for_menu { |
|
|
my $name_of_resourse = $hash{'title_'.$hash{'ids_'.$ENV{'form.postdata'}}}; |
my $name_of_resourse = &Apache::lonnet::gettitle($ENV{'form.postdata'}); |
$name_of_resourse=&character_chart($name_of_resourse); |
|
my $symbolic = &Apache::lonnet::symbread($ENV{'form.postdata'}); |
my $symbolic = &Apache::lonnet::symbread($ENV{'form.postdata'}); |
my ($map,$id,$resource)=&Apache::lonnet::decode_symb($symbolic); |
my ($map,$id,$resource)=&Apache::lonnet::decode_symb($symbolic); |
$map=&Apache::lonnet::clutter($map); |
$map=&Apache::lonnet::clutter($map); |
my $name_of_sequence; |
my $name_of_sequence = &Apache::lonnet::gettitle($map); |
$name_of_sequence = $hash{'title_'.$hash{'ids_'.$map}}; |
|
$name_of_sequence=&character_chart($name_of_sequence); |
|
if ($name_of_sequence =~ /^\s*$/) { |
if ($name_of_sequence =~ /^\s*$/) { |
$map =~ m|([^/]+)$|; |
$map =~ m|([^/]+)$|; |
$name_of_sequence = $1; |
$name_of_sequence = $1; |
} |
} |
my $name_of_map = $hash{'title_'.$hash{'ids_'.&Apache::lonnet::clutter($ENV{'request.course.uri'})}}; |
my $name_of_map = &Apache::lonnet::gettitle($ENV{'request.course.uri'}); |
$name_of_map=&character_chart($name_of_map); |
|
if ($name_of_map =~ /^\s*$/) { |
if ($name_of_map =~ /^\s*$/) { |
$ENV{'request.course.uri'} =~ m|([^/]+)$|; |
$ENV{'request.course.uri'} =~ m|([^/]+)$|; |
$name_of_map = $1; |
$name_of_map = $1; |
Line 710 ENDPART
|
Line 705 ENDPART
|
$LaTeXwidth = $1*25.4; |
$LaTeXwidth = $1*25.4; |
} |
} |
$LaTeXwidth.=' mm'; |
$LaTeXwidth.=' mm'; |
|
my @print_array=(); |
|
|
if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') { |
if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') { |
#-- single document - problem, page, html, xml, ... |
#-- single document - problem, page, html, xml, ... |
Line 877 ENDPART
|
Line 873 ENDPART
|
my $flag_page_in_sequence = 'NO'; |
my $flag_page_in_sequence = 'NO'; |
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; |
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; |
my $prevassignment=''; |
my $prevassignment=''; |
|
&Apache::lonnet::delenv('form.counter'); |
&Apache::lonxml::init_counter(); |
&Apache::lonxml::init_counter(); |
for (my $i=0;$i<=$#master_seq;$i++) { |
for (my $i=0;$i<=$#master_seq;$i++) { |
my (undef,undef,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]); |
my (undef,undef,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]); |
Line 892 ENDPART
|
Line 889 ENDPART
|
} |
} |
$form{'symb'}=$master_seq[$i]; |
$form{'symb'}=$master_seq[$i]; |
my ($sequence)=&Apache::lonnet::decode_symb($master_seq[$i]); |
my ($sequence)=&Apache::lonnet::decode_symb($master_seq[$i]); |
$assignment=&character_chart($assignment); |
|
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'); #tittle of the assignment which contains this problem |
if ($selectionmade==7) {$helper->{VARS}->{'assignment'}=$assignment;} |
if ($selectionmade==7) {$helper->{VARS}->{'assignment'}=$assignment;} |
if ($i==0) {$prevassignment=$assignment;} |
if ($i==0) {$prevassignment=$assignment;} |
Line 959 ENDPART
|
Line 955 ENDPART
|
$selectionmade=8; |
$selectionmade=8; |
} |
} |
my @students=split /\|\|\|/, $helper->{'VARS'}->{'STUDENTS'}; |
my @students=split /\|\|\|/, $helper->{'VARS'}->{'STUDENTS'}; |
|
if ($helper->{'VARS'}->{'NUMBER_TO_PRINT'} eq '0') {$helper->{'VARS'}->{'NUMBER_TO_PRINT'}=$#students+1;} |
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; |
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; |
#loop over students |
#loop over students |
my $flag_latex_header_remove = 'NO'; |
my $flag_latex_header_remove = 'NO'; |
Line 966 ENDPART
|
Line 963 ENDPART
|
$moreenv{'form.textwidth'}=$LaTeXwidth; |
$moreenv{'form.textwidth'}=$LaTeXwidth; |
&Apache::lonnet::appenv(%moreenv); |
&Apache::lonnet::appenv(%moreenv); |
my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1); |
my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1); |
|
my $student_counter=-1; |
foreach my $person (@students) { |
foreach my $person (@students) { |
|
$student_counter++; |
my $current_output = ''; |
my $current_output = ''; |
# my ($usersection,$username,$userdomain) = split /:/,$person; |
my ($username,$userdomain,$usersection) = split /:/,$person; |
my ($username,$userdomain) = split /:/,$person; |
|
my $fullname = &get_name($username,$userdomain); |
my $fullname = &get_name($username,$userdomain); |
|
|
if ($parmhash{'anonymous_quiz'}=~/yes/) {$fullname=' ';} #put here something reasonable for anonymous exams or quiz |
if ($parmhash{'anonymous_quiz'}=~/yes/) {$fullname=' ';} #put here something reasonable for anonymous exams or quiz |
Line 1016 ENDPART
|
Line 1014 ENDPART
|
} |
} |
my $courseidinfo = &get_course(); |
my $courseidinfo = &get_course(); |
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
$assignment=&character_chart($assignment); |
if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection} |
my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header'); |
my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header'); |
if ($current_output=~/\\documentclass/) { |
if ($current_output=~/\\documentclass/) { |
$current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\lhead{\\textit{\\textbf{$fullname}}$courseidinfo \\hfill \\thepage \\\\ \\textit{$currentassignment}}\\vskip 3 mm /; |
$current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\lhead{\\textit{\\textbf{$fullname}}$courseidinfo \\hfill \\thepage \\\\ \\textit{$currentassignment}}\\vskip 3 mm /; |
Line 1025 ENDPART
|
Line 1023 ENDPART
|
for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blanspages.='\clearpage\strut\clearpage';} |
for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blanspages.='\clearpage\strut\clearpage';} |
$current_output = '\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 }\\newpage '.$blanspages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}}} \vskip -5 mm '.$current_output; |
$current_output = '\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 }\\newpage '.$blanspages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}}} \vskip -5 mm '.$current_output; |
} |
} |
$result .= $current_output; |
$print_array[int($student_counter/$helper->{'VARS'}->{'NUMBER_TO_PRINT'})].=$current_output; |
&Apache::lonnet::delenv('form.counter'); |
&Apache::lonnet::delenv('form.counter'); |
&Apache::lonxml::init_counter(); |
&Apache::lonxml::init_counter(); |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, |
&mt('last student').' '.$fullname); |
&mt('last student').' '.$fullname); |
} |
} |
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
$result .= '\end{document}'; |
$result .= $print_array[0].' \end{document}'; |
&Apache::lonnet::delenv('form.textwidth'); |
&Apache::lonnet::delenv('form.textwidth'); |
} elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_from_directory') { |
} elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_from_directory') { |
#prints selected problems from the subdirectory |
#prints selected problems from the subdirectory |
Line 1109 ENDPART
|
Line 1107 ENDPART
|
#-------------------------------------------------------- corrections for the different page formats |
#-------------------------------------------------------- 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'}); |
$result = &page_format_transformation($papersize,$laystyle,$numberofcolumns,$helper->{'VARS'}->{'PRINT_TYPE'},$result,$helper->{VARS}->{'assignment'},$helper->{'VARS'}->{'TABLE_CONTENTS'},$helper->{'VARS'}->{'TABLE_INDEX'}); |
$result = &latex_corrections($number_of_columns,$result); |
$result = &latex_corrections($number_of_columns,$result); |
|
for (my $i=1;$i<=$#print_array;$i++) {$print_array[$i] = &latex_corrections($number_of_columns,$print_array[$i]);} |
#changes page's parameters for the one column output |
#changes page's parameters for the one column output |
if ($numberofcolumns == 1) { |
if ($numberofcolumns == 1) { |
$result =~ s/\\textwidth\s*=\s*\d*\.?\d*\s*(cm|mm|in)/\\textwidth= $helper->{'VARS'}->{'pagesize.width'} $helper->{'VARS'}->{'pagesize.widthunit'} /; |
$result =~ s/\\textwidth\s*=\s*\d*\.?\d*\s*(cm|mm|in)/\\textwidth= $helper->{'VARS'}->{'pagesize.width'} $helper->{'VARS'}->{'pagesize.widthunit'} /; |
Line 1123 ENDPART
|
Line 1122 ENDPART
|
$r->log_error("Couldn't open $filename for output $!"); |
$r->log_error("Couldn't open $filename for output $!"); |
return SERVER_ERROR; |
return SERVER_ERROR; |
} |
} |
|
print $temp_file $result; |
|
my $begin=index($result,'\begin{document}',0); |
|
my $inc=substr($result,0,$begin+16); |
|
my $newfilename=$filename; |
|
if ($#print_array>0) { |
|
for (my $i=1;$i<=$#print_array;$i++) { |
|
my $anobegin=index($print_array[$i],'\setcounter{page}',0); |
|
substr($print_array[$i],0,$anobegin)=''; |
|
$print_array[$i]=$inc.$print_array[$i].'\end{document}'; |
|
my $temp_file; |
|
$newfilename =~s/\.tex$/_add$i\.tex/; |
|
unless ($temp_file = Apache::File->new('>'.$newfilename)) { |
|
$r->log_error("Couldn't open $newfilename for output $!"); |
|
return SERVER_ERROR; |
|
} |
|
print $temp_file $print_array[$i]; |
|
} |
|
|
|
} |
|
|
my $identifier = time.'_'.int(rand(1000)); |
my $identifier = time.'_'.int(rand(1000)); |
&Apache::lonnet::appenv('cgi.'.$identifier.'.file' => $filename, |
&Apache::lonnet::appenv('cgi.'.$identifier.'.file' => $filename, |
Line 1131 ENDPART
|
Line 1149 ENDPART
|
'cgi.'.$identifier.'.selection' => $selectionmade, |
'cgi.'.$identifier.'.selection' => $selectionmade, |
'cgi.'.$identifier.'tableofcontents' => $helper->{'VARS'}->{'TABLE_CONTENTS'}, |
'cgi.'.$identifier.'tableofcontents' => $helper->{'VARS'}->{'TABLE_CONTENTS'}, |
'cgi.'.$identifier.'tableofindex' => $helper->{'VARS'}->{'TABLE_INDEX'}, |
'cgi.'.$identifier.'tableofindex' => $helper->{'VARS'}->{'TABLE_INDEX'}, |
'cgi.'.$identifier.'role' => $ENV{'request.role.adv'}); |
'cgi.'.$identifier.'role' => $ENV{'request.role.adv'}, |
|
'cgi.'.$identifier.'numberoffiles' => $#print_array); |
|
|
print $temp_file $result; |
|
|
|
$r->print(<<FINALEND); |
$r->print(<<FINALEND); |
<meta http-equiv="Refresh" content="0; url=/cgi-bin/printout.pl?$identifier"> |
<meta http-equiv="Refresh" content="0; url=/cgi-bin/printout.pl?$identifier"> |
Line 1383 HELPERFRAGMENT
|
Line 1401 HELPERFRAGMENT
|
if ($helper->{VARS}->{'assignment'}) { |
if ($helper->{VARS}->{'assignment'}) { |
push @{$printChoices}, ["<b>Problems</b> from <b><i>$sequenceTitle</i></b> for <b>selected students</b>", 'problems_for_students', 'CHOOSE_STUDENTS']; |
push @{$printChoices}, ["<b>Problems</b> from <b><i>$sequenceTitle</i></b> for <b>selected students</b>", 'problems_for_students', 'CHOOSE_STUDENTS']; |
} |
} |
|
|
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS); |
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS); |
<state name="ALL_PROBLEMS" title="Select Problem(s) to print"> |
<state name="ALL_PROBLEMS" title="Select Problem(s) to print"> |
<message>(mark them then click "next" button) <br /></message> |
<message>(mark them then click "next" button) <br /></message> |
Line 1414 HELPERFRAGMENT
|
Line 1431 HELPERFRAGMENT
|
</state> |
</state> |
CHOOSE_STUDENTS |
CHOOSE_STUDENTS |
|
|
|
addMessage("<hr width='33%' /><b>Number of assignments printed at the same time: </b>"); |
|
$paramHash = Apache::lonhelper::getParamHash(); |
|
$paramHash->{'variable'} = 'NUMBER_TO_PRINT'; |
|
$helper->declareVar('NUMBER_TO_PRINT'); |
|
addMessage("<input type='text' name='NUMBER_TO_PRINT.forminput' size='3' value='0' /><hr width='33%' />"); |
|
|
if ($helper->{VARS}->{'assignment'}) { |
if ($helper->{VARS}->{'assignment'}) { |
push @{$printChoices}, ["<b>Resources</b> from <b><i>$sequenceTitle</i></b> for <b>selected students</b>", 'resources_for_students', 'CHOOSE_STUDENTS1']; |
push @{$printChoices}, ["<b>Resources</b> from <b><i>$sequenceTitle</i></b> for <b>selected students</b>", 'resources_for_students', 'CHOOSE_STUDENTS1']; |
} |
} |
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS1); |
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS1); |
<state name="CHOOSE_STUDENTS1" title="Select Students and Resources"> |
<state name="CHOOSE_STUDENTS1" title="Select Students and Resources"> |
<student multichoice='1' variable="STUDENTS" nextstate="PAGESIZE" /> |
<student multichoice='1' variable="STUDENTS" nextstate="PAGESIZE" /> |
<message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message> |
<message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message> |
Line 1436 CHOOSE_STUDENTS
|
Line 1459 CHOOSE_STUDENTS
|
</state> |
</state> |
CHOOSE_STUDENTS1 |
CHOOSE_STUDENTS1 |
|
|
|
addMessage("<hr width='33%' /><b>Number of assignments printed at the same time: </b>"); |
|
$paramHash = Apache::lonhelper::getParamHash(); |
|
$paramHash->{'variable'} = 'NUMBER_TO_PRINT'; |
|
$helper->declareVar('NUMBER_TO_PRINT'); |
|
addMessage("<input type='text' name='NUMBER_TO_PRINT.forminput' size='3' value='0' /><hr width='33%' />"); |
} |
} |
|
|
# FIXME: That RE should come from a library somewhere. |
# FIXME: That RE should come from a library somewhere. |