version 1.621, 2012/11/20 12:01:54
|
version 1.627.2.1, 2012/12/28 00:25:11
|
Line 705 sub incomplete {
|
Line 705 sub incomplete {
|
# to only those that are in the original set selcted to be printed. |
# to only those that are in the original set selcted to be printed. |
# |
# |
# Parameters: |
# Parameters: |
# $helper - The helper we need $helper->{'VARS'}->{'symb'} |
# $map - The URL of the folder being printed. |
# to construct the navmap and the iteration. |
# Used to determine which startResource and finishResource |
# $seq - The original set of resources to print |
# to use when using the navmap's getIterator method. |
|
# $seq - The original set of resources to print. |
# (really an array of resource names (array of symb's). |
# (really an array of resource names (array of symb's). |
# $who - Student/domain for whome the sequence will be generated. |
# $who - Student/domain for whome the sequence will be generated. |
|
# $code - CODE being printed when printing Problems/Resources |
|
# from folder for CODEd assignments |
# |
# |
# Implicit inputs: |
# Implicit inputs: |
# $ |
# $ |
Line 718 sub incomplete {
|
Line 721 sub incomplete {
|
# print_resources. |
# print_resources. |
# |
# |
sub master_seq_to_person_seq { |
sub master_seq_to_person_seq { |
my ($helper, $seq, $who) = @_; |
my ($map, $seq, $who, $code) = @_; |
|
|
|
|
my ($username, $userdomain, $usersection) = split(/:/, $who); |
my ($username, $userdomain, $usersection) = split(/:/, $who); |
|
|
|
|
# Toss the sequence up into a hash so that we have O(1) lookup time. |
# Toss the sequence up into a hash so that we have O(1) lookup time. |
# on the items that come out of the user's list of resources. |
# on the items that come out of the user's list of resources. |
# |
# |
|
|
my %seq_hash = map {$_ => 1} @$seq; |
my %seq_hash = map {$_ => 1} @$seq; |
my @output_seq; |
my @output_seq; |
|
|
my ($map, $id, $url) = &Apache::lonnet::decode_symb($helper->{VARS}->{'symb'}); |
my $navmap = Apache::lonnavmaps::navmap->new($username, $userdomain, |
my $navmap = Apache::lonnavmaps::navmap->new($username, $userdomain); |
$code); |
my $iterator = $navmap->getIterator($navmap->firstResource(), |
my ($start,$finish); |
$navmap->finishResource(), |
|
{}, 1); |
if ($map) { |
my %nonResourceItems = ( |
my $mapres = $navmap->getResourceByUrl($map); |
$iterator->BEGIN_MAP => 1, |
if ($mapres->is_map()) { |
$iterator->BEGIN_BRANCH => 1, |
$start = $mapres->map_start(); |
$iterator->END_BRANCH => 1, |
$finish = $mapres->map_finish(); |
$iterator->END_MAP => 1, |
} |
$iterator->FORWARD => 1, |
} |
$iterator->BACKWARD => 1 |
unless ($start && $finish) { |
|
$start = $navmap->firstResource(); |
|
$finish = $navmap->finishResource(); |
|
} |
|
|
); # These items are not resources but appear in the midst of iteration. |
my $iterator = $navmap->getIterator($start,$finish,{},1); |
|
|
# Iterate on the resource..select the items that are randomly selected |
# Iterate on the resource..select the items that are randomly selected |
# and that are in the seq_has. Presumably the iterator will take care |
# and that are in the seq_has. Presumably the iterator will take care |
Line 756 sub master_seq_to_person_seq {
|
Line 761 sub master_seq_to_person_seq {
|
# Only process resources..that are not removed by randomout... |
# Only process resources..that are not removed by randomout... |
# and are selected for printint as well. |
# and are selected for printint as well. |
# |
# |
|
|
if (! exists $nonResourceItems{$curres} && ! $curres->randomout()) { |
if (ref($curres) && ! $curres->randomout()) { |
my $symb = $curres->symb(); |
my $currsymb = $curres->symb(); |
if (exists $seq_hash{$symb}) { |
if (exists($seq_hash{$currsymb})) { |
push(@output_seq, $symb); |
push(@output_seq, $currsymb); |
} |
} |
} |
} |
} |
} |
|
|
|
|
return \@output_seq; # for now. |
return \@output_seq; # for now. |
|
|
Line 1044 sub printf_style_subst {
|
Line 1048 sub printf_style_subst {
|
# %s - The section if it is supplied. |
# %s - The section if it is supplied. |
# |
# |
sub format_page_header { |
sub format_page_header { |
my ($width, $format, $assignment, $course, $student, $section) = @_; |
my ($width, $format, $assignment, $course, $student) = @_; |
|
|
|
|
|
|
$width = &recalcto_mm($width); # Get width in mm. |
$width = &recalcto_mm($width); # Get width in mm. |
my $chars_per_line = int($width/1.6); # Character/textline. |
my $chars_per_line = int($width/2); # Character/textline. |
|
|
# Default format? |
# Default format? |
|
|
Line 1065 sub format_page_header {
|
Line 1069 sub format_page_header {
|
# - Allow the assignment to be 2 lines (wrapped). |
# - Allow the assignment to be 2 lines (wrapped). |
# |
# |
|
|
|
my $firstline = "$student $course"; |
|
if (length($firstline) > $chars_per_line) { |
|
my $lastchar = $chars_per_line - length($student) - 1; |
|
if ($lastchar > 0) { |
|
$course = substr($course, 0, $lastchar); |
|
} else { # Nothing left of course: |
|
$course = ''; |
|
} |
|
} |
|
if (length($assignment) > $chars_per_line) { |
|
$assignment = substr($assignment, 0, $chars_per_line); |
|
} |
|
|
my $name_length = int($chars_per_line *3 /4); |
$format = "\\textbf{$student} $course \\hfill \\thepage \\\\ \\textit{$assignment}"; |
my $sec_length = int($chars_per_line / 5); |
|
|
|
$format = "%$name_length".'n'; |
} else { |
|
# An open question is how to handle long user formatted page headers... |
|
# A possible future is to support e.g. %na so that the user can control |
|
# the truncation of the elements that can appear in the header. |
|
# |
|
$format = &printf_style_subst("a", $format, $assignment); |
|
$format = &printf_style_subst("c", $format, $course); |
|
$format = &printf_style_subst("n", $format, $student); |
|
|
|
# If the user put %'s in the format string, they must be escaped |
|
# to \% else LaTeX will think they are comments and terminate |
|
# the line.. which is bad!!! |
|
|
if ($section) { |
} |
$format .= ' - Sec: '."%$sec_length".'s'; |
|
} |
|
|
|
$format .= '\\\\%c \\\\ %a'; |
return $format; |
|
|
|
|
} |
|
# An open question is how to handle long user formatted page headers... |
|
# A possible future is to support e.g. %na so that the user can control |
|
# the truncation of the elements that can appear in the header. |
|
# |
|
$format = &printf_style_subst("a", $format, $assignment); |
|
$format = &printf_style_subst("c", $format, $course); |
|
$format = &printf_style_subst("n", $format, $student); |
|
$format = &printf_style_subst("s", $format, $section); |
|
|
|
|
|
# If the user put %'s in the format string, they must be escaped |
|
# to \% else LaTeX will think they are comments and terminate |
|
# the line.. which is bad!!! |
|
|
|
# If the user has role author, $course and $assignment are empty so |
# If the user has role author, $course and $assignment are empty so |
# there is '\\ \\ ' in the page header. That's cause a error in LaTeX |
# there is '\\ \\ ' in the page header. That's cause a error in LaTeX |
Line 1828 sub get_course {
|
Line 1836 sub get_course {
|
my $courseidinfo; |
my $courseidinfo; |
if (defined($env{'request.course.id'})) { |
if (defined($env{'request.course.id'})) { |
$courseidinfo = &Apache::lonxml::latex_special_symbols(&unescape($env{'course.'.$env{'request.course.id'}.'.description'}),'header'); |
$courseidinfo = &Apache::lonxml::latex_special_symbols(&unescape($env{'course.'.$env{'request.course.id'}.'.description'}),'header'); |
my $sec = $env{'request.course.sec'}; |
|
|
|
} |
} |
return $courseidinfo; |
return $courseidinfo; |
} |
} |
Line 1852 sub page_format_transformation {
|
Line 1858 sub page_format_transformation {
|
|
|
my $name = &get_name(); |
my $name = &get_name(); |
my $courseidinfo = &get_course(); |
my $courseidinfo = &get_course(); |
|
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
my $header_text = $parmhash{'print_header_format'}; |
my $header_text = $parmhash{'print_header_format'}; |
$header_text = &format_page_header($textwidth, $header_text, $assignment, |
$header_text = &format_page_header($textwidth, $header_text, $assignment, |
$courseidinfo, $name); |
$courseidinfo, $name); |
Line 2060 sub unsupported {
|
Line 2067 sub unsupported {
|
my $result.= &print_latex_header($mode); |
my $result.= &print_latex_header($mode); |
if ($currentURL=~m|^(/adm/wrapper/)?ext/|) { |
if ($currentURL=~m|^(/adm/wrapper/)?ext/|) { |
$currentURL=~s|^(/adm/wrapper/)?ext/|http://|; |
$currentURL=~s|^(/adm/wrapper/)?ext/|http://|; |
|
$currentURL=~s|^http://https://|https://|; |
my $title=&Apache::lonnet::gettitle($symb); |
my $title=&Apache::lonnet::gettitle($symb); |
$title = &Apache::lonxml::latex_special_symbols($title); |
$title = &Apache::lonxml::latex_special_symbols($title); |
$result.=' \strut \\\\ '.$title.' \strut \\\\ '.$currentURL.' '; |
$result.=' \strut \\\\ '.$title.' \strut \\\\ '.$currentURL.' '; |
Line 2139 sub print_page_in_course {
|
Line 2147 sub print_page_in_course {
|
my @page_resources = $navmap->retrieveResources($resource_src); |
my @page_resources = $navmap->retrieveResources($resource_src); |
$result .= &print_page_in_course($helper, $rparmhash, |
$result .= &print_page_in_course($helper, $rparmhash, |
$resource_src, \@page_resources); |
$resource_src, \@page_resources); |
|
} elsif ($resource->ext()) { |
|
$result .= &unsupported($currentURL,$mode,$symb); |
} |
} |
# these resources go through the XML transformer: |
# these resources go through the XML transformer: |
|
|
Line 2605 sub print_construction_sequence {
|
Line 2615 sub print_construction_sequence {
|
# For item 100, filtering was done at the helper level. |
# For item 100, filtering was done at the helper level. |
|
|
sub output_data { |
sub output_data { |
&Apache::lonnet::logthis("outptu_data"); |
|
|
|
my ($r,$helper,$rparmhash) = @_; |
my ($r,$helper,$rparmhash) = @_; |
my %parmhash = %$rparmhash; |
my %parmhash = %$rparmhash; |
Line 2880 ENDPART
|
Line 2889 ENDPART
|
($print_type eq 'select_sequences') or |
($print_type eq 'select_sequences') or |
($print_type eq 'map_incomplete_problems_seq') |
($print_type eq 'map_incomplete_problems_seq') |
) { |
) { |
&Apache::lonnet::logthis("map_problems maybe"); |
|
&Apache::lonnet::logthis($print_type eq 'map_problems' ? " Yes" : "No"); |
|
|
|
#-- produce an output string |
#-- produce an output string |
if (($print_type eq 'map_problems') or |
if (($print_type eq 'map_problems') or |
Line 3018 ENDPART
|
Line 3025 ENDPART
|
if (($selectionmade == 4) and ($assignment ne $prevassignment)) { |
if (($selectionmade == 4) and ($assignment ne $prevassignment)) { |
my $name = &get_name(); |
my $name = &get_name(); |
my $courseidinfo = &get_course(); |
my $courseidinfo = &get_course(); |
|
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
$prevassignment=$assignment; |
$prevassignment=$assignment; |
my $header_text = $parmhash{'print_header_format'}; |
my $header_text = $parmhash{'print_header_format'}; |
$header_text = &format_page_header($textwidth, $header_text, |
$header_text = &format_page_header($textwidth, $header_text, |
Line 3144 ENDPART
|
Line 3152 ENDPART
|
} |
} |
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; |
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; |
|
|
|
my $map; |
|
if ($helper->{VARS}->{'symb'}) { |
|
($map, my $id, my $resource) = |
|
&Apache::lonnet::decode_symb($helper->{VARS}->{'symb'}); |
|
} |
|
|
#loop over students |
#loop over students |
|
|
my $flag_latex_header_remove = 'NO'; |
my $flag_latex_header_remove = 'NO'; |
Line 3178 ENDPART
|
Line 3192 ENDPART
|
} else { |
} else { |
$i=int($student_counter/$helper->{'VARS'}{'NUMBER_TO_PRINT'}); |
$i=int($student_counter/$helper->{'VARS'}{'NUMBER_TO_PRINT'}); |
} |
} |
my $actual_seq = master_seq_to_person_seq($helper, \@master_seq, $person); |
my $actual_seq = master_seq_to_person_seq($map, \@master_seq, |
|
$person); |
my ($output,$fullname, $printed)=&print_resources($r,$helper, |
my ($output,$fullname, $printed)=&print_resources($r,$helper, |
$person,$type, |
$person,$type, |
\%moreenv, $actual_seq, |
\%moreenv, $actual_seq, |
Line 3204 ENDPART
|
Line 3219 ENDPART
|
my $old_name=$helper->{'VARS'}->{'REUSE_OLD_CODES'}; |
my $old_name=$helper->{'VARS'}->{'REUSE_OLD_CODES'}; |
my $single_code = $helper->{'VARS'}->{'SINGLE_CODE'}; |
my $single_code = $helper->{'VARS'}->{'SINGLE_CODE'}; |
my $selected_code = $helper->{'VARS'}->{'CODE_SELECTED_FROM_LIST'}; |
my $selected_code = $helper->{'VARS'}->{'CODE_SELECTED_FROM_LIST'}; |
|
|
my $code_option=$helper->{'VARS'}->{'CODE_OPTION'}; |
my $code_option=$helper->{'VARS'}->{'CODE_OPTION'}; |
my @lines = &Apache::grades::get_scantronformat_file(); |
my @lines = &Apache::grades::get_scantronformat_file(); |
my ($code_type,$code_length,$bubbles_per_row)=('letter',6,10); |
my ($code_type,$code_length,$bubbles_per_row)=('letter',6,10); |
Line 3221 ENDPART
|
Line 3235 ENDPART
|
} |
} |
} |
} |
} |
} |
|
my ($randomorder,$randompick,$map); |
|
if ($helper->{VARS}{'symb'}) { |
|
($map, my $id, my $resource) = |
|
&Apache::lonnet::decode_symb($helper->{VARS}{'symb'}); |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
if (defined($navmap)) { |
|
if ($map) { |
|
my $mapres = $navmap->getResourceByUrl($map); |
|
$randomorder = $mapres->randomorder(); |
|
$randompick = $mapres->randompick(); |
|
} |
|
} |
|
} |
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'}; |
$moreenv{'instructor_comments'}='hide'; |
$moreenv{'instructor_comments'}='hide'; |
Line 3282 ENDPART
|
Line 3309 ENDPART
|
} else { |
} else { |
$moreenv{'CODE'}=&num_to_letters($code); |
$moreenv{'CODE'}=&num_to_letters($code); |
} |
} |
|
my $actual_seq = \@master_seq; |
|
if ($randomorder) { |
|
$env{'form.CODE'} = $moreenv{'CODE'}; |
|
$actual_seq = master_seq_to_person_seq($map, \@master_seq, |
|
undef, |
|
$moreenv{'CODE'}); |
|
delete($env{'form.CODE'}); |
|
} |
my ($output,$fullname, $printed)= |
my ($output,$fullname, $printed)= |
&print_resources($r,$helper,'anonymous',$type,\%moreenv, |
&print_resources($r,$helper,'anonymous',$type,\%moreenv, |
\@master_seq,$flag_latex_header_remove, |
$actual_seq,$flag_latex_header_remove, |
$LaTeXwidth); |
$LaTeXwidth); |
$resources_printed .= ":"; |
$resources_printed .= ":"; |
$print_array[$file_num].=$output; |
$print_array[$file_num].=$output; |
Line 3577 sub print_resources {
|
Line 3612 sub print_resources {
|
my $current_assignment = ""; |
my $current_assignment = ""; |
my $assignment; |
my $assignment; |
my $courseidinfo = &get_course(); |
my $courseidinfo = &get_course(); |
|
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
|
if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection} |
|
|
foreach my $curresline (@{$master_seq}) { |
foreach my $curresline (@{$master_seq}) { |
if (defined $page_breaks{$curresline}) { |
if (defined $page_breaks{$curresline}) { |
Line 3700 sub print_resources {
|
Line 3737 sub print_resources {
|
if (($assignment ne $current_assignment) && ($assignment ne "")) { |
if (($assignment ne $current_assignment) && ($assignment ne "")) { |
my $header_line = &format_page_header($LaTeXwidth, $parmhash{'print_header_format'}, |
my $header_line = &format_page_header($LaTeXwidth, $parmhash{'print_header_format'}, |
$assignment, $courseidinfo, |
$assignment, $courseidinfo, |
$fullname, $usersection); |
$fullname); |
my $header_start = ($columns_in_format == 1) ? '\lhead' |
my $header_start = ($columns_in_format == 1) ? '\lhead' |
: '\fancyhead[LO]'; |
: '\fancyhead[LO]'; |
$header_line = $header_start.'{'.$header_line.'}'; |
$header_line = $header_start.'{'.$header_line.'}'; |
Line 3732 sub print_resources {
|
Line 3769 sub print_resources {
|
my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header'); |
my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header'); |
my $header_line = |
my $header_line = |
&format_page_header($LaTeXwidth, $parmhash{'print_header_format'}, |
&format_page_header($LaTeXwidth, $parmhash{'print_header_format'}, |
$currentassignment, $courseidinfo, $fullname, $usersection); |
$currentassignment, $courseidinfo, $fullname); |
my $header_start = ($columns_in_format == 1) ? '\lhead' |
my $header_start = ($columns_in_format == 1) ? '\lhead' |
: '\fancyhead[LO]'; |
: '\fancyhead[LO]'; |
$header_line = $header_start.'{'.$header_line.'}'; |
$header_line = $header_start.'{'.$header_line.'}'; |
Line 3802 sub handler {
|
Line 3839 sub handler {
|
} |
} |
|
|
&init_perm(); |
&init_perm(); |
&Apache::lonnet::logthis("Handler"); |
|
my $helper = printHelper($r); |
my $helper = printHelper($r); |
if (!ref($helper)) { |
if (!ref($helper)) { |
return $helper; |
return $helper; |
Line 4629 CHOOSE_FROM_ANY_SEQUENCE
|
Line 4665 CHOOSE_FROM_ANY_SEQUENCE
|
if (!$res_printable) { |
if (!$res_printable) { |
$paramHash = Apache::lonhelper::getParamHash(); |
$paramHash = Apache::lonhelper::getParamHash(); |
$paramHash->{MESSAGE_TEXT} = |
$paramHash->{MESSAGE_TEXT} = |
&mt('<p><b>Printing for current resource is only possible between [_1] and [_1]</b></p>', |
&mt('[_1]Printing for current resource is only possible between [_2] and [_3]', |
$res_printstartdate, $res_printenddate); |
'<p><b>',$res_printstartdate, $res_printenddate.'</b></p>'); |
Apache::lonhelper::message->new(); |
Apache::lonhelper::message->new(); |
} |
} |
$paramHash = Apache::lonhelper::getParamHash(); |
$paramHash = Apache::lonhelper::getParamHash(); |