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

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

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