version 1.374, 2005/04/07 07:03:23
|
version 1.386, 2005/08/16 10:25:15
|
Line 42 use Apache::lonratedt;
|
Line 42 use Apache::lonratedt;
|
use POSIX qw(strftime); |
use POSIX qw(strftime); |
use Apache::lonlocal; |
use Apache::lonlocal; |
|
|
|
my $resources_printed = ''; |
|
|
|
# |
|
# Convert a numeric code to letters |
|
# |
|
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; |
|
} |
|
# Convert a letter code to numeric. |
|
# |
|
sub letters_to_num { |
|
my ($letters) = @_; |
|
my @letters = split('', uc($letters)); |
|
my %substitution; |
|
my $digit = 0; |
|
foreach my $letter ('A'..'J') { |
|
$substitution{$letter} = $digit; |
|
$digit++; |
|
} |
|
# The substitution is done as below to preserve leading |
|
# zeroes which are needed to keep the code size exact |
|
# |
|
my $result =""; |
|
foreach my $letter (@letters) { |
|
$result.=$substitution{$letter}; |
|
} |
|
return $result; |
|
} |
|
|
|
# Determine if a code is a valid numeric code. Valid |
|
# numeric codes must be comprised entirely of digits and |
|
# have a correct number of digits. |
|
# |
|
# Parameters: |
|
# value - proposed code value. |
|
# num_digits - Number of digits required. |
|
# |
|
sub is_valid_numeric_code { |
|
my ($value, $num_digits) = @_; |
|
# Remove leading/trailing whitespace; |
|
$value =~ s/^\s*//; |
|
$value =~ s/\s*$//; |
|
|
|
# All digits? |
|
if ($value =~ /^[0-9]+$/) { |
|
return "Numeric code $value has invalid characters - must only be digits"; |
|
} |
|
if (length($value) != $num_digits) { |
|
return "Numeric code $value incorrect number of digits (correct = $num_digits)"; |
|
} |
|
return undef; |
|
} |
|
# Determines if a code is a valid alhpa code. Alpha codes |
|
# are ciphers that map [A-J,a-j] -> 0..9 0..9. |
|
# They also have a correct digit count. |
|
# Parameters: |
|
# value - Proposed code value. |
|
# num_letters - correct number of letters. |
|
# Note: |
|
# leading and trailing whitespace are ignored. |
|
# |
|
sub is_valid_alpha_code { |
|
my ($value, $num_letters) = @_; |
|
|
|
# strip leading and trailing spaces. |
|
|
|
$value =~ s/^\s*//g; |
|
$value =~ s/\s*$//g; |
|
|
|
# All alphas in the right range? |
|
if ($value !~ /^[A-J,a-j]+$/) { |
|
return "Invalid letter code $value must only contain A-J"; |
|
} |
|
if (length($value) != $num_letters) { |
|
return "Letter code $value has incorrect number of letters (correct = $num_letters)"; |
|
} |
|
return undef; |
|
} |
|
|
|
# Determine if a code entered by the user in a helper is valid. |
|
# valid depends on the code type and the type of code selected. |
|
# The type of code selected can either be numeric or |
|
# Alphabetic. If alphabetic, the code, in fact is a simple |
|
# substitution cipher for the actual numeric code: 0->A, 1->B ... |
|
# We'll be nice and be case insensitive for alpha codes. |
|
# Parameters: |
|
# code_value - the value of the code the user typed in. |
|
# code_option - The code type selected from the set in the scantron format |
|
# table. |
|
# Returns: |
|
# undef - The code is valid. |
|
# other - An error message indicating what's wrong. |
|
# |
|
sub is_code_valid { |
|
my ($code_value, $code_option) = @_; |
|
my ($code_type, $code_length) = ('letter', 6); # defaults. |
|
open(FG, $Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab'); |
|
foreach my $line (<FG>) { |
|
my ($name, $type, $length) = (split(/:/, $line))[0,2,4]; |
|
if($name eq $code_option) { |
|
$code_length = $length; |
|
if($type eq 'number') { |
|
$code_type = 'number'; |
|
} |
|
} |
|
} |
|
my $valid; |
|
if ($code_type eq 'number') { |
|
return &is_valid_numeric_code($code_value, $code_length); |
|
} else { |
|
return &is_valid_alpha_code($code_value, $code_length); |
|
} |
|
|
|
} |
|
|
# Compare two students by name. The students are in the form |
# Compare two students by name. The students are in the form |
# returned by the helper: |
# returned by the helper: |
# user:domain:section:last, first:status |
# user:domain:section:last, first:status |
Line 443 my %page_formats=
|
Line 563 my %page_formats=
|
'2' => ['3.16 in','13 in','-0.57 in','-0.57 in','-0.5 in'] |
'2' => ['3.16 in','13 in','-0.57 in','-0.57 in','-0.5 in'] |
}, |
}, |
'album' => { |
'album' => { |
'1' => [], |
'1' => ['12 in','7.1 in',,'-0.57 in','-0.57 in','-0.5 in'], |
'2' => [] |
'2' => ['6.0 in','7.1 in','-1 in','-1 in','5 in'] |
}, |
}, |
}, |
}, |
'tabloid' => { |
'tabloid' => { |
Line 453 my %page_formats=
|
Line 573 my %page_formats=
|
'2' => ['4.9 in','16 in','-0.57 in','-0.57 in','-0.5 in'] |
'2' => ['4.9 in','16 in','-0.57 in','-0.57 in','-0.5 in'] |
}, |
}, |
'album' => { |
'album' => { |
'1' => [], |
'1' => ['16 in','9.8 in','-0.57 in','-0.57 in','-0.5 in'], |
'2' => [] |
'2' => ['16 in','4.9 in','-0.57 in','-0.57 in','-0.5 in'] |
}, |
}, |
}, |
}, |
'executive' => { |
'executive' => { |
Line 648 sub latex_corrections {
|
Line 768 sub latex_corrections {
|
$first_comment = index($result,'<!--',$first_comment); |
$first_comment = index($result,'<!--',$first_comment); |
} |
} |
$result =~ s/^\s+$//gm; #remove empty lines |
$result =~ s/^\s+$//gm; #remove empty lines |
$result =~ s/(\s)(\s+)/$1/g; #removes more than one empty space |
#removes more than one empty space |
|
$result =~ s|(\s\s+)|($1=~/[\n\r]/)?"\n":" "|ge; |
$result =~ s/\\\\\s*\\vskip/\\vskip/gm; |
$result =~ s/\\\\\s*\\vskip/\\vskip/gm; |
$result =~ s/\\\\\s*\\noindent\s*(\\\\)+/\\\\\\noindent /g; |
$result =~ s/\\\\\s*\\noindent\s*(\\\\)+/\\\\\\noindent /g; |
$result =~ s/{\\par }\s*\\\\/\\\\/gm; |
$result =~ s/{\\par }\s*\\\\/\\\\/gm; |
Line 893 ENDPART
|
Line 1014 ENDPART
|
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, ... |
my ($currentURL,$cleanURL); |
my ($currentURL,$cleanURL); |
|
|
if ($helper->{'VARS'}->{'construction'} ne '1') { |
if ($helper->{'VARS'}->{'construction'} ne '1') { |
#prints published resource |
#prints published resource |
$currentURL=$helper->{'VARS'}->{'postdata'}; |
$currentURL=$helper->{'VARS'}->{'postdata'}; |
Line 929 ENDPART
|
Line 1051 ENDPART
|
&Apache::lonnet::appenv(%moreenv); |
&Apache::lonnet::appenv(%moreenv); |
&Apache::lonnet::delenv('form.counter'); |
&Apache::lonnet::delenv('form.counter'); |
&Apache::lonxml::init_counter(); |
&Apache::lonxml::init_counter(); |
|
$resources_printed .= $currentURL.':'; |
$texversion.=&Apache::lonnet::ssi($currentURL,%form); |
$texversion.=&Apache::lonnet::ssi($currentURL,%form); |
&Apache::lonnet::delenv('form.counter'); |
&Apache::lonnet::delenv('form.counter'); |
&Apache::lonnet::delenv('request.filename'); |
&Apache::lonnet::delenv('request.filename'); |
Line 939 ENDPART
|
Line 1062 ENDPART
|
$form{'grade_target'}='answer'; |
$form{'grade_target'}='answer'; |
$form{'answer_output_mode'}='tex'; |
$form{'answer_output_mode'}='tex'; |
$form{'rndseed'}=$rndseed; |
$form{'rndseed'}=$rndseed; |
|
$resources_printed .= $currentURL.':'; |
my $answer=&Apache::lonnet::ssi($currentURL,%form); |
my $answer=&Apache::lonnet::ssi($currentURL,%form); |
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { |
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { |
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; |
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; |
Line 986 ENDPART
|
Line 1110 ENDPART
|
$form{'suppress_tries'}=$parmhash{'suppress_tries'}; |
$form{'suppress_tries'}=$parmhash{'suppress_tries'}; |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
$form{'rndseed'}=$rndseed; |
$form{'rndseed'}=$rndseed; |
|
$resources_printed .=$urlp.':'; |
$texversion=&Apache::lonnet::ssi($urlp,%form); |
$texversion=&Apache::lonnet::ssi($urlp,%form); |
} |
} |
if((($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || |
if((($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || |
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) && |
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) && |
($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page)$/)) { |
($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page)$/)) { |
$form{'grade_target'}='answer'; |
# Don't permanently modify %$form... |
$form{'answer_output_mode'}='tex'; |
my %answerform = %form; |
$form{'rndseed'}=$rndseed; |
$answerform{'grade_target'}='answer'; |
$form{'problem_split'}=$parmhash{'problem_stream_switch'}; |
$answerform{'answer_output_mode'}='tex'; |
|
$answerform{'rndseed'}=$rndseed; |
|
$answerform{'problem_split'}=$parmhash{'problem_stream_switch'}; |
if ($urlp=~/\/res\//) {$env{'request.state'}='published';} |
if ($urlp=~/\/res\//) {$env{'request.state'}='published';} |
my $answer=&Apache::lonnet::ssi($urlp,%form); |
$resources_printed .= $urlp.':'; |
|
my $answer=&Apache::lonnet::ssi($urlp,%answerform); |
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { |
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { |
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; |
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; |
} else { |
} else { |
Line 1028 ENDPART
|
Line 1156 ENDPART
|
} elsif ($cleanURL=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { |
} elsif ($cleanURL=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;} |
if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;} |
|
$resources_printed .= $currentURL.':'; |
my $texversion=&Apache::lonnet::ssi($currentURL,%form); |
my $texversion=&Apache::lonnet::ssi($currentURL,%form); |
$result .= $texversion; |
$result .= $texversion; |
} else { |
} else { |
Line 1080 ENDPART
|
Line 1209 ENDPART
|
if ($i==0) {$prevassignment=$assignment;} |
if ($i==0) {$prevassignment=$assignment;} |
my $texversion=''; |
my $texversion=''; |
if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { |
if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { |
|
$resources_printed .= $urlp.':'; |
$texversion.=&Apache::lonnet::ssi($urlp,%form); |
$texversion.=&Apache::lonnet::ssi($urlp,%form); |
if ($urlp=~/\.page$/) { |
if ($urlp=~/\.page$/) { |
($texversion,my $number_of_columns_page) = &page_cleanup($texversion); |
($texversion,my $number_of_columns_page) = &page_cleanup($texversion); |
Line 1095 ENDPART
|
Line 1225 ENDPART
|
my $current_counter=$env{'form.counter'}; |
my $current_counter=$env{'form.counter'}; |
if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || |
if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || |
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) { |
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) { |
$form{'grade_target'}='answer'; |
# Don't permanently pervert the %form hash |
$form{'answer_output_mode'}='tex'; |
my %answerform = %form; |
my $answer=&Apache::lonnet::ssi($urlp,%form); |
$answerform{'grade_target'}='answer'; |
|
$answerform{'answer_output_mode'}='tex'; |
|
$resources_printed .= $urlp.':'; |
|
my $answer=&Apache::lonnet::ssi($urlp,%answerform); |
&Apache::lonnet::appenv(('form.counter' => $current_counter)); |
&Apache::lonnet::appenv(('form.counter' => $current_counter)); |
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { |
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { |
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; |
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; |
Line 1132 ENDPART
|
Line 1265 ENDPART
|
} elsif ($urlp=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { |
} elsif ($urlp=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;} |
if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;} |
|
$resources_printed .= $urlp.':'; |
my $texversion=&Apache::lonnet::ssi($urlp,%form); |
my $texversion=&Apache::lonnet::ssi($urlp,%form); |
if ($flag_latex_header_remove ne 'NO') { |
if ($flag_latex_header_remove ne 'NO') { |
$texversion = &latex_header_footer_remove($texversion); |
$texversion = &latex_header_footer_remove($texversion); |
Line 1207 ENDPART
|
Line 1341 ENDPART
|
} |
} |
$student_counter++; |
$student_counter++; |
my $i=int($student_counter/$helper->{'VARS'}{'NUMBER_TO_PRINT'}); |
my $i=int($student_counter/$helper->{'VARS'}{'NUMBER_TO_PRINT'}); |
my ($output,$fullname)=&print_resources($r,$helper, |
my ($output,$fullname, $printed)=&print_resources($r,$helper, |
$person,$type, |
$person,$type, |
\%moreenv,\@master_seq, |
\%moreenv,\@master_seq, |
$flag_latex_header_remove, |
$flag_latex_header_remove, |
$LaTeXwidth); |
$LaTeXwidth); |
|
$resources_printed .= ":"; |
$print_array[$i].=$output; |
$print_array[$i].=$output; |
$student_names[$i].=$person.':'.$fullname.'_END_'; |
$student_names[$i].=$person.':'.$fullname.'_END_'; |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,&mt('last student').' '.$fullname); |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,&mt('last student').' '.$fullname); |
Line 1227 ENDPART
|
Line 1362 ENDPART
|
my $num_todo=$helper->{'VARS'}->{'NUMBER_TO_PRINT_TOTAL'}; |
my $num_todo=$helper->{'VARS'}->{'NUMBER_TO_PRINT_TOTAL'}; |
my $code_name=$helper->{'VARS'}->{'ANON_CODE_STORAGE_NAME'}; |
my $code_name=$helper->{'VARS'}->{'ANON_CODE_STORAGE_NAME'}; |
my $old_name=$helper->{'VARS'}->{'REUSE_OLD_CODES'}; |
my $old_name=$helper->{'VARS'}->{'REUSE_OLD_CODES'}; |
|
my $single_code = $helper->{'VARS'}->{'SINGLE_CODE'}; |
|
my $code_option=$helper->{'VARS'}->{'CODE_OPTION'}; |
|
open(FH,$Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab'); |
|
my ($code_type,$code_length)=('letter',6); |
|
foreach my $line (<FH>) { |
|
my ($name,$type,$length) = (split(/:/,$line))[0,2,4]; |
|
if ($name eq $code_option) { |
|
$code_length=$length; |
|
if ($type eq 'number') { $code_type = 'number'; } |
|
} |
|
} |
my %moreenv = ('textwidth' => &get_textwidth($helper,$LaTeXwidth)); |
my %moreenv = ('textwidth' => &get_textwidth($helper,$LaTeXwidth)); |
$moreenv{'problem_split'} = $parmhash{'problem_stream_switch'}; |
$moreenv{'problem_split'} = $parmhash{'problem_stream_switch'}; |
my $seed=time+($$<<16)+($$); |
my $seed=time+($$<<16)+($$); |
my @allcodes; |
my @allcodes; |
if ($old_name) { |
if ($old_name) { |
my %result=&Apache::lonnet::get('CODEs',[$old_name],$cdom,$cnum); |
my %result=&Apache::lonnet::get('CODEs', |
|
[$old_name,"type\0$old_name"], |
|
$cdom,$cnum); |
|
$code_type=$result{"type\0$old_name"}; |
@allcodes=split(',',$result{$old_name}); |
@allcodes=split(',',$result{$old_name}); |
$num_todo=scalar(@allcodes); |
$num_todo=scalar(@allcodes); |
|
} elsif ($single_code) { |
|
|
|
# If an alpha code have to convert to numbers so it can be |
|
# converted back to letters again :-) |
|
# |
|
if ($code_type ne 'number') { |
|
$single_code = &letters_to_num($single_code); |
|
$num_todo = 1; |
|
} |
|
@allcodes = ($single_code); |
} else { |
} else { |
my %allcodes; |
my %allcodes; |
srand($seed); |
srand($seed); |
for (my $i=0;$i<$num_todo;$i++) { |
for (my $i=0;$i<$num_todo;$i++) { |
$moreenv{'CODE'}=&get_CODE(\%allcodes,$i,$seed,'6'); |
$moreenv{'CODE'}=&get_CODE(\%allcodes,$i,$seed,$code_length, |
|
$code_type); |
} |
} |
if ($code_name) { |
if ($code_name) { |
&Apache::lonnet::put('CODEs', |
&Apache::lonnet::put('CODEs', |
{$code_name =>join(',',keys(%allcodes))}, |
{ |
|
$code_name =>join(',',keys(%allcodes)), |
|
"type\0$code_name" => $code_type |
|
}, |
$cdom,$cnum); |
$cdom,$cnum); |
} |
} |
@allcodes=keys(%allcodes); |
@allcodes=keys(%allcodes); |
Line 1259 ENDPART
|
Line 1422 ENDPART
|
my $count=0; |
my $count=0; |
foreach my $code (sort(@allcodes)) { |
foreach my $code (sort(@allcodes)) { |
my $file_num=int($count/$number_per_page); |
my $file_num=int($count/$number_per_page); |
$moreenv{'CODE'}=&num_to_letters($code); |
if ($code_type eq 'number') { |
my ($output,$fullname)= |
$moreenv{'CODE'}=$code; |
|
} else { |
|
$moreenv{'CODE'}=&num_to_letters($code); |
|
} |
|
my ($output,$fullname, $printed)= |
&print_resources($r,$helper,'anonymous',$type,\%moreenv, |
&print_resources($r,$helper,'anonymous',$type,\%moreenv, |
\@master_seq,$flag_latex_header_remove, |
\@master_seq,$flag_latex_header_remove, |
$LaTeXwidth); |
$LaTeXwidth); |
|
$resources_printed .= ":"; |
$print_array[$file_num].=$output; |
$print_array[$file_num].=$output; |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, |
&mt('last assignment').' '.$fullname); |
&mt('last assignment').' '.$fullname); |
Line 1294 ENDPART
|
Line 1462 ENDPART
|
} else { |
} else { |
$urlp =~ s|^$Apache::lonnet::perlvar{'lonDocRoot'}||; |
$urlp =~ s|^$Apache::lonnet::perlvar{'lonDocRoot'}||; |
} |
} |
|
$resources_printed .= $urlp.':'; |
my $texversion=&Apache::lonnet::ssi($urlp,%form); |
my $texversion=&Apache::lonnet::ssi($urlp,%form); |
if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || |
if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || |
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) { |
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) { |
$form{'grade_target'}='answer'; |
# Don't permanently pervert %form: |
$form{'answer_output_mode'}='tex'; |
my %answerform = %form; |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
$answerform{'grade_target'}='answer'; |
$form{'rndseed'}=$rndseed; |
$answerform{'answer_output_mode'}='tex'; |
my $answer=&Apache::lonnet::ssi($urlp,%form); |
$answerform{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
|
$answerform{'rndseed'}=$rndseed; |
|
$resources_printed .= $urlp.':'; |
|
my $answer=&Apache::lonnet::ssi($urlp,%answerform); |
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { |
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { |
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; |
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; |
} else { |
} else { |
Line 1357 ENDPART
|
Line 1529 ENDPART
|
#-- writing .tex file in prtspool |
#-- writing .tex file in prtspool |
my $temp_file; |
my $temp_file; |
my $identifier = &Apache::loncommon::get_cgi_id(); |
my $identifier = &Apache::loncommon::get_cgi_id(); |
my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout_".$identifier.".tex"; |
my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout_$identifier.tex"; |
if (!($#print_array>0)) { |
if (!($#print_array>0)) { |
unless ($temp_file = Apache::File->new('>'.$filename)) { |
unless ($temp_file = Apache::File->new('>'.$filename)) { |
$r->log_error("Couldn't open $filename for output $!"); |
$r->log_error("Couldn't open $filename for output $!"); |
Line 1380 ENDPART
|
Line 1552 ENDPART
|
my $temp_file; |
my $temp_file; |
my $newfilename=$filename; |
my $newfilename=$filename; |
my $num=$i+1; |
my $num=$i+1; |
$newfilename =~s/\.tex$/_$num\.tex/; |
$newfilename =~s/\.tex$//; |
|
$newfilename=sprintf("%s_%03d.tex",$newfilename, $num); |
unless ($temp_file = Apache::File->new('>'.$newfilename)) { |
unless ($temp_file = Apache::File->new('>'.$newfilename)) { |
$r->log_error("Couldn't open $newfilename for output $!"); |
$r->log_error("Couldn't open $newfilename for output $!"); |
return SERVER_ERROR; |
return SERVER_ERROR; |
Line 1416 ENDPART
|
Line 1589 ENDPART
|
$URLback=~s|^/~|/priv/|; |
$URLback=~s|^/~|/priv/|; |
} |
} |
} |
} |
|
# logic for now is too complex to trace if this has been defined |
|
# yet. |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
&Apache::lonnet::appenv('cgi.'.$identifier.'.file' => $filename, |
&Apache::lonnet::appenv('cgi.'.$identifier.'.file' => $filename, |
'cgi.'.$identifier.'.layout' => $laystyle, |
'cgi.'.$identifier.'.layout' => $laystyle, |
'cgi.'.$identifier.'.numcol' => $numberofcolumns, |
'cgi.'.$identifier.'.numcol' => $numberofcolumns, |
'cgi.'.$identifier.'.paper' => $papersize, |
'cgi.'.$identifier.'.paper' => $papersize, |
'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, |
'cgi.'.$identifier.'.numberoffiles' => $#print_array, |
'cgi.'.$identifier.'studentnames' => $student_names, |
'cgi.'.$identifier.'.studentnames' => $student_names, |
'cgi.'.$identifier.'backref' => $URLback,); |
'cgi.'.$identifier.'.backref' => $URLback,); |
|
&Apache::lonnet::appenv("cgi.$identifier.user" => $env{'user.name'}, |
|
"cgi.$identifier.domain" => $env{'user.domain'}, |
|
"cgi.$identifier.courseid" => $cnum, |
|
"cgi.$identifier.coursedom" => $cdom, |
|
"cgi.$identifier.resources" => $resources_printed); |
|
|
$r->print(<<FINALEND); |
$r->print(<<FINALEND); |
<br /> |
<br /> |
<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 1438 $r->print(<<FINALEND);
|
Line 1619 $r->print(<<FINALEND);
|
FINALEND |
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 { |
sub get_CODE { |
my ($all_codes,$num,$seed,$size)=@_; |
my ($all_codes,$num,$seed,$size,$type)=@_; |
my $max='1'.'0'x$size; |
my $max='1'.'0'x$size; |
my $newcode; |
my $newcode; |
while(1) { |
while(1) { |
$newcode=sprintf("%06d",int(rand($max))); |
$newcode=sprintf("%06d",int(rand($max))); |
if (!exists($$all_codes{$newcode})) { |
if (!exists($$all_codes{$newcode})) { |
$$all_codes{$newcode}=1; |
$$all_codes{$newcode}=1; |
return &num_to_letters($newcode); |
if ($type eq 'number' ) { |
|
return $newcode; |
|
} else { |
|
return &num_to_letters($newcode); |
|
} |
} |
} |
} |
} |
} |
} |
Line 1464 sub print_resources {
|
Line 1641 sub print_resources {
|
my ($r,$helper,$person,$type,$moreenv,$master_seq,$remove_latex_header, |
my ($r,$helper,$person,$type,$moreenv,$master_seq,$remove_latex_header, |
$LaTeXwidth)=@_; |
$LaTeXwidth)=@_; |
my $current_output = ''; |
my $current_output = ''; |
|
my $printed = ''; |
my ($username,$userdomain,$usersection) = split /:/,$person; |
my ($username,$userdomain,$usersection) = split /:/,$person; |
my $fullname = &get_name($username,$userdomain); |
my $fullname = &get_name($username,$userdomain); |
my $namepostfix; |
my $namepostfix; |
Line 1491 sub print_resources {
|
Line 1669 sub print_resources {
|
my ($map,$id,$res_url) = &Apache::lonnet::decode_symb($curresline); |
my ($map,$id,$res_url) = &Apache::lonnet::decode_symb($curresline); |
if (&Apache::lonnet::allowed('bre',$res_url)) { |
if (&Apache::lonnet::allowed('bre',$res_url)) { |
if ($res_url=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { |
if ($res_url=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { |
|
$printed .= $curresline.':'; |
my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv); |
my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv); |
my $lonidsdir=$r->dir_config('lonIDsDir'); |
my $lonidsdir=$r->dir_config('lonIDsDir'); |
my $envfile=$env{'user.environment'}; |
my $envfile=$env{'user.environment'}; |
Line 1500 sub print_resources {
|
Line 1679 sub print_resources {
|
my $current_counter=$env{'form.counter'}; |
my $current_counter=$env{'form.counter'}; |
if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || |
if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || |
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) { |
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) { |
$moreenv->{'answer_output_mode'}='tex'; |
# Use a copy of the hash so we don't pervert it on future loop passes. |
$moreenv->{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
my %answerenv = %{$moreenv}; |
my $ansrendered = &Apache::loncommon::get_student_answers($curresline,$username,$userdomain,$env{'request.course.id'},%{$moreenv}); |
$answerenv{'answer_output_mode'}='tex'; |
|
$answerenv{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
|
my $ansrendered = &Apache::loncommon::get_student_answers($curresline,$username,$userdomain,$env{'request.course.id'},%answerenv); |
&Apache::lonnet::appenv(('form.counter' => $current_counter)); |
&Apache::lonnet::appenv(('form.counter' => $current_counter)); |
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { |
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { |
$rendered=~s/(\\keephidden{ENDOFPROBLEM})/$ansrendered$1/; |
$rendered=~s/(\\keephidden{ENDOFPROBLEM})/$ansrendered$1/; |
Line 1520 sub print_resources {
|
Line 1701 sub print_resources {
|
} |
} |
$current_output .= $rendered; |
$current_output .= $rendered; |
} elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { |
} elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { |
|
$printed .= $curresline.':'; |
my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv); |
my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv); |
my $lonidsdir=$r->dir_config('lonIDsDir'); |
my $lonidsdir=$r->dir_config('lonIDsDir'); |
my $envfile=$env{'user.environment'}; |
my $envfile=$env{'user.environment'}; |
Line 1558 sub print_resources {
|
Line 1740 sub print_resources {
|
for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blankpages.='\clearpage\strut\clearpage';} |
for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blankpages.='\clearpage\strut\clearpage';} |
$current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}'.$namepostfix.'}} \vskip 5 mm '.$current_output; |
$current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}'.$namepostfix.'}} \vskip 5 mm '.$current_output; |
} |
} |
return ($current_output,$fullname); |
return ($current_output,$fullname, $printed); |
|
|
} |
} |
|
|
Line 1903 CHOOSE_STUDENTS
|
Line 2085 CHOOSE_STUDENTS
|
my $namechoice='<choice></choice>'; |
my $namechoice='<choice></choice>'; |
foreach my $name (sort {uc($a) cmp uc($b)} @names) { |
foreach my $name (sort {uc($a) cmp uc($b)} @names) { |
if ($name =~ /^error: 2 /) { next; } |
if ($name =~ /^error: 2 /) { next; } |
|
if ($name =~ /^type\0/) { next; } |
$namechoice.='<choice computer="'.$name.'">'.$name.'</choice>'; |
$namechoice.='<choice computer="'.$name.'">'.$name.'</choice>'; |
} |
} |
|
open(FH,$Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab'); |
|
my $codechoice=''; |
|
foreach my $line (<FH>) { |
|
my ($name,$description,$code_type,$code_length)= |
|
(split(/:/,$line))[0,1,2,4]; |
|
if ($code_length > 0 && |
|
$code_type =~/^(letter|number|-1)/) { |
|
$codechoice.='<choice computer="'.$name.'">'.$description.'</choice>'; |
|
} |
|
} |
|
if ($codechoice eq '') { |
|
$codechoice='<choice computer="default">Default</choice>'; |
|
} |
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_ANON1); |
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_ANON1); |
<state name="CHOOSE_ANON1" title="Select Students and Resources"> |
<state name="CHOOSE_ANON1" title="Select Students and Resources"> |
<nextstate>PAGESIZE</nextstate> |
<nextstate>PAGESIZE</nextstate> |
Line 1913 CHOOSE_STUDENTS
|
Line 2109 CHOOSE_STUDENTS
|
<string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"> |
<string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"> |
<validator> |
<validator> |
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && |
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && |
!\$helper->{'VARS'}{'REUSE_OLD_CODES'}) { |
!\$helper->{'VARS'}{'REUSE_OLD_CODES'} && |
|
!\$helper->{'VARS'}{'SINGLE_CODE'}) { |
return "You need to specify the number of assignments to print"; |
return "You need to specify the number of assignments to print"; |
} |
} |
return undef; |
return undef; |
</validator> |
</validator> |
</string> |
</string> |
<message></td></tr><tr><td></message> |
<message></td></tr><tr><td></message> |
|
<message><b>Value of CODE to print?</b></td><td></message> |
|
<string variable="SINGLE_CODE" size="10" defaultvalue="zzzz"> |
|
<validator> |
|
if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'} && |
|
!\$helper->{'VARS'}{'REUSE_OLD_CODES'}) { |
|
return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'}, |
|
\$helper->{'VARS'}{'CODE_OPTION'}); |
|
} else { |
|
return undef; # Other forces control us. |
|
} |
|
</validator> |
|
</string> |
|
<message></td></tr><tr><td></message> |
<message><b>Names to store the CODEs under for later:</b></message> |
<message><b>Names to store the CODEs under for later:</b></message> |
<message></td><td></message> |
<message></td><td></message> |
<string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" /> |
<string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" /> |
|
<message></td></tr><tr><td></message> |
|
<message><b>Bubble sheet type:</b></message> |
|
<message></td><td></message> |
|
<dropdown variable="CODE_OPTION" multichoice="0" allowempty="0"> |
|
$codechoice |
|
</dropdown> |
<message></td></tr></table></message> |
<message></td></tr></table></message> |
<message><hr width='33%' /></message> |
<message><hr width='33%' /></message> |
<message><b>Reprint a set of saved CODEs:</b></message> |
<message><b>Reprint a set of saved CODEs:</b></message> |
Line 1980 CHOOSE_STUDENTS1
|
Line 2196 CHOOSE_STUDENTS1
|
<string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"> |
<string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"> |
<validator> |
<validator> |
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && |
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && |
!\$helper->{'VARS'}{'REUSE_OLD_CODES'}) { |
!\$helper->{'VARS'}{'REUSE_OLD_CODES'} && |
|
!\$helper->{'VARS'}{'SINGLE_CODE'}) { |
return "You need to specify the number of assignments to print"; |
return "You need to specify the number of assignments to print"; |
} |
} |
return undef; |
return undef; |
</validator> |
</validator> |
</string> |
</string> |
<message></td></tr><tr><td></message> |
<message></td></tr><tr><td></message> |
|
<message><b>Value of CODE to print?</b></td><td></message> |
|
<string variable="SINGLE_CODE" size="10" defaultvalue="zzzz"> |
|
<validator> |
|
if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'} && |
|
!\$helper->{'VARS'}{'REUSE_OLD_CODES'}) { |
|
return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'}, |
|
\$helper->{'VARS'}{'CODE_OPTION'}); |
|
} else { |
|
return undef; # Other forces control us. |
|
} |
|
</validator> |
|
</string> |
|
<message></td></tr><tr><td></message> |
<message><b>Names to store the CODEs under for later:</b></message> |
<message><b>Names to store the CODEs under for later:</b></message> |
<message></td><td></message> |
<message></td><td></message> |
<string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" /> |
<string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" /> |
|
<message></td></tr><tr><td></message> |
|
<message><b>Bubble sheet type:</b></message> |
|
<message></td><td></message> |
|
<dropdown variable="CODE_OPTION" multichoice="0" allowempty="0"> |
|
$codechoice |
|
</dropdown> |
<message></td></tr></table></message> |
<message></td></tr></table></message> |
<message><hr width='33%' /></message> |
<message><hr width='33%' /></message> |
<message><b>Reprint a set of saved CODEs:</b></message> |
<message><b>Reprint a set of saved CODEs:</b></message> |
Line 2165 CHOOSE_FROM_ANY_SEQUENCE
|
Line 2401 CHOOSE_FROM_ANY_SEQUENCE
|
</defaultvalue> |
</defaultvalue> |
</string> |
</string> |
<message></td></tr><tr><td align="right">Use style file:</td><td></message> |
<message></td></tr><tr><td align="right">Use style file:</td><td></message> |
<message><input type="text" size="40" name="style_file_value" value="$stylevalue" /> <a href="javascript:openbrowser('helpform','style_file','sty')">Select style file</a> </td><td></message> |
<message><input type="text" size="40" name="style_file_value" value="$stylevalue" /> <a href="javascript:openbrowser('helpform','style_file','sty')">Select style file</a> </td><tr><td></message> |
<message></td></tr></message> |
|
<choices allowempty="1" multichoice="true" variable="showallfoils"> |
<choices allowempty="1" multichoice="true" variable="showallfoils"> |
<choice computer="1">Show all foils?</choice> |
<choice computer="1">Show all foils?</choice> |
</choices> |
</choices> |
|
<message></td></tr></message> |
RNDSEED |
RNDSEED |
&Apache::lonxml::xmlparse($r, 'helper', $xmlfrag); |
&Apache::lonxml::xmlparse($r, 'helper', $xmlfrag); |
$helper->{'VARS'}->{'style_file'}=$env{'form.style_file_value'}; |
$helper->{'VARS'}->{'style_file'}=$env{'form.style_file_value'}; |
Line 2245 use Apache::lonlocal;
|
Line 2481 use Apache::lonlocal;
|
use Apache::lonnet; |
use Apache::lonnet; |
|
|
my $maxColumns = 2; |
my $maxColumns = 2; |
|
# it'd be nice if these all worked |
|
#my @paperSize = ("letter [8 1/2x11 in]", "legal [8 1/2x14 in]", |
|
# "tabloid (ledger) [11x17 in]", "executive [7 1/2x10 in]", |
|
# "a2 [420x594 mm]", "a3 [297x420 mm]", "a4 [210x297 mm]", |
|
# "a5 [148x210 mm]", "a6 [105x148 mm]" ); |
my @paperSize = ("letter [8 1/2x11 in]", "legal [8 1/2x14 in]", |
my @paperSize = ("letter [8 1/2x11 in]", "legal [8 1/2x14 in]", |
"tabloid (ledger) [11x17 in]", "executive [7 1/2x10 in]", |
"a4 [210x297 mm]"); |
"a2 [420x594 mm]", "a3 [297x420 mm]", "a4 [210x297 mm]", |
|
"a5 [148x210 mm]", "a6 [105x148 mm]" ); |
|
|
|
# Tentative format: Orientation (L = Landscape, P = portrait) | Colnum | |
# Tentative format: Orientation (L = Landscape, P = portrait) | Colnum | |
# Paper type |
# Paper type |
Line 2284 sub render {
|
Line 2523 sub render {
|
</tr> |
</tr> |
<tr> |
<tr> |
<td> |
<td> |
<input type="radio" name="${var}.layout" value="L" /> Landscape<br /> |
<label><input type="radio" name="${var}.layout" value="L" /> Landscape </label><br /> |
<input type="radio" name="${var}.layout" value="P" checked='1' /> Portrait |
<label><input type="radio" name="${var}.layout" value="P" checked='1' /> Portrait </label> |
</td> |
</td> |
<td align="center"> |
<td align="center"> |
<select name="${var}.cols"> |
<select name="${var}.cols"> |