version 1.175, 2003/04/11 20:13:25
|
version 1.205, 2003/06/16 15:08:22
|
Line 47 use Apache::Constants qw(:common :http);
|
Line 47 use Apache::Constants qw(:common :http);
|
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonmenu(); |
use Apache::lonmenu(); |
use POSIX qw (floor strftime); |
use POSIX qw (floor strftime); |
|
use Data::Dumper; # for debugging, not always used |
|
|
# symbolic constants |
# symbolic constants |
sub SYMB { return 1; } |
sub SYMB { return 1; } |
Line 71 my %statusIconMap =
|
Line 72 my %statusIconMap =
|
$resObj->TRIES_LEFT => 'navmap.open.gif', |
$resObj->TRIES_LEFT => 'navmap.open.gif', |
$resObj->INCORRECT => 'navmap.wrong.gif', |
$resObj->INCORRECT => 'navmap.wrong.gif', |
$resObj->OPEN => 'navmap.open.gif', |
$resObj->OPEN => 'navmap.open.gif', |
$resObj->ATTEMPTED => 'navmap.open.gif' ); |
$resObj->ATTEMPTED => 'navmap.ellipsis.gif', |
|
$resObj->ANSWER_SUBMITTED => '' ); |
|
|
my %iconAltTags = |
my %iconAltTags = |
( 'navmap.correct.gif' => 'Correct', |
( 'navmap.correct.gif' => 'Correct', |
Line 159 sub real_handler {
|
Line 161 sub real_handler {
|
# Now that we've displayed some stuff to the user, init the navmap |
# Now that we've displayed some stuff to the user, init the navmap |
$navmap->init(); |
$navmap->init(); |
|
|
$r->print('<br> '); |
$r->print('<br>'); |
$r->rflush(); |
$r->rflush(); |
|
|
# Check that it's defined |
# Check that it's defined |
Line 169 sub real_handler {
|
Line 171 sub real_handler {
|
return OK; |
return OK; |
} |
} |
|
|
# See if there's only one map in the top-level... if so, |
# See if there's only one map in the top-level, if we don't |
# automatically display it |
# already have a filter... if so, automatically display it |
my $iterator = $navmap->getIterator(undef, undef, undef, 0); |
if ($ENV{QUERY_STRING} !~ /filter/) { |
my $depth = 1; |
my $iterator = $navmap->getIterator(undef, undef, undef, 0); |
$iterator->next(); |
my $depth = 1; |
my $curRes = $iterator->next(); |
$iterator->next(); |
my $sequenceCount = 0; |
my $curRes = $iterator->next(); |
my $sequenceId; |
my $sequenceCount = 0; |
while ($depth > 0) { |
my $sequenceId; |
if ($curRes == $iterator->BEGIN_MAP()) { $depth++; } |
while ($depth > 0) { |
if ($curRes == $iterator->END_MAP()) { $depth--; } |
if ($curRes == $iterator->BEGIN_MAP()) { $depth++; } |
|
if ($curRes == $iterator->END_MAP()) { $depth--; } |
|
|
|
if (ref($curRes) && $curRes->is_sequence()) { |
|
$sequenceCount++; |
|
$sequenceId = $curRes->map_pc(); |
|
} |
|
|
|
$curRes = $iterator->next(); |
|
} |
|
|
|
if ($sequenceCount == 1) { |
|
# The automatic iterator creation in the render call |
|
# will pick this up. We know the condition because |
|
# the defined($ENV{'form.filter'}) also ensures this |
|
# is a fresh call. |
|
$ENV{'form.filter'} = "$sequenceId"; |
|
} |
|
} |
|
|
|
my $jumpToFirstHomework = 0; |
|
# Check to see if the student is jumping to next open, do-able problem |
|
if ($ENV{QUERY_STRING} eq 'jumpToFirstHomework') { |
|
$jumpToFirstHomework = 1; |
|
# Find the next homework problem that they can do. |
|
my $iterator = $navmap->getIterator(undef, undef, undef, 1); |
|
my $depth = 1; |
|
$iterator->next(); |
|
my $curRes = $iterator->next(); |
|
my $foundDoableProblem = 0; |
|
my $problemRes; |
|
|
|
while ($depth > 0 && !$foundDoableProblem) { |
|
if ($curRes == $iterator->BEGIN_MAP()) { $depth++; } |
|
if ($curRes == $iterator->END_MAP()) { $depth--; } |
|
|
|
if (ref($curRes) && $curRes->is_problem()) { |
|
my $status = $curRes->status(); |
|
if ($curRes->completable()) { |
|
$problemRes = $curRes; |
|
$foundDoableProblem = 1; |
|
|
|
# Pop open all previous maps |
|
my $stack = $iterator->getStack(); |
|
pop @$stack; # last resource in the stack is the problem |
|
# itself, which we don't need in the map stack |
|
my @mapPcs = map {$_->map_pc()} @$stack; |
|
$ENV{'form.filter'} = join(',', @mapPcs); |
|
|
if (ref($curRes) && $curRes->is_sequence()) { |
# Mark as both "here" and "jump" |
$sequenceCount++; |
$ENV{'form.postsymb'} = $curRes->symb(); |
$sequenceId = $curRes->map_pc(); |
} |
|
} |
|
} continue { |
|
$curRes = $iterator->next(); |
} |
} |
|
|
$curRes = $iterator->next(); |
# If we found no problems, print a note to that effect. |
|
if (!$foundDoableProblem) { |
|
$r->print("<font size='+2'>All homework assignments have been completed.</font><br /><br />"); |
|
} |
|
} else { |
|
$r->print("<a href='navmaps?jumpToFirstHomework'>" . |
|
"Go To My First Homework Problem</a><br />"); |
} |
} |
|
|
if ($sequenceCount == 1) { |
my $suppressEmptySequences = 0; |
# The automatic iterator creation in the render call |
my $filterFunc = undef; |
# will pick this up. |
my $resource_no_folder_link = 0; |
$ENV{'form.filter'} = "$sequenceId"; |
|
|
# Display only due homework. |
|
my $showOnlyHomework = 0; |
|
if ($ENV{QUERY_STRING} eq 'showOnlyHomework') { |
|
$showOnlyHomework = 1; |
|
$suppressEmptySequences = 1; |
|
$filterFunc = sub { my $res = shift; |
|
return $res->completable() || $res->is_map(); |
|
}; |
|
$r->print("<p><font size='+2'>Uncompleted Homework</font></p>"); |
|
$ENV{'form.filter'} = ''; |
|
$ENV{'form.condition'} = 1; |
|
$resource_no_folder_link = 1; |
|
} else { |
|
$r->print("<a href='navmaps?showOnlyHomework'>" . |
|
"Show Only Uncompleted Homework</a><br />"); |
} |
} |
|
|
# renderer call |
# renderer call |
my $render = render({ 'cols' => [0,1,2,3], |
my $renderArgs = { 'cols' => [0,1,2,3], |
'url' => '/adm/navmaps', |
'url' => '/adm/navmaps', |
'navmap' => $navmap, |
'navmap' => $navmap, |
'suppressNavmap' => 1, |
'suppressNavmap' => 1, |
'r' => $r}); |
'suppressEmptySequences' => $suppressEmptySequences, |
|
'filterFunc' => $filterFunc, |
|
'resource_no_folder_link' => $resource_no_folder_link, |
|
'r' => $r}; |
|
my $render = render($renderArgs); |
$navmap->untieHashes(); |
$navmap->untieHashes(); |
|
|
|
# If no resources were printed, print a reassuring message so the |
|
# user knows there was no error. |
|
if ($renderArgs->{'counter'} == 0) { |
|
if ($showOnlyHomework) { |
|
$r->print("<p><font size='+1'>All homework is currently completed.</font></p>"); |
|
} else { # both jumpToFirstHomework and normal use the same: course must be empty |
|
$r->print("<p><font size='+1'>This course is empty.</font></p>"); |
|
} |
|
} |
|
|
$r->print("</body></html>"); |
$r->print("</body></html>"); |
$r->rflush(); |
$r->rflush(); |
|
|
Line 267 sub getDescription {
|
Line 353 sub getDescription {
|
my $part = shift; |
my $part = shift; |
my $status = $res->status($part); |
my $status = $res->status($part); |
|
|
if ($status == $res->NETWORK_FAILURE) { return ""; } |
if ($status == $res->NETWORK_FAILURE) { |
|
return "Having technical difficulties; please check status later"; |
|
} |
if ($status == $res->NOTHING_SET) { |
if ($status == $res->NOTHING_SET) { |
return "Not currently assigned."; |
return "Not currently assigned."; |
} |
} |
Line 294 sub getDescription {
|
Line 382 sub getDescription {
|
return "Excused by instructor"; |
return "Excused by instructor"; |
} |
} |
if ($status == $res->ATTEMPTED) { |
if ($status == $res->ATTEMPTED) { |
return "Not yet graded."; |
return "Answer submitted, not yet graded."; |
} |
} |
if ($status == $res->TRIES_LEFT) { |
if ($status == $res->TRIES_LEFT) { |
my $tries = $res->tries($part); |
my $tries = $res->tries($part); |
Line 313 sub getDescription {
|
Line 401 sub getDescription {
|
return "No due date $triesString"; |
return "No due date $triesString"; |
} |
} |
} |
} |
|
if ($status == $res->ANSWER_SUBMITTED) { |
|
return 'Answer submitted'; |
|
} |
} |
} |
|
|
# 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 |
Line 343 sub lastTry {
|
Line 434 sub lastTry {
|
} |
} |
|
|
# This puts a human-readable name on the ENV variable. |
# This puts a human-readable name on the ENV variable. |
# FIXME: This needs better logic: Who gets the advanced view of navmaps? |
|
# As of 3-13-03, it's an open question. Guy doesn't want to check |
|
# roles directly because it should be a check of capabilities for future |
|
# role compatibity. There is no capability that matches this one for |
|
# now, so this is done. (A hack for 1.0 might be to simply check roles |
|
# anyhow.) |
|
sub advancedUser { |
sub advancedUser { |
return $ENV{'user.adv'}; |
return $ENV{'request.role.adv'}; |
} |
} |
|
|
|
|
Line 470 Apache::lonnavmap - Subroutines to handl
|
Line 556 Apache::lonnavmap - Subroutines to handl
|
|
|
The main handler generates the navigational listing for the course, |
The main handler generates the navigational listing for the course, |
the other objects export this information in a usable fashion for |
the other objects export this information in a usable fashion for |
other modules |
other modules. |
|
|
=head1 Object: render |
=head1 Subroutine: render |
|
|
The navmap renderer package provides a sophisticated rendering of the |
The navmap renderer package provides a sophisticated rendering of the |
standard navigation maps interface into HTML. The provided nav map |
standard navigation maps interface into HTML. The provided nav map |
Line 486 understand then "undef, undef, undef, 1,
|
Line 572 understand then "undef, undef, undef, 1,
|
undef, 0" when you mostly want default behaviors. |
undef, 0" when you mostly want default behaviors. |
|
|
The package provides a function called 'render', called as |
The package provides a function called 'render', called as |
Apache::lonnavmaps::renderer->render({}). |
Apache::lonnavmaps::render({}). |
|
|
=head2 Overview of Columns |
=head2 Overview of Columns |
|
|
Line 494 The renderer will build an HTML table fo
|
Line 580 The renderer will build an HTML table fo
|
it. The table is consists of several columns, and a row for each |
it. The table is consists of several columns, and a row for each |
resource (or possibly each part). You tell the renderer how many |
resource (or possibly each part). You tell the renderer how many |
columns to create and what to place in each column, optionally using |
columns to create and what to place in each column, optionally using |
one or more of the preparent columns, and the renderer will assemble |
one or more of the prepared columns, and the renderer will assemble |
the table. |
the table. |
|
|
Any additional generally useful column types should be placed in the |
Any additional generally useful column types should be placed in the |
Line 512 argument hash passed to the renderer, an
|
Line 598 argument hash passed to the renderer, an
|
be inserted into the HTML representation as it. |
be inserted into the HTML representation as it. |
|
|
The pre-packaged column names are refered to by constants in the |
The pre-packaged column names are refered to by constants in the |
Apache::lonnavmaps::renderer namespace. The following currently exist: |
Apache::lonnavmaps namespace. The following currently exist: |
|
|
=over 4 |
=over 4 |
|
|
Line 520 Apache::lonnavmaps::renderer namespace.
|
Line 606 Apache::lonnavmaps::renderer namespace.
|
|
|
The general info about the resource: Link, icon for the type, etc. The |
The general info about the resource: Link, icon for the type, etc. The |
first column in the standard nav map display. This column also accepts |
first column in the standard nav map display. This column also accepts |
the following parameter in the renderer hash: |
the following parameters in the renderer hash: |
|
|
=over 4 |
=over 4 |
|
|
Line 686 returns a true or false value. If true,
|
Line 772 returns a true or false value. If true,
|
false, it is simply skipped in the display. By default, all resources |
false, it is simply skipped in the display. By default, all resources |
are shown. |
are shown. |
|
|
|
=item * B<suppressEmptySequences>: |
|
|
|
If you're using a filter function, and displaying sequences to orient |
|
the user, then frequently some sequences will be empty. Setting this to |
|
true will cause those sequences not to display, so as not to confuse the |
|
user into thinking that if the sequence is there there should be things |
|
under it. |
|
|
=item * B<suppressNavmaps>: |
=item * B<suppressNavmaps>: |
|
|
If true, will not display Navigate Content resources. Default to |
If true, will not display Navigate Content resources. Default to |
Line 745 sub render_resource {
|
Line 839 sub render_resource {
|
my $linkopen = "<a href='$link'>"; |
my $linkopen = "<a href='$link'>"; |
my $linkclose = "</a>"; |
my $linkclose = "</a>"; |
|
|
# Default icon: HTML page |
# Default icon: unknown page |
my $icon = "<img src='/adm/lonIcons/html.gif' alt='' border='0' />"; |
my $icon = "<img src='/adm/lonIcons/unknown.gif' alt='' border='0' />"; |
|
|
if ($resource->is_problem()) { |
if ($resource->is_problem()) { |
if ($part eq "" || $params->{'condensed'}) { |
if ($part eq '0' || $params->{'condensed'}) { |
$icon = '<img src="/adm/lonIcons/problem.gif" alt="" border="0" />'; |
$icon = '<img src="/adm/lonIcons/problem.gif" alt="" border="0" />'; |
} else { |
} else { |
$icon = $params->{'indentString'}; |
$icon = $params->{'indentString'}; |
} |
} |
|
} else { |
|
my $curfext= (split (/\./,$resource->src))[-1]; |
|
my $embstyle = &Apache::loncommon::fileembstyle($curfext); |
|
# 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 764 sub render_resource {
|
Line 865 sub render_resource {
|
$nowOpen = !$nowOpen; |
$nowOpen = !$nowOpen; |
} |
} |
|
|
|
my $folderType = $resource->is_sequence() ? 'folder' : 'page'; |
|
|
if (!$params->{'resource_no_folder_link'}) { |
if (!$params->{'resource_no_folder_link'}) { |
$icon = 'navmap.folder.' . ($nowOpen ? 'closed' : 'open') . '.gif'; |
$icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . '.gif'; |
$icon = "<img src='/adm/lonIcons/$icon' alt='' border='0' />"; |
$icon = "<img src='/adm/lonIcons/$icon' alt='' border='0' />"; |
|
|
$linkopen = "<a href='" . $params->{'url'} . '?' . |
$linkopen = "<a href='" . $params->{'url'} . '?' . |
Line 781 sub render_resource {
|
Line 884 sub render_resource {
|
"&folderManip=1'>"; |
"&folderManip=1'>"; |
} else { |
} else { |
# Don't allow users to manipulate folder |
# Don't allow users to manipulate folder |
$icon = 'navmap.folder.' . ($nowOpen ? 'closed' : 'open') . |
$icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . |
'.nomanip.gif'; |
'.nomanip.gif'; |
$icon = "<img src='/adm/lonIcons/$icon' alt='' border='0' />"; |
$icon = "<img src='/adm/lonIcons/$icon' alt='' border='0' />"; |
|
|
Line 819 sub render_resource {
|
Line 922 sub render_resource {
|
$params->{'displayedHereMarker'} = 1; |
$params->{'displayedHereMarker'} = 1; |
} |
} |
|
|
if ($resource->is_problem() && $part ne "" && |
if ($resource->is_problem() && $part ne '0' && |
!$params->{'condensed'}) { |
!$params->{'condensed'}) { |
$partLabel = " (Part $part)"; |
$partLabel = " (Part $part)"; |
$title = ""; |
$title = ""; |
Line 829 sub render_resource {
|
Line 932 sub render_resource {
|
$nonLinkedText .= ' (' . $resource->countParts() . ' parts)'; |
$nonLinkedText .= ' (' . $resource->countParts() . ' parts)'; |
} |
} |
|
|
if (!$params->{'resource_nolink'}) { |
if (!$params->{'resource_nolink'} && $src !~ /^\/uploaded\// && |
|
!$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 876 sub render_communication_status {
|
Line 980 sub render_communication_status {
|
} |
} |
} |
} |
|
|
|
if ($params->{'multipart'} && $part != '0') { |
|
$discussionHTML = $feedbackHTML = $errorHTML = ''; |
|
} |
|
|
return "<td width=\"75\" align=\"left\" valign=\"center\">$discussionHTML$feedbackHTML$errorHTML </td>"; |
return "<td width=\"75\" align=\"left\" valign=\"center\">$discussionHTML$feedbackHTML$errorHTML </td>"; |
|
|
} |
} |
Line 911 sub render_long_status {
|
Line 1019 sub render_long_status {
|
$params->{'multipart'} && $part eq "0"; |
$params->{'multipart'} && $part eq "0"; |
|
|
my $color; |
my $color; |
if ($resource->is_problem()) { |
if ($resource->is_problem() && ($resource->countParts() <= 1 || $part ne '') ) { |
$color = $colormap{$resource->status}; |
$color = $colormap{$resource->status}; |
|
|
if (dueInLessThen24Hours($resource, $part) || |
if (dueInLessThen24Hours($resource, $part) || |
Line 931 sub render_long_status {
|
Line 1039 sub render_long_status {
|
$result .= '(randomly select ' . $resource->randompick() .')'; |
$result .= '(randomly select ' . $resource->randompick() .')'; |
} |
} |
|
|
$result .= " </td>\n"; |
|
|
|
return $result; |
return $result; |
} |
} |
|
|
Line 982 sub render {
|
Line 1088 sub render {
|
} |
} |
} |
} |
|
|
|
# Filter: Remember filter function and add our own filter: Refuse |
|
# to show hidden resources unless the user can see them. |
|
my $userCanSeeHidden = advancedUser(); |
|
my $filterFunc = setDefault($args->{'filterFunc'}, |
|
sub {return 1;}); |
|
if (!$userCanSeeHidden) { |
|
# Without renaming the filterfunc, the server seems to go into |
|
# an infinite loop |
|
my $oldFilterFunc = $filterFunc; |
|
$filterFunc = sub { my $res = shift; return !$res->randomout() && |
|
&$oldFilterFunc($res);}; |
|
} |
|
|
my $condition = 0; |
my $condition = 0; |
if ($ENV{'form.condition'}) { |
if ($ENV{'form.condition'}) { |
$condition = 1; |
$condition = 1; |
Line 1078 sub render {
|
Line 1197 sub render {
|
} |
} |
|
|
# (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 |
|
# to be fixed? |
my $mapIterator = $navmap->getIterator(undef, undef, $filterHash, 0); |
my $mapIterator = $navmap->getIterator(undef, undef, $filterHash, 0); |
my $depth = 1; |
my $depth = 1; |
$mapIterator->next(); |
$mapIterator->next(); |
Line 1110 sub render {
|
Line 1231 sub render {
|
my $printKey = $args->{'printKey'}; |
my $printKey = $args->{'printKey'}; |
my $printCloseAll = $args->{'printCloseAll'}; |
my $printCloseAll = $args->{'printCloseAll'}; |
if (!defined($printCloseAll)) { $printCloseAll = 1; } |
if (!defined($printCloseAll)) { $printCloseAll = 1; } |
my $filterFunc = setDefault($args->{'filterFunc'}, |
|
sub {return 1;}); |
|
|
|
# Print key? |
# Print key? |
if ($printKey) { |
if ($printKey) { |
Line 1172 sub render {
|
Line 1291 sub render {
|
$args->{'indentString'} = setDefault($args->{'indentString'}, "<img src='/adm/lonIcons/whitespace1.gif' width='25' height='1' alt='' border='0' />"); |
$args->{'indentString'} = setDefault($args->{'indentString'}, "<img src='/adm/lonIcons/whitespace1.gif' width='25' height='1' alt='' border='0' />"); |
$args->{'displayedHereMarker'} = 0; |
$args->{'displayedHereMarker'} = 0; |
|
|
|
# If we're suppressing empty sequences, look for them here. Use DFS for speed, |
|
# since structure actually doesn't matter, except what map has what resources. |
|
if ($args->{'suppressEmptySequences'}) { |
|
my $dfsit = Apache::lonnavmaps::DFSiterator->new($navmap, |
|
$it->{FIRST_RESOURCE}, |
|
$it->{FINISH_RESOURCE}, |
|
{}, undef, 1); |
|
$depth = 0; |
|
$dfsit->next(); |
|
my $curRes = $dfsit->next(); |
|
while ($depth > -1) { |
|
if ($curRes == $dfsit->BEGIN_MAP()) { $depth++; } |
|
if ($curRes == $dfsit->END_MAP()) { $depth--; } |
|
|
|
if (ref($curRes)) { |
|
# Parallel pre-processing: Do sequences have non-filtered-out children? |
|
if ($curRes->is_map()) { |
|
$curRes->{DATA}->{HAS_VISIBLE_CHILDREN} = 0; |
|
# Sequences themselves do not count as visible children, |
|
# unless those sequences also have visible children. |
|
# This means if a sequence appears, there's a "promise" |
|
# that there's something under it if you open it, somewhere. |
|
} else { |
|
# Not a sequence: if it's filtered, ignore it, otherwise |
|
# rise up the stack and mark the sequences as having children |
|
if (&$filterFunc($curRes)) { |
|
for my $sequence (@{$dfsit->getStack()}) { |
|
$sequence->{DATA}->{HAS_VISIBLE_CHILDREN} = 1; |
|
} |
|
} |
|
} |
|
} |
|
} continue { |
|
$curRes = $dfsit->next(); |
|
} |
|
} |
|
|
my $displayedJumpMarker = 0; |
my $displayedJumpMarker = 0; |
# Set up iteration. |
# Set up iteration. |
$depth = 1; |
$depth = 1; |
Line 1207 sub render {
|
Line 1363 sub render {
|
next; |
next; |
} |
} |
|
|
$args->{'counter'}++; |
|
|
|
# If this has been filtered out, continue on |
# If this has been filtered out, continue on |
if (!(&$filterFunc($curRes))) { |
if (!(&$filterFunc($curRes))) { |
$args->{'isNewBranch'} = 0; # Don't falsely remember this |
$args->{'isNewBranch'} = 0; # Don't falsely remember this |
next; |
next; |
} |
} |
|
|
|
# If this is an empty sequence and we're filtering them, continue on |
|
if ($curRes->is_map() && $args->{'suppressEmptySequences'} && |
|
!$curRes->{DATA}->{HAS_VISIBLE_CHILDREN}) { |
|
next; |
|
} |
|
|
# If we're suppressing navmaps and this is a navmap, continue on |
# If we're suppressing navmaps and this is a navmap, continue on |
if ($suppressNavmap && $curRes->src() =~ /^\/adm\/navmaps/) { |
if ($suppressNavmap && $curRes->src() =~ /^\/adm\/navmaps/) { |
next; |
next; |
} |
} |
|
|
|
$args->{'counter'}++; |
|
|
# Does it have multiple parts? |
# Does it have multiple parts? |
$args->{'multipart'} = 0; |
$args->{'multipart'} = 0; |
$args->{'condensed'} = 0; |
$args->{'condensed'} = 0; |
Line 1228 sub render {
|
Line 1390 sub render {
|
# Decide what parts to show. |
# Decide what parts to show. |
if ($curRes->is_problem() && $showParts) { |
if ($curRes->is_problem() && $showParts) { |
@parts = @{$curRes->parts()}; |
@parts = @{$curRes->parts()}; |
$args->{'multipart'} = scalar(@parts) > 1; |
$args->{'multipart'} = $curRes->multipart(); |
|
|
if ($condenseParts) { # do the condensation |
if ($condenseParts) { # do the condensation |
if (!$curRes->opendate("0")) { |
if (!$curRes->opendate("0")) { |
Line 1237 sub render {
|
Line 1399 sub render {
|
} |
} |
if (!$args->{'condensed'}) { |
if (!$args->{'condensed'}) { |
# Decide whether to condense based on similarity |
# Decide whether to condense based on similarity |
my $status = $curRes->status($parts[1]); |
my $status = $curRes->status($parts[0]); |
my $due = $curRes->duedate($parts[1]); |
my $due = $curRes->duedate($parts[0]); |
my $open = $curRes->opendate($parts[1]); |
my $open = $curRes->opendate($parts[0]); |
my $statusAllSame = 1; |
my $statusAllSame = 1; |
my $dueAllSame = 1; |
my $dueAllSame = 1; |
my $openAllSame = 1; |
my $openAllSame = 1; |
for (my $i = 2; $i < scalar(@parts); $i++) { |
for (my $i = 1; $i < scalar(@parts); $i++) { |
if ($curRes->status($parts[$i]) != $status){ |
if ($curRes->status($parts[$i]) != $status){ |
$statusAllSame = 0; |
$statusAllSame = 0; |
} |
} |
Line 1264 sub render {
|
Line 1426 sub render {
|
if (($statusAllSame && defined($condenseStatuses{$status})) || |
if (($statusAllSame && defined($condenseStatuses{$status})) || |
($dueAllSame && $status == $curRes->OPEN && $statusAllSame)|| |
($dueAllSame && $status == $curRes->OPEN && $statusAllSame)|| |
($openAllSame && $status == $curRes->OPEN_LATER && $statusAllSame) ){ |
($openAllSame && $status == $curRes->OPEN_LATER && $statusAllSame) ){ |
@parts = (); |
@parts = ($parts[0]); |
$args->{'condensed'} = 1; |
$args->{'condensed'} = 1; |
} |
} |
|
|
} |
} |
|
# Multipart problem with one part: always "condense" (happens |
|
# to match the desirable behavior) |
|
if ($curRes->countParts() == 1) { |
|
@parts = ($parts[0]); |
|
$args->{'condensed'} = 1; |
|
} |
} |
} |
} |
} |
|
|
# If the multipart problem was condensed, "forget" it was multipart |
# If the multipart problem was condensed, "forget" it was multipart |
if (scalar(@parts) == 1) { |
if (scalar(@parts) == 1) { |
$args->{'multipart'} = 0; |
$args->{'multipart'} = 0; |
|
} else { |
|
# Add part 0 so we display it correctly. |
|
unshift @parts, '0'; |
} |
} |
|
|
# Now, we've decided what parts to show. Loop through them and |
# Now, we've decided what parts to show. Loop through them and |
# show them. |
# show them. |
foreach my $part ('', @parts) { |
foreach my $part (@parts) { |
if ($part eq '0') { |
|
next; |
|
} |
|
$rownum ++; |
$rownum ++; |
my $backgroundColor = $backgroundColors[$rownum % scalar(@backgroundColors)]; |
my $backgroundColor = $backgroundColors[$rownum % scalar(@backgroundColors)]; |
|
|
Line 1473 sub init {
|
Line 1640 sub init {
|
unless ((time-$courserdatas{$cid.'.last_cache'})<240) { |
unless ((time-$courserdatas{$cid.'.last_cache'})<240) { |
my $reply=&Apache::lonnet::reply('dump:'.$cdom.':'.$cnum. |
my $reply=&Apache::lonnet::reply('dump:'.$cdom.':'.$cnum. |
':resourcedata',$chome); |
':resourcedata',$chome); |
if ($reply!~/^error\:/) { |
# Check for network failure |
|
if ( $reply =~ /no.such.host/i || $reply =~ /con_lost/i) { |
|
$self->{NETWORK_FAILURE} = 1; |
|
} elsif ($reply!~/^error\:/) { |
$courserdatas{$cid}=$reply; |
$courserdatas{$cid}=$reply; |
$courserdatas{$cid.'.last_cache'}=time; |
$courserdatas{$cid.'.last_cache'}=time; |
} |
} |
# check to see if network failed |
|
elsif ( $reply=~/no.such.host/i || $reply=~/con.*lost/i ) |
|
{ |
|
$self->{NETWORK_FAILURE} = 1; |
|
} |
|
} |
} |
foreach (split(/\&/,$courserdatas{$cid})) { |
foreach (split(/\&/,$courserdatas{$cid})) { |
my ($name,$value)=split(/\=/,$_); |
my ($name,$value)=split(/\=/,$_); |
Line 1518 sub init {
|
Line 1683 sub init {
|
my %emailstatus = &Apache::lonnet::dump('email_status'); |
my %emailstatus = &Apache::lonnet::dump('email_status'); |
my $logoutTime = $emailstatus{'logout'}; |
my $logoutTime = $emailstatus{'logout'}; |
my $courseLeaveTime = $emailstatus{'logout_'.$ENV{'request.course.id'}}; |
my $courseLeaveTime = $emailstatus{'logout_'.$ENV{'request.course.id'}}; |
$self->{LAST_CHECK} = ($courseLeaveTime < $logoutTime ? |
$self->{LAST_CHECK} = (($courseLeaveTime > $logoutTime) ? |
$courseLeaveTime : $logoutTime); |
$courseLeaveTime : $logoutTime); |
my %discussiontime = &Apache::lonnet::dump('discussiontimes', |
my %discussiontime = &Apache::lonnet::dump('discussiontimes', |
$cdom, $cnum); |
$cdom, $cnum); |
Line 1635 object for that resource. This method, o
|
Line 1800 object for that resource. This method, o
|
(as in the resource object) is the only proper way to obtain a |
(as in the resource object) is the only proper way to obtain a |
resource object. |
resource object. |
|
|
|
=item * B<getBySymb>(symb): |
|
|
|
Based on the symb of the resource, get a resource object for that |
|
resource. This is one of the proper ways to get a resource object. |
|
|
|
=item * B<getMapByMapPc>(map_pc): |
|
|
|
Based on the map_pc of the resource, get a resource object for |
|
the given map. This is one of the proper ways to get a resource object. |
|
|
=cut |
=cut |
|
|
# The strategy here is to cache the resource objects, and only construct them |
# The strategy here is to cache the resource objects, and only construct them |
Line 1665 sub getBySymb {
|
Line 1840 sub getBySymb {
|
return $self->getById($map->map_pc() . '.' . $id); |
return $self->getById($map->map_pc() . '.' . $id); |
} |
} |
|
|
|
sub getByMapPc { |
|
my $self = shift; |
|
my $map_pc = shift; |
|
my $map_id = $self->{NAV_HASH}->{'map_id_' . $map_pc}; |
|
$map_id = $self->{NAV_HASH}->{'ids_' . $map_id}; |
|
return $self->getById($map_id); |
|
} |
|
|
=pod |
=pod |
|
|
=item * B<firstResource>(): |
=item * B<firstResource>(): |
Line 1959 corresponds to where you want the iterat
|
Line 2142 corresponds to where you want the iterat
|
navmap->finishResource(). filterHash is a hash used as a set |
navmap->finishResource(). filterHash is a hash used as a set |
containing strings representing the resource IDs, defaulting to |
containing strings representing the resource IDs, defaulting to |
empty. Condition is a 1 or 0 that sets what to do with the filter |
empty. Condition is a 1 or 0 that sets what to do with the filter |
hash: If a 0, then only resource that exist IN the filterHash will be |
hash: If a 0, then only resources that exist IN the filterHash will be |
recursed on. If it is a 1, only resources NOT in the filterHash will |
recursed on. If it is a 1, only resources NOT in the filterHash will |
be recursed on. Defaults to 0. forceTop is a boolean value. If it is |
be recursed on. Defaults to 0. forceTop is a boolean value. If it is |
false (default), the iterator will only return the first level of map |
false (default), the iterator will only return the first level of map |
Line 2145 sub new {
|
Line 2328 sub new {
|
|
|
$curRes->{DATA}->{DISPLAY_DEPTH} = $finalDepth; |
$curRes->{DATA}->{DISPLAY_DEPTH} = $finalDepth; |
if ($finalDepth > $maxDepth) {$maxDepth = $finalDepth;} |
if ($finalDepth > $maxDepth) {$maxDepth = $finalDepth;} |
} |
} |
|
} continue { |
$curRes = $iterator->next(); |
$curRes = $iterator->next(); |
} |
} |
} |
} |
Line 2522 sub next {
|
Line 2706 sub next {
|
return $self->{HERE}; |
return $self->{HERE}; |
} |
} |
|
|
|
# Identical to the full iterator methods of the same name. Hate to copy/paste |
|
# but I also hate to "inherit" either iterator from the other. |
|
|
|
sub getStack { |
|
my $self=shift; |
|
|
|
my @stack; |
|
|
|
$self->populateStack(\@stack); |
|
|
|
return \@stack; |
|
} |
|
|
|
# Private method: Calls the iterators recursively to populate the stack. |
|
sub populateStack { |
|
my $self=shift; |
|
my $stack = shift; |
|
|
|
push @$stack, $self->{HERE} if ($self->{HERE}); |
|
|
|
if ($self->{RECURSIVE_ITERATOR_FLAG}) { |
|
$self->{RECURSIVE_ITERATOR}->populateStack($stack); |
|
} |
|
} |
|
|
1; |
1; |
|
|
package Apache::lonnavmaps::resource; |
package Apache::lonnavmaps::resource; |
Line 2545 You will probably never need to instanti
|
Line 2754 You will probably never need to instanti
|
Apache::lonnavmaps::navmap, and use the "start" method to obtain the |
Apache::lonnavmaps::navmap, and use the "start" method to obtain the |
starting resource. |
starting resource. |
|
|
|
Resource objects respect the parameter_hiddenparts, which suppresses |
|
various parts according to the wishes of the map author. As of this |
|
writing, there is no way to override this parameter, and suppressed |
|
parts will never be returned, nor will their response types or ids be |
|
stored. |
|
|
=head2 Public Members |
=head2 Public Members |
|
|
resource objects have a hash called DATA ($resourceRef->{DATA}) that |
resource objects have a hash called DATA ($resourceRef->{DATA}) that |
Line 2690 sub to { my $self=shift; return $self->n
|
Line 2905 sub to { my $self=shift; return $self->n
|
sub compTitle { |
sub compTitle { |
my $self = shift; |
my $self = shift; |
my $title = $self->title(); |
my $title = $self->title(); |
|
$title=~s/\&colon\;/\:/gs; |
if (!$title) { |
if (!$title) { |
$title = $self->src(); |
$title = $self->src(); |
$title = substr($title, rindex($title, '/') + 1); |
$title = substr($title, rindex($title, '/') + 1); |
Line 2736 sub is_map { my $self=shift; return defi
|
Line 2952 sub is_map { my $self=shift; return defi
|
sub is_page { |
sub is_page { |
my $self=shift; |
my $self=shift; |
my $src = $self->src(); |
my $src = $self->src(); |
return ($src =~ /page$/); |
return $self->navHash("is_map_", 1) && |
|
$self->navHash("map_type_" . $self->map_pc()) eq 'page'; |
} |
} |
sub is_problem { |
sub is_problem { |
my $self=shift; |
my $self=shift; |
Line 2746 sub is_problem {
|
Line 2963 sub is_problem {
|
sub is_sequence { |
sub is_sequence { |
my $self=shift; |
my $self=shift; |
my $src = $self->src(); |
my $src = $self->src(); |
return ($src =~ /sequence$/); |
return $self->navHash("is_map_", 1) && |
|
$self->navHash("map_type_" . $self->map_pc()) eq 'sequence'; |
} |
} |
|
|
# 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 { |
my $self = shift; |
my $self = shift; |
my $what = shift; |
my $what = shift; |
my $part = shift || "0"; |
my $part = shift; |
|
if (!defined($part)) { |
|
$part = '0'; |
|
} |
return $self->{NAV_MAP}->parmval($part.'.'.$what, $self->symb()); |
return $self->{NAV_MAP}->parmval($part.'.'.$what, $self->symb()); |
} |
} |
|
|
Line 2818 sub map_type {
|
Line 3039 sub map_type {
|
return $self->navHash("map_type_$pc", 0); |
return $self->navHash("map_type_$pc", 0); |
} |
} |
|
|
|
|
|
|
##### |
##### |
# Property queries |
# Property queries |
##### |
##### |
Line 2927 sub opendate {
|
Line 3146 sub opendate {
|
} |
} |
return $self->parmval("opendate"); |
return $self->parmval("opendate"); |
} |
} |
|
sub problemstatus { |
|
(my $self, my $part) = @_; |
|
return $self->parmval("problemstatus", $part); |
|
} |
sub sig { |
sub sig { |
(my $self, my $part) = @_; |
(my $self, my $part) = @_; |
return $self->parmval("sig", $part); |
return $self->parmval("sig", $part); |
Line 3027 sub getErrors {
|
Line 3250 sub getErrors {
|
=item * B<parts>(): |
=item * B<parts>(): |
|
|
Returns a list reference containing sorted strings corresponding to |
Returns a list reference containing sorted strings corresponding to |
each part of the problem. To count the number of parts, use the list |
each part of the problem. Single part problems have only a part '0'. |
in a scalar context, and subtract one if greater than two. (One part |
Multipart problems do not return their part '0', since they typically |
problems have a part 0. Multi-parts have a part 0, plus a part for |
do not really matter. |
each part. Filtering part 0 if you want it is up to you.) |
|
|
|
=item * B<countParts>(): |
=item * B<countParts>(): |
|
|
Returns the number of parts of the problem a student can answer. Thus, |
Returns the number of parts of the problem a student can answer. Thus, |
for single part problems, returns 1. For multipart, it returns the |
for single part problems, returns 1. For multipart, it returns the |
number of parts in the problem, not including psuedo-part 0. Thus, |
number of parts in the problem, not including psuedo-part 0. |
B<parts> may return an array with fewer parts in it then countParts |
|
might lead you to believe. |
=item * B<multipart>(): |
|
|
|
Returns true if the problem is multipart, false otherwise. Use this instead |
|
of countParts if all you want is multipart/not multipart. |
|
|
|
=item * B<responseType>($part): |
|
|
|
Returns the response type of the part, without the word "response" on the |
|
end. Example return values: 'string', 'essay', 'numeric', etc. |
|
|
|
=item * B<responseIds>($part): |
|
|
|
Retreives the response IDs for the given part as an array reference containing |
|
strings naming the response IDs. This may be empty. |
|
|
=back |
=back |
|
|
Line 3047 might lead you to believe.
|
Line 3282 might lead you to believe.
|
sub parts { |
sub parts { |
my $self = shift; |
my $self = shift; |
|
|
if ($self->ext) { return ['0']; } |
if ($self->ext) { return []; } |
|
|
$self->extractParts(); |
$self->extractParts(); |
return $self->{PARTS}; |
return $self->{PARTS}; |
Line 3057 sub countParts {
|
Line 3292 sub countParts {
|
my $self = shift; |
my $self = shift; |
|
|
my $parts = $self->parts(); |
my $parts = $self->parts(); |
my $delta = 0; |
|
for my $part (@$parts) { |
# If I left this here, then it's not necessary. |
if ($part eq '0') { $delta--; } |
#my $delta = 0; |
} |
#for my $part (@$parts) { |
|
# if ($part eq '0') { $delta--; } |
|
#} |
|
|
if ($self->{RESOURCE_ERROR}) { |
if ($self->{RESOURCE_ERROR}) { |
return 0; |
return 0; |
} |
} |
|
|
return scalar(@{$parts}) + $delta; |
return scalar(@{$parts}); # + $delta; |
} |
} |
|
|
# Private function: Extracts the parts information and saves it |
sub multipart { |
|
my $self = shift; |
|
return $self->countParts() > 1; |
|
} |
|
|
|
sub responseType { |
|
my $self = shift; |
|
my $part = shift; |
|
|
|
$self->extractParts(); |
|
return $self->{RESPONSE_TYPE}->{$part}; |
|
} |
|
|
|
sub responseIds { |
|
my $self = shift; |
|
my $part = shift; |
|
|
|
$self->extractParts(); |
|
return $self->{RESPONSE_IDS}->{$part}; |
|
} |
|
|
|
# Private function: Extracts the parts information, both part names and |
|
# part types, and saves it. |
sub extractParts { |
sub extractParts { |
my $self = shift; |
my $self = shift; |
|
|
Line 3078 sub extractParts {
|
Line 3337 sub extractParts {
|
|
|
$self->{PARTS} = []; |
$self->{PARTS} = []; |
|
|
|
my %parts; |
|
|
# Retrieve part count, if this is a problem |
# Retrieve part count, if this is a problem |
if ($self->is_problem()) { |
if ($self->is_problem()) { |
my $metadata = &Apache::lonnet::metadata($self->src(), 'packages'); |
my $metadata = &Apache::lonnet::metadata($self->src(), 'packages'); |
if (!$metadata) { |
if (!$metadata) { |
$self->{RESOURCE_ERROR} = 1; |
$self->{RESOURCE_ERROR} = 1; |
$self->{PARTS} = []; |
$self->{PARTS} = []; |
|
$self->{PART_TYPE} = {}; |
return; |
return; |
} |
} |
foreach (split(/\,/,$metadata)) { |
foreach (split(/\,/,$metadata)) { |
if ($_ =~ /^part_(.*)$/) { |
if ($_ =~ /^part_(.*)$/) { |
my $part = $1; |
my $part = $1; |
|
# This floods the logs if it blows up |
|
if (defined($parts{$part})) { |
|
Apache::lonnet::logthis("$part multiply defined in metadata for " . $self->symb()); |
|
} |
|
|
# check to see if part is turned off. |
# check to see if part is turned off. |
if (! Apache::loncommon::check_if_partid_hidden($part, $self->symb())) { |
|
push @{$self->{PARTS}}, $1; |
if (!Apache::loncommon::check_if_partid_hidden($part, $self->symb())) { |
|
$parts{$part} = 1; |
} |
} |
} |
} |
} |
} |
|
|
|
|
my @sortedParts = sort @{$self->{PARTS}}; |
my @sortedParts = sort keys %parts; |
$self->{PARTS} = \@sortedParts; |
$self->{PARTS} = \@sortedParts; |
|
|
|
my %responseIdHash; |
|
my %responseTypeHash; |
|
|
|
|
|
# Init the responseIdHash |
|
foreach (@{$self->{PARTS}}) { |
|
$responseIdHash{$_} = []; |
|
} |
|
|
|
# Now, the unfortunate thing about this is that parts, part name, and |
|
# response if are delimited by underscores, but both the part |
|
# name and response id can themselves have underscores in them. |
|
# So we have to use our knowlege of part names to figure out |
|
# where the part names begin and end, and even then, it is possible |
|
# to construct ambiguous situations. |
|
foreach (split /,/, $metadata) { |
|
if ($_ =~ /^([a-zA-Z]+)response_(.*)/) { |
|
my $responseType = $1; |
|
my $partStuff = $2; |
|
my $partIdSoFar = ''; |
|
my @partChunks = split /_/, $partStuff; |
|
my $i = 0; |
|
|
|
for ($i = 0; $i < scalar(@partChunks); $i++) { |
|
if ($partIdSoFar) { $partIdSoFar .= '_'; } |
|
$partIdSoFar .= $partChunks[$i]; |
|
if ($parts{$partIdSoFar}) { |
|
my @otherChunks = @partChunks[$i+1..$#partChunks]; |
|
my $responseId = join('_', @otherChunks); |
|
push @{$responseIdHash{$partIdSoFar}}, $responseId; |
|
$responseTypeHash{$partIdSoFar} = $responseType; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
|
|
$self->{RESPONSE_IDS} = \%responseIdHash; |
|
$self->{RESPONSE_TYPES} = \%responseTypeHash; |
} |
} |
|
|
return; |
return; |
Line 3302 sub queryRestoreHash {
|
Line 3610 sub queryRestoreHash {
|
my $self = shift; |
my $self = shift; |
my $hashentry = shift; |
my $hashentry = shift; |
my $part = shift; |
my $part = shift; |
$part = "0" if (!defined($part)); |
$part = "0" if (!defined($part) || $part eq ''); |
return $self->NETWORK_FAILURE if ($self->{NAV_MAP}->{NETWORK_FAILURE}); |
return $self->NETWORK_FAILURE if ($self->{NAV_MAP}->{NETWORK_FAILURE}); |
|
|
$self->getReturnHash(); |
$self->getReturnHash(); |
Line 3317 B<Composite Status>
|
Line 3625 B<Composite Status>
|
Along with directly returning the date or completion status, the |
Along with directly returning the date or completion status, the |
resource object includes a convenience function B<status>() that will |
resource object includes a convenience function B<status>() that will |
combine the two status tidbits into one composite status that can |
combine the two status tidbits into one composite status that can |
represent the status of the resource as a whole. The precise logic is |
represent the status of the resource as a whole. This method represents |
|
the concept of the thing we want to display to the user on the nav maps |
|
screen, which is a combination of completion and open status. The precise logic is |
documented in the comments of the status method. The following results |
documented in the comments of the status method. The following results |
may be returned, all available as methods on the resource object |
may be returned, all available as methods on the resource object |
($res->NETWORK_FAILURE): |
($res->NETWORK_FAILURE): In addition to the return values that match |
|
the date or completion status, this function can return "ANSWER_SUBMITTED" |
|
if that problemstatus parameter value is set to No, suppressing the |
|
incorrect/correct feedback. |
|
|
=over 4 |
=over 4 |
|
|
Line 3379 The item is open and not yet tried.
|
Line 3692 The item is open and not yet tried.
|
|
|
The problem has been attempted. |
The problem has been attempted. |
|
|
|
=item * B<ANSWER_SUBMITTED>: |
|
|
|
An answer has been submitted, but the student should not see it. |
|
|
=back |
=back |
|
|
=cut |
=cut |
|
|
sub TRIES_LEFT { return 10; } |
sub TRIES_LEFT { return 20; } |
|
sub ANSWER_SUBMITTED { return 21; } |
|
|
sub status { |
sub status { |
my $self = shift; |
my $self = shift; |
Line 3398 sub status {
|
Line 3716 sub status {
|
|
|
if ($completionStatus == NETWORK_FAILURE) { return NETWORK_FAILURE; } |
if ($completionStatus == NETWORK_FAILURE) { return NETWORK_FAILURE; } |
|
|
|
my $suppressFeedback = lc($self->parmval("problemstatus", $part)) eq 'no'; |
|
|
# There are a few whole rows we can dispose of: |
# There are a few whole rows we can dispose of: |
if ($completionStatus == CORRECT || |
if ($completionStatus == CORRECT || |
$completionStatus == CORRECT_BY_OVERRIDE ) { |
$completionStatus == CORRECT_BY_OVERRIDE ) { |
return CORRECT; |
return $suppressFeedback? ANSWER_SUBMITTED : CORRECT; |
} |
} |
|
|
if ($completionStatus == ATTEMPTED) { |
if ($completionStatus == ATTEMPTED) { |
Line 3442 sub status {
|
Line 3762 sub status {
|
if ($self->tries($part) < $self->maxtries($part) || !$self->maxtries($part)) { |
if ($self->tries($part) < $self->maxtries($part) || !$self->maxtries($part)) { |
return TRIES_LEFT; |
return TRIES_LEFT; |
} |
} |
return INCORRECT; # otherwise, return orange; student can't fix this |
return $suppressFeedback ? ANSWER_SUBMITTED : INCORRECT; # otherwise, return orange; student can't fix this |
} |
} |
|
|
# Otherwise, it's untried and open |
# Otherwise, it's untried and open |
Line 3450 sub status {
|
Line 3770 sub status {
|
} |
} |
|
|
=pod |
=pod |
|
|
|
B<Completable> |
|
|
|
The completable method represents the concept of I<whether the student can |
|
currently do the problem>. If the student can do the problem, which means |
|
that it is open, there are tries left, and if the problem is manually graded |
|
or the grade is suppressed via problemstatus, the student has not tried it |
|
yet, then the method returns 1. Otherwise, it returns 0, to indicate that |
|
either the student has tried it and there is no feedback, or that for |
|
some reason it is no longer completable (not open yet, successfully completed, |
|
out of tries, etc.). As an example, this is used as the filter for the |
|
"Uncompleted Homework" option for the nav maps. |
|
|
|
If this does not quite meet your needs, do not fiddle with it (unless you are |
|
fixing it to better match the student's conception of "completable" because |
|
it's broken somehow)... make a new method. |
|
|
|
=cut |
|
|
|
sub completable { |
|
my $self = shift; |
|
if (!$self->is_problem()) { return 0; } |
|
my $partCount = $self->countParts(); |
|
|
|
foreach my $part (@{$self->parts()}) { |
|
if ($part eq '0' && $partCount != 1) { next; } |
|
my $status = $self->status($part); |
|
# "If any of the parts are open, or have tries left (implies open), |
|
# and it is not "attempted" (manually graded problem), it is |
|
# not "complete" |
|
if (!(($status == OPEN() || $status == TRIES_LEFT()) |
|
&& $self->getCompletionStatus($part) != ATTEMPTED() |
|
&& $status != ANSWER_SUBMITTED())) { |
|
return 0; |
|
} |
|
} |
|
|
|
# If all the parts were complete, so was this problem. |
|
return 1; |
|
} |
|
|
|
=pod |
|
|
=head2 Resource/Nav Map Navigation |
=head2 Resource/Nav Map Navigation |
|
|