Diff for /loncom/homework/lonhomework.pm between versions 1.170 and 1.171

version 1.170, 2004/03/02 20:59:25 version 1.171, 2004/03/09 20:37:58
Line 399  sub handle_save_or_undo { Line 399  sub handle_save_or_undo {
  if ((!$error) && (!copy($filebak,$file))) { $error=1; }   if ((!$error) && (!copy($filebak,$file))) { $error=1; }
  if ((!$error) && (!move($filetmp,$filebak))) { $error=1; }   if ((!$error) && (!move($filetmp,$filebak))) { $error=1; }
  if (!$error) {   if (!$error) {
     $request->print("<p><b>".&mt("Undid changes, Switched")." $filebak ".&mt("and")." $file</b></p>");      &Apache::lonxml::info("<p><b>".&mt("Undid changes, Switched")." $filebak ".&mt("and")." $file</b></p>");
  } else {   } else {
     $request->print("<p><font color=\"red\" size=\"+1\"><b>".&mt("Unable to undo, unable to switch")." $filebak ".&mt("and")." $file</b></font></p>");      &Apache::lonxml::info("<p><font color=\"red\" size=\"+1\"><b>".&mt("Unable to undo, unable to switch")." $filebak ".&mt("and")." $file</b></font></p>");
     $error=1;      $error=1;
  }   }
     } else {      } else {
  my $fs=Apache::File->new(">$filebak");   my $fs=Apache::File->new(">$filebak");
  if (defined($fs)) {   if (defined($fs)) {
     print $fs $$problem;      print $fs $$problem;
     $request->print("<b>".&mt("Making Backup to").      &Apache::lonxml::info("<b>".&mt("Making Backup to").
     " $filebak</b><br />");    " $filebak</b>");
  } else {   } else {
     $request->print("<font color=\"red\" size=\"+1\"><b>".&mt("Unable to make backup")." $filebak</b></font>");      &Apache::lonxml::info("<font color=\"red\" size=\"+1\"><b>".&mt("Unable to make backup")." $filebak</b></font>");
     $error=2;      $error=2;
  }   }
  my $fh=Apache::File->new(">$file");   my $fh=Apache::File->new(">$file");
  if (defined($fh)) {   if (defined($fh)) {
     print $fh $$result;      print $fh $$result;
     $request->print("<b>".&mt("Saving Modifications to").      &Apache::lonxml::info("<b>".&mt("Saving Modifications to").
     " $file</b><br />");    " $file</b>");
  } else {   } else {
     $request->print("<font color=\"red\" size=\"+1\"><b>".      &Apache::lonxml::info("<font color=\"red\" size=\"+1\"><b>".
     &mt("Unable to write to")." $file</b></font>");    &mt("Unable to write to")." $file</b></font>");
     $error|=4;      $error|=4;
  }   }
     }      }
Line 432  sub analyze_header { Line 432  sub analyze_header {
     my ($request) = @_;      my ($request) = @_;
     my $result.='<html>      my $result.='<html>
             <head><title>'.&mt("Analyzing a problem").'</title></head>              <head><title>'.&mt("Analyzing a problem").'</title></head>
             <body bgcolor="#FFFFFF">              <body bgcolor="#FFFFFF">'.&Apache::lonxml::message_location().'
             <form name="lonhomework" method="POST" action="'.              <form name="lonhomework" method="POST" action="'.
     $ENV{'request.uri'}.'">      $ENV{'request.uri'}.'">
             <input type="submit" name="problemmode" value="'.&mt("EditXML").'" />              <input type="submit" name="problemmode" value="'.&mt("EditXML").'" />
Line 442  sub analyze_header { Line 442  sub analyze_header {
             <hr />              <hr />
             '.&mt('List of possible answers').':              '.&mt('List of possible answers').':
             </form>';              </form>';
       &Apache::lonxml::add_messages(\$result);
     $request->print($result);      $request->print($result);
     $request->rflush();      $request->rflush();
 }  }
Line 549  sub editxmlmode { Line 550  sub editxmlmode {
  if ($cols > 80) { $cols = 80; }   if ($cols > 80) { $cols = 80; }
  if ($cols < 70) { $cols = 70; }   if ($cols < 70) { $cols = 70; }
  if ($rows < 20) { $rows = 20; }   if ($rows < 20) { $rows = 20; }
  $result.='<html><body bgcolor="#FFFFFF">   $result.='<html><body bgcolor="#FFFFFF">'.
       &Apache::lonxml::message_location().'
             <form name="lonhomework" method="POST" action="'.              <form name="lonhomework" method="POST" action="'.
     $ENV{'request.uri'}.'">      $ENV{'request.uri'}.'">
             <input type="hidden" name="problemmode" value="'.&mt('EditXML').'" />              <input type="hidden" name="problemmode" value="'.&mt('EditXML').'" />
Line 564  sub editxmlmode { Line 566  sub editxmlmode {
             <textarea rows="'.$rows.'" cols="'.$cols.'" name="editxmltext">'.              <textarea rows="'.$rows.'" cols="'.$cols.'" name="editxmltext">'.
     &HTML::Entities::encode($problem).'</textarea>      &HTML::Entities::encode($problem).'</textarea>
             </form></body></html>';              </form></body></html>';
    &Apache::lonxml::add_messages(\$result);
  $request->print($result);   $request->print($result);
     }      }
     return '';      return '';
Line 575  sub renderpage { Line 578  sub renderpage {
     my (@targets) = &get_target();      my (@targets) = &get_target();
     &Apache::lonhomework::showhashsubset(\%ENV,'form.');      &Apache::lonhomework::showhashsubset(\%ENV,'form.');
     &Apache::lonxml::debug("Running targets ".join(':',@targets));      &Apache::lonxml::debug("Running targets ".join(':',@targets));
       my $overall_result;
     foreach my $target (@targets) {      foreach my $target (@targets) {
  #my $t0 = [&gettimeofday()];   #my $t0 = [&gettimeofday()];
  my $problem=&Apache::lonnet::getfile($file);   my $problem=&Apache::lonnet::getfile($file);
Line 606  sub renderpage { Line 610  sub renderpage {
     #$result =~ s:</body>::;      #$result =~ s:</body>::;
     #$result.="<br />Spent $td seconds processing target $target\n</body>";      #$result.="<br />Spent $td seconds processing target $target\n</body>";
     #}      #}
     $request->print($result);  #    $request->print($result);
     $request->rflush();      $overall_result.=$result;
   #    $request->rflush();
  }   }
  #$request->print(":Result ends");   #$request->print(":Result ends");
  #my $td=&tv_interval($t0);   #my $td=&tv_interval($t0);
     }      }
       &Apache::lonxml::add_messages(\$overall_result);
       $request->print($overall_result);   
       $request->rflush();   
 }  }
   
 # with no arg it returns a HTML <option> list of the template titles  # with no arg it returns a HTML <option> list of the template titles

Removed from v.1.170  
changed lines
  Added in v.1.171


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