# The LON-CAPA Homework handler
# Guy Albertelli
package Apache::lonhomework;
use strict;
use Apache::style;
use Apache::lonxml;
use Apache::lonnet;
use Apache::inputtags;
use Apache::structuretags;
sub handler {
my $request=shift;
$request->content_type('text/html');
$request->send_http_header;
&Apache::lonhomework::send_header($request);
my $file = "/home/httpd/html".$request->uri;
my %mystyle;
&Apache::inputtags::initialize_inputtags;
my $result = Apache::lonxml::xmlparse("web",'<scriptlib>/home/httpd/html/res/103/albertel/default_homework</scriptlib>'.&setup_vars.&getfile($file),%mystyle);
#$request->print("Result follows:");
$request->print($result);
#$request->print(":Result ends");
&Apache::lonhomework::send_footer($request);
}
sub setup_vars {
$Apache::lonhomework::target="web";
return '<script>$external::target=web;</script>';
}
sub send_header {
my ($request)= @_;
$request->print('<html>');
$request->print('<form method="POST" action="'.$request->uri.'">');
}
sub send_footer {
my ($request)= @_;
$request->print('</form>');
$request->print('</html>');
}
sub getfile {
my ($filename) = @_;
my $a="";
&Apache::lonnet::repcopy($filename);
{
my $fh=Apache::File->new($filename);
while (<$fh>) {
$a .=$_;
}
}
return $a
}
1;
__END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>