Diff for /loncom/homework/inputtags.pm between versions 1.43 and 1.46

version 1.43, 2001/08/06 20:33:23 version 1.46, 2001/11/12 20:27:28
Line 23  sub initialize_inputtags { Line 23  sub initialize_inputtags {
   @Apache::inputtags::previous=();    @Apache::inputtags::previous=();
   # id of current part, 0 means that no part is current (inside <problem> only    # id of current part, 0 means that no part is current (inside <problem> only
   $Apache::inputtags::part='';    $Apache::inputtags::part='';
   # list of problem date statuses, the first element is for <problem>     # list of problem date statuses, the first element is for <problem>
   #if there is a second element it is for the current <part>    # if there is a second element it is for the current <part>
   @Apache::inputtags::status=();    @Apache::inputtags::status=();
   #hash of defined params for the current response    # hash of defined params for the current response
   %Apache::inputtags::params=();    %Apache::inputtags::params=();
     # list of all ids, for <import>, these get join()ed and prepended
     @Apache::inputtags::import=();
 }  }
   
 sub start_input {  sub start_input {
Line 54  sub start_textarea { Line 56  sub start_textarea {
     if ( $cols eq '') { $cols = 80; }      if ( $cols eq '') { $cols = 80; }
     my $rows = &Apache::lonxml::get_param('rows',$parstack,$safeeval);      my $rows = &Apache::lonxml::get_param('rows',$parstack,$safeeval);
     if ( $rows eq '') { $rows = 10; }      if ( $rows eq '') { $rows = 10; }
     $result= '<textarea name="HWVAL'.$Apache::inputtags::response['-1'].'" '.      if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
       "rows=\"$rows\" cols=\"$cols\">".$oldresponse;        $result= '<textarea name="HWVAL'.$Apache::inputtags::response['-1'].'" '.
    "rows=\"$rows\" cols=\"$cols\">".$oldresponse;
       } else {
         $result='<table border="1"><tr><td><i>'.$oldresponse.'</i></td></tr></table>';
       }
     if ($oldresponse ne '') {      if ($oldresponse ne '') {
       #get rid of any startup text if the user has already responded        #get rid of any startup text if the user has already responded
       &Apache::lonxml::get_all_text("/textarea",$$parser[$#$parser]);        &Apache::lonxml::get_all_text("/textarea",$$parser[$#$parser]);
Line 67  sub start_textarea { Line 73  sub start_textarea {
 sub end_textarea {  sub end_textarea {
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;    my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   if ($target eq 'web') {    if ($target eq 'web') {
     return "</textarea>";      if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
   }         return "</textarea>";
       }
     }
   &end_input;    &end_input;
   return '';    return '';
 }  }
Line 79  sub start_textline { Line 87  sub start_textline {
   if ($target eq 'web') {    if ($target eq 'web') {
     my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);      my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);
     if ($size eq '') { $size=20; }      if ($size eq '') { $size=20; }
     my $oldresponse = $Apache::lonhomework::history{"resource.$Apache::inputtags::part.$Apache::inputtags::response['-1'].submission"};      my $partid=$Apache::inputtags::part;
     $result= '<input type="text" name="HWVAL'.$Apache::inputtags::response['-1'].'" value="'.$oldresponse.'" size="'.$size.'" />';      my $id=$Apache::inputtags::response['-1'];
   }      my $oldresponse = 
   if ($target eq 'edit') {        $Apache::lonhomework::history{"resource.$partid.$id.submission"};
     $result.=&Apache::edit::tag_start($target,$token,&Apache::lonxml::description($token));      if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
         $result= '<input type="text" name="HWVAL'.$id.'" value="'.
    $oldresponse.'" size="'.$size.'" />';
       } else {
         $result='<i>'.$oldresponse.'</i>';
       }
     } elsif ($target eq 'edit') {
       $result=&Apache::edit::tag_start($target,$token,
        &Apache::lonxml::description($token));
     $result.=&Apache::edit::text_arg('Size:','size',$token,'5')."</td></tr>";      $result.=&Apache::edit::text_arg('Size:','size',$token,'5')."</td></tr>";
     $result.=&Apache::edit::end_table;      $result.=&Apache::edit::end_table;
   }    } elsif ($target eq 'modified') {
   if ($target eq 'modified') {  
     my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,'size');      my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,'size');
     if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }      if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
   }    }
Line 101  sub end_textline { Line 116  sub end_textline {
 }  }
   
 sub start_datasubmission {  sub start_datasubmission {
   return '';    my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $id = &Apache::response::start_response($parstack,$safeeval);
     my $result;
     if ($target eq 'meta') {
       $result = &Apache::response::meta_stores_write($token->[2]->{'name'},
      $token->[2]->{'type'},
      $token->[2]->{'display'});
       $result .= &Apache::response::meta_package_write('datasubmission');
     }
     return $result;
 }  }
   
 sub end_datasubmission {  sub end_datasubmission {
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;    my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   if ( $target == 'web' ) {    my $result;
     return '<input type="submit" name="submit" value="Submit All Data" />';    if ( $target eq 'web' ) {
     } elsif ($target eq 'grade' ) {
       if ( defined $ENV{'form.submitted'}) {
         &Apache::response::setup_params('datasubmission');
         my $partid = $Apache::inputtags::part;
         my $id = $Apache::inputtags::response['-1'];
         my $response = $ENV{'form.HWVAL'.$id};
         my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
         if ( $response =~ /[^\s]/) {
    $Apache::lonhomework::results{"resource.$partid.$id.$name"}=
     $response;
         }
       }
   }    }
   return '';    &Apache::response::end_response;
     return $result;
 }  }
   
 sub finalizeawards {  sub finalizeawards {

Removed from v.1.43  
changed lines
  Added in v.1.46


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