Apache::lonnavmaps - Subroutines to handle and render the navigation
Handles navigational maps.
The main handler generates the navigational listing for the course, the other objects export this information in a usable fashion for other modules.
This is part of the LearningOnline Network with CAPA project described at http://www.lon-capa.org.
When a user enters a course, LON-CAPA examines the course structure and caches it in what is often referred to as the ``big hash'' . You can see it if you are logged into LON-CAPA, in a course, by going to /adm/test. (You may need to tweak the /home/httpd/lonTabs/htpasswd file to view it.) The content of the hash will be under the heading ``Big Hash''.
Big Hash contains, among other things, how resources are related to each other (next/previous), what resources are maps, which resources are being chosen to not show to the student (for random selection), and a lot of other things that can take a lot of time to compute due to the amount of data that needs to be collected and processed.
Apache::lonnavmaps provides an object model for manipulating this information in a higher-level fashion than directly manipulating the hash. It also provides access to several auxilary functions that aren't necessarily stored in the Big Hash, but are a per- resource sort of value, like whether there is any feedback on a given resource.
Apache::lonnavmaps also abstracts away branching, and someday, conditions, for the times where you don't really care about those things.
Apache::lonnavmaps also provides fairly powerful routines for rendering navmaps, and last but not least, provides the navmaps view for when the user clicks the NAV button.
Note: Apache::lonnavmaps only works for the ``currently logged in user''; if you want things like ``due dates for another student'' lonnavmaps can not directly retrieve information like that. You need the EXT function. This module can still help, because many things, such as the course structure, are constant between users, and Apache::lonnavmaps can help by providing symbs for the EXT call.
The rest of this file will cover the provided rendering routines, which can often be used without fiddling with the navmap object at all, then documents the Apache::lonnavmaps::navmap object, which is the key to accessing the Big Hash information, covers the use of the Iterator (which provides the logic for traversing the somewhat-complicated Big Hash data structure), documents the Apache::lonnavmaps::Resource objects that are returned by
The navmap renderer package provides a sophisticated rendering of the standard navigation maps interface into HTML. The provided nav map handler is actually just a glorified call to this.
Because of the large number of parameters this function accepts, instead of passing it arguments as is normal, pass it in an anonymous hash with the desired options.
The package provides a function called 'render', called as Apache::lonnavmaps::render({}).
The renderer will build an HTML table for the navmap and return it. The table consists of several columns, and a row for each resource (or possibly each part). You tell the renderer how many columns to create and what to place in each column, optionally using one or more of the prepared columns, and the renderer will assemble the table.
Any additional generally useful column types should be placed in the renderer code here, so anybody can use it anywhere else. Any code specific to the current application (such as the addition of <input> elements in a column) should be placed in the code of the thing using the renderer.
At the core of the renderer is the array reference COLS (see Example section below for how to pass this correctly). The COLS array will consist of entries of one of two types of things: Either an integer representing one of the pre-packaged column types, or a sub reference that takes a resource reference, a part number, and a reference to the argument hash passed to the renderer, and returns a string that will be inserted into the HTML representation as it.
All other parameters are ways of either changing how the columns are printing, or which rows are shown.
The pre-packaged column names are refered to by constants in the Apache::lonnavmaps namespace. The following currently exist:
The general info about the resource: Link, icon for the type, etc. The first column in the standard nav map display. This column provides the indentation effect seen in the NAV screen. This column also accepts the following parameters in the renderer hash:
If true, the resource will not be linked. By default, all non-folder resources are linked.
If true, the resource will show a part count if the full part list is not displayed. (See ``condense_parts'' later.) If false, the resource will never show a part count.
If true, the resource's folder will not be clickable to open or close it. Default is false. True implies printCloseAll is false, since you can't close or open folders when this is on anyhow.
Whether there is discussion on the resource, email for the user, or (lumped in here) perl errors in the execution of the problem. This is the second column in the main nav map.
An icon for the status of a problem, with five possible states: Correct, incorrect, open, awaiting grading (for a problem where the computer's grade is suppressed, or the computer can't grade, like essay problem), or none (not open yet, not a problem). The third column of the standard navmap.
A text readout of the details of the current status of the problem, such as ``Due in 22 hours''. The fourth column of the standard navmap.
A text readout summarizing the status of the problem. If it is a single part problem, will display ``Correct'', ``Incorrect'', ``Not yet open'', ``Open'', ``Attempted'', or ``Error''. If there are multiple parts, this will output a string that in HTML will show a status of how many parts are in each status, in color coding, trying to match the colors of the icons within reason.
Note this only makes sense if you are not showing parts. If
showParts
is true (see below), this column will not output
anything.
If you add any others please be sure to document them here.
An example of a column renderer that will show the ID number of a resource, along with the part name if any:
sub { my ($resource, $part, $params) = @_; if ($part) { return '<td>' . $resource->{ID} . ' ' . $part . '</td>'; } return '<td>' . $resource->{ID} . '</td>'; }
Note these functions are responsible for the TD tags, which allow them to override vertical and horizontal alignment, etc.
Minimally, you should be able to get away with just using 'cols' (to specify the columns shown), 'url' (necessary for the folders to link to the current screen correctly), and possibly 'queryString' if your app calls for it. In that case, maintaining the state of the folders will be done automatically.
A reference to a fresh ::iterator to use from the navmaps. The rendering will reflect the options passed to the iterator, so you can use that to just render a certain part of the course, if you like. If one is not passed, the renderer will attempt to construct one from env{'form.filter'} and env{'form.condition'} information, plus the 'iterator_map' parameter if any.
If you are letting the renderer do the iterator handling, you can instruct the renderer to render only a particular map by passing it the source of the map you want to process, like '/res/103/jerf/navmap.course.sequence'.
If you need to include the top level map (meaning the course) in the rendered output set this to true
A reference to a navmap, used only if an iterator is not passed in. If this is necessary to make an iterator but it is not passed in, a new one will be constructed based on env info. This is useful to do basic error checking before passing it off to render.
The standard Apache response object. This must be passed to the renderer or the course hash will be locked.
An array reference
A flag. If true, a line for the resource itself, and a line for each part will be displayed. If not, only one line for each resource will be displayed.
A flag. If true, if all parts of the problem have the same status and that status is Nothing Set, Correct, or Network Failure, then only one line will be displayed for that resource anyhow. If no, all parts will always be displayed. If showParts is 0, this is ignored.
A string identifying the URL to place the anchor 'curloc' at. It is the responsibility of the renderer user to ensure that the #curloc is in the URL. By default, determined through the use of the env{} 'jump' information, and should normally ``just work'' correctly.
A Symb identifying where to place the 'here' marker. The empty string means no marker.
A string identifying the indentation string to use.
A string which will be prepended to the query string used when the folders are opened or closed. You can use this to pass application-specific values.
The url the folders will link to, which should be the current page. Required if the resource info column is shown, and you are allowing the user to open and close folders.
Describes the currently-open row number to cause the browser to jump to, because the user just opened that folder. By default, pulled from the Jump information in the env{'form.*'}.
If true, print the key that appears on the top of the standard navmaps.
If true, print the ``Close all folders'' or ``open all folders'' links.
A function that takes the resource object as its only parameter and returns a true or false value. If true, the resource is displayed. If false, it is simply skipped in the display.
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; for example, see the ``Show Uncompleted Homework'' view on the NAV screen.
If true, will not display Navigate Content resources.
In addition to the parameters you can pass to the renderer, which will be passed through unchange to the column renderers, the renderer will generate the following information which your renderer may find useful:
Contains the number of rows printed. Useful after calling the render function, as you can detect whether anything was printed at all.
Useful for renderers: If this resource is currently the first resource of a new branch, this will be true. The Resource column (leftmost in the navmaps screen) uses this to display the ``new branch'' icon
update()
addToFilter()
Convenience functions: Returns a string that adds or subtracts the second argument from the first hash, appropriate for the query string that determines which folders to recurse on
removeFromFilter()
getLinkForResource()
Convenience function: Given a stack returned from getStack on the iterator,
return the correct src()
value.
getDescription()
Convenience function: This separates the logic of how to create the problem text strings (``Due: DATE'', ``Open: DATE'', ``Not yet assigned'', etc.) into a separate function. It takes a resource object as the 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.
dueInLessThan24Hours()
Convenience function, so others can use it: Is the problem due in less than 24 hours, and still can be done?
lastTry()
Convenience function, so others can use it: Is there only one try remaining for the part, with more than one try to begin with, not due yet and still can be done?
advancedUser()
This puts a human-readable name on the env variable.
timeToHumanString()
timeToHumanString takes a time number and converts it to a human-readable representation, meant to be used in the following manner:
Very, very, very, VERY English-only... goodness help a localizer on this func...
resource()
returns 0
communication_status()
returns 1
quick_status()
returns 2
long_status()
returns 3
part_status_summary()
returns 4
render_resource()
render_communication_status()
render_quick_status()
render_long_status()
render_parts_summary_status()
setDefault()
cmp_title()
render()
add_linkitem()
show_linkitems()
The navmap object's job is to provide access to the resources in the course as Apache::lonnavmaps::resource objects, and to query and manage the relationship between those resource objects.
Generally, you'll use the navmap object in one of three basic ways. In order of increasing complexity and power:
$navmap->getByX
, where X is Id, Symb or MapPc and getResourceByUrl. This provides
various ways to obtain resource objects, based on various identifiers.
Use this when you want to request information about one object or
a handful of resources you already know the identities of, from some
other source. For more about Ids, Symbs, and MapPcs, see the
Resource documentation. Note that Url should be a last resort,
not your first choice; it only really works when there is only one
instance of the resource in the course, which only applies to
maps, and even that may change in the future (see the getResourceByUrl
documentation for more details.)
my @resources = $navmap->retrieveResources(args)
. This
retrieves resources matching some criterion and returns them
in a flat array, with no structure information. Use this when
you are manipulating a series of resources, based on what map
the are in, but do not care about branching, or exactly how
the maps and resources are related. This is the most common case.
$it = $navmap->getIterator(args)
. This allows you traverse
the course's navmap in various ways without writing the traversal
code yourself. See iterator documentation below. Use this when
you need to know absolutely everything about the course, including
branches and the precise relationship between maps and resources.
To create a navmap object, use the following function:
Creates a new navmap object. Returns the navmap object if this is successful, or undef if not.
See iterator documentation below.
Based on the ID of the resource (1.1, 3.2, etc.), get a resource object for that resource. This method, or other methods that use it (as in the resource object) is the only proper way to obtain a resource object.
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.
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.
Returns a resource object reference corresponding to the first resource in the navmap.
Returns a resource object reference corresponding to the last resource in the navmap.
Retrieves a resource object by URL of the resource, unless the optional multiple parameter is included in which case an array of resource objects is returned. If passed a resource object, it will simply return it, so it is safe to use this method in code like ``$res = $navmap->getResourceByUrl($res)'' if you're not sure if $res is already an object, or just a URL. If the resource appears multiple times in the course, only the first instance will be returned (useful for maps), unless the multiple parameter has been included, in which case all instances are returned in an array.
The map is a specification of a map to retreive the resources from, either as a url or as an object. The filterFunc is a reference to a function that takes a resource object as its one argument and returns true if the resource should be included, or false if it should not be. If recursive is true, the map will be recursively examined, otherwise it will not be. If bailout is true, the function will return as soon as it finds a resource, if false it will finish. If showall is true it will not hide maps that contain nothing but one other map. By default, the map is the top-level map of the course, filterFunc is a function that always returns 1, recursive is true, bailout is false, showall is false. The resources will be returned in a list containing the resource objects for the corresponding resources, with no structure information in the list; regardless of branching, recursion, etc., it will be a flat list.
Thus, this is suitable for cases where you don't want the structure, just a list of all resources. It is also suitable for finding out how many resources match a given description; for this use, if all you want to know is if any resources match the description, the bailout parameter will allow you to avoid potentially expensive enumeration of all matching resources.
Convenience method for
scalar(retrieveResources($map, $filterFunc, $recursive, 1, $showall)) > 0
which will tell whether the map has resources matching the description in the filter function.
Retrieves version infomation for a url. Returns the version (a number, or the string ``mostrecent'') for resources which have version information in the big hash.
=cut
sub getResourceByUrl { my $self = shift; my $resUrl = shift; my $multiple = shift;
if (ref($resUrl)) { return $resUrl; }
$resUrl = &Apache::lonnet::clutter($resUrl); my $resId = $self->{NAV_HASH}->{'ids_' . $resUrl}; if (!$resId) { return ''; } if ($multiple) { my @resources = (); my @resIds = split (/,/, $resId); foreach my $id (@resIds) { my $resourceId = $self->getById($id); if ($resourceId) { push(@resources,$resourceId); } } return @resources; } else { if ($resId =~ /,/) { $resId = (split (/,/, $resId))[0]; } return $self->getById($resId); } }
sub retrieveResources { my $self = shift; my $map = shift; my $filterFunc = shift; if (!defined ($filterFunc)) { $filterFunc = sub {return 1;}; } my $recursive = shift; if (!defined($recursive)) { $recursive = 1; } my $bailout = shift; if (!defined($bailout)) { $bailout = 0; } my $showall = shift; # Create the necessary iterator. if (!ref($map)) { # assume it's a url of a map. $map = $self->getResourceByUrl($map); }
# If nothing was passed, assume top-level map if (!$map) { $map = $self->getById('0.0'); }
# Check the map's validity. if (!$map->is_map()) { # Oh, to throw an exception.... how I'd love that! return (); }
# Get an iterator. my $it = $self->getIterator($map->map_start(), $map->map_finish(), undef, $recursive, $showall);
my @resources = ();
if (&$filterFunc($map)) { push(@resources, $map); }
# Run down the iterator and collect the resources. my $curRes;
while ($curRes = $it->next()) { if (ref($curRes)) { if (!&$filterFunc($curRes)) { next; }
push(@resources, $curRes);
if ($bailout) { return @resources; } }
}
return @resources; }
sub hasResource { my $self = shift; my $map = shift; my $filterFunc = shift; my $recursive = shift; my $showall = shift;
return scalar($self->retrieveResources($map, $filterFunc, $recursive, 1, $showall)) > 0; }
sub usedVersion { my $self = shift; my $linkurl = shift; return $self->navhash(``version_$linkurl''); }
1;
package Apache::lonnavmaps::iterator; use Scalar::Util qw(weaken); use Apache::lonnet;
An iterator encapsulates the logic required to traverse a data structure. navmap uses an iterator to traverse the course map according to the criteria you wish to use.
To obtain an iterator, call the getIterator() function of a navmap object. (Do not instantiate Apache::lonnavmaps::iterator directly.) This will return a reference to the iterator:
my $resourceIterator = $navmap->getIterator();
To get the next thing from the iterator, call next:
my $nextThing = $resourceIterator->next()
getIterator behaves as follows:
All parameters are optional. firstResource is a resource reference
corresponding to where the iterator should start. It defaults to
navmap->firstResource()
for the corresponding nav map. finishResource
corresponds to where you want the iterator to end, defaulting to
navmap->finishResource(). filterHash is a hash used as a set
containing strings representing the resource IDs, defaulting to
empty. Condition is a 1 or 0 that sets what to do with the filter
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
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
that is not just a single, 'redirecting' map. If true, the iterator
will return all information, starting with the top-level map,
regardless of content. returnTopMap, if true (default false), will
cause the iterator to return the top-level map object (resource 0.0)
before anything else.
Thus, by default, only top-level resources will be shown. Change the condition to a 1 without changing the hash, and all resources will be shown. Changing the condition to 1 and including some values in the hash will allow you to selectively suppress parts of the navmap, while leaving it on 0 and adding things to the hash will allow you to selectively add parts of the nav map. See the handler code for examples.
The iterator will return either a reference to a resource object, or a token representing something in the map, such as the beginning of a new branch. The possible tokens are:
The iterator has returned all that it's going to. Further calls to the iterator will just produce more of these. This is a ``false'' value, and is the only false value the iterator which will be returned, so it can be used as a loop sentinel.
A new map is being recursed into. This is returned after the map resource itself is returned.
The map is now done.
A branch is now starting. The next resource returned will be the first in that branch.
The branch is now done.
The tokens are retreivable via methods on the iterator object, i.e., $iterator->END_MAP.
Maps can contain empty resources. The iterator will automatically skip over such resources, but will still treat the structure correctly. Thus, a complicated map with several branches, but consisting entirely of empty resources except for one beginning or ending resource, will cause a lot of BRANCH_STARTs and BRANCH_ENDs, but only one resource will be returned.
Normal usage of the iterator object is to do the following:
my $it = $navmap->getIterator([your params here]); my $curRes; while ($curRes = $it->next()) { [your logic here] }
Note that inside of the loop, it's frequently useful to check if ``$curRes'' is a reference or not with the reference function; only resource objects will be references, and any non-references will be the tokens described above.
Also note there is some old code floating around that trys to track the depth of the iterator to see when it's done; do not copy that code. It is difficult to get right and harder to understand than this. They should be migrated to this new style.
The other method available on the iterator is getStack, which returns an array populated with the current 'stack' of maps, as references to the resource objects. Example: This is useful when making the navigation map, as we need to check whether we are under a page map to see if we need to link directly to the resource, or to the page. The first elements in the array will correspond to the top of the stack (most inclusive map).
A resource object encapsulates a resource in a resource map, allowing easy manipulation of the resource, querying the properties of the resource (including user properties), and represents a reference that can be used as the canonical representation of the resource by lonnavmap clients like renderers.
A resource only makes sense in the context of a navmap, as some of the data is stored in the navmap object.
You will probably never need to instantiate this object directly. Use Apache::lonnavmaps::navmap, and use the ``start'' method to obtain the 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.
A Resource is the most granular type of object in LON-CAPA that can be included in a course. It can either be a particular resource, like an HTML page, external resource, problem, etc., or it can be a container sequence, such as a ``page'' or a ``map''.
To see a sequence from the user's point of view, please see the Creating a Course: Maps and Sequences chapter of the Author's Manual.
A Resource Object, once obtained from a navmap object via a getBy* method of the navmap, or from an iterator, allows you to query information about that resource.
Generally, you do not ever want to create a resource object yourself, so creation has been left undocumented. Always retrieve resources from navmap objects.
Every resource is identified by a Resource ID in the big hash that is unique to that resource for a given course. The Resource ID has the form #.#, where the first number is the same for every resource in a map, and the second is unique. For instance, for a course laid out like this:
* Problem 1 * Map * Resource 2 * Resource 3
Problem 1
and Map
will share a first number, and Resource 2
Resource 3
will share a first number. The second number may end up
re-used between the two groups.
The resource ID is only used in the big hash, but can be used in the context of a course to identify a resource easily. (For instance, the printing system uses it to record which resources from a sequence you wish to print.)
All resources also have symbs, which uniquely identify a resource in a course. Many internal LON-CAPA functions expect a symb. A symb carries along with it the URL of the resource, and the map it appears in. Symbs are much larger than resource IDs.
Once you have a resource object, here's what you can do with it:
Every resource has certain attributes that can be retrieved and used:
$res-
{ID}).
Returns a ``composite title'', that is equal to $res->title()
if the
resource has a title, and is otherwise the last part of the URL (e.g.,
``problem.problem'').
Returns true if the resource is external.
Returns the kind of the resource from the compiled nav map.
Returns true if this resource was chosen to NOT be shown to the user by the random map selection feature. In other words, this is usually false.
Returns the number of randomly picked items for a map if the randompick feature is being used on the map.
Returns true for a map if the randomorder feature is being used on the map.
Returns the source for the resource.
Returns the symb for the resource.
Returns the title of the resource.
Predicate Testing the Resource
These methods are shortcuts to deciding if a given resource has a given property.
Returns true if the resource is a map type.
Returns true if the resource is a problem type, false otherwise. (Looks at the extension on the src field; might need more to work correctly.)
Returns true if the resource is a page.
Returns true if the resource is a sequence.
Map Methods
These methods are useful for getting information about the map properties of the resource, if the resource is a map (is_map).
Returns a reference to a resource object corresponding to the finish resource of the map.
Returns the pc value of the map, which is the first number that appears in the resource ID of the resources in the map, and is the number that appears around the middle of the symbs of the resources in that map.
Returns a reference to a resource object corresponding to the start resource of the map.
Returns a string with the type of the map in it.
Returns a string with a comma-separated ordered list of map_pc IDs for the hierarchy of maps containing a map, with the top level map first, then descending to deeper levels, with the enclosing map last.
In order to use the resource parameters correctly, the nav map must have been instantiated with genCourseAndUserOptions set to true, so the courseopt and useropt is read correctly. Then, you can call these functions to get the relevant parameters for the resource. Each function defaults to part ``0'', but can be directed to another part by passing the part as the parameter.
These methods are responsible for getting the parameter correct, not merely reflecting the contents of the GDBM hashes. As we move towards dates relative to other dates, these methods should be updated to reflect that. (Then, anybody using these methods will not have to update their code.)
Get the Client IP/Name Access Control information.
Get the answer-reveal date for the problem.
Gets the awarded value for the problem part. Requires genUserData set to true when the navmap object was created.
Get the due date for the problem.
Get the number of tries the student has used on the problem.
Get the number of max tries allowed.
Get the open date for the problem.
Get the significant figures setting.
Get the tolerance for the problem.
Get the number of tries the user has already used on the problem.
Get the question type for the problem.
Get the weight for the problem.
Misc. functions for the resource.
Returns a false value if there has been discussion since the user last logged in, true if there has. Always returns false if the discussion data was not extracted when the nav map was constructed.
Returns a false value if there hasn't been discussion otherwise returns unix timestamp of last time a discussion posting (or edit) was made.
optional argument is a filter (currently can be 'unread'); returns in scalar context the count of the number of discussion postings.
returns in list context both the count of postings and a hash ref containing information about the postings (subject, id, timestamp) in a hash.
Default is to return counts for all postings. However if called with a second argument set to 'unread', will return information about only unread postings.
Gets the feedback for the resource and returns the raw feedback string for the resource, or the null string if there is no feedback or the email data was not extracted when the nav map was constructed. Usually used like this:
for my $url (split(/\,/, $res->getFeedback())) { my $link = &escape($url); ...
and use the link as appropriate.
Returns a list reference containing sorted strings corresponding to each part of the problem. Single part problems have only a part '0'. Multipart problems do not return their part '0', since they typically do not really matter.
Returns the number of parts of the problem a student can answer. Thus, for single part problems, returns 1. For multipart, it returns the number of parts in the problem, not including psuedo-part 0.
Returns the total number of responses in the problem a student can answer.
Returns a hash whose keys are the response types. The values are the number of times each response type is used. This is for the entire problem, not just a single part.
Returns true if the problem is multipart, false otherwise. Use this instead of countParts if all you want is multipart/not multipart.
Returns the response type of the part, without the word ``response'' on the end. Example return values: 'string', 'essay', 'numeric', etc.
Retreives the response IDs for the given part as an array reference containing strings naming the response IDs. This may be empty.
Problem resources have status information, reflecting their various dates and completion statuses.
There are two aspects to the status: the date-related information and the completion information.
Idiomatic usage of these two methods would probably look something like
foreach my $part ($resource->parts()) { my $dateStatus = $resource->getDateStatus($part); my $completionStatus = $resource->getCompletionStatus($part);
or
my $status = $resource->status($part);
... use it here ... }
Which you use depends on exactly what you are looking for. The
status()
function has been optimized for the nav maps display and may
not precisely match what you need elsewhere.
The symbolic constants shown below can be accessed through the
resource object: $res-
OPEN>.
($part defaults to 0). A convenience function that returns a symbolic constant telling you about the date status of the part. The possible return values are:
Date Codes
The problem will be opened later.
Open and not yet due.
The due date has passed, but the answer date has not yet arrived.
The due date has passed and there is no answer opening date set.
The answer date is here.
The information is unknown due to network failure.
($part defaults to 0.) A convenience function that returns a symbolic constant telling you about the completion status of the part, with the following possible results:
Completion Codes
Has not been attempted at all.
Attempted, but wrong by student.
Attempted, but wrong by instructor override.
Correct or correct by instructor.
Correct by instructor override.
Excused. Not yet implemented.
Information not available due to network failure.
Attempted, and not yet graded.
Attempted, and credit received for attempt (survey and anonymous survey only).
Composite Status
Along with directly returning the date or completion status, the resource object includes a convenience function status() that will combine the two status tidbits into one composite status that can 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 may be returned, all available as methods on the resource object ($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.
The network has failed and the information is not available.
No dates have been set for this problem (part) at all. (Because only certain parts of a multi-part problem may be assigned, this can not be collapsed into ``open later'', as we do not know a given part will EVER be opened. For single part, this is the same as ``OPEN_LATER''.)
For any reason at all, the part is considered correct.
For any reason at all, the problem is excused.
The problem is past due, not considered correct, and no answer date is set.
The problem is past due, not considered correct, and an answer date in the future is set.
The problem is past due, not correct, and the answer is now available.
The problem is not yet open.
The problem is open, has been tried, is not correct, but there are tries left.
The problem is open, and all tries have been used without getting the correct answer.
The item is open and not yet tried.
The problem has been attempted.
The problem has been attempted, and credit given for the attempt (survey and anonymous survey only).
An answer has been submitted, but the student should not see it.
Simple Status
Convenience method simpleStatus provides a ``simple status'' for the resource. ``Simple status'' corresponds to ``which icon is shown on the Navmaps''. There are six ``simple'' statuses:
simpleStatusCount will return an array reference containing, in this order, the number of OPEN, CLOSED, CORRECT, INCORRECT, ATTEMPTED, and ERROR parts the given problem has.
Completable
The completable method represents the concept of 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.
Retreive an array of the possible next resources after this one. Always returns an array, even in the one- or zero-element case.
Retreive an array of the possible previous resources from this one. Always returns an array, even in the one- or zero-element case.