version 1.355, 2005/12/20 16:43:27
|
version 1.370, 2006/03/14 22:17:55
|
Line 530 sub getDescription {
|
Line 530 sub getDescription {
|
if ($status == $res->PAST_DUE_NO_ANSWER) { |
if ($status == $res->PAST_DUE_NO_ANSWER) { |
return &mt("Was due")." " . timeToHumanString($res->duedate($part),'end'); |
return &mt("Was due")." " . timeToHumanString($res->duedate($part),'end'); |
} |
} |
if ($status == $res->ANSWER_OPEN || $status == $res->PARTIALLY_CORRECT) { |
if (($status == $res->ANSWER_OPEN || $status == $res->PARTIALLY_CORRECT) |
|
&& $res->handgrade($part) ne 'yes') { |
return &mt("Answer available"); |
return &mt("Answer available"); |
} |
} |
if ($status == $res->EXCUSED) { |
if ($status == $res->EXCUSED) { |
Line 1094 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 1111 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 1133 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 1142 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 1177 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 1471 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 2065 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 2268 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 2339 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 2753 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 3234 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 3418 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 3597 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 3656 sub condition {
|
Line 3715 sub condition {
|
} |
} |
sub condval { |
sub condval { |
my $self=shift; |
my $self=shift; |
my $uri=&Apache::lonnet::deversion(&Apache::lonnet::declutter($self->src())); |
my ($pathname,$filename) = |
my ($pathname,$filename)=($uri=~m|(.*)/([^/]*)|); |
&Apache::lonnet::split_uri_for_cond($self->src()); |
$pathname=~s/^adm\/wrapper\///; |
|
|
|
my $match=($env{'acc.res.'.$env{'request.course.id'}.'.'.$pathname}=~ |
my $match=($env{'acc.res.'.$env{'request.course.id'}.'.'.$pathname}=~ |
/\&\Q$filename\E\:([\d\|]+)\&/); |
/\&\Q$filename\E\:([\d\|]+)\&/); |
Line 3717 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 3729 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 3759 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 4043 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 4063 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 4160 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 4272 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 = ''; |