version 1.285, 2004/03/23 16:17:48
|
version 1.288, 2004/04/01 15:24:44
|
Line 663 sub recalcto_mm {
|
Line 663 sub recalcto_mm {
|
|
|
sub get_textwidth { |
sub get_textwidth { |
my ($helper,$LaTeXwidth)=@_; |
my ($helper,$LaTeXwidth)=@_; |
|
my $textwidth=$LaTeXwidth; |
if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ && |
if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ && |
$helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) { |
$helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) { |
$moreenv{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'}); |
$textwidth=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '. |
} else { |
$helper->{'VARS'}->{'pagesize.widthunit'}); |
$moreenv{'textwidth'}=$LaTeXwidth; |
|
} |
} |
|
return $textwidth; |
} |
} |
|
|
sub output_data { |
sub output_data { |
Line 1000 ENDPART
|
Line 1001 ENDPART
|
$result .= $print_array[0].' \end{document}'; |
$result .= $print_array[0].' \end{document}'; |
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon') || |
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon') || |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_anon') ) { |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_anon') ) { |
$selectionmade="Seems to be useless"; |
my $num_todo=$helper->{'VARS'}->{'NUMBER_TO_PRINT_TOTAL'}; |
|
my $code_name=$helper->{'VARS'}->{'ANON_CODE_STORAGE_NAME'}; |
|
if ($helper->{'VARS'}->{'REMEBER_ANON_CODES'} != 1) { |
|
$code_name=undef; |
|
} |
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; |
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; |
|
my ($type) = split(/_/,$helper->{'VARS'}->{'PRINT_TYPE'}); |
} elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_from_directory') { |
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'); |
|
my $seed=time+($$<<16)+($$); |
|
my %allcodes; |
|
for (my $i=0;$i<$num_todo;$i++) { |
|
$moreenv{'CODE'}=&get_CODE(\%allcodes,$i,$seed,'6'); |
|
my ($output,$fullname)= |
|
&print_resources($r,$helper,'anonymous',$type,\%moreenv, |
|
\@master_seq,$flag_latex_header_remove); |
|
$print_array[$i].=$output; |
|
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, |
|
&mt('last assignment').' '.$fullname); |
|
$flag_latex_header_remove = 'YES'; |
|
} |
|
if ($code_name) { |
|
my $cdom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; |
|
my $cnum = $ENV{'course.'.$ENV{'request.course.id'}.'.num'}; |
|
&Apache::lonnet::put('CODEs', |
|
{ $code_name => join(',',keys(%allcodes)) }, |
|
$cdom,$cnum); |
|
} |
|
&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 |
#prints selected problems from the subdirectory |
$selectionmade = 6; |
$selectionmade = 6; |
my @list_of_files=split /\|\|\|/, $helper->{'VARS'}->{'FILES'}; |
my @list_of_files=split /\|\|\|/, $helper->{'VARS'}->{'FILES'}; |
Line 1161 ENDPART
|
Line 1190 ENDPART
|
'cgi.'.$identifier.'backref' => $URLback,); |
'cgi.'.$identifier.'backref' => $URLback,); |
|
|
$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" /> |
</body> |
</body> |
</html> |
</html> |
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 { |
|
my ($all_codes,$num,$seed,$size)=@_; |
|
my $max='1'.'0'x$size; |
|
srand($seed); |
|
my $newcode; |
|
while(1) { |
|
$newcode=int(rand($max)); |
|
if (!exists($$all_codes{$newcode})) { |
|
$$all_codes{$newcode}=1; |
|
return &num_to_letters($newcode); |
|
} |
|
} |
|
} |
|
|
sub print_resources { |
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)=@_; |
my $current_output = ''; |
my $current_output = ''; |
my ($username,$userdomain,$usersection) = split /:/,$person; |
my ($username,$userdomain,$usersection) = split /:/,$person; |
my $fullname = &get_name($username,$userdomain); |
my $fullname = &get_name($username,$userdomain); |
|
if ($person =~ 'anon') { |
|
$fullname = "CODE - ".$moreenv->{'CODE'}; |
|
} |
#goes through all resources, checks if they are available for |
#goes through all resources, checks if they are available for |
#current student, and produces output |
#current student, and produces output |
&Apache::lonnet::delenv('form.counter'); |
&Apache::lonnet::delenv('form.counter'); |
Line 1414 sub printHelper {
|
Line 1467 sub printHelper {
|
# $r->print($helper->{VARS}->{'postdata'}); |
# $r->print($helper->{VARS}->{'postdata'}); |
|
|
# Useful filter strings |
# Useful filter strings |
my $isProblem = '$res->is_problem()'; |
my $isProblem = '($res->is_problem()||$res->contains_problem) '; |
$isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden; |
$isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden; |
my $isProblemOrMap = '$res->is_problem() || $res->is_map()'; |
my $isProblemOrMap = '$res->is_problem() || $res->contains_problem() || $res->is_sequence()'; |
my $isNotMap = '!$res->is_map()'; |
my $isNotMap = '!$res->is_sequence()'; |
$isNotMap .= ' && !$res->randomout()' if !$userCanSeeHidden; |
$isNotMap .= ' && !$res->randomout()' if !$userCanSeeHidden; |
my $isMap = '$res->is_map()'; |
my $isMap = '$res->is_map()'; |
my $symbFilter = '$res->symb()'; |
my $symbFilter = '$res->symb()'; |
Line 1441 sub printHelper {
|
Line 1494 sub printHelper {
|
my $helperFragment = <<HELPERFRAGMENT; |
my $helperFragment = <<HELPERFRAGMENT; |
<state name="CHOOSE_PROBLEMS" title="Select Problem(s) to print"> |
<state name="CHOOSE_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> |
<resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"> |
<resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1" |
|
closeallpages="1"> |
<nextstate>PAGESIZE</nextstate> |
<nextstate>PAGESIZE</nextstate> |
<filterfunc>return $isProblem;</filterfunc> |
<filterfunc>return $isProblem;</filterfunc> |
<mapurl>$map</mapurl> |
<mapurl>$map</mapurl> |
Line 1451 sub printHelper {
|
Line 1505 sub printHelper {
|
|
|
<state name="CHOOSE_PROBLEMS_HTML" title="Select Resource(s) to print"> |
<state name="CHOOSE_PROBLEMS_HTML" title="Select Resource(s) to print"> |
<message>(mark them then click "next" button) <br /></message> |
<message>(mark them then click "next" button) <br /></message> |
<resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"> |
<resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1" |
|
closeallpages="1"> |
<nextstate>PAGESIZE</nextstate> |
<nextstate>PAGESIZE</nextstate> |
<filterfunc>return $isNotMap;</filterfunc> |
<filterfunc>return $isNotMap;</filterfunc> |
<mapurl>$map</mapurl> |
<mapurl>$map</mapurl> |
Line 1470 HELPERFRAGMENT
|
Line 1525 HELPERFRAGMENT
|
&Apache::lonxml::xmlparse($r, 'helper', <<ALL_PROBLEMS); |
&Apache::lonxml::xmlparse($r, 'helper', <<ALL_PROBLEMS); |
<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> |
<resource variable="RESOURCES" multichoice="1" |
<resource variable="RESOURCES" toponly='0' multichoice="1" |
suppressEmptySequences='1' addstatus="1"> |
suppressEmptySequences='0' addstatus="1" closeallpages="1"> |
<nextstate>PAGESIZE</nextstate> |
<nextstate>PAGESIZE</nextstate> |
<filterfunc>return $isProblemOrMap;</filterfunc> |
<filterfunc>return $isProblemOrMap;</filterfunc> |
<choicefunc>return $isProblem;</choicefunc> |
<choicefunc>return $isNotMap;</choicefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
</resource> |
</resource> |
</state> |
</state> |
Line 1482 ALL_PROBLEMS
|
Line 1537 ALL_PROBLEMS
|
|
|
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']; |
push @{$printChoices}, ["<b>Problems</b> from <b><i>$sequenceTitle</i></b> for <b>anonymous students</b>", 'problems_for_anonymous', 'CHOOSE_ANON1']; |
push @{$printChoices}, ["<b>Problems</b> from <b><i>$sequenceTitle</i></b> for <b>anonymous students</b>", 'problems_for_anon', 'CHOOSE_ANON1']; |
} |
} |
my $resource_selector=<<RESOURCE_SELECTOR; |
my $resource_selector=<<RESOURCE_SELECTOR; |
<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> |
<resource variable="RESOURCES" multichoice="1" addstatus="1"> |
<resource variable="RESOURCES" multichoice="1" addstatus="1" |
|
closeallpages="1"> |
<filterfunc>return $isProblem;</filterfunc> |
<filterfunc>return $isProblem;</filterfunc> |
<mapurl>$map</mapurl> |
<mapurl>$map</mapurl> |
<valuefunc>return $symbFilter;</valuefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
Line 1510 RESOURCE_SELECTOR
|
Line 1566 RESOURCE_SELECTOR
|
CHOOSE_STUDENTS |
CHOOSE_STUDENTS |
&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"> |
<message><hr width='33%' /><b>How many Anonymous exams to print?</b></message> |
<nextstate>PAGESIZE</nextstate> |
|
<message><hr width='33%' /><b>Number of anonymous assignments to print?</b></message> |
<string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"></string> |
<string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"></string> |
|
<choices variable="REMEBER_ANON_CODES" allowempty="1" multichoice="1"> |
|
<choice computer="1"> |
|
Should the CODEs used on this printing be remebered for later? |
|
</choice> |
|
</choices> |
|
<message><b>Names to store the CODEs under for later:</b></message> |
|
<string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" /> |
<message><hr width='33%' /></message> |
<message><hr width='33%' /></message> |
$resource_selector |
$resource_selector |
</state> |
</state> |
Line 1520 CHOOSE_ANON1
|
Line 1584 CHOOSE_ANON1
|
|
|
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']; |
push @{$printChoices}, ["<b>Resources</b> from <b><i>$sequenceTitle</i></b> for <b>anonymous students</b>", 'resources_for_anonymous', 'CHOOSE_ANON2']; |
push @{$printChoices}, ["<b>Resources</b> from <b><i>$sequenceTitle</i></b> for <b>anonymous students</b>", 'resources_for_anon', 'CHOOSE_ANON2']; |
} |
} |
|
|
|
|
$resource_selector=<<RESOURCE_SELECTOR; |
$resource_selector=<<RESOURCE_SELECTOR; |
<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> |
<resource variable="RESOURCES" multichoice="1" addstatus="1"> |
<resource variable="RESOURCES" multichoice="1" addstatus="1" |
|
closeallpages="1"> |
<filterfunc>return $isNotMap;</filterfunc> |
<filterfunc>return $isNotMap;</filterfunc> |
<mapurl>$map</mapurl> |
<mapurl>$map</mapurl> |
<valuefunc>return $symbFilter;</valuefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
Line 1604 CHOOSE_FROM_SUBDIR
|
Line 1669 CHOOSE_FROM_SUBDIR
|
</state> |
</state> |
<state name="CHOOSE_FROM_ANY_SEQUENCE" title="Select Resources To Print"> |
<state name="CHOOSE_FROM_ANY_SEQUENCE" title="Select Resources To Print"> |
<message>(mark desired resources then click "next" button) <br /></message> |
<message>(mark desired resources then click "next" button) <br /></message> |
<resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"> |
<resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1" |
|
closeallpages="1"> |
<nextstate>PAGESIZE</nextstate> |
<nextstate>PAGESIZE</nextstate> |
<filterfunc>return $isProblem</filterfunc> |
<filterfunc>return $isProblem</filterfunc> |
<mapurl evaluate='1'>return '$escapedSequenceName';</mapurl> |
<mapurl evaluate='1'>return '$escapedSequenceName';</mapurl> |