version 1.66, 2002/10/04 20:34:04
|
version 1.68, 2002/10/07 21:07:47
|
Line 920 sub new_handle {
|
Line 920 sub new_handle {
|
|
|
my $condition = 0; |
my $condition = 0; |
if ($ENV{'form.condition'}) { |
if ($ENV{'form.condition'}) { |
$condition = 1; |
$condition = 1; |
} |
} |
|
|
my $mapIterator = $navmap->getIterator(undef, undef, \%filterHash, $condition); |
my $mapIterator = $navmap->getIterator(undef, undef, \%filterHash, $condition); |
Line 946 sub new_handle {
|
Line 946 sub new_handle {
|
$isNewBranch = 1; |
$isNewBranch = 1; |
} |
} |
|
|
|
# Is this resource being blotted out? |
|
if (ref($curRes) && !advancedUser() && $curRes->randomout()) { |
|
$curRes = $mapIterator->next(); |
|
next; # and totally ignore this resource |
|
} |
|
|
if (ref($curRes) && $curRes->src()) { |
if (ref($curRes) && $curRes->src()) { |
|
|
# Step one: Decide which parts to show |
# Step one: Decide which parts to show |
Line 962 sub new_handle {
|
Line 968 sub new_handle {
|
# just display first |
# just display first |
if (!$curRes->opendate("0")) { |
if (!$curRes->opendate("0")) { |
@parts = ("0"); # just display the zero-th part |
@parts = ("0"); # just display the zero-th part |
$condensed = 1; |
$condensed = 1; |
} else { |
} else { |
# Otherwise, only display part 0 if we want to |
# Otherwise, only display part 0 if we want to |
# attach feedback or email information to it |
# attach feedback or email information to it |
Line 1026 sub new_handle {
|
Line 1032 sub new_handle {
|
foreach my $part (@parts) { |
foreach my $part (@parts) { |
|
|
my $deltalevel = 0; # for inserting the branch icon |
my $deltalevel = 0; # for inserting the branch icon |
|
my $nonLinkedText = ""; # unlinked stuff after title |
|
|
# For each thing we're displaying... |
# For each thing we're displaying... |
|
|
Line 1075 sub new_handle {
|
Line 1082 sub new_handle {
|
removeFromFilter(\%filterHash, $mapId); |
removeFromFilter(\%filterHash, $mapId); |
$linkopen .= "&condition=$condition&$queryAdd\">"; |
$linkopen .= "&condition=$condition&$queryAdd\">"; |
$linkclose = "</a>"; |
$linkclose = "</a>"; |
|
|
} |
} |
|
|
my $colorizer = ""; |
my $colorizer = ""; |
Line 1087 sub new_handle {
|
Line 1094 sub new_handle {
|
} |
} |
} |
} |
|
|
|
if ($curRes->randomout()) { |
|
$nonLinkedText .= ' <i>(hidden)</i> '; |
|
} |
|
|
# FIRST COL: The resource indentation, branch icon, and name |
# FIRST COL: The resource indentation, branch icon, and name |
$r->print(" <tr><td align=\"left\" valign=\"bottom\">\n"); |
$r->print(" <tr><td align=\"left\" valign=\"bottom\">\n"); |
|
|
Line 1097 sub new_handle {
|
Line 1108 sub new_handle {
|
|
|
$r->print(" ${newBranchText}${linkopen}$icon${linkclose}\n"); |
$r->print(" ${newBranchText}${linkopen}$icon${linkclose}\n"); |
|
|
my $nonLinkedText = ""; |
|
|
|
if ($curRes->is_problem() && $part != "0" && !$condensed) { |
if ($curRes->is_problem() && $part != "0" && !$condensed) { |
$partLabel = " (Part $part)"; |
$partLabel = " (Part $part)"; |
$title = ""; |
$title = ""; |
} |
} |
if ($multipart && $condensed) { |
if ($multipart && $condensed) { |
$nonLinkedText = ' (' . $curRes->countParts() . ' parts)'; |
$nonLinkedText .= ' (' . $curRes->countParts() . ' parts)'; |
} |
} |
|
|
$r->print(" <a href=\"$link\">$title$partLabel</a> $nonLinkedText"); |
$r->print(" <a href=\"$link\">$title$partLabel</a> $nonLinkedText"); |
Line 1163 sub new_handle {
|
Line 1172 sub new_handle {
|
!$firstDisplayed) { |
!$firstDisplayed) { |
$r->print (getDescription($curRes, $part)); |
$r->print (getDescription($curRes, $part)); |
} |
} |
|
if ($curRes->is_map() && advancedUser() && $curRes->randompick()) { |
|
$r->print('(randomly select ' . $curRes->randompick() .')'); |
|
} |
|
|
$r->print("</td></tr>\n"); |
$r->print("</td></tr>\n"); |
} |
} |
Line 1273 sub getDescription {
|
Line 1285 sub getDescription {
|
} |
} |
} |
} |
|
|
|
sub advancedUser { |
|
return $ENV{'user.adv'}; |
|
} |
|
|
# I want to change this into something more human-friendly. For |
# I want to change this into something more human-friendly. For |
# now, this is a simple call to localtime. The final function |
# now, this is a simple call to localtime. The final function |
# probably belongs in loncommon. |
# probably belongs in loncommon. |
Line 1770 sub new {
|
Line 1786 sub new {
|
return $self; |
return $self; |
} |
} |
|
|
|
# FIXME: Document this. |
|
sub cancelTopRecursion { |
|
my $self = shift; |
|
|
|
if (!$self->{RECURSIVE_ITERATOR_FLAG}) {return;} |
|
|
|
# is this the iterator we want to kill? |
|
if ($self->{RECURSIVE_ITERATOR_FLAG} && |
|
!$self->{RECURSIVE_ITERATOR}->{RECURSIVE_ITERATOR_FLAG}) { |
|
$self->{RECURSIVE_ITERATOR_FLAG} = 0; |
|
undef $self->{RECURSIVE_ITERATOR}; |
|
return; |
|
} |
|
|
|
$self->{RECURSIVE_ITERATOR}->cancelTopRecursion(); |
|
} |
|
|
# Note... this function is *touchy*. I strongly recommend tracing |
# Note... this function is *touchy*. I strongly recommend tracing |
# through it with the debugger a few times on a non-trivial map before |
# through it with the debugger a few times on a non-trivial map before |
# modifying it. Order is *everything*. |
# modifying it. Order is *everything*. |
|
# FIXME: Doc that skipMap will prevent the recursion, if any. |
sub next { |
sub next { |
my $self = shift; |
my $self = shift; |
|
my $skipMap = shift; |
|
|
# Iterator logic goes here |
# Iterator logic goes here |
|
|
# Is this return value pre-determined? |
|
if (defined($self->{FORCE_NEXT})) { |
|
my $tmp = $self->{FORCE_NEXT}; |
|
$self->{FORCE_NEXT} = undef; |
|
return $tmp; |
|
} |
|
|
|
# Are we using a recursive iterator? If so, pull from that and |
# Are we using a recursive iterator? If so, pull from that and |
# watch the depth; we want to resume our level at the correct time. |
# watch the depth; we want to resume our level at the correct time. |
if ($self->{RECURSIVE_ITERATOR_FLAG}) |
if ($self->{RECURSIVE_ITERATOR_FLAG}) |
Line 1804 sub next {
|
Line 1832 sub next {
|
return $next; |
return $next; |
} |
} |
|
|
|
# Is this return value pre-determined? |
|
if (defined($self->{FORCE_NEXT})) { |
|
my $tmp = $self->{FORCE_NEXT}; |
|
$self->{FORCE_NEXT} = undef; |
|
return $tmp; |
|
} |
|
|
# Is there a current resource to grab? If not, then return |
# Is there a current resource to grab? If not, then return |
# END_BRANCH and END_MAP in succession. |
# END_BRANCH and END_MAP in succession. |
if (scalar(@{$self->{BRANCH_STACK}}) == 0) { |
if (scalar(@{$self->{BRANCH_STACK}}) == 0) { |
Line 1892 sub next {
|
Line 1927 sub next {
|
$self->{FORCE_NEXT} = $self->END_BRANCH(); |
$self->{FORCE_NEXT} = $self->END_BRANCH(); |
$self->{BRANCH_DEPTH}--; |
$self->{BRANCH_DEPTH}--; |
} |
} |
return $self->{HERE}; |
|
} |
} |
|
|
while (@$next) { |
while (@$next) { |
Line 1908 sub next {
|
Line 1942 sub next {
|
} |
} |
|
|
# If this is a map and we want to recurse down it... (not filtered out) |
# If this is a map and we want to recurse down it... (not filtered out) |
if ($self->{HERE}->is_map() && |
if ($self->{HERE}->is_map() && !$skipMap && |
(defined($self->{FILTER}->{$self->{HERE}->map_pc()}) xor $self->{CONDITION})) { |
(defined($self->{FILTER}->{$self->{HERE}->map_pc()}) xor $self->{CONDITION})) { |
$self->{RECURSIVE_ITERATOR_FLAG} = 1; |
$self->{RECURSIVE_ITERATOR_FLAG} = 1; |
my $firstResource = $self->{HERE}->map_start(); |
my $firstResource = $self->{HERE}->map_start(); |
my $finishResource = $self->{HERE}->map_finish(); |
my $finishResource = $self->{HERE}->map_finish(); |
|
|
# Odd perl syntax here; $self->new allows one to create a new iterator |
|
# can't figure out how to ref this package directly correctly |
|
# isn't MAIN::new, __PACKAGE__::new or Apache::lonnavmaps::iterator->new |
|
$self->{RECURSIVE_ITERATOR} = |
$self->{RECURSIVE_ITERATOR} = |
Apache::lonnavmaps::iterator->new ($self->{NAV_MAP}, $firstResource, |
Apache::lonnavmaps::iterator->new ($self->{NAV_MAP}, $firstResource, |
$finishResource, $self->{FILTER}, $self->{ALREADY_SEEN}, |
$finishResource, $self->{FILTER}, $self->{ALREADY_SEEN}, |
Line 2037 sub goesto { my $self=shift; return $sel
|
Line 2068 sub goesto { my $self=shift; return $sel
|
# "to" can return a comma seperated list for branches |
# "to" can return a comma seperated list for branches |
sub to { my $self=shift; return $self->navHash("to_", 1); } |
sub to { my $self=shift; return $self->navHash("to_", 1); } |
sub kind { my $self=shift; return $self->navHash("kind_", 1); } |
sub kind { my $self=shift; return $self->navHash("kind_", 1); } |
|
sub ext { my $self=shift; return $self->navHash("ext_", 1) eq 'true:'; } |
|
sub randomout { my $self=shift; return $self->navHash("randomout_", 1); } |
|
sub randompick { |
|
my $self = shift; |
|
return $self->{NAV_MAP}->{PARM_HASH}->{$self->symb . |
|
'.0.parameter_randompick'}; |
|
} |
sub src { |
sub src { |
my $self=shift; |
my $self=shift; |
return $self->navHash("src_", 1); |
return $self->navHash("src_", 1); |
Line 2286 sub getFeedback {
|
Line 2324 sub getFeedback {
|
sub parts { |
sub parts { |
my $self = shift; |
my $self = shift; |
|
|
|
if ($self->ext) { return ['0']; } |
|
|
$self->extractParts(); |
$self->extractParts(); |
return $self->{PARTS}; |
return $self->{PARTS}; |
} |
} |
Line 2309 sub extractParts {
|
Line 2349 sub extractParts {
|
my $self = shift; |
my $self = shift; |
|
|
return if ($self->{PARTS}); |
return if ($self->{PARTS}); |
|
return if ($self->ext); |
|
|
$self->{PARTS} = []; |
$self->{PARTS} = []; |
|
|