# The LearningOnline Network with CAPA # Page Handler # # (TeX Content Handler # # 05/29/00,05/30 Gerd Kortemeyer) # 08/30,08/31 Gerd Kortemeyer package Apache::lonpage; use strict; use Apache::Constants qw(:common :http); use Apache::lonnet(); use GDBM_File; # -------------------------------------------------------------- Module Globals my %hash; my @rows; # ------------------------------------------------------------ Build page table sub tracetable { my ($sofar,$rid,$beenhere)=@_; my $further=$sofar; unless ($beenhere=~/\&$rid\&/) { $beenhere.=$rid.'&'; if (defined($hash{'is_map_'.$rid})) { if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) && (defined($hash{'map_finish_'.$hash{'src_'.$rid}}))) { $sofar= &tracetable($sofar,$hash{'map_start_'.$hash{'src_'.$rid}}, '&'.$hash{'map_finish_'.$hash{'src_'.$rid}}.'&'); $sofar++; if (defined($rows[$sofar])) { $rows[$sofar].='&'.$hash{'map_finish_'.$hash{'src_'.$rid}}; } else { $rows[$sofar]=$hash{'map_finish_'.$hash{'src_'.$rid}}; } } } else { $sofar++; if (defined($rows[$sofar])) { $rows[$sofar].='&'.$rid; } else { $rows[$sofar]=$rid; } } if (defined($hash{'to_'.$rid})) { map { my $now=&tracetable($sofar,$hash{'goesto_'.$_},$beenhere); if ($now>$further) { $further=$now; } } split(/\,/,$hash{'to_'.$rid}); } } return $further; } # ================================================================ Main Handler sub handler { my $r=shift; # ----------------------------------------------------------- Set document type if ($ENV{'browser.mathml'}) { $r->content_type('text/xml'); } else { $r->content_type('text/html'); } $r->send_http_header; return OK if $r->header_only; my $requrl=$r->uri; # ----------------------------------------------------------------- Tie db file if ($ENV{'request.course.fn'}) { my $fn=$ENV{'request.course.fn'}; if (-e "$fn.db") { if (tie(%hash,'GDBM_File',"$fn.db",&GDBM_WRCREAT,0640)) { # ------------------------------------------------------------------- Hash tied my $firstres=$hash{'map_start_'.$requrl}; my $lastres=$hash{'map_finish_'.$requrl}; if (($firstres) && ($lastres)) { # ----------------------------------------------------------------- Render page $r->print("

All is cool.

"); @rows=(); &tracetable(0,$firstres,'&'.$lastres.'&'); $rows[$#rows+1]=''.$lastres; my $i; for ($i=0;$i<=$#rows;$i++) { $r->print($i.' - '.$rows[$i].'
'); } # ------------------------------------------------------------- End render page } else { $r->print("

Page undefined.

"); } # ------------------------------------------------------------------ Untie hash unless (untie(%hash)) { &Apache::lonnet::logthis("WARNING: ". "Could not untie coursemap $fn (browse)."); } # -------------------------------------------------------------------- All done return OK; # ----------------------------------------------- Errors, hash could no be tied } } } $ENV{'user.error.msg'}="$requrl:bre:1:1:Course not initialized"; return HTTP_NOT_ACCEPTABLE; } 1; __END__ 500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.