--- loncom/interface/lonnavmaps.pm 2003/01/10 18:45:30 1.124 +++ loncom/interface/lonnavmaps.pm 2003/01/14 18:47:50 1.130 @@ -2,7 +2,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.124 2003/01/10 18:45:30 bowersj2 Exp $ +# $Id: lonnavmaps.pm,v 1.130 2003/01/14 18:47:50 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -46,6 +46,24 @@ use Apache::Constants qw(:common :http); use Apache::loncommon(); use POSIX qw (floor strftime); +my %navmaphash; +my %parmhash; + +sub cleanup { + if (tied(%navmaphash)){ + &Apache::lonnet::logthis('Cleanup navmaps: navmaphash'); + unless (untie(%navmaphash)) { + &Apache::lonnet::logthis('Failed cleanup navmaps: navmaphash'); + } + } + if (tied(%parmhash)){ + &Apache::lonnet::logthis('Cleanup navmaps: parmhash'); + unless (untie(%parmhash)) { + &Apache::lonnet::logthis('Failed cleanup navmaps: parmhash'); + } + } +} + sub handler { my $r = shift; real_handler($r); @@ -686,10 +704,10 @@ sub real_handler { $r->print(''); } - $r->print(""); - $navmap->untieHashes(); + $r->print(""); + return OK; } @@ -985,13 +1003,12 @@ sub new { $self->{NETWORK_FAILURE} = 0; # tie the nav hash - my %navmaphash; + if (!(tie(%navmaphash, 'GDBM_File', $self->{NAV_HASH_FILE}, &GDBM_READER(), 0640))) { return undef; } - my %parmhash; if (!(tie(%parmhash, 'GDBM_File', $self->{PARM_HASH_FILE}, &GDBM_READER(), 0640))) { @@ -999,11 +1016,11 @@ sub new { return undef; } + $self->{HASH_TIED} = 1; $self->{NAV_HASH} = \%navmaphash; $self->{PARM_HASH} = \%parmhash; bless($self); - $self->untieHashes(); return $self; } @@ -1155,7 +1172,7 @@ sub DESTROY { $self->untieHashes(); } -# Does the given resource (as a symb string) have +# Private method: Does the given resource (as a symb string) have # current discussion? Returns 0 if chat/mail data not extracted. sub hasDiscussion { my $self = shift; @@ -1167,7 +1184,7 @@ sub hasDiscussion { $self->{LAST_CHECK}; } -# Does the given resource (as a symb string) have +# Private method: Does the given resource (as a symb string) have # current feedback? Returns the string in the feedback hash, which # will be false if it does not exist. sub getFeedback { @@ -1179,6 +1196,7 @@ sub getFeedback { return $self->{FEEDBACK}->{$symb}; } +# Private method: Get the errors for that resource (by source). sub getErrors { my $self = shift; my $src = shift; @@ -2253,7 +2271,7 @@ sub hasDiscussion { sub getFeedback { my $self = shift; my $source = $self->src(); - if ($source !~ /^\/res\//) { $source = substr $source, 5; } + if ($source =~ /^\/res\//) { $source = substr $source, 5; } return $self->{NAV_MAP}->getFeedback($source); }