--- rat/lonambiguous.pm 2001/11/29 19:23:48 1.4 +++ rat/lonambiguous.pm 2003/09/22 03:02:06 1.10 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to resolve ambiguous file locations # -# $Id: lonambiguous.pm,v 1.4 2001/11/29 19:23:48 www Exp $ +# $Id: lonambiguous.pm,v 1.10 2003/09/22 03:02:06 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -37,17 +37,31 @@ use strict; use Apache::lonnet; use Apache::Constants qw(:common REDIRECT); use GDBM_File; +use Apache::loncommon; +use Apache::lonlocal; +my %bighash; + +sub cleanup { + if (tied(%bighash)){ + &Apache::lonnet::logthis('Cleanup ambiguous: bighash'); + unless (untie(%bighash)) { + &Apache::lonnet::logthis('Failed cleanup ambiguous: bighash'); + } + } +} # ----------------------------------------------------------- Could not resolve sub getlost { my ($r,$errmsg)=@_; + $errmsg=&mt($errmsg); $r->content_type('text/html'); $r->send_http_header; $r->print( - 'Unknown Error

'. - 'LON-CAPA

Could not handle ambiguous resource reference.

'.$errmsg. + 'Unknown Error'. + &Apache::loncommon::bodytag('Could not handle ambiguous resource reference'). + $errmsg. ''); } @@ -57,19 +71,17 @@ sub handler { my $r=shift; if ($r->header_only) { - $r->content_type('text/html'); + &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; return OK; } # ---------------------------------------------------------- Is this selecting? - - my %bighash; - + if ($ENV{'form.selecturl'}) { my $envkey; if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db', - &GDBM_READER,0640)) { + &GDBM_READER(),0640)) { foreach $envkey (keys %ENV) { if ($envkey=~/^form\.(\d+)\.(\d+)$/) { # ---------------------------------------------------- Update symb and redirect @@ -106,7 +118,7 @@ sub handler { my $syval=''; if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db', - &GDBM_READER,0640)) { + &GDBM_READER(),0640)) { $syval=$hash{$thisfn}; untie(%hash); } @@ -132,9 +144,9 @@ sub handler { # ------------------------------------------------ Would be standalone resource if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db', - &GDBM_READER,0640)) { + &GDBM_READER(),0640)) { # ---------------------------------------------- Get ID(s) for current resource - my $ids=$bighash{'ids_/res/'.$thisfn}; + my $ids=$bighash{'ids_'.&Apache::lonnet::clutter($thisfn)}; if ($ids) { # ------------------------------------------------------------------- Has ID(s) my @possibilities=split(/\,/,$ids); @@ -154,10 +166,11 @@ sub handler { # ----------------------------------------------- Okay, really multiple choices $r->content_type('text/html'); $r->send_http_header; + my $bodytag= + &Apache::loncommon::bodytag('Pick Instance of Resource'); $r->print(<Choose Location - -

LON-CAPA

+$bodytag The resource you had been accessing appears more than once in this course, and LON-CAPA has insufficient session information to determine which instance of the resource you meant. @@ -175,8 +188,10 @@ ENDSTART $r->print(''.$bighash{'title_'.$_}. ''.$bighash{'type_'.$_}. - ''.$mapurl. - ''); + ''. + ($mapurl=~/^\/uploaded\//?'':''). + &Apache::lonnet::gettitle($mapurl).' '. + ($mapurl=~/^\/uploaded\//?'':'').''); } @possibilities; $r->print(''); untie(%bighash);