Diff for /loncom/homework/lonhomework.pm between versions 1.45 and 1.47

version 1.45, 2001/06/05 16:32:18 version 1.47, 2001/06/26 21:39:15
Line 14  use Apache::response; Line 14  use Apache::response;
 use Apache::hint;  use Apache::hint;
 use Apache::outputtags;  use Apache::outputtags;
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
   #use Time::HiRes qw( gettimeofday tv_interval );
   
 sub BEGIN {  sub BEGIN {
   &Apache::lonxml::register_insert();    &Apache::lonxml::register_insert();
Line 172  sub setupheader { Line 172  sub setupheader {
   return ''    return ''
 }  }
   
   sub handle_save_or_undo {
     my ($request,$problem,$result) = @_;
     my $fileout = &Apache::lonnet::filelocation("",$request->uri);
     my $filesave=$fileout.".bak";
   
     if ($ENV{'form.Undo'} eq 'undo') {
       if (copy($filesave,$fileout)) {
         $request->print("<b>Undid changes, Copied $filesave to $fileout<br /></b>");
       } else {
         $request->print("<font color=\"red\" size=\"+1\"><b>Unable to undo, unable to copy $filesave to $fileout<br /></b></font>");
       }
     } else {
       my $fs=Apache::File->new(">$filesave");
       if (defined($fs)) {
         print $fs $$problem;
         $request->print("<b>Making Backup to $filesave</b><br />");
       } else {
         $request->print("<font color=\"red\" size=\"+1\"><b>Unable to make backup $filesave</b></font>");
       }
       my $fh=Apache::File->new(">$fileout");
       if (defined($fh)) {
         print $fh $$result;
         $request->print("<b>Saving Modifications to $fileout</b><br />");
       } else {
         $request->print("<font color=\"red\" size=\"+1\"><b>Unable to write to $fileout</b></font>");
       }
     }
   }
   
 sub renderpage {  sub renderpage {
   my ($request,$file) = @_;    my ($request,$file) = @_;
   
   my (@targets) = &get_target();    my (@targets) = &get_target();
   foreach my $target (@targets) {    foreach my $target (@targets) {
       #my $t0 = [&gettimeofday()];
     my $problem=&Apache::lonnet::getfile($file);      my $problem=&Apache::lonnet::getfile($file);
     if ($problem == -1) {      if ($problem == -1) {
       &Apache::lonxml::error("<b> Unable to find <i>$file</i></b>");        &Apache::lonxml::error("<b> Unable to find <i>$file</i></b>");
Line 186  sub renderpage { Line 216  sub renderpage {
     my %mystyle;      my %mystyle;
     my $result = '';      my $result = '';
     &Apache::inputtags::initialize_inputtags;      &Apache::inputtags::initialize_inputtags;
       &Apache::edit::initialize_edit;
     %Apache::lonhomework::results=();      %Apache::lonhomework::results=();
     %Apache::lonhomework::history=&Apache::lonnet::restore();      %Apache::lonhomework::history=&Apache::lonnet::restore();
     #ignore error conditions      #ignore error conditions
Line 213  sub renderpage { Line 244  sub renderpage {
   
     #$request->print("Result follows:");      #$request->print("Result follows:");
     if ($target eq 'modified') {      if ($target eq 'modified') {
       my $fileout = &Apache::lonnet::filelocation("",$request->uri);        &handle_save_or_undo($request,\$problem,\$result);
       my $filesave=$fileout.".bak";  
   
       my $fs=Apache::File->new(">$filesave");  
       print $fs $problem;  
       $request->print("<b>Making Backup to $filesave</b><br />");  
   
       my $fh=Apache::File->new(">$fileout");  
       print $fh $result;  
       $request->print("<b>Saving Modifications to $fileout</b><br />");  
     } else {      } else {
         #my $td=&tv_interval($t0);
         #if ( $Apache::lonxml::debug) {
    #$result =~ s:</body>::;
    #$result.="<br />Spent $td seconds processing target $target\n</body>";
         #}
       $request->print($result);        $request->print($result);
     }      }
     #$request->print(":Result ends");      #$request->print(":Result ends");
Line 235  sub renderpage { Line 262  sub renderpage {
       &Apache::lonxml::debug("Store return message:".        &Apache::lonxml::debug("Store return message:".
      &Apache::lonnet::cstore(\%Apache::lonhomework::results));       &Apache::lonnet::cstore(\%Apache::lonhomework::results));
     }      }
       #my $td=&tv_interval($t0);
   }    }
 }  }
   
Line 297  EDITMENU Line 325  EDITMENU
 }  }
   
 sub handler {  sub handler {
     #my $t0 = [&gettimeofday()];
   my $request=$_[0];    my $request=$_[0];
   
   #if ( $ENV{'user.name'} eq 'albertel' ) {$Apache::lonxml::debug=1;}    #if ( $ENV{'user.name'} eq 'albertel' ) {$Apache::lonxml::debug=1;}
Line 337  sub handler { Line 366  sub handler {
     # just render the page normally outside of construction space      # just render the page normally outside of construction space
     &renderpage($request,$file);      &renderpage($request,$file);
   }    }
     #my $td=&tv_interval($t0);
   &Apache::lonhomework::send_footer($request);    #&Apache::lonxml::debug("Spent $td seconds processing");
     # &Apache::lonhomework::send_footer($request);
   # always turn off debug messages    # always turn off debug messages
   $Apache::lonxml::debug=0;    $Apache::lonxml::debug=0;
   return OK;    return OK;

Removed from v.1.45  
changed lines
  Added in v.1.47


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