--- rat/lonratedt.pm 2001/05/01 15:23:40 1.2 +++ rat/lonratedt.pm 2001/05/26 19:55:07 1.3 @@ -9,18 +9,11 @@ package Apache::lonratedt; use strict; use Apache::Constants qw(:common); +use Apache::lonnet; -# ================================================================ Main Handler - -sub handler { - my $r=shift; - $r->content_type('text/html'); - $r->send_http_header; - - return OK if $r->header_only; - - my $url=$r->uri; - +# --------------------------------------------------------- Build up RAT screen +sub ratedt { + my ($r,$url)=@_; $r->print(< @@ -37,6 +30,49 @@ sub handler { ENDDOCUMENT +} + +sub smpedt { + my ($r,$fn)=@_; + $r->print(< + +
+
+ENDSMPHEAD + $r->print( + '
'); +} + +# ================================================================ Main Handler + +sub handler { + my $r=shift; + $r->content_type('text/html'); + $r->send_http_header; + + return OK if $r->header_only; + + my $url=$r->uri; + my $fn=&Apache::lonnet::filelocation('',$url); + + my $adv=0; + + unless ($ENV{'form.forcesmp'}) { + if ($ENV{'form.forceadv'}) { + $adv=1; + } elsif (my $fh=Apache::File->new($fn)) { + my $allmap=join('',<$fh>); + $adv=($allmap=~/\]+mode\s*\=\s*(\'|\")rat/is); + } + } + + if ($adv) { + &ratedt($r,$url); + } else { + &smpedt($r,$fn); + } return OK; }