File:  [LON-CAPA] / loncom / homework / lonhomework.pm
Revision 1.2: download - view: text, annotated - select for diffs
Tue Jul 25 21:27:30 2000 UTC (23 years, 8 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
-started work on web target for homework tags
-lonhomework kinda works

# 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>'.&getfile($file),%mystyle);
  #$request->print("Result follows:");
  $request->print($result);
  #$request->print(":Result ends");
  &Apache::lonhomework::send_footer($request);
}

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>