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, 9 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
-started work on web target for homework tags
-lonhomework kinda works

    1: # The LON-CAPA Homework handler
    2: # Guy Albertelli
    3: 
    4: package Apache::lonhomework;
    5: use strict;
    6: use Apache::style;
    7: use Apache::lonxml;
    8: use Apache::lonnet;
    9: use Apache::inputtags;
   10: use Apache::structuretags;
   11: 
   12: sub handler {
   13:   my $request=shift;
   14: 
   15:   $request->content_type('text/html');
   16:   $request->send_http_header;
   17:   &Apache::lonhomework::send_header($request);
   18:   my $file = "/home/httpd/html".$request->uri;
   19:   my %mystyle;
   20:   &Apache::inputtags::initialize_inputtags;
   21:   my $result = Apache::lonxml::xmlparse("web",'<scriptlib>/home/httpd/html/res/103/albertel/default_homework</scriptlib>'.&getfile($file),%mystyle);
   22:   #$request->print("Result follows:");
   23:   $request->print($result);
   24:   #$request->print(":Result ends");
   25:   &Apache::lonhomework::send_footer($request);
   26: }
   27: 
   28: sub send_header {
   29:   my ($request)= @_;
   30:   $request->print('<html>');
   31:   $request->print('<form method="POST" action="'.$request->uri.'">');
   32: }
   33: 
   34: sub send_footer {
   35:   my ($request)= @_;
   36:   $request->print('</form>');
   37:   $request->print('</html>');
   38: }
   39: 
   40: sub getfile {
   41:   my ($filename) = @_;
   42:   my $a="";
   43:   &Apache::lonnet::repcopy($filename);
   44:   {
   45:     my $fh=Apache::File->new($filename);
   46: 
   47:     while (<$fh>) {
   48:       $a .=$_;
   49:     }
   50:   }
   51:   return $a
   52: }
   53: 
   54: 1;
   55: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>