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