Annotation of loncom/homework/lonhomework.pm, revision 1.8
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);
1.8 ! albertel 19: my $file = "/home/httpd/html".$request->uri;
1.2 albertel 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),
1.8 ! albertel 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="";
1.8 ! albertel 55: if (! -e $filename ) {
! 56: &Apache::lonnet::subscribe($filename);
! 57: &Apache::lonnet::repcopy($filename);
! 58: }
1.1 albertel 59: {
1.8 ! albertel 60: my $fh=Apache::File->new($filename);
1.2 albertel 61:
62: while (<$fh>) {
63: $a .=$_;
64: }
1.1 albertel 65: }
1.2 albertel 66: return $a
1.1 albertel 67: }
68:
69: 1;
70: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>