Diff for /loncom/homework/lonhomework.pm between versions 1.11 and 1.15

version 1.11, 2000/09/19 19:10:01 version 1.15, 2000/11/07 17:21:18
Line 12  use Apache::response; Line 12  use Apache::response;
   
 sub handler {  sub handler {
   my $request=shift;    my $request=shift;
     
   my $target=&get_target();    my $target=&get_target();
   $request->content_type('text/html');    $Apache::lonxml::debug=1;
     if ($ENV{'browser.mathml'}) {
       $request->content_type('text/xml');
     } else {
       $request->content_type('text/html');
     }
   $request->send_http_header;    $request->send_http_header;
     return 'OK' if $request->header_only;
   
   &Apache::lonhomework::send_header($request);    &Apache::lonhomework::send_header($request);
   my $file = "/home/httpd/html".$request->uri;    my $file = &Apache::lonnet::filelocation("",$request->uri);
   my %mystyle;    my %mystyle;
   my $result = '';    my $result = '';
   &Apache::inputtags::initialize_inputtags;    &Apache::inputtags::initialize_inputtags;
   $result = Apache::lonxml::xmlparse($target, &getfile($file),  
  &getfile('/home/httpd/html/res/adm/includes/default_homework').&setup_vars($target),%mystyle);    my $problem=&Apache::lonnet::getfile($file);
     if ($problem == -1) {
       &Apache::lonxml::error("<b> Unable to find <i>$file</i></b>");
       $problem='';
     }
     my $default=&Apache::lonnet::getfile('/home/httpd/html/res/adm/includes/default_homework.lcpm');
     if ($default == -1) {
       &Apache::lonxml::error("<b>Unable to find <i>$file</i></b>");
       $default='';
     }
   
     $result = Apache::lonxml::xmlparse($target, $problem,
        $default.&setup_vars($target),%mystyle);
   #$request->print("Result follows:");    #$request->print("Result follows:");
   $request->print($result);    $request->print($result);
   #$request->print(":Result ends");    #$request->print(":Result ends");
   &Apache::lonhomework::send_footer($request);    &Apache::lonhomework::send_footer($request);
     return 'OK';
 }  }
   
 sub get_target {  sub get_target {
   return "web";    if ( $ENV{'request.state'} eq "published") {
       return 'web';
     } elsif ($ENV{'request.state'} eq "construct") {
       if ( defined $ENV{'form.'.$ENV{'form.request.prefix'}.'preview'}) {
         return 'web';
       } else {
         return 'edit';
       }
     }
 }  }
   
 sub setup_vars {  sub setup_vars {
Line 41  sub setup_vars { Line 69  sub setup_vars {
   
 sub send_header {  sub send_header {
   my ($request)= @_;    my ($request)= @_;
   $request->print('<html>');    $request->print(&Apache::lontexconvert::header());
   $request->print('<form method="POST" action="'.$request->uri.'">');    $request->print('<form name='.$ENV{'form.request.prefix'}.'lonhomework method="POST" action="'.$request->uri.'">');
 }  }
   
 sub send_footer {  sub send_footer {
   my ($request)= @_;    my ($request)= @_;
   $request->print('</form>');    $request->print('</form>');
   $request->print('</html>');    $request->print(&Apache::lontexconvert::footer());
 }  }
   
 sub getfile {  sub getfilenothere {
   my ($filename) = @_;    my ($filename) = @_;
   my $a="";    my $a="";
   if (! -e $filename ) {    if (! -e $filename ) {

Removed from v.1.11  
changed lines
  Added in v.1.15


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>