File:  [LON-CAPA] / loncom / homework / lonhomework.pm
Revision 1.11: download - view: text, annotated - select for diffs
Tue Sep 19 19:10:01 2000 UTC (23 years, 7 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- moved $external::target to always be defined
- fixed scripttag to allow it be able to report results from scripts
- fixed caparesponse to not print out anything

    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: use Apache::response;
   12: 
   13: sub handler {
   14:   my $request=shift;
   15: 
   16:   my $target=&get_target();
   17:   $request->content_type('text/html');
   18:   $request->send_http_header;
   19:   &Apache::lonhomework::send_header($request);
   20:   my $file = "/home/httpd/html".$request->uri;
   21:   my %mystyle;
   22:   my $result = '';
   23:   &Apache::inputtags::initialize_inputtags;
   24:   $result = Apache::lonxml::xmlparse($target, &getfile($file),
   25: 		&getfile('/home/httpd/html/res/adm/includes/default_homework').&setup_vars($target),%mystyle);
   26:   #$request->print("Result follows:");
   27:   $request->print($result);
   28:   #$request->print(":Result ends");
   29:   &Apache::lonhomework::send_footer($request);
   30: }
   31: 
   32: sub get_target {
   33:   return "web";
   34: }
   35: 
   36: sub setup_vars {
   37:   my ($target) = @_;
   38:   return ';'
   39: #  return ';$external::target='.$target.';';
   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="";
   57:   if (! -e $filename ) {
   58:     &Apache::lonnet::subscribe($filename);
   59:     &Apache::lonnet::repcopy($filename);
   60:   }
   61:   {
   62:     my $fh=Apache::File->new($filename);
   63: 
   64:     while (<$fh>) {
   65:       $a .=$_;
   66:     }
   67:   }
   68:   return $a
   69: }
   70: 
   71: 1;
   72: __END__

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