--- loncom/interface/lonnavmaps.pm 2007/04/27 17:59:50 1.398 +++ loncom/interface/lonnavmaps.pm 2007/10/05 18:48:20 1.402 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.398 2007/04/27 17:59:50 banghart Exp $ +# $Id: lonnavmaps.pm,v 1.402 2007/10/05 18:48:20 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -170,7 +170,10 @@ sub getLinkForResource { if (defined($item)) { $res = $item; } } - return ($res->link(),$res->shown_symb()); + if ($res) { + return ($res->link(),$res->shown_symb()); + } + return; } # Convenience function: This separates the logic of how to create @@ -195,7 +198,11 @@ sub getDescription { } if ($status == $res->OPEN) { if ($res->duedate($part)) { - return &mt("Due")." " .timeToHumanString($res->duedate($part),'end'); + if ($res->is_practice()) { + return &mt("Closes ")." " .timeToHumanString($res->duedate($part),'start'); + } else { + return &mt("Due")." " .timeToHumanString($res->duedate($part),'end'); + } } else { return &mt("Open, no due date"); } @@ -204,7 +211,11 @@ sub getDescription { return &mt("Answer open")." " . timeToHumanString($res->answerdate($part),'start'); } if ($status == $res->PAST_DUE_NO_ANSWER) { - return &mt("Was due")." " . timeToHumanString($res->duedate($part),'end'); + if ($res->is_practice()) { + return &mt("Closed")." " . timeToHumanString($res->duedate($part),'start'); + } else { + return &mt("Was due")." " . timeToHumanString($res->duedate($part),'end'); + } } if (($status == $res->ANSWER_OPEN || $status == $res->PARTIALLY_CORRECT) && $res->handgrade($part) ne 'yes') { @@ -604,6 +615,11 @@ instruct the renderer to render only a p the source of the map you want to process, like '/res/103/jerf/navmap.course.sequence'. +=item * B: default: false + +If you need to include the top level map (meaning the course) in the +rendered output set this to true + =item * B: default: constructs one from %env A reference to a navmap, used only if an iterator is not passed in. If @@ -974,7 +990,7 @@ sub render_long_status { $params->{'multipart'} && $part eq "0"; my $color; - if ($resource->is_problem()) { + if ($resource->is_problem() || $resource->is_practice()) { $color = $colormap{$resource->status}; if (dueInLessThan24Hours($resource, $part) || @@ -984,14 +1000,17 @@ sub render_long_status { } if ($resource->kind() eq "res" && - $resource->is_problem() && + ($resource->is_problem() || $resource->is_practice()) && !$firstDisplayed) { if ($color) {$result .= ""; } $result .= getDescription($resource, $part); if ($color) {$result .= ""; } } - if ($resource->is_map() && advancedUser() && $resource->randompick()) { - $result .= '(randomly select ' . $resource->randompick() .')'; + if ($resource->is_map() && &advancedUser() && $resource->randompick()) { + $result .= &mt('(randomly select [_1])', $resource->randompick()); + } + if ($resource->is_map() && &advancedUser() && $resource->randomorder()) { + $result .= &mt('(randomly ordered)'); } # Debugging code @@ -1233,7 +1252,7 @@ sub render { $args->{'iterator'} = $it = $navmap->getIterator($firstResource, $finishResource, $filterHash, $condition); } else { - $args->{'iterator'} = $it = $navmap->getIterator(undef, undef, $filterHash, $condition); + $args->{'iterator'} = $it = $navmap->getIterator(undef, undef, $filterHash, $condition,undef,$args->{'include_top_level_map'}); } } @@ -2271,14 +2290,14 @@ sub finishResource { # the actual lookup; parmval caches the results. sub parmval { my $self = shift; - my ($what,$symb)=@_; + my ($what,$symb,$recurse)=@_; my $hashkey = $what."|||".$symb; if (defined($self->{PARM_CACHE}->{$hashkey})) { return $self->{PARM_CACHE}->{$hashkey}; } - my $result = $self->parmval_real($what, $symb); + my $result = $self->parmval_real($what, $symb, $recurse); $self->{PARM_CACHE}->{$hashkey} = $result; return $result; } @@ -2388,7 +2407,7 @@ sub parmval_real { if (defined($partgeneral)) { return $partgeneral; } } if ($recurse) { return undef; } - my $pack_def=&Apache::lonnet::packages_tab_default($fn,'resource.'.$what); + my $pack_def=&Apache::lonnet::packages_tab_default($fn,'resource.'.$rwhat); if (defined($pack_def)) { return $pack_def; } return ''; } @@ -2511,6 +2530,10 @@ sub retrieveResources { my @resources = (); + if (&$filterFunc($map)) { + push(@resources, $map); + } + # Run down the iterator and collect the resources. my $curRes; @@ -2520,7 +2543,7 @@ sub retrieveResources { next; } - push @resources, $curRes; + push(@resources, $curRes); if ($bailout) { return @resources; @@ -2851,6 +2874,10 @@ sub next { $self->{HAVE_RETURNED_0} = 1; return $self->{NAV_MAP}->getById('0.0'); } + if ($self->{RETURN_0} && !$self->{HAVE_RETURNED_0_BEGIN_MAP}) { + $self->{HAVE_RETURNED_0_BEGIN_MAP} = 1; + return $self->BEGIN_MAP(); + } if ($self->{RECURSIVE_ITERATOR_FLAG}) { # grab the next from the recursive iterator @@ -3364,8 +3391,13 @@ false. =item * B: -Returns true for a map if the randompick feature is being used on the -map. (?) +Returns the number of randomly picked items for a map if the randompick +feature is being used on the map. + +=item * B: + +Returns true for a map if the randomorder feature is being used on the +map. =item * B: @@ -3397,6 +3429,10 @@ sub randompick { my $self = shift; return $self->parmval('randompick'); } +sub randomorder { + my $self = shift; + return ($self->parmval('randomorder') =~ /^yes$/i); +} sub link { my $self=shift; if ($self->encrypted()) { return &Apache::lonenc::encrypted($self->src); } @@ -3473,6 +3509,7 @@ sub compTitle { } return $title; } + =pod B @@ -3559,6 +3596,15 @@ sub contains_problem { } return 0; } +sub map_contains_problem { + my $self=shift; + if ($self->is_map()) { + my $has_problem= + $self->hasResource($self,sub { $_[0]->is_problem() },1); + return $has_problem; + } + return 0; +} sub is_sequence { my $self=shift; return $self->navHash("is_map_", 1) && @@ -3781,6 +3827,15 @@ sub duedate { } sub handgrade { (my $self, my $part) = @_; + my @response_ids = $self->responseIds($part); + if (@response_ids) { + foreach my $response_id (@response_ids) { + if (lc($self->parmval("handgrade",$part.'_'.$response_id)) + eq 'yes') { + return 'yes'; + } + } + } return $self->parmval("handgrade", $part); } sub maxtries {