--- loncom/homework/lonhomework.pm 2000/08/02 16:47:06 1.3
+++ loncom/homework/lonhomework.pm 2000/10/11 21:02:13 1.14
@@ -8,44 +8,76 @@ use Apache::lonxml;
use Apache::lonnet;
use Apache::inputtags;
use Apache::structuretags;
+use Apache::response;
sub handler {
my $request=shift;
- $request->content_type('text/html');
+ my $target=&get_target();
+ $Apache::lonxml::debug=1;
+ if ($ENV{'browser.mathml'}) {
+ $request->content_type('text/xml');
+ } else {
+ $request->content_type('text/html');
+ }
$request->send_http_header;
+ return 'OK' if $request->header_only;
+
&Apache::lonhomework::send_header($request);
my $file = "/home/httpd/html".$request->uri;
my %mystyle;
+ my $result = '';
&Apache::inputtags::initialize_inputtags;
- my $result = Apache::lonxml::xmlparse("web",'/home/httpd/html/res/103/albertel/default_homework'.&setup_vars.&getfile($file),%mystyle);
+
+ my $problem=&Apache::lonnet::getfile($file);
+ if ($problem == -1) {
+ &Apache::lonxml::error(" Unable to find $file");
+ $problem='';
+ }
+ my $default=&Apache::lonnet::getfile('/home/httpd/html/res/adm/includes/default_homework.lcpm');
+ if ($default == -1) {
+ &Apache::lonxml::error("Unable to find $file");
+ $default='';
+ }
+
+ $result = Apache::lonxml::xmlparse($target, $problem,
+ $default.&setup_vars($target),%mystyle);
#$request->print("Result follows:");
$request->print($result);
#$request->print(":Result ends");
&Apache::lonhomework::send_footer($request);
+ return 'OK';
+}
+
+sub get_target {
+ return "web";
}
sub setup_vars {
- $Apache::lonhomework::target="web";
- return '';
+ my ($target) = @_;
+ return ';'
+# return ';$external::target='.$target.';';
}
sub send_header {
my ($request)= @_;
- $request->print('');
- $request->print('
');
- $request->print('');
+ $request->print(&Apache::lontexconvert::footer());
}
sub getfile {
my ($filename) = @_;
my $a="";
- &Apache::lonnet::repcopy($filename);
+ if (! -e $filename ) {
+ &Apache::lonnet::subscribe($filename);
+ &Apache::lonnet::repcopy($filename);
+ }
{
my $fh=Apache::File->new($filename);