version 1.67, 2002/10/07 19:00:38
|
version 1.69, 2002/10/08 18:54:39
|
Line 892 sub new_handle {
|
Line 892 sub new_handle {
|
$res->OPEN_LATER => '', |
$res->OPEN_LATER => '', |
$res->TRIES_LEFT => 'navmap.open.gif', |
$res->TRIES_LEFT => 'navmap.open.gif', |
$res->INCORRECT => 'navmap.wrong.gif', |
$res->INCORRECT => 'navmap.wrong.gif', |
$res->OPEN => 'navmap.open.gif' ); |
$res->OPEN => 'navmap.open.gif', |
|
$res->ATTEMPTED => '' ); |
|
|
|
my %iconAltTags = |
|
( 'navmap.correct.gif' => 'Correct', |
|
'navmap.wrong.gif' => 'Incorrect', |
|
'navmap.open.gif' => 'Open' ); |
|
|
my %condenseStatuses = |
my %condenseStatuses = |
( $res->NETWORK_FAILURE => 1, |
( $res->NETWORK_FAILURE => 1, |
Line 920 sub new_handle {
|
Line 926 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 952 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 974 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 1038 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 1088 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 1100 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 1114 sub new_handle {
|
|
|
$r->print(" ${newBranchText}${linkopen}$icon${linkclose}\n"); |
$r->print(" ${newBranchText}${linkopen}$icon${linkclose}\n"); |
|
|
my $nonLinkedText = ""; |
if ($curRes->is_problem() && $part ne "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 1142 sub new_handle {
|
Line 1157 sub new_handle {
|
# columns? |
# columns? |
my $firstDisplayed = !$condensed && $multipart && $part eq "0"; |
my $firstDisplayed = !$condensed && $multipart && $part eq "0"; |
|
|
# THIRD ROW: Problem status icon |
# THIRD COL: Problem status icon |
if ($curRes->is_problem() && |
if ($curRes->is_problem() && |
!$firstDisplayed) { |
!$firstDisplayed) { |
my $icon = $statusIconMap{$curRes->status($part)}; |
my $icon = $statusIconMap{$curRes->status($part)}; |
|
my $alt = $iconAltTags{$icon}; |
if ($icon) { |
if ($icon) { |
$r->print("<td valign=\"bottom\" width=\"50\" align=\"right\">$linkopen<img src=\"/adm/lonIcons/$icon\" border=\"0\" />$linkclose</td>\n"); |
$r->print("<td valign=\"bottom\" width=\"50\" align=\"right\">$linkopen<img src=\"/adm/lonIcons/$icon\" border=\"0\" alt=\"$alt\" />$linkclose</td>\n"); |
} else { |
} else { |
$r->print("<td></td>\n"); |
$r->print("<td></td>\n"); |
} |
} |
Line 1155 sub new_handle {
|
Line 1171 sub new_handle {
|
$r->print("<td></td>\n"); |
$r->print("<td></td>\n"); |
} |
} |
|
|
# FOURTH ROW: Text description |
# FOURTH COL: Text description |
$r->print("<td $colorizer align=\"right\" valign=\"bottom\">\n"); |
$r->print("<td $colorizer align=\"right\" valign=\"bottom\">\n"); |
|
|
if ($curRes->kind() eq "res" && |
if ($curRes->kind() eq "res" && |
Line 1163 sub new_handle {
|
Line 1179 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 1232 sub getLinkForResource {
|
Line 1251 sub getLinkForResource {
|
sub getDescription { |
sub getDescription { |
my $res = shift; |
my $res = shift; |
my $part = shift; |
my $part = shift; |
my $status = $res->getDateStatus(); |
my $status = $res->status($part); |
|
|
if ($status == $res->NETWORK_FAILURE) { return ""; } |
if ($status == $res->NETWORK_FAILURE) { return ""; } |
if ($status == $res->NOTHING_SET) { |
if ($status == $res->NOTHING_SET) { |
Line 1260 sub getDescription {
|
Line 1279 sub getDescription {
|
if ($status == $res->EXCUSED) { |
if ($status == $res->EXCUSED) { |
return "Excused by instructor"; |
return "Excused by instructor"; |
} |
} |
|
if ($status == $res->ATTEMPTED) { |
|
return "Not yet graded."; |
|
} |
if ($status == $res->TRIES_LEFT) { |
if ($status == $res->TRIES_LEFT) { |
my $tries = $res->tries(); |
my $tries = $res->tries(); |
my $maxtries = $res->maxtries(); |
my $maxtries = $res->maxtries(); |
Line 1273 sub getDescription {
|
Line 1295 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 1796 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 1842 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 1937 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 1952 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 2038 sub goesto { my $self=shift; return $sel
|
Line 2079 sub goesto { my $self=shift; return $sel
|
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 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 2452 B<Completion Codes>
|
Line 2499 B<Completion Codes>
|
|
|
=item * B<NETWORK_FAILURE>: Information not available due to network failure. |
=item * B<NETWORK_FAILURE>: Information not available due to network failure. |
|
|
|
=item * B<ATTEMPTED>: Attempted, and not yet graded. |
|
|
=back |
=back |
|
|
=cut |
=cut |
Line 2462 sub INCORRECT_BY_OVERRIDE { return 12; }
|
Line 2511 sub INCORRECT_BY_OVERRIDE { return 12; }
|
sub CORRECT { return 13; } |
sub CORRECT { return 13; } |
sub CORRECT_BY_OVERRIDE { return 14; } |
sub CORRECT_BY_OVERRIDE { return 14; } |
sub EXCUSED { return 15; } |
sub EXCUSED { return 15; } |
|
sub ATTEMPTED { return 16; } |
|
|
sub getCompletionStatus { |
sub getCompletionStatus { |
my $self = shift; |
my $self = shift; |
Line 2480 sub getCompletionStatus {
|
Line 2530 sub getCompletionStatus {
|
if ($status eq 'incorrect_attempted') {return $self->INCORRECT; } |
if ($status eq 'incorrect_attempted') {return $self->INCORRECT; } |
if ($status eq 'incorrect_by_override') {return $self->INCORRECT_BY_OVERRIDE; } |
if ($status eq 'incorrect_by_override') {return $self->INCORRECT_BY_OVERRIDE; } |
if ($status eq 'excused') {return $self->EXCUSED; } |
if ($status eq 'excused') {return $self->EXCUSED; } |
|
if ($status eq 'ungraded_attempted') {return $self->ATTEMPTED; } |
return $self->NOT_ATTEMPTED; |
return $self->NOT_ATTEMPTED; |
} |
} |
|
|
Line 2513 Along with directly returning the date o
|
Line 2564 Along with directly returning the date o
|
|
|
=item * OPEN: The item is open and not yet tried. |
=item * OPEN: The item is open and not yet tried. |
|
|
|
=item * ATTEMPTED: The problem has been attempted. |
|
|
=back |
=back |
|
|
=cut |
=cut |
Line 2535 sub status {
|
Line 2588 sub status {
|
# There are a few whole rows we can dispose of: |
# There are a few whole rows we can dispose of: |
if ($completionStatus == CORRECT || |
if ($completionStatus == CORRECT || |
$completionStatus == CORRECT_BY_OVERRIDE ) { |
$completionStatus == CORRECT_BY_OVERRIDE ) { |
return CORRECT(); |
return CORRECT; |
|
} |
|
|
|
if ($completionStatus == ATTEMPTED) { |
|
return ATTEMPTED; |
} |
} |
|
|
# If it's EXCUSED, then return that no matter what |
# If it's EXCUSED, then return that no matter what |
Line 2547 sub status {
|
Line 2604 sub status {
|
return NOTHING_SET; |
return NOTHING_SET; |
} |
} |
|
|
# Now we're down to a 3 (incorrect, incorrect_override, not_attempted) |
# Now we're down to a 4 (incorrect, incorrect_override, not_attempted) |
# by 4 matrix (date status). |
# by 4 matrix (date statuses). |
|
|
if ($dateStatus == PAST_DUE_ANSWER_LATER || |
if ($dateStatus == PAST_DUE_ANSWER_LATER || |
$dateStatus == PAST_DUE_NO_ANSWER ) { |
$dateStatus == PAST_DUE_NO_ANSWER ) { |