version 1.255, 2004/03/22 22:17:40
|
version 1.257, 2004/04/05 18:16:36
|
Line 864 sub render_resource {
|
Line 864 sub render_resource {
|
my $filter = $it->{FILTER}; |
my $filter = $it->{FILTER}; |
|
|
my $title = $resource->compTitle(); |
my $title = $resource->compTitle(); |
if ($src =~ /^\/uploaded\//) { |
# if ($src =~ /^\/uploaded\//) { |
$nonLinkedText=$title; |
# $nonLinkedText=$title; |
$title = ''; |
# $title = ''; |
} |
# } |
my $partLabel = ""; |
my $partLabel = ""; |
my $newBranchText = ""; |
my $newBranchText = ""; |
|
|
Line 973 sub render_resource {
|
Line 973 sub render_resource {
|
$nonLinkedText .= ' (' . $resource->countParts() . ' parts)'; |
$nonLinkedText .= ' (' . $resource->countParts() . ' parts)'; |
} |
} |
|
|
if (!$params->{'resource_nolink'} && $src !~ /^\/uploaded\// && |
# if (!$params->{'resource_nolink'} && $src !~ /^\/uploaded\// && |
!$resource->is_sequence()) { |
# !$resource->is_sequence()) { |
|
if (!$params->{'resource_nolink'} && !$resource->is_sequence()) { |
$result .= " $curMarkerBegin<a href='$link'>$title$partLabel</a>$curMarkerEnd $nonLinkedText</td>"; |
$result .= " $curMarkerBegin<a href='$link'>$title$partLabel</a>$curMarkerEnd $nonLinkedText</td>"; |
} else { |
} else { |
$result .= " $curMarkerBegin$title$partLabel$curMarkerEnd $nonLinkedText</td>"; |
$result .= " $curMarkerBegin$title$partLabel$curMarkerEnd $nonLinkedText</td>"; |
Line 1119 my @statuses = ($resObj->CORRECT, $resOb
|
Line 1120 my @statuses = ($resObj->CORRECT, $resOb
|
use Data::Dumper; |
use Data::Dumper; |
sub render_parts_summary_status { |
sub render_parts_summary_status { |
my ($resource, $part, $params) = @_; |
my ($resource, $part, $params) = @_; |
if (!$resource->is_problem()) { return '<td></td>'; } |
if (!$resource->is_problem() && !$resource->contains_problem) { return '<td></td>'; } |
if ($params->{showParts}) { |
if ($params->{showParts}) { |
return '<td></td>'; |
return '<td></td>'; |
} |
} |
|
|
my $td = "<td align='right'>\n"; |
my $td = "<td align='right'>\n"; |
my $endtd = "</td>\n"; |
my $endtd = "</td>\n"; |
|
my @probs; |
|
|
# If there is a single part, just show the simple status |
if ($resource->contains_problem) { |
if ($resource->singlepart()) { |
@probs=$resource->retrieveResources($resource,sub { $_[0]->is_problem() },1,0); |
my $status = $resource->simpleStatus(${$resource->parts}[0]); |
} else { |
return $td . "<font color='" . $statusColors{$status} . "'>" |
@probs=($resource); |
. $statusStrings{$status} . "</font>" . $endtd; |
} |
} |
my $return; |
|
my %overallstatus; |
# Now we can be sure the $part doesn't really matter. |
my $totalParts; |
my $statusCount = $resource->simpleStatusCount(); |
foreach my $resource (@probs) { |
my @counts; |
# If there is a single part, just show the simple status |
foreach my $status(@statuses) { |
if ($resource->singlepart()) { |
# decouple display order from the simpleStatusCount order |
my $status = $resource->simpleStatus(${$resource->parts}[0]); |
my $slot = Apache::lonnavmaps::resource::statusToSlot($status); |
$overallstatus{$status}++; |
if ($statusCount->[$slot]) { |
$totalParts++; |
push @counts, "<font color='" . $statusColors{$status} . |
next; |
"'>" . $statusCount->[$slot] . ' ' |
} |
|
# Now we can be sure the $part doesn't really matter. |
|
my $statusCount = $resource->simpleStatusCount(); |
|
my @counts; |
|
foreach my $status (@statuses) { |
|
# decouple display order from the simpleStatusCount order |
|
my $slot = Apache::lonnavmaps::resource::statusToSlot($status); |
|
if ($statusCount->[$slot]) { |
|
$overallstatus{$status}+=$statusCount->[$slot]; |
|
$totalParts+=$statusCount->[$slot]; |
|
} |
|
} |
|
} |
|
$return.= $td . $totalParts . ' parts: '; |
|
foreach my $status (@statuses) { |
|
if ($overallstatus{$status}) { |
|
$return.="<font color='" . $statusColors{$status} . |
|
"'>" . $overallstatus{$status} . ' ' |
. $statusStrings{$status} . "</font>"; |
. $statusStrings{$status} . "</font>"; |
} |
} |
} |
} |
|
$return.= $endtd; |
return $td . $resource->countParts() . ' parts: ' . join (', ', @counts) . $endtd; |
return $return; |
} |
} |
|
|
my @preparedColumns = (\&render_resource, \&render_communication_status, |
my @preparedColumns = (\&render_resource, \&render_communication_status, |
Line 1182 sub render {
|
Line 1201 sub render {
|
my $jump = $args->{'jump'}; |
my $jump = $args->{'jump'}; |
my $here = $args->{'here'}; |
my $here = $args->{'here'}; |
my $suppressNavmap = setDefault($args->{'suppressNavmap'}, 0); |
my $suppressNavmap = setDefault($args->{'suppressNavmap'}, 0); |
|
my $closeAllPages = setDefault($args->{'closeAllPages'}, 0); |
my $currentJumpDelta = 2; # change this to change how many resources are displayed |
my $currentJumpDelta = 2; # change this to change how many resources are displayed |
# before the current resource when using #current |
# before the current resource when using #current |
|
|
Line 1290 sub render {
|
Line 1310 sub render {
|
$args->{'iterator'} = $it = $navmap->getIterator(undef, undef, $filterHash, $condition); |
$args->{'iterator'} = $it = $navmap->getIterator(undef, undef, $filterHash, $condition); |
} |
} |
} |
} |
|
|
# (re-)Locate the jump point, if any |
# (re-)Locate the jump point, if any |
# Note this does not take filtering or hidden into account... need |
# Note this does not take filtering or hidden into account... need |
# to be fixed? |
# to be fixed? |
Line 1427 sub render {
|
Line 1447 sub render {
|
$args->{'here'} = $here; |
$args->{'here'} = $here; |
|
|
$args->{'indentLevel'} = -1; # first BEGIN_MAP takes this to 0 |
$args->{'indentLevel'} = -1; # first BEGIN_MAP takes this to 0 |
while ($curRes = $it->next()) { |
while ($curRes = $it->next($closeAllPages)) { |
# Maintain indentation level. |
# Maintain indentation level. |
if ($curRes == $it->BEGIN_MAP() || |
if ($curRes == $it->BEGIN_MAP() || |
$curRes == $it->BEGIN_BRANCH() ) { |
$curRes == $it->BEGIN_BRANCH() ) { |
Line 2168 want to know is if I<any> resources matc
|
Line 2188 want to know is if I<any> resources matc
|
parameter will allow you to avoid potentially expensive enumeration of |
parameter will allow you to avoid potentially expensive enumeration of |
all matching resources. |
all matching resources. |
|
|
=item * B<hasResources>(map, filterFunc, recursive): |
=item * B<hasResource>(map, filterFunc, recursive): |
|
|
Convience method for |
Convience method for |
|
|
Line 2547 sub new {
|
Line 2567 sub new {
|
|
|
sub next { |
sub next { |
my $self = shift; |
my $self = shift; |
|
my $closeAllPages=shift; |
if ($self->{FINISHED}) { |
if ($self->{FINISHED}) { |
return END_ITERATOR(); |
return END_ITERATOR(); |
} |
} |
Line 2561 sub next {
|
Line 2581 sub next {
|
|
|
if ($self->{RECURSIVE_ITERATOR_FLAG}) { |
if ($self->{RECURSIVE_ITERATOR_FLAG}) { |
# grab the next from the recursive iterator |
# grab the next from the recursive iterator |
my $next = $self->{RECURSIVE_ITERATOR}->next(); |
my $next = $self->{RECURSIVE_ITERATOR}->next($closeAllPages); |
|
|
# is it a begin or end map? If so, update the depth |
# is it a begin or end map? If so, update the depth |
if ($next == BEGIN_MAP() ) { $self->{RECURSIVE_DEPTH}++; } |
if ($next == BEGIN_MAP() ) { $self->{RECURSIVE_DEPTH}++; } |
Line 2675 sub next {
|
Line 2695 sub next {
|
|
|
# That ends the main iterator logic. Now, do we want to recurse |
# That ends the main iterator logic. Now, do we want to recurse |
# down this map (if this resource is a map)? |
# down this map (if this resource is a map)? |
if ($self->{HERE}->is_map() && |
if ( ($self->{HERE}->is_sequence() || (!$closeAllPages && $self->{HERE}->is_page())) && |
(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(); |
Line 2693 sub next {
|
Line 2713 sub next {
|
my $browsePriv = $self->{HERE}->browsePriv(); |
my $browsePriv = $self->{HERE}->browsePriv(); |
if (!$self->{HERE}->src() || |
if (!$self->{HERE}->src() || |
(!($browsePriv eq 'F') && !($browsePriv eq '2')) ) { |
(!($browsePriv eq 'F') && !($browsePriv eq '2')) ) { |
return $self->next(); |
return $self->next($closeAllPages); |
} |
} |
|
|
return $self->{HERE}; |
return $self->{HERE}; |
Line 3162 Returns true if the resource is a sequen
|
Line 3182 Returns true if the resource is a sequen
|
|
|
=cut |
=cut |
|
|
|
sub hasResource { |
|
my $self = shift; |
|
return $self->{NAV_MAP}->hasResource(@_); |
|
} |
|
|
|
sub retrieveResources { |
|
my $self = shift; |
|
return $self->{NAV_MAP}->retrieveResources(@_); |
|
} |
|
|
sub is_html { |
sub is_html { |
my $self=shift; |
my $self=shift; |
Line 3178 sub is_page {
|
Line 3207 sub is_page {
|
sub is_problem { |
sub is_problem { |
my $self=shift; |
my $self=shift; |
my $src = $self->src(); |
my $src = $self->src(); |
return ($src =~ /\.(problem|exam|quiz|assess|survey|form|library)$/); |
return ($src =~ /\.(problem|exam|quiz|assess|survey|form|library)$/) |
|
} |
|
sub contains_problem { |
|
my $self=shift; |
|
if ($self->is_page()) { |
|
my $hasProblem=$self->hasResource($self,sub { $_[0]->is_problem() },1); |
|
return $hasProblem; |
|
} |
|
return 0; |
} |
} |
sub is_sequence { |
sub is_sequence { |
my $self=shift; |
my $self=shift; |