version 1.594, 2011/06/19 13:38:44
|
version 1.595, 2011/06/22 11:00:47
|
Line 444 RESOURCE_SELECTOR
|
Line 444 RESOURCE_SELECTOR
|
sub incomplete { |
sub incomplete { |
my ($username, $domain, $map) = @_; |
my ($username, $domain, $map) = @_; |
|
|
# Manipulate the env so the navmap is made |
|
# in the context of the appropriate user: |
|
|
|
my $me = $env{'user.name'}; |
my $navmap = Apache::lonnavmaps::navmap->new($username, $domain); |
my $my_domain = $env{'user.domain'}; |
|
|
|
$env{'user.name'} = $username; |
|
$env{'user.domain'} = $domain; |
|
|
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
|
|
$env{'user.name'} = $me; # Restore user/domain context. |
|
$env{'user.domain'} = $my_domain; |
|
|
|
if (defined($navmap)) { |
if (defined($navmap)) { |
my $res = $navmap->getResourceByUrl($map); |
my $res = $navmap->getResourceByUrl($map); |
Line 466 sub incomplete {
|
Line 456 sub incomplete {
|
return 1; |
return 1; |
} |
} |
} |
} |
|
# |
|
# When printing for students, the resoures and order of the |
|
# resources may need to be altered if there are folders with |
|
# random selectiopn or random ordering (or both) enabled. |
|
# This sub computes the set of resources to print for a student |
|
# modified both by random ordering and selection and filtered |
|
# to only those that are in the original set selcted to be printed. |
|
# |
|
# Parameters: |
|
# $helper - The helper we need $helper->{'VARS'}->{'symb'} |
|
# to construct the navmap and the iteration. |
|
# $seq - The original set of resources to print |
|
# (really an array of resource names |
|
# $who - Student/domain for whome the sequence will be generated. |
|
# |
|
# Implicit inputs: |
|
# $ |
|
# Returns: |
|
# reference to an array of resources that can be passed to |
|
# print_resources. |
|
# |
|
sub master_seq_to_person_seq { |
|
my ($helper, $seq, $who) = @_; |
|
|
|
|
|
my ($username, $userdomain, $usersection) = split(/:/, $who); |
|
|
|
# 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. |
|
# |
|
|
|
my %seq_hash = map {$_ => 1} @$seq; |
|
my @output_seq; |
|
|
|
my ($map, $id, $url) = &Apache::lonnet::decode_symb($helper->{VARS}->{'symb'}); |
|
my $navmap = Apache::lonnavmaps::navmap->new($username, $userdomain); |
|
my $iterator = $navmap->getIterator($navmap->firstResource(), |
|
$navmap->finishResource(), |
|
{}, 1); |
|
my %nonResourceItems = ( |
|
$iterator->BEGIN_MAP => 1, |
|
$iterator->BEGIN_BRANCH => 1, |
|
$iterator->END_BRANCH => 1, |
|
$iterator->END_MAP => 1, |
|
$iterator->FORWARD => 1, |
|
$iterator->BACKWARD => 1 |
|
|
|
); # These items are not resources but appear in the midst of iteration. |
|
|
|
# Iterate on the resource..select the items that are randomly selected |
|
# and that are in the seq_has. Presumably the iterator will take care |
|
# of the random ordering part of the deal. |
|
# |
|
my $curres; |
|
while ($curres = $iterator->next()) { |
|
# |
|
# Only process resources..that re not removed by randomout... |
|
# |
|
if (! exists $nonResourceItems{$curres} && ! $curres->randomout()) { |
|
my $symb = $curres->symb(); |
|
if (exists $seq_hash{$symb}) { |
|
push(@output_seq, $symb); |
|
} |
|
} |
|
} |
|
|
|
|
|
return \@output_seq; # for now. |
|
|
|
} |
|
|
|
|
# Fetch the contents of a resource, uninterpreted. |
# Fetch the contents of a resource, uninterpreted. |
# This is used here to fetch a latex file to be included |
# This is used here to fetch a latex file to be included |
Line 640 sub ssi_with_retries {
|
Line 701 sub ssi_with_retries {
|
$ssi_last_error_resource = $resource; |
$ssi_last_error_resource = $resource; |
$ssi_last_error = $response->code . " " . $response->message; |
$ssi_last_error = $response->code . " " . $response->message; |
$content='\section*{!!! An error occurred !!!}'; |
$content='\section*{!!! An error occurred !!!}'; |
&Apache::lonnet::logthis("Error in SSI resource: $resource Error: $ssi_last_error"); |
|
} |
} |
|
|
return $content; |
return $content; |
Line 656 sub get_student_view_with_retries {
|
Line 716 sub get_student_view_with_retries {
|
$ssi_last_error_resource = $curresline.' for user '.$username.':'.$userdomain; |
$ssi_last_error_resource = $curresline.' for user '.$username.':'.$userdomain; |
$ssi_last_error = $response->code . " " . $response->message; |
$ssi_last_error = $response->code . " " . $response->message; |
$content='\section*{!!! An error occurred !!!}'; |
$content='\section*{!!! An error occurred !!!}'; |
&Apache::lonnet::logthis("Error in SSI (student view) resource: $curresline Error: $ssi_last_error User: $username:$userdomain"); |
|
} |
} |
return $content; |
return $content; |
|
|
Line 2840 ENDPART
|
Line 2899 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 ($output,$fullname, $printed)=&print_resources($r,$helper, |
my ($output,$fullname, $printed)=&print_resources($r,$helper, |
$person,$type, |
$person,$type, |
\%moreenv,\@master_seq, |
\%moreenv, $actual_seq, |
$flag_latex_header_remove, |
$flag_latex_header_remove, |
$LaTeXwidth); |
$LaTeXwidth); |
$resources_printed .= ":"; |
$resources_printed .= ":"; |
Line 3355 sub print_resources {
|
Line 3415 sub print_resources {
|
# incomplete resources for the person. |
# incomplete resources for the person. |
# |
# |
|
|
&Apache::lonnet::logthis("Number printed: $actually_printed"); |
|
if ($actually_printed == 0) { |
if ($actually_printed == 0) { |
&Apache::lonnet::logthis("Remove? $remove_latex_header"); |
|
$current_output = &encapsulate_minipage("\\vskip -10mm \nNo incomplete resources\n \\vskip 100 mm { }\n"); |
$current_output = &encapsulate_minipage("\\vskip -10mm \nNo incomplete resources\n \\vskip 100 mm { }\n"); |
if ($remove_latex_header eq "NO") { |
if ($remove_latex_header eq "NO") { |
$current_output = &print_latex_header() . $current_output; |
$current_output = &print_latex_header() . $current_output; |