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

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.5       albertel   15:   my $target=&get_target();
1.2       albertel   16:   $request->content_type('text/html');
                     17:   $request->send_http_header;
                     18:   &Apache::lonhomework::send_header($request);
                     19:   my $file = "/home/httpd/html".$request->uri;
                     20:   my %mystyle;
1.5       albertel   21:   my $result = '';
1.2       albertel   22:   &Apache::inputtags::initialize_inputtags;
1.6     ! albertel   23:   $result = Apache::lonxml::xmlparse($target, &getfile($file),
        !            24: 		&getfile('/home/httpd/html/res/103/albertel/default_homework').&setup_vars($target),%mystyle);
1.2       albertel   25:   #$request->print("Result follows:");
                     26:   $request->print($result);
                     27:   #$request->print(":Result ends");
                     28:   &Apache::lonhomework::send_footer($request);
1.3       albertel   29: }
                     30: 
1.5       albertel   31: sub get_target {
1.6     ! albertel   32:   return "web";
1.5       albertel   33: }
                     34: 
1.3       albertel   35: sub setup_vars {
1.5       albertel   36:   my ($target) = @_;
1.6     ! albertel   37:   return ';$external::target='.$target.';';
1.2       albertel   38: }
                     39: 
                     40: sub send_header {
                     41:   my ($request)= @_;
                     42:   $request->print('<html>');
                     43:   $request->print('<form method="POST" action="'.$request->uri.'">');
                     44: }
                     45: 
                     46: sub send_footer {
                     47:   my ($request)= @_;
                     48:   $request->print('</form>');
                     49:   $request->print('</html>');
                     50: }
                     51: 
                     52: sub getfile {
                     53:   my ($filename) = @_;
                     54:   my $a="";
                     55:   &Apache::lonnet::repcopy($filename);
1.1       albertel   56:   {
1.2       albertel   57:     my $fh=Apache::File->new($filename);
                     58: 
                     59:     while (<$fh>) {
                     60:       $a .=$_;
                     61:     }
1.1       albertel   62:   }
1.2       albertel   63:   return $a
1.1       albertel   64: }
                     65: 
                     66: 1;
                     67: __END__

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