Annotation of loncom/homework/lonhomework.pm, revision 1.2

1.1       albertel    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;
1.2     ! albertel    8: use Apache::lonnet;
        !             9: use Apache::inputtags;
        !            10: use Apache::structuretags;
1.1       albertel   11: 
                     12: sub handler {
                     13:   my $request=shift;
                     14: 
1.2     ! albertel   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);
1.1       albertel   44:   {
1.2     ! albertel   45:     my $fh=Apache::File->new($filename);
        !            46: 
        !            47:     while (<$fh>) {
        !            48:       $a .=$_;
        !            49:     }
1.1       albertel   50:   }
1.2     ! albertel   51:   return $a
1.1       albertel   52: }
                     53: 
                     54: 1;
                     55: __END__

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