version 1.242.2.1, 2004/05/06 15:04:00
|
version 1.266, 2004/07/09 23:05:51
|
Line 25
|
Line 25
|
# |
# |
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/ |
# |
# |
# (Page Handler |
### |
# |
|
# (TeX Content Handler |
|
# |
|
# 05/29/00,05/30 Gerd Kortemeyer) |
|
# 08/30,08/31,09/06,09/14,09/15,09/16,09/19,09/20,09/21,09/23, |
|
# 10/02,10/10,10/14,10/16,10/18,10/19,10/31,11/6,11/14,11/16 Gerd Kortemeyer) |
|
# |
|
# 3/1/1,6/1,17/1,29/1,30/1,2/8,9/21,9/24,9/25 Gerd Kortemeyer |
|
# YEAR=2002 |
|
# 1/1 Gerd Kortemeyer |
|
# Oct-Nov Jeremy Bowers |
|
# YEAR=2003 |
|
# Jeremy Bowers ... lots of days |
|
|
|
package Apache::lonnavmaps; |
package Apache::lonnavmaps; |
|
|
Line 150 sub real_handler {
|
Line 137 sub real_handler {
|
$r->print('</head>'. |
$r->print('</head>'. |
&Apache::loncommon::bodytag('Navigate Course Contents','', |
&Apache::loncommon::bodytag('Navigate Course Contents','', |
$addentries,'','',$ENV{'form.register'})); |
$addentries,'','',$ENV{'form.register'})); |
$r->print('<script>window.focus();</script>'); |
$r->print('<script>window.focus();</script>'. |
|
&Apache::loncommon::help_open_menu('','Navigation Screen','Navigation_Screen','',undef,'RAT')); |
|
|
$r->rflush(); |
$r->rflush(); |
|
|
# Check that it's defined |
# Check that it's defined |
Line 303 sub getLinkForResource {
|
Line 291 sub getLinkForResource {
|
|
|
# Check to see if there are any pages in the stack |
# Check to see if there are any pages in the stack |
foreach $res (@$stack) { |
foreach $res (@$stack) { |
if (defined($res) && $res->is_page()) { |
if (defined($res)) { |
return $res->src(); |
if ($res->is_page()) { |
|
return $res->src(); |
|
} |
|
# in case folder was skipped over as "only sequence" |
|
my ($map,$id,$src)=&Apache::lonnet::decode_symb($res->symb()); |
|
if ($map=~/\.page$/) { |
|
return &Apache::lonnet::clutter($map).'#'. |
|
&Apache::lonnet::escape(&Apache::lonnet::declutter($src)); |
|
} |
} |
} |
} |
} |
|
|
Line 319 sub getLinkForResource {
|
Line 315 sub getLinkForResource {
|
return $res->src(); |
return $res->src(); |
} |
} |
|
|
# Convenience function: This seperates the logic of how to create |
# Convenience function: This separates the logic of how to create |
# the problem text strings ("Due: DATE", "Open: DATE", "Not yet assigned", |
# the problem text strings ("Due: DATE", "Open: DATE", "Not yet assigned", |
# etc.) into a seperate function. It takes a resource object as the |
# etc.) into a separate function. It takes a resource object as the |
# first parameter, and the part number of the resource as the second. |
# first parameter, and the part number of the resource as the second. |
# It's basically a big switch statement on the status of the resource. |
# It's basically a big switch statement on the status of the resource. |
|
|
Line 371 sub getDescription {
|
Line 367 sub getDescription {
|
$triesString = "<b>$triesString</b>"; |
$triesString = "<b>$triesString</b>"; |
} |
} |
} |
} |
if ($res->duedate()) { |
if ($res->duedate($part)) { |
return &mt("Due")." " . timeToHumanString($res->duedate($part)) . |
return &mt("Due")." " . timeToHumanString($res->duedate($part)) . |
" $triesString"; |
" $triesString"; |
} else { |
} else { |
Line 386 sub getDescription {
|
Line 382 sub getDescription {
|
# Convenience function, so others can use it: Is the problem due in less then |
# Convenience function, so others can use it: Is the problem due in less then |
# 24 hours, and still can be done? |
# 24 hours, and still can be done? |
|
|
sub dueInLessThen24Hours { |
sub dueInLessThan24Hours { |
my $res = shift; |
my $res = shift; |
my $part = shift; |
my $part = shift; |
my $status = $res->status($part); |
my $status = $res->status($part); |
|
|
return ($status == $res->OPEN() || |
return ($status == $res->OPEN() || |
$status == $res->TRIES_LEFT()) && |
$status == $res->TRIES_LEFT()) && |
$res->duedate() && $res->duedate() < time()+(24*60*60) && |
$res->duedate($part) && $res->duedate($part) < time()+(24*60*60) && |
$res->duedate() > time(); |
$res->duedate($part) > time(); |
} |
} |
|
|
# Convenience function, so others can use it: Is there only one try remaining for the |
# Convenience function, so others can use it: Is there only one try remaining for the |
Line 406 sub lastTry {
|
Line 402 sub lastTry {
|
my $tries = $res->tries($part); |
my $tries = $res->tries($part); |
my $maxtries = $res->maxtries($part); |
my $maxtries = $res->maxtries($part); |
return $tries && $maxtries && $maxtries > 1 && |
return $tries && $maxtries && $maxtries > 1 && |
$maxtries - $tries == 1 && $res->duedate() && |
$maxtries - $tries == 1 && $res->duedate($part) && |
$res->duedate() > time(); |
$res->duedate($part) > time(); |
} |
} |
|
|
# This puts a human-readable name on the ENV variable. |
# This puts a human-readable name on the ENV variable. |
Line 869 sub render_resource {
|
Line 865 sub render_resource {
|
my $filter = $it->{FILTER}; |
my $filter = $it->{FILTER}; |
|
|
my $title = $resource->compTitle(); |
my $title = $resource->compTitle(); |
if ($src =~ /^\/uploaded\//) { |
|
$nonLinkedText=$title; |
|
$title = ''; |
|
} |
|
my $partLabel = ""; |
my $partLabel = ""; |
my $newBranchText = ""; |
my $newBranchText = ""; |
|
|
Line 895 sub render_resource {
|
Line 888 sub render_resource {
|
$icon = $params->{'indentString'}; |
$icon = $params->{'indentString'}; |
} |
} |
} else { |
} else { |
my $curfext= (split (/\./,$resource->src))[-1]; |
$icon = "<img src='".&Apache::loncommon::icon($resource->src). |
my $embstyle = &Apache::loncommon::fileembstyle($curfext); |
"' alt='' border='0' />"; |
# The unless conditional that follows is a bit of overkill |
|
if (!(!defined($embstyle) || $embstyle eq 'unk' || $embstyle eq 'hdn')) { |
|
$icon = "<img src='/adm/lonIcons/$curfext.gif' alt='' border='0' />"; |
|
} |
|
} |
} |
|
|
# Display the correct map icon to open or shut map |
# Display the correct map icon to open or shut map |
Line 970 sub render_resource {
|
Line 959 sub render_resource {
|
|
|
if ($resource->is_problem() && $part ne '0' && |
if ($resource->is_problem() && $part ne '0' && |
!$params->{'condensed'}) { |
!$params->{'condensed'}) { |
$partLabel = " (Part $part)"; |
my $displaypart=&Apache::lonnet::EXT('resource.'.$part.'.display', |
|
$resource->symb()); |
|
unless ($displaypart) { $displaypart=$part; } |
|
$partLabel = " (Part: $displaypart)"; |
|
$link.='#'.&Apache::lonnet::escape($part); |
$title = ""; |
$title = ""; |
} |
} |
|
|
Line 978 sub render_resource {
|
Line 971 sub render_resource {
|
$nonLinkedText .= ' (' . $resource->countParts() . ' parts)'; |
$nonLinkedText .= ' (' . $resource->countParts() . ' parts)'; |
} |
} |
|
|
if (!$params->{'resource_nolink'} && $src !~ /^\/uploaded\// && |
if (!$params->{'resource_nolink'} && !$resource->is_sequence() && !$resource->is_empty_sequence) { |
!$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 1016 sub render_communication_status {
|
Line 1008 sub render_communication_status {
|
|
|
if ($resource->getErrors()) { |
if ($resource->getErrors()) { |
my $errors = $resource->getErrors(); |
my $errors = $resource->getErrors(); |
|
my $errorcount = 0; |
foreach (split(/,/, $errors)) { |
foreach (split(/,/, $errors)) { |
|
last if ($errorcount>=10); # Only output 10 bombs maximum |
if ($_) { |
if ($_) { |
|
$errorcount++; |
$errorHTML .= ' <a href="/adm/email?display=' |
$errorHTML .= ' <a href="/adm/email?display=' |
. &Apache::lonnet::escape($_) . '">' |
. &Apache::lonnet::escape($_) . '">' |
. '<img src="/adm/lonMisc/bomb.gif" ' |
. '<img src="/adm/lonMisc/bomb.gif" ' |
Line 1069 sub render_long_status {
|
Line 1064 sub render_long_status {
|
if ($resource->is_problem()) { |
if ($resource->is_problem()) { |
$color = $colormap{$resource->status}; |
$color = $colormap{$resource->status}; |
|
|
if (dueInLessThen24Hours($resource, $part) || |
if (dueInLessThan24Hours($resource, $part) || |
lastTry($resource, $part)) { |
lastTry($resource, $part)) { |
$color = $hurryUpColor; |
$color = $hurryUpColor; |
} |
} |
Line 1121 my @statuses = ($resObj->CORRECT, $resOb
|
Line 1116 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('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 1184 sub render {
|
Line 1197 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 1292 sub render {
|
Line 1306 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 1355 sub render {
|
Line 1369 sub render {
|
"&here=" . Apache::lonnet::escape($here) . |
"&here=" . Apache::lonnet::escape($here) . |
"\">".&mt('Open All Folders')."</a>"; |
"\">".&mt('Open All Folders')."</a>"; |
} |
} |
$result .= "<br /><br />\n"; |
$result .= "\n"; |
} |
} |
|
|
|
# Check for any unread discussions in all resources. |
|
my $totdisc = 0; |
|
my $haveDisc = ''; |
|
my @allres=$navmap->retrieveResources(); |
|
foreach my $resource (@allres) { |
|
if ($resource->hasDiscussion()) { |
|
my $ressymb; |
|
if ($resource->symb() =~ m-(___adm/\w+/\w+)/(\d+)/bulletinboard$-) { |
|
$ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard'; |
|
} else { |
|
$ressymb = $resource->symb(); |
|
} |
|
$haveDisc .= $ressymb.':'; |
|
$totdisc ++; |
|
} |
|
} |
|
if ($totdisc > 0) { |
|
$haveDisc =~ s/:$//; |
|
my %lt = &Apache::lonlocal::texthash( |
|
'mapr' => 'Mark all posts read', |
|
); |
|
$result .= (<<END); |
|
<a href="javascript:document.clearbubbles.submit()">$lt{'mapr'}</a> <a href="javascript:void(open('/adm/help/NavMaps_MarkPosts_Read.hlp', 'Help_for_NavMaps_MarkPosts', 'menubar=0,toolbar=1,scrollbars=1,width=350,height=400,resizable=yes'))" title="Online Help"><image src="/adm/help/gif/smallHelp.gif" border="0" alt="(Help: NavMaps_MarkPostsLink)" /></a> |
|
<form name="clearbubbles" method="post" action="/adm/feedback"> |
|
<input type="hidden" name="navurl" value="$ENV{'QUERY_STRING'}" /> |
|
<input type="hidden" name="navmaps" value="$haveDisc" /> |
|
</form> |
|
END |
|
} else { |
|
$result .= '<br />'; |
|
} |
|
$result .= "<br />\n"; |
if ($r) { |
if ($r) { |
$r->print($result); |
$r->print($result); |
$r->rflush(); |
$r->rflush(); |
Line 1429 sub render {
|
Line 1475 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 1545 sub render {
|
Line 1591 sub render {
|
my $filter = $it->{FILTER}; |
my $filter = $it->{FILTER}; |
my $stack = $it->getStack(); |
my $stack = $it->getStack(); |
my $src = getLinkForResource($stack); |
my $src = getLinkForResource($stack); |
|
my $anchor=''; |
|
if ($src=~s/(\#.*$)//) { |
|
$anchor=$1; |
|
} |
my $srcHasQuestion = $src =~ /\?/; |
my $srcHasQuestion = $src =~ /\?/; |
$args->{"resourceLink"} = $src. |
$args->{"resourceLink"} = $src. |
($srcHasQuestion?'&':'?') . |
($srcHasQuestion?'&':'?') . |
'symb=' . &Apache::lonnet::escape($curRes->symb()); |
'symb=' . &Apache::lonnet::escape($curRes->symb()). |
|
$anchor; |
|
|
# Now, display each column. |
# Now, display each column. |
foreach my $col (@$cols) { |
foreach my $col (@$cols) { |
Line 1600 sub render {
|
Line 1650 sub render {
|
# it's quite likely this might fix other browsers, too, and |
# it's quite likely this might fix other browsers, too, and |
# certainly won't hurt anything. |
# certainly won't hurt anything. |
if ($displayedJumpMarker) { |
if ($displayedJumpMarker) { |
$result .= "<script>setTimeout(\"location += '#curloc';\", 0)</script>\n"; |
$result .= " |
|
<script> |
|
if (location.href.indexOf('#curloc')==-1) { |
|
setTimeout(\"location += '#curloc';\", 0) |
|
} |
|
</script>"; |
} |
} |
|
|
$result .= "</table>"; |
$result .= "</table>"; |
Line 1791 sub generate_course_user_opt {
|
Line 1846 sub generate_course_user_opt {
|
|
|
sub generate_email_discuss_status { |
sub generate_email_discuss_status { |
my $self = shift; |
my $self = shift; |
|
my $symb = shift; |
if ($self->{EMAIL_DISCUSS_GENERATED}) { return; } |
if ($self->{EMAIL_DISCUSS_GENERATED}) { return; } |
|
|
my $cid=$ENV{'request.course.id'}; |
my $cid=$ENV{'request.course.id'}; |
Line 1803 sub generate_email_discuss_status {
|
Line 1859 sub generate_email_discuss_status {
|
$courseLeaveTime : $logoutTime); |
$courseLeaveTime : $logoutTime); |
my %discussiontime = &Apache::lonnet::dump('discussiontimes', |
my %discussiontime = &Apache::lonnet::dump('discussiontimes', |
$cdom, $cnum); |
$cdom, $cnum); |
|
my %lastread = &Apache::lonnet::dump('nohist_'.$cid.'_discuss', |
|
$ENV{'user.domain'},$ENV{'user.name'},'lastread'); |
|
my %lastreadtime = (); |
|
foreach (keys %lastread) { |
|
my $key = $_; |
|
$key =~ s/_lastread$//; |
|
$lastreadtime{$key} = $lastread{$_}; |
|
} |
|
|
my %feedback=(); |
my %feedback=(); |
my %error=(); |
my %error=(); |
my $keys = &Apache::lonnet::reply('keys:'. |
my $keys = &Apache::lonnet::reply('keys:'. |
Line 1836 sub generate_email_discuss_status {
|
Line 1901 sub generate_email_discuss_status {
|
$self->{ERROR_MSG} = \%error; # what is this? JB |
$self->{ERROR_MSG} = \%error; # what is this? JB |
$self->{DISCUSSION_TIME} = \%discussiontime; |
$self->{DISCUSSION_TIME} = \%discussiontime; |
$self->{EMAIL_STATUS} = \%emailstatus; |
$self->{EMAIL_STATUS} = \%emailstatus; |
|
$self->{LAST_READ} = \%lastreadtime; |
|
|
$self->{EMAIL_DISCUSS_GENERATED} = 1; |
$self->{EMAIL_DISCUSS_GENERATED} = 1; |
} |
} |
Line 1904 sub hasDiscussion {
|
Line 1970 sub hasDiscussion {
|
if (!defined($self->{DISCUSSION_TIME})) { return 0; } |
if (!defined($self->{DISCUSSION_TIME})) { return 0; } |
|
|
#return defined($self->{DISCUSSION_TIME}->{$symb}); |
#return defined($self->{DISCUSSION_TIME}->{$symb}); |
return $self->{DISCUSSION_TIME}->{$symb} > |
|
$self->{LAST_CHECK}; |
# backward compatibility (bulletin boards used to be 'wrapped') |
|
my $ressymb = $symb; |
|
if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) { |
|
unless ($ressymb =~ m|adm/wrapper/adm|) { |
|
$ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard'; |
|
} |
|
} |
|
|
|
if ( defined ( $self->{LAST_READ}->{$ressymb} ) ) { |
|
return $self->{DISCUSSION_TIME}->{$ressymb} > $self->{LAST_READ}->{$ressymb}; |
|
} else { |
|
# return $self->{DISCUSSION_TIME}->{$ressymb} > $self->{LAST_CHECK}; # v.1.1 behavior |
|
return $self->{DISCUSSION_TIME}->{$ressymb} > 0; # in 1.2 will display speech bubble icons for all items with posts until marked as read (even if read in v 1.1). |
|
} |
} |
} |
|
|
# Private method: Does the given resource (as a symb string) have |
# Private method: Does the given resource (as a symb string) have |
Line 2102 sub parmval_real {
|
Line 2181 sub parmval_real {
|
|
|
# ----------------------------------------------------- fourth , check default |
# ----------------------------------------------------- fourth , check default |
|
|
my $default=&Apache::lonnet::metadata($fn,$rwhat.'.default'); |
my $meta_rwhat=$rwhat; |
|
$meta_rwhat=~s/\./_/g; |
|
my $default=&Apache::lonnet::metadata($fn,$meta_rwhat); |
|
if (defined($default)) { return $default} |
|
$default=&Apache::lonnet::metadata($fn,'parameter_'.$meta_rwhat); |
if (defined($default)) { return $default} |
if (defined($default)) { return $default} |
|
|
# --------------------------------------------------- fifth , cascade up parts |
# --------------------------------------------------- fifth , cascade up parts |
Line 2157 want to know is if I<any> resources matc
|
Line 2240 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 2503 sub new {
|
Line 2586 sub new {
|
} |
} |
|
|
# Check: Was this only one resource, a map? |
# Check: Was this only one resource, a map? |
if ($resourceCount == 1 && $resource->is_map() && !$self->{FORCE_TOP}) { |
if ($resourceCount == 1 && $resource->is_sequence() && !$self->{FORCE_TOP}) { |
my $firstResource = $resource->map_start(); |
my $firstResource = $resource->map_start(); |
my $finishResource = $resource->map_finish(); |
my $finishResource = $resource->map_finish(); |
return |
return |
Line 2536 sub new {
|
Line 2619 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 2550 sub next {
|
Line 2633 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 2664 sub next {
|
Line 2747 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 2682 sub next {
|
Line 2765 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 2734 package Apache::lonnavmaps::DFSiterator;
|
Line 2817 package Apache::lonnavmaps::DFSiterator;
|
# useful for pre-processing of some kind, and is in fact used by the main |
# useful for pre-processing of some kind, and is in fact used by the main |
# iterator that way, but that's about it. |
# iterator that way, but that's about it. |
# One could imagine merging this into the init routine of the main iterator, |
# One could imagine merging this into the init routine of the main iterator, |
# but this might as well be left seperate, since it is possible some other |
# but this might as well be left separate, since it is possible some other |
# use might be found for it. - Jeremy |
# use might be found for it. - Jeremy |
|
|
# Unlike the main iterator, this DOES return all resources, even blank ones. |
# Unlike the main iterator, this DOES return all resources, even blank ones. |
Line 3151 Returns true if the resource is a sequen
|
Line 3234 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 3167 sub is_page {
|
Line 3259 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; |
Line 3175 sub is_sequence {
|
Line 3275 sub is_sequence {
|
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'; |
} |
} |
|
sub is_survey { |
|
my $self = shift(); |
|
my $part = shift(); |
|
if ($self->parmval('type',$part) eq 'survey') { |
|
return 1; |
|
} |
|
if ($self->src() =~ /\.(survey)$/) { |
|
return 1; |
|
} |
|
return 0; |
|
} |
|
|
|
sub is_empty_sequence { |
|
my $self=shift; |
|
my $src = $self->src(); |
|
return !$self->is_page() && $self->navHash("is_map_", 1) && !$self->navHash("map_type_" . $self->map_pc()); |
|
} |
|
|
# Private method: Shells out to the parmval in the nav map, handler parts. |
# Private method: Shells out to the parmval in the nav map, handler parts. |
sub parmval { |
sub parmval { |
Line 3351 sub awarded {
|
Line 3468 sub awarded {
|
} |
} |
sub duedate { |
sub duedate { |
(my $self, my $part) = @_; |
(my $self, my $part) = @_; |
|
my $interval=$self->parmval("interval", $part); |
|
if ($interval) { |
|
my $first_access=&Apache::lonnet::get_first_access('map',$self->symb); |
|
if ($first_access) { return ($first_access+$interval); } |
|
} |
return $self->parmval("duedate", $part); |
return $self->parmval("duedate", $part); |
} |
} |
sub maxtries { |
sub maxtries { |
Line 3651 sub extractParts {
|
Line 3773 sub extractParts {
|
} |
} |
} |
} |
} |
} |
|
my $resorder = &Apache::lonnet::metadata($self->src(),'responseorder'); |
|
if ($resorder) { |
|
my @resorder=split(/,/,$resorder); |
|
foreach my $part (keys(%responseIdHash)) { |
|
my %resids = map { ($_,1) } @{ $responseIdHash{$part} }; |
|
my @neworder; |
|
foreach my $possibleid (@resorder) { |
|
if (exists($resids{$possibleid})) { |
|
push(@neworder,$possibleid); |
|
} |
|
} |
|
$responseIdHash{$part}=\@neworder; |
|
} |
|
} |
$self->{RESPONSE_IDS} = \%responseIdHash; |
$self->{RESPONSE_IDS} = \%responseIdHash; |
$self->{RESPONSE_TYPES} = \%responseTypeHash; |
$self->{RESPONSE_TYPES} = \%responseTypeHash; |
} |
} |
Line 3842 sub getCompletionStatus {
|
Line 3978 sub getCompletionStatus {
|
|
|
my $status = $self->queryRestoreHash('solved', shift); |
my $status = $self->queryRestoreHash('solved', shift); |
|
|
# Left as seperate if statements in case we ever do more with this |
# Left as separate if statements in case we ever do more with this |
if ($status eq 'correct_by_student') {return $self->CORRECT;} |
if ($status eq 'correct_by_student') {return $self->CORRECT;} |
if ($status eq 'correct_by_override') {return $self->CORRECT_BY_OVERRIDE; } |
if ($status eq 'correct_by_override') {return $self->CORRECT_BY_OVERRIDE; } |
if ($status eq 'incorrect_attempted') {return $self->INCORRECT; } |
if ($status eq 'incorrect_attempted') {return $self->INCORRECT; } |