Annotation of loncom/homework/lonhomework.pm, revision 1.9
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.8 albertel 25: &getfile('/home/httpd/html/res/103/albertel/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.6 albertel 38: return ';$external::target='.$target.';';
1.2 albertel 39: }
40:
41: sub send_header {
42: my ($request)= @_;
43: $request->print('<html>');
44: $request->print('<form method="POST" action="'.$request->uri.'">');
45: }
46:
47: sub send_footer {
48: my ($request)= @_;
49: $request->print('</form>');
50: $request->print('</html>');
51: }
52:
53: sub getfile {
54: my ($filename) = @_;
55: my $a="";
1.8 albertel 56: if (! -e $filename ) {
57: &Apache::lonnet::subscribe($filename);
58: &Apache::lonnet::repcopy($filename);
59: }
1.1 albertel 60: {
1.8 albertel 61: my $fh=Apache::File->new($filename);
1.2 albertel 62:
63: while (<$fh>) {
64: $a .=$_;
65: }
1.1 albertel 66: }
1.2 albertel 67: return $a
1.1 albertel 68: }
69:
70: 1;
71: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>