--- loncom/interface/lonnavmaps.pm 2005/12/05 21:37:19 1.349.2.2 +++ loncom/interface/lonnavmaps.pm 2005/11/22 16:39:45 1.351 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.349.2.2 2005/12/05 21:37:19 albertel Exp $ +# $Id: lonnavmaps.pm,v 1.351 2005/11/22 16:39:45 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2475,6 +2475,12 @@ sub parmval_real { my $cid=$env{'request.course.id'}; my $csec=$env{'request.course.sec'}; + my $cgroup=''; + my @cgrps=split(/:/,$env{'request.course.groups'}); + if (@cgrps > 0) { + @cgrps = sort(@cgrps); + $cgroup = $cgrps[0]; + } my $uname=$env{'user.name'}; my $udom=$env{'user.domain'}; @@ -2492,6 +2498,10 @@ sub parmval_real { my $mapparm=$mapname.'___(all).'.$what; my $usercourseprefix=$cid; + my $grplevel=$usercourseprefix.'.['.$cgroup.'].'.$what; + my $grplevelr=$usercourseprefix.'.['.$cgroup.'].'.$symbparm; + my $grplevelm=$usercourseprefix.'.['.$cgroup.'].'.$mapparm; + my $seclevel= $usercourseprefix.'.['.$csec.'].'.$what; my $seclevelr=$usercourseprefix.'.['.$csec.'].'.$symbparm; my $seclevelm=$usercourseprefix.'.['.$csec.'].'.$mapparm; @@ -2512,6 +2522,12 @@ sub parmval_real { } # ------------------------------------------------------- second, check course + if ($cgroup ne '' and defined($courseopt)) { + if (defined($$courseopt{$grplevelr})) { return $$courseopt{$grplevelr}; } + if (defined($$courseopt{$grplevelm})) { return $$courseopt{$grplevelm}; } + if (defined($$courseopt{$grplevel})) { return $$courseopt{$grplevel}; } + } + if ($csec and defined($courseopt)) { if (defined($$courseopt{$seclevelr})) { return $$courseopt{$seclevelr}; } if (defined($$courseopt{$seclevelm})) { return $$courseopt{$seclevelm}; } @@ -2562,17 +2578,14 @@ sub parmval_real { =pod -=item * B(url,multiple): +=item * B(url): -Retrieves a resource object by URL of the resource, unless the optional -multiple parameter is included in wahich caes an array of resource -objects is returned. If passed a resource object, it will simply return -it, so it is safe to use this method in code like -"$res = $navmap->getResourceByUrl($res)" -if you're not sure if $res is already an object, or just a URL. If the -resource appears multiple times in the course, only the first instance -will be returned (useful for maps), unless the multiple parameter has -been included, in which case all instances are returned in an array. +Retrieves a resource object by URL of the resource. If passed a +resource object, it will simply return it, so it is safe to use this +method in code like "$res = $navmap->getResourceByUrl($res)", if +you're not sure if $res is already an object, or just a URL. If the +resource appears multiple times in the course, only the first instance +will be returned. As a result, this is probably useful only for maps. =item * B(map, filterFunc, recursive, bailout, showall): @@ -2607,41 +2620,22 @@ Convience method for which will tell whether the map has resources matching the description in the filter function. -=item * B(url): - -Retrieves version infomation for a url. Returns the version (a number, or -the string "mostrecent") for resources which have version information in -the big hash. - =cut sub getResourceByUrl { my $self = shift; my $resUrl = shift; - my $multiple = shift; if (ref($resUrl)) { return $resUrl; } $resUrl = &Apache::lonnet::clutter($resUrl); my $resId = $self->{NAV_HASH}->{'ids_' . $resUrl}; - if (!$resId) { return ''; } - if ($multiple) { - my @resources = (); - my @resIds = split (/,/, $resId); - foreach my $id (@resIds) { - my $resourceId = $self->getById($id); - if ($resourceId) { - push(@resources,$resourceId); - } - } - return @resources; - } else { - if ($resId =~ /,/) { - $resId = (split (/,/, $resId))[0]; - } - return $self->getById($resId); + if ($resId =~ /,/) { + $resId = (split (/,/, $resId))[0]; } + if (!$resId) { return ''; } + return $self->getById($resId); } sub retrieveResources { @@ -2709,12 +2703,6 @@ sub hasResource { return scalar($self->retrieveResources($map, $filterFunc, $recursive, 1, $showall)) > 0; } -sub usedVersion { - my $self = shift; - my $linkurl = shift; - return $self->navhash("version_$linkurl"); -} - 1; package Apache::lonnavmaps::iterator;