Diff for /loncom/homework/inputtags.pm between versions 1.59 and 1.61

version 1.59, 2002/08/01 15:18:58 version 1.61, 2002/09/23 07:08:40
Line 79  sub start_textfield { Line 79  sub start_textfield {
   my $resid=$Apache::inputtags::response[-1];    my $resid=$Apache::inputtags::response[-1];
   if ($target eq 'web') {    if ($target eq 'web') {
     $Apache::lonxml::evaluate--;      $Apache::lonxml::evaluate--;
     my $partid=$Apache::inputtags::part;  
     my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$resid.submission"});  
     my $cols = &Apache::lonxml::get_param('cols',$parstack,$safeeval);  
     if ( $cols eq '') { $cols = 80; }  
     my $rows = &Apache::lonxml::get_param('rows',$parstack,$safeeval);  
     if ( $rows eq '') { $rows = 10; }  
     if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {      if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
       $result= '<textarea name="HWVAL'.$resid.'" '.   my $partid=$Apache::inputtags::part;
  "rows=\"$rows\" cols=\"$cols\">".$oldresponse;   my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$resid.submission"});
    my $cols = &Apache::lonxml::get_param('cols',$parstack,$safeeval);
    if ( $cols eq '') { $cols = 80; }
    my $rows = &Apache::lonxml::get_param('rows',$parstack,$safeeval);
    if ( $rows eq '') { $rows = 10; }
    $result= '<textarea name="HWVAL'.$resid.'" '.
       "rows=\"$rows\" cols=\"$cols\">".$oldresponse;
    if ($oldresponse ne '') {
       #get rid of any startup text if the user has already responded
       &Apache::lonxml::get_all_text("/textfield",$$parser[-1]);
    }
     } else {      } else {
       $result='<table border="1"><tr><td><i>'.$oldresponse.'</i></td></tr></table>';   #right or wrong don't show it
    #$result='<table border="1"><tr><td><i>'.$oldresponse.'</i></td></tr></table>';
    $result='';
    #get rid of any startup text
    &Apache::lonxml::get_all_text("/textfield",$$parser[-1]);
     }      }
     if ($oldresponse ne '') {    } elsif ($target eq 'grade') {
       #get rid of any startup text if the user has already responded  
       &Apache::lonxml::get_all_text("/textfield",$$parser[-1]);  
     }  
   }  
   if ($target eq 'grade') {  
     my $seedtext=&Apache::lonxml::get_all_text("/textfield",$$parser[-1]);      my $seedtext=&Apache::lonxml::get_all_text("/textfield",$$parser[-1]);
     if ($seedtext eq $ENV{'form.HWVAL'.$resid}) {      if ($seedtext eq $ENV{'form.HWVAL'.$resid}) {
       # if the seed text is still there it wasn't a real submission        # if the seed text is still there it wasn't a real submission
       $ENV{'form.HWVAL'.$resid}='';        $ENV{'form.HWVAL'.$resid}='';
     }      }
     } elsif ($target eq 'edit') {
       $result.=&Apache::edit::tag_start($target,$token);
       $result.=&Apache::edit::text_arg('Rows:','rows',$token,4);
       $result.=&Apache::edit::text_arg('Columns:','cols',$token,4);
       my $bodytext=&Apache::lonxml::get_all_text("/textfield",$$parser[-1]);
       $result.=&Apache::edit::editfield($token->[1],$bodytext,'Text you want to appear by default:',50,2);
     } elsif ($target eq 'modified') {
       my $constructtag=&Apache::edit::get_new_args($token,$parstack,
    $safeeval,'rows','cols');
       if ($constructtag) {
         $result = &Apache::edit::rebuild_tag($token);
       } else {
         $result=$token->[4];
       }
       $result.=&Apache::edit::modifiedfield();
   }    }
   return $result;    return $result;
 }  }
   
 sub end_textfield {  sub end_textfield {
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;    my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $result;
   if ($target eq 'web') {    if ($target eq 'web') {
     $Apache::lonxml::evaluate++;      $Apache::lonxml::evaluate++;
     if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {      if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
       return "</textarea>";        return "</textarea>";
     }      }
     } elsif ($target eq 'edit') {
       $result=&Apache::edit::end_table();
   }    }
   &end_input;    &end_input;
   return '';    return $result;
 }  }
   
 sub start_textline {  sub start_textline {
Line 123  sub start_textline { Line 144  sub start_textline {
   my $result = "";    my $result = "";
   if ($target eq 'web') {    if ($target eq 'web') {
     $Apache::lonxml::evaluate--;      $Apache::lonxml::evaluate--;
     my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);  
     if ($size eq '') { $size=20; }  
     my $partid=$Apache::inputtags::part;  
     my $id=$Apache::inputtags::response[-1];  
     my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"});  
     if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {      if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
         my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);
         if ($size eq '') { $size=20; }
         my $partid=$Apache::inputtags::part;
         my $id=$Apache::inputtags::response[-1];
         my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"});
       $result= '<input type="text" name="HWVAL'.$id.'" value="'.        $result= '<input type="text" name="HWVAL'.$id.'" value="'.
  $oldresponse.'" size="'.$size.'" />';   $oldresponse.'" size="'.$size.'" />';
     } else {      } else {
       $result='<i>'.$oldresponse.'</i>';        #right or wrong don't show what was last typed in.
         #$result='<i>'.$oldresponse.'</i>';
         $result='';
     }      }
   } elsif ($target eq 'edit') {    } elsif ($target eq 'edit') {
     $result=&Apache::edit::tag_start($target,$token);      $result=&Apache::edit::tag_start($target,$token);

Removed from v.1.59  
changed lines
  Added in v.1.61


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