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

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

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