--- loncom/interface/lonnavmaps.pm 2003/06/18 15:14:23 1.207 +++ loncom/interface/lonnavmaps.pm 2003/07/16 19:22:49 1.215 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.207 2003/06/18 15:14:23 bowersj2 Exp $ +# $Id: lonnavmaps.pm,v 1.215 2003/07/16 19:22:49 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1021,7 +1021,7 @@ sub render_long_status { $params->{'multipart'} && $part eq "0"; my $color; - if ($resource->is_problem() && ($resource->countParts() <= 1) ) { + if ($resource->is_problem()) { $color = $colormap{$resource->status}; if (dueInLessThen24Hours($resource, $part) || @@ -1040,6 +1040,12 @@ sub render_long_status { if ($resource->is_map() && advancedUser() && $resource->randompick()) { $result .= '(randomly select ' . $resource->randompick() .')'; } + + # Debugging code + #$result .= " " . $resource->awarded($part) . '/' . $resource->weight($part) . + # ' - Part: ' . $part; + + $result .= "\n"; return $result; } @@ -1499,6 +1505,16 @@ sub render { } } continue { $curRes = $it->next(); + + if ($r) { + # If we have the connection, make sure the user is still connected + my $c = $r->connection; + if ($c->aborted()) { + Apache::lonnet::logthis("navmaps aborted"); + # Who cares what we do, nobody will see it anyhow. + return ''; + } + } } # Print out the part that jumps to #curloc if it exists @@ -1554,7 +1570,7 @@ You must obtain resource objects through =over 4 =item * B(navHashFile, parmHashFile, genCourseAndUserOptions, - genMailDiscussStatus): + genMailDiscussStatus, getUserData): Binds a new navmap object to the compiled nav map hash and parm hash given as filenames. genCourseAndUserOptions is a flag saying whether @@ -1565,7 +1581,8 @@ documentation. genMailDiscussStatus caus information about the email and discussion status of resources. Returns the navmap object if this is successful, or B if not. You must check for undef; errors will occur when you -try to use the other methods otherwise. +try to use the other methods otherwise. getUserData, if true, will +retreive the user's performance data for various problems. =item * B(first, finish, filter, condition): @@ -1586,6 +1603,7 @@ sub new { $self->{PARM_HASH_FILE} = shift; $self->{GENERATE_COURSE_USER_OPT} = shift; $self->{GENERATE_EMAIL_DISCUSS_STATUS} = shift; + $self->{GET_USER_DATA} = shift; # Resource cache stores navmap resources as we reference them. We generate # them on-demand so we don't pay for creating resources unless we use them. @@ -1723,7 +1741,15 @@ sub init { $self->{DISCUSSION_TIME} = \%discussiontime; $self->{EMAIL_STATUS} = \%emailstatus; - } + } + + if ($self->{GET_USER_DATA}) { + # Retreive performance data on problems + my %student_data = Apache::lonnet::currentdump($ENV{'request.course.id'}, + $ENV{'user.domain'}, + $ENV{'user.name'}); + $self->{STUDENT_DATA} = \%student_data; + } $self->{PARM_CACHE} = {}; $self->{INITED} = 1; @@ -2055,15 +2081,20 @@ sub retrieveResources { $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 || !$map->is_map()) { + 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(), - !$recursive); + undef, $recursive); my @resources = (); @@ -2092,6 +2123,7 @@ sub retrieveResources { } } + } continue { $curRes = $it->next(); } @@ -2216,11 +2248,6 @@ sub min { if ($a < $b) { return $a; } else { return $b; } } -# In the CVS repository, documentation of this algorithm is included -# in /doc/lonnavdocs, as a PDF and .tex source. Markers like **1** -# will reference the same location in the text as the part of the -# algorithm is running through. - sub new { # magic invocation to create a class instance my $proto = shift; @@ -2276,6 +2303,9 @@ sub new { # that isn't just a redirector. my $resource; my $resourceCount = 0; + # Documentation on this algorithm can be found in the CVS repository at + # /docs/lonnavdocs; these "**#**" markers correspond to documentation + # in that file. # **1** foreach my $pass (@iterations) { @@ -2902,7 +2932,14 @@ sub symb { $self->navHash('map_id_'.$first)) . '___' . $second . '___' . $symbSrc; } -sub title { my $self=shift; return $self->navHash("title_", 1); } +sub title { + my $self=shift; + if ($self->{ID} eq '0.0') { + # If this is the top-level map, return the title of the course + # since this map can not be titled otherwise. + return $ENV{'course.'.$ENV{'request.course.id'}.'.description'}; + } + return $self->navHash("title_", 1); } sub to { my $self=shift; return $self->navHash("to_", 1); } sub compTitle { my $self = shift; @@ -3078,6 +3115,11 @@ Get the Client IP/Name Access Control in Get the answer-reveal date for the problem. +=item * B: + +Gets the awarded value for the problem part. Requires genUserData set to +true when the navmap object was created. + =item * B: Get the due date for the problem. @@ -3131,7 +3173,11 @@ sub answerdate { } return $self->parmval("answerdate", $part); } -sub awarded { my $self = shift; return $self->queryRestoreHash('awarded', shift); } +sub awarded { + my $self = shift; my $part = shift; + if (!defined($part)) { $part = '0'; } + return $self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$part.'.awarded'}; +} sub duedate { (my $self, my $part) = @_; return $self->parmval("duedate", $part); @@ -3172,7 +3218,12 @@ sub type { } sub weight { my $self = shift; my $part = shift; - return $self->parmval("weight", $part); + if (!defined($part)) { $part = '0'; } + return &Apache::lonnet::EXT('resource.'.$part.'.weight', + $self->symb(), $ENV{'user.domain'}, + $ENV{'user.name'}, + $ENV{'request.course.sec'}); + } # Multiple things need this @@ -3318,7 +3369,7 @@ sub responseType { my $part = shift; $self->extractParts(); - return $self->{RESPONSE_TYPE}->{$part}; + return $self->{RESPONSE_TYPES}->{$part}; } sub responseIds {