version 1.349.2.7, 2006/05/11 21:55:37
|
version 1.370, 2006/03/14 22:17:55
|
Line 1095 sub render_resource {
|
Line 1095 sub render_resource {
|
|
|
if ($resource->is_problem()) { |
if ($resource->is_problem()) { |
if ($part eq '0' || $params->{'condensed'}) { |
if ($part eq '0' || $params->{'condensed'}) { |
$icon ='<img src="'.$location.'/problem.gif" alt=" " border="0" />'; |
$icon ='<img src="'.$location.'/problem.gif" alt="'.&mt('Problem').'" border="0" />'; |
} else { |
} else { |
$icon = $params->{'indentString'}; |
$icon = $params->{'indentString'}; |
} |
} |
Line 1112 sub render_resource {
|
Line 1112 sub render_resource {
|
} |
} |
|
|
my $folderType = $resource->is_sequence() ? 'folder' : 'page'; |
my $folderType = $resource->is_sequence() ? 'folder' : 'page'; |
|
my $title=$resource->title; |
|
$title=~s/\"/\"/g; |
if (!$params->{'resource_no_folder_link'}) { |
if (!$params->{'resource_no_folder_link'}) { |
$icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . '.gif'; |
$icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . '.gif'; |
$icon = "<img src='$location/$icon' alt='". |
$icon = "<img src='$location/$icon' alt=\"". |
($nowOpen ? 'Open Folder' : 'Close Folder')."' border='0' />"; |
($nowOpen ? &mt('Open Folder') : &mt('Close Folder')).' '.$title."\" border='0' />"; |
|
|
$linkopen = "<a href=\"" . $params->{'url'} . '?' . |
$linkopen = "<a href=\"" . $params->{'url'} . '?' . |
$params->{'queryString'} . '&filter='; |
$params->{'queryString'} . '&filter='; |
Line 1134 sub render_resource {
|
Line 1135 sub render_resource {
|
# Don't allow users to manipulate folder |
# Don't allow users to manipulate folder |
$icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . |
$icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . |
'.nomanip.gif'; |
'.nomanip.gif'; |
$icon = "<img src='$location/$icon' alt='". |
$icon = "<img src='$location/$icon' alt=\"". |
($nowOpen ? 'Open Folder' : 'Close Folder')."' border='0' />"; |
($nowOpen ? &mt('Open Folder') : &mt('Close Folder')).' '.$title."\" border='0' />"; |
|
|
$linkopen = ""; |
$linkopen = ""; |
$linkclose = ""; |
$linkclose = ""; |
Line 1143 sub render_resource {
|
Line 1144 sub render_resource {
|
} |
} |
|
|
if ($resource->randomout()) { |
if ($resource->randomout()) { |
$nonLinkedText .= ' <i>(hidden)</i> '; |
$nonLinkedText .= ' <i>('.&mt('hidden').')</i> '; |
} |
} |
if (!$resource->condval()) { |
if (!$resource->condval()) { |
$nonLinkedText .= ' <i>(conditionally hidden)</i> '; |
$nonLinkedText .= ' <i>('.&mt('conditionally hidden').')</i> '; |
} |
} |
|
|
# We're done preparing and finally ready to start the rendering |
# We're done preparing and finally ready to start the rendering |
Line 1178 sub render_resource {
|
Line 1179 sub render_resource {
|
if ($resource->is_problem() && $part ne '0' && |
if ($resource->is_problem() && $part ne '0' && |
!$params->{'condensed'}) { |
!$params->{'condensed'}) { |
my $displaypart=$resource->part_display($part); |
my $displaypart=$resource->part_display($part); |
$partLabel = " (Part: $displaypart)"; |
$partLabel = " (".&mt('Part: [_1]', $displaypart).")"; |
if ($link!~/\#/) { $link.='#'.&Apache::lonnet::escape($part); } |
if ($link!~/\#/) { $link.='#'.&Apache::lonnet::escape($part); } |
$title = ""; |
$title = ""; |
} |
} |
|
|
if ($params->{'condensed'} && $resource->countParts() > 1) { |
if ($params->{'condensed'} && $resource->countParts() > 1) { |
$nonLinkedText .= ' (' . $resource->countParts() . ' parts)'; |
$nonLinkedText .= ' ('.&mt('[_1] parts', $resource->countParts()).')'; |
} |
} |
|
|
my $target; |
my $target; |
Line 1472 sub render {
|
Line 1473 sub render {
|
$navmap = Apache::lonnavmaps::navmap->new(); |
$navmap = Apache::lonnavmaps::navmap->new(); |
if (!defined($navmap)) { |
if (!defined($navmap)) { |
# no londer in course |
# no londer in course |
return '<font color="red">No course selected</font><br /> |
return '<font color="red">'.&mt('No course selected').'</font><br /> |
<a href="/adm/roles">Select a course</a><br />'; |
<a href="/adm/roles">'.&mt('Select a course').'</a><br />'; |
} |
} |
} |
} |
|
|
Line 2066 In order of increasing complexity and po
|
Line 2067 In order of increasing complexity and po
|
|
|
=over 4 |
=over 4 |
|
|
=item * C<$navmap-E<gt>getByX>, where X is B<Id>, B<Symb>, B<Url> or B<MapPc>. This provides |
=item * C<$navmap-E<gt>getByX>, where X is B<Id>, B<Symb> or B<MapPc> and getResourceByUrl. This provides |
various ways to obtain resource objects, based on various identifiers. |
various ways to obtain resource objects, based on various identifiers. |
Use this when you want to request information about one object or |
Use this when you want to request information about one object or |
a handful of resources you already know the identities of, from some |
a handful of resources you already know the identities of, from some |
other source. For more about Ids, Symbs, and MapPcs, see the |
other source. For more about Ids, Symbs, and MapPcs, see the |
Resource documentation. Note that Url should be a B<last resort>, |
Resource documentation. Note that Url should be a B<last resort>, |
not your first choice; it only works when there is only one |
not your first choice; it only really works when there is only one |
instance of the resource in the course, which only applies to |
instance of the resource in the course, which only applies to |
maps, and even that may change in the future. |
maps, and even that may change in the future (see the B<getResourceByUrl> |
|
documentation for more details.) |
|
|
=item * C<my @resources = $navmap-E<gt>retrieveResources(args)>. This |
=item * C<my @resources = $navmap-E<gt>retrieveResources(args)>. This |
retrieves resources matching some criterion and returns them |
retrieves resources matching some criterion and returns them |
Line 2269 sub get_user_data {
|
Line 2271 sub get_user_data {
|
sub get_discussion_data { |
sub get_discussion_data { |
my $self = shift; |
my $self = shift; |
if ($self->{RETRIEVED_DISCUSSION_DATA}) { |
if ($self->{RETRIEVED_DISCUSSION_DATA}) { |
return $self->{DISCUSSION_DATA}; |
return $self->{DISCUSSION_DATA}; |
} |
} |
|
|
|
$self->generate_email_discuss_status(); |
|
|
my $cid=$env{'request.course.id'}; |
my $cid=$env{'request.course.id'}; |
my $cdom=$env{'course.'.$cid.'.domain'}; |
my $cdom=$env{'course.'.$cid.'.domain'}; |
my $cnum=$env{'course.'.$cid.'.num'}; |
my $cnum=$env{'course.'.$cid.'.num'}; |
|
|
# Retrieve discussion data for resources in course |
# Retrieve discussion data for resources in course |
my %discussion_data = &Apache::lonnet::dump($cid,$cdom,$cnum); |
my %discussion_data = &Apache::lonnet::dumpstore($cid,$cdom,$cnum); |
|
|
|
|
$self->{DISCUSSION_DATA} = \%discussion_data; |
$self->{DISCUSSION_DATA} = \%discussion_data; |
$self->{RETRIEVED_DISCUSSION_DATA} = 1; |
$self->{RETRIEVED_DISCUSSION_DATA} = 1; |
return $self->{DISCUSSION_DATA}; |
return $self->{DISCUSSION_DATA}; |
Line 2340 sub hasDiscussion {
|
Line 2344 sub hasDiscussion {
|
} |
} |
} |
} |
|
|
|
sub last_post_time { |
|
my $self = shift; |
|
my $symb = shift; |
|
my $ressymb = $self->wrap_symb($symb); |
|
return $self->{DISCUSSION_TIME}->{$ressymb}; |
|
} |
|
|
|
sub unread_discussion { |
|
my $self = shift; |
|
my $symb = shift; |
|
|
|
$self->get_discussion_data(); |
|
|
|
my $ressymb = $self->wrap_symb($symb); |
|
|
|
my $version = $self->{DISCUSSION_DATA}{'version:'.$ressymb}; |
|
if (!$version) { return; } |
|
|
|
my $prevread = $self->{LAST_READ}{$ressymb}; |
|
|
|
my $unreadcount = 0; |
|
my $hiddenflag = 0; |
|
my $deletedflag = 0; |
|
my ($hidden,$deleted); |
|
|
|
my %subjects; |
|
|
|
for (my $id=$version; $id>0; $id--) { |
|
my $vkeys=$self->{DISCUSSION_DATA}{$id.':keys:'.$ressymb}; |
|
my @keys=split(/:/,$vkeys); |
|
if (grep(/^hidden$/ ,@keys)) { |
|
if (!$hiddenflag) { |
|
$hidden = $self->{DISCUSSION_DATA}{$id.':'.$ressymb.':hidden'}; |
|
$hiddenflag = 1; |
|
} |
|
} elsif (grep(/^deleted$/,@keys)) { |
|
if (!$deletedflag) { |
|
$deleted = $self->{DISCUSSION_DATA}{$id.':'.$ressymb.':deleted'}; |
|
$deletedflag = 1; |
|
} |
|
} else { |
|
if (($hidden !~/\.$id\./) && ($deleted !~/\.$id\./) |
|
&& $prevread < $self->{DISCUSSION_DATA}{$id.':'.$ressymb.':timestamp'}) { |
|
$unreadcount++; |
|
$subjects{$unreadcount}= |
|
$id.': '.$self->{DISCUSSION_DATA}{$id.':'.$ressymb.':subject'}; |
|
} |
|
} |
|
} |
|
if (wantarray) { |
|
return ($unreadcount,\%subjects); |
|
} |
|
return $unreadcount |
|
} |
|
|
sub wrap_symb { |
sub wrap_symb { |
my $self = shift; |
my $self = shift; |
my $symb = shift; |
my $symb = shift; |
Line 2495 sub parmval_real {
|
Line 2554 sub parmval_real {
|
|
|
my $cid=$env{'request.course.id'}; |
my $cid=$env{'request.course.id'}; |
my $csec=$env{'request.course.sec'}; |
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 $uname=$env{'user.name'}; |
my $udom=$env{'user.domain'}; |
my $udom=$env{'user.domain'}; |
|
|
Line 2512 sub parmval_real {
|
Line 2577 sub parmval_real {
|
my $mapparm=$mapname.'___(all).'.$what; |
my $mapparm=$mapname.'___(all).'.$what; |
my $usercourseprefix=$cid; |
my $usercourseprefix=$cid; |
|
|
|
my $grplevel=$usercourseprefix.'.['.$cgroup.'].'.$what; |
|
my $grplevelr=$usercourseprefix.'.['.$cgroup.'].'.$symbparm; |
|
my $grplevelm=$usercourseprefix.'.['.$cgroup.'].'.$mapparm; |
|
|
my $seclevel= $usercourseprefix.'.['.$csec.'].'.$what; |
my $seclevel= $usercourseprefix.'.['.$csec.'].'.$what; |
my $seclevelr=$usercourseprefix.'.['.$csec.'].'.$symbparm; |
my $seclevelr=$usercourseprefix.'.['.$csec.'].'.$symbparm; |
my $seclevelm=$usercourseprefix.'.['.$csec.'].'.$mapparm; |
my $seclevelm=$usercourseprefix.'.['.$csec.'].'.$mapparm; |
Line 2532 sub parmval_real {
|
Line 2601 sub parmval_real {
|
} |
} |
|
|
# ------------------------------------------------------- second, check course |
# ------------------------------------------------------- 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 ($csec and defined($courseopt)) { |
if (defined($$courseopt{$seclevelr})) { return $$courseopt{$seclevelr}; } |
if (defined($$courseopt{$seclevelr})) { return $$courseopt{$seclevelr}; } |
if (defined($$courseopt{$seclevelm})) { return $$courseopt{$seclevelm}; } |
if (defined($$courseopt{$seclevelm})) { return $$courseopt{$seclevelm}; } |
Line 2738 sub usedVersion {
|
Line 2813 sub usedVersion {
|
1; |
1; |
|
|
package Apache::lonnavmaps::iterator; |
package Apache::lonnavmaps::iterator; |
use WeakRef; |
use Scalar::Util qw(weaken); |
use Apache::lonnet; |
use Apache::lonnet; |
|
|
=pod |
=pod |
Line 3219 sub populateStack {
|
Line 3294 sub populateStack {
|
1; |
1; |
|
|
package Apache::lonnavmaps::DFSiterator; |
package Apache::lonnavmaps::DFSiterator; |
use WeakRef; |
use Scalar::Util qw(weaken); |
use Apache::lonnet; |
use Apache::lonnet; |
|
|
# Not documented in the perldoc: This is a simple iterator that just walks |
# Not documented in the perldoc: This is a simple iterator that just walks |
Line 3403 sub populateStack {
|
Line 3478 sub populateStack {
|
1; |
1; |
|
|
package Apache::lonnavmaps::resource; |
package Apache::lonnavmaps::resource; |
use WeakRef; |
use Scalar::Util qw(weaken); |
use Apache::lonnet; |
use Apache::lonnet; |
|
|
=pod |
=pod |
Line 3582 sub kind { my $self=shift; return $self-
|
Line 3657 sub kind { my $self=shift; return $self-
|
sub randomout { my $self=shift; return $self->navHash("randomout_", 1); } |
sub randomout { my $self=shift; return $self->navHash("randomout_", 1); } |
sub randompick { |
sub randompick { |
my $self = shift; |
my $self = shift; |
return $self->{NAV_MAP}->{PARM_HASH}->{$self->symb . |
return $self->parmval('randompick'); |
'.0.parameter_randompick'}; |
|
} |
} |
sub link { |
sub link { |
my $self=shift; |
my $self=shift; |
Line 3701 sub retrieveResources {
|
Line 3775 sub retrieveResources {
|
return $self->{NAV_MAP}->retrieveResources(@_); |
return $self->{NAV_MAP}->retrieveResources(@_); |
} |
} |
|
|
|
sub is_exam { |
|
my ($self,$part) = @_; |
|
if ($self->parmval('type',$part) eq 'exam') { |
|
return 1; |
|
} |
|
if ($self->src() =~ /\.(exam)$/) { |
|
return 1; |
|
} |
|
return 0; |
|
} |
sub is_html { |
sub is_html { |
my $self=shift; |
my $self=shift; |
my $src = $self->src(); |
my $src = $self->src(); |
Line 3713 sub is_page {
|
Line 3797 sub is_page {
|
return $self->navHash("is_map_", 1) && |
return $self->navHash("is_map_", 1) && |
$self->navHash("map_type_" . $self->map_pc()) eq 'page'; |
$self->navHash("map_type_" . $self->map_pc()) eq 'page'; |
} |
} |
|
sub is_practice { |
|
my $self=shift; |
|
my ($part) = @_; |
|
if ($self->parmval('type',$part) eq 'practice') { |
|
return 1; |
|
} |
|
return 0; |
|
} |
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|task)$/) |
if ($src =~ /\.(problem|exam|quiz|assess|survey|form|library|task)$/) { |
|
return !($self->is_practice()); |
|
} |
|
return 0; |
} |
} |
sub contains_problem { |
sub contains_problem { |
my $self=shift; |
my $self=shift; |
Line 3728 sub contains_problem {
|
Line 3823 sub contains_problem {
|
} |
} |
sub is_sequence { |
sub is_sequence { |
my $self=shift; |
my $self=shift; |
|
my $src = $self->src(); |
return $self->navHash("is_map_", 1) && |
return $self->navHash("is_map_", 1) && |
$self->navHash("map_type_" . $self->map_pc()) eq 'sequence'; |
$self->navHash("map_type_" . $self->map_pc()) eq 'sequence'; |
} |
} |
Line 3742 sub is_survey {
|
Line 3838 sub is_survey {
|
} |
} |
return 0; |
return 0; |
} |
} |
|
sub is_task { |
|
my $self=shift; |
|
my $src = $self->src(); |
|
return ($src =~ /\.(task)$/) |
|
} |
|
|
sub is_empty_sequence { |
sub is_empty_sequence { |
my $self=shift; |
my $self=shift; |
Line 3797 Returns a string with the type of the ma
|
Line 3898 Returns a string with the type of the ma
|
sub map_finish { |
sub map_finish { |
my $self = shift; |
my $self = shift; |
my $src = $self->src(); |
my $src = $self->src(); |
$src = &Apache::lonnet::deversion(&Apache::lonnet::clutter($src)); |
$src = Apache::lonnet::clutter($src); |
my $res = $self->navHash("map_finish_$src", 0); |
my $res = $self->navHash("map_finish_$src", 0); |
$res = $self->{NAV_MAP}->getById($res); |
$res = $self->{NAV_MAP}->getById($res); |
return $res; |
return $res; |
} |
} |
sub map_pc { |
sub map_pc { |
my $self = shift; |
my $self = shift; |
my $src = &Apache::lonnet::deversion($self->src()); |
my $src = $self->src(); |
return $self->navHash("map_pc_$src", 0); |
return $self->navHash("map_pc_$src", 0); |
} |
} |
sub map_start { |
sub map_start { |
my $self = shift; |
my $self = shift; |
my $src = $self->src(); |
my $src = $self->src(); |
$src = &Apache::lonnet::deversion(&Apache::lonnet::clutter($src)); |
$src = Apache::lonnet::clutter($src); |
my $res = $self->navHash("map_start_$src", 0); |
my $res = $self->navHash("map_start_$src", 0); |
$res = $self->{NAV_MAP}->getById($res); |
$res = $self->{NAV_MAP}->getById($res); |
return $res; |
return $res; |
Line 4026 Returns a false value if there has been
|
Line 4127 Returns a false value if there has been
|
logged in, true if there has. Always returns false if the discussion |
logged in, true if there has. Always returns false if the discussion |
data was not extracted when the nav map was constructed. |
data was not extracted when the nav map was constructed. |
|
|
|
=item * B<last_post_time>: |
|
|
|
Returns a false value if there hasn't been discussion otherwise returns |
|
unix timestamp of last time a discussion posting (or edit) was made. |
|
|
|
=item * B<unread_discussion>: |
|
|
|
returns in scalar context the count of the number of unread discussion |
|
postings |
|
|
|
returns in list context both the count of postings and a hash ref |
|
containing the subjects of all unread postings |
|
|
=item * B<getFeedback>: |
=item * B<getFeedback>: |
|
|
Gets the feedback for the resource and returns the raw feedback string |
Gets the feedback for the resource and returns the raw feedback string |
Line 4046 sub hasDiscussion {
|
Line 4160 sub hasDiscussion {
|
return $self->{NAV_MAP}->hasDiscussion($self->symb()); |
return $self->{NAV_MAP}->hasDiscussion($self->symb()); |
} |
} |
|
|
|
sub last_post_time { |
|
my $self = shift; |
|
return $self->{NAV_MAP}->last_post_time($self->symb()); |
|
} |
|
|
|
sub unread_discussion { |
|
my $self = shift; |
|
return $self->{NAV_MAP}->unread_discussion($self->symb()); |
|
} |
|
|
sub getFeedback { |
sub getFeedback { |
my $self = shift; |
my $self = shift; |
my $source = $self->src(); |
my $source = $self->src(); |
Line 4143 sub countResponses {
|
Line 4267 sub countResponses {
|
sub responseTypes { |
sub responseTypes { |
my $self = shift; |
my $self = shift; |
my %responses; |
my %responses; |
foreach my $part ($self->parts()) { |
foreach my $part (@{$self->parts()}) { |
foreach my $responsetype ($self->responseType($part)) { |
foreach my $responsetype ($self->responseType($part)) { |
$responses{$responsetype}++ if (defined($responsetype)); |
$responses{$responsetype}++ if (defined($responsetype)); |
} |
} |
Line 4255 sub extractParts {
|
Line 4379 sub extractParts {
|
# where the part names begin and end, and even then, it is possible |
# where the part names begin and end, and even then, it is possible |
# to construct ambiguous situations. |
# to construct ambiguous situations. |
foreach (split /,/, $metadata) { |
foreach (split /,/, $metadata) { |
if ($_ =~ /^([a-zA-Z]+)response_(.*)/) { |
if ($_ =~ /^([a-zA-Z]+)response_(.*)/ |
|
|| $_ =~ /^(Task)_(.*)/) { |
my $responseType = $1; |
my $responseType = $1; |
my $partStuff = $2; |
my $partStuff = $2; |
my $partIdSoFar = ''; |
my $partIdSoFar = ''; |