--- loncom/homework/lonhomework.pm 2000/11/07 17:21:18 1.15
+++ loncom/homework/lonhomework.pm 2000/11/30 16:20:49 1.17
@@ -1,5 +1,6 @@
# The LON-CAPA Homework handler
# Guy Albertelli
+# 11/30 Gerd Kortemeyer
package Apache::lonhomework;
use strict;
@@ -10,50 +11,38 @@ use Apache::inputtags;
use Apache::structuretags;
use Apache::response;
-sub handler {
- my $request=shift;
-
- 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 = &Apache::lonnet::filelocation("",$request->uri);
+sub subhandler {
+ my ($target,$problem)=@_;
my %mystyle;
my $result = '';
&Apache::inputtags::initialize_inputtags;
-
- my $problem=&Apache::lonnet::getfile($file);
- if ($problem == -1) {
- &Apache::lonxml::error(" Unable to find $file");
- $problem='';
+ %Apache::lonhomework::results=();
+ %Apache::lonhomework::history=&Apache::lonnet::restore;
+ #ignore error conditions
+ my ($temp)=keys %Apache::lonhomework::history ;
+ if ($temp =~ m/^error:.*/) { %Apache::lonhomework::history=(); }
+
+ my $resultkey;
+ foreach $resultkey (sort keys %Apache::lonhomework::history) {
+ &Apache::lonxml::debug("$resultkey ---- $Apache::lonhomework::history{$resultkey}");
}
+ &Apache::lonxml::debug("\n
restored values^\n");
my $default=&Apache::lonnet::getfile('/home/httpd/html/res/adm/includes/default_homework.lcpm');
if ($default == -1) {
- &Apache::lonxml::error("Unable to find $file");
+ &Apache::lonxml::error("Unable to find default_homework.lcpm");
$default='';
}
- $result = Apache::lonxml::xmlparse($target, $problem,
+ return 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 {
if ( $ENV{'request.state'} eq "published") {
return 'web';
} elsif ($ENV{'request.state'} eq "construct") {
- if ( defined $ENV{'form.'.$ENV{'form.request.prefix'}.'preview'}) {
+ if ( defined $ENV{'form.preview'}) {
return 'web';
} else {
return 'edit';
@@ -70,12 +59,13 @@ sub setup_vars {
sub send_header {
my ($request)= @_;
$request->print(&Apache::lontexconvert::header());
- $request->print('