Diff for /loncom/homework/structuretags.pm between versions 1.159 and 1.161

version 1.159, 2003/04/03 14:31:58 version 1.161, 2003/04/03 17:44:12
Line 251  sub start_problem { Line 251  sub start_problem {
  my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser);   my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser);
  return '';   return '';
     }      }
 #intialize globals  #initialize globals
     $Apache::inputtags::part='0';      $Apache::inputtags::part='0';
     @Apache::inputtags::responselist = ();      @Apache::inputtags::responselist = ();
     @Apache::inputtags::previous=();      @Apache::inputtags::previous=();
     @Apache::inputtags::previous_version=();      @Apache::inputtags::previous_version=();
     $Apache::structuretags::printanswer='No';      $Apache::structuretags::printanswer='No';
       @Apache::structuretags::whileconds=();
       @Apache::structuretags::whilebody=();
       @Apache::structuretags::whileline=();
   
     if ($target ne 'analyze') {      if ($target ne 'analyze') {
  &initialize_storage();   &initialize_storage();
  if ($target eq 'web') {   if ($target eq 'web') {
Line 540  sub start_block { Line 544  sub start_block {
   
     my $result;      my $result;
   
     if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||       if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
  $target eq 'tex' || $target eq 'analyze') {   $target eq 'tex' || $target eq 'analyze') {
  my $code = $token->[2]->{'condition'};   my $code = $token->[2]->{'condition'};
  if ($code) {   if ($code) {
Line 572  sub start_block { Line 576  sub start_block {
   
 sub end_block {  sub end_block {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my @result=('','');      my $result;
     if ($target eq "edit" || $target eq 'modified') { @result=('','no'); }      if ($target eq "edit") {
     return (@result);   $result.= &Apache::edit::tag_end($target,$token,'');
       }
       return $result;
 }  }
   
 sub start_while {  sub start_while {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   
     my $code = $token->[2]->{'condition'};      my $result;
       if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
    $target eq 'tex' || $target eq 'analyze') {
    my $code = $token->[2]->{'condition'};
   
     push( @Apache::structuretags::whileconds, $code);    push( @Apache::structuretags::whileconds, $code);
     if (!$Apache::lonxml::default_homework_loaded) {   if (!$Apache::lonxml::default_homework_loaded) {
  &Apache::lonxml::default_homework_load($safeeval);      &Apache::lonxml::default_homework_load($safeeval);
     }   }
     my $result = &Apache::run::run($code,$safeeval);   my $result = &Apache::run::run($code,$safeeval);
     my $bodytext=$$parser[$#$parser]->get_text("/while");   my $bodytext=&Apache::lonxml::get_all_text("/while",$parser);
     push( @Apache::structuretags::whilebody, $bodytext);   push( @Apache::structuretags::whilebody, $bodytext);
     if ( $result ) {   push( @Apache::structuretags::whileline, $token->[5]);
  &Apache::lonxml::newparser($parser,\$bodytext);   &Apache::lonxml::debug("s code $code got -$result-");
    if ( $result ) {
       &Apache::lonxml::newparser($parser,\$bodytext);
    }
       } elsif ($target eq 'edit') {
    $result .=&Apache::edit::tag_start($target,$token);
    $result .=&Apache::edit::text_arg('Test Condition:','condition',
     $token,40);
    $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
       } elsif ($target eq 'modified') {
    my $constructtag=&Apache::edit::get_new_args($token,$parstack,
        $safeeval,'condition');
    if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
     }      }
     return "";      return $result;
 }  }
   
 sub end_while {  sub end_while {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $code = pop @Apache::structuretags::whileconds;      my $result;
     my $bodytext = pop @Apache::structuretags::whilebody;  
     my $result = &Apache::run::run($code,$safeeval);      if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
     if ( $result ) {   $target eq 'tex' || $target eq 'analyze') {
  &Apache::lonxml::newparser($parser,\$bodytext);   my $code = pop(@Apache::structuretags::whileconds);
    my $bodytext = pop(@Apache::structuretags::whilebody);
    my $line = pop(@Apache::structuretags::whileline);
    my $return = &Apache::run::run($code,$safeeval);
    my $starttime=time;
    my $error=0;
    while ($return) {
       if (time-$starttime >
    $Apache::lonnet::perlvar{'lonScriptTimeout'}) {
    $return = 0; $error=1; next;
       }
       $result.=&Apache::scripttag::xmlparse($bodytext);
       $return = &Apache::run::run($code,$safeeval);
    }
    if ($error) {
       &Apache::lonxml::error('<pre>Code ran too long. It ran for more than '.$Apache::lonnet::perlvar{'lonScriptTimeout'}.' seconds occured while running &lt;while$gt; on line '.$line.'</pre>');
    }
       } elsif ($target eq "edit") {
    $result.= &Apache::edit::tag_end($target,$token,'');
     }      }
     return "";      return $result;
 }  }
   
 # <randomlist show="1">   # <randomlist show="1">
 #  <tag1>..</tag1>  #  <tag1>..</tag1>
 #  <tag2>..</tag2>  #  <tag2>..</tag2>
 #  <tag3>..</tag3>  #  <tag3>..</tag3>
 #  ...   #  ...
 # </randomlist>  # </randomlist>
 sub start_randomlist {  sub start_randomlist {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;

Removed from v.1.159  
changed lines
  Added in v.1.161


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