Diff for /loncom/homework/inputtags.pm between versions 1.204 and 1.205

version 1.204, 2006/07/20 21:48:07 version 1.205, 2006/09/21 21:23:19
Line 140  sub start_textfield { Line 140  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"},'<>&"');
  if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {   if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
     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);      my $cols = &Apache::lonxml::get_param('cols',$parstack,$safeeval);
     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);
Line 161  sub start_textfield { Line 161  sub start_textfield {
  &Apache::lonxml::get_all_text("/textfield",$parser,$style);   &Apache::lonxml::get_all_text("/textfield",$parser,$style);
     }      }
  } else {   } else {
     #right or wrong don't show it      #show past answer in the essayresponse case
     #$result='<table border="1"><tr><td><i>'.$oldresponse.'</i></td></tr></table>';      if ($oldresponse =~ /\S/
     $result='';   && &Apache::londefdef::is_inside_of($tagstack,
       'essayresponse') ) {
    $result='<table class="LC_pastsubmission"><tr><td>'.
       $oldresponse.'</td></tr></table>';
       }
     #get rid of any startup text      #get rid of any startup text
     &Apache::lonxml::get_all_text("/textfield",$parser,$style);      &Apache::lonxml::get_all_text("/textfield",$parser,$style);
  }   }
Line 415  sub file_selector { Line 419  sub file_selector {
  $result.=&mt('Submit a file: (only one file can be uploaded)').   $result.=&mt('Submit a file: (only one file can be uploaded)').
     ' <br /><input type="file" size="50" name="HWFILE'.      ' <br /><input type="file" size="50" name="HWFILE'.
     $jspart.'_'.$id.'" /><br />';      $jspart.'_'.$id.'" /><br />';
  my $uploadedfile= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.uploadedfile"},'<>&"');   $result .= &show_past_file_submission($part,$id);
   
  if ($uploadedfile) {  
     my $url=$Apache::lonhomework::history{"resource.$part.$id.uploadedurl"};  
     &Apache::lonxml::extlink($url);  
     &Apache::lonnet::allowuploaded('/adm/essayresponse',$url);  
     my $icon=&Apache::loncommon::icon($url);  
     my $curfile='<a href="'.$url.'"><img src="'.$icon.  
  '" border="0" />'.$uploadedfile.'</a>';  
     $result.=&mt('Currently submitted: <tt>[_1]</tt>',$curfile);  
  } else {  
     #$result.=&mt('(Hand in a file you have prepared on your computer)');  
  }  
     }      }
     if ( $which eq 'both') {       if ( $which eq 'both') { 
  $result.='<br />'.'<strong>'.&mt('OR:').'</strong><br />';   $result.='<br />'.'<strong>'.&mt('OR:').'</strong><br />';
Line 437  sub file_selector { Line 429  sub file_selector {
     &mt('Select Portfolio Files').'</a><br />'.      &mt('Select Portfolio Files').'</a><br />'.
     '<input type="text" size="50" name="HWPORT'.$jspart.'_'.$id.'" value="" />'.      '<input type="text" size="50" name="HWPORT'.$jspart.'_'.$id.'" value="" />'.
     '<br />';      '<br />';
  if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"}=~/[^\s]/){   $result .= &show_past_portfile_submission($part,$id);
     my (@file_list,@bad_file_list);  
     foreach my $file (split(/\s*,\s*/,&unescape($Apache::lonhomework::history{"resource.$part.$id.portfiles"}))) {  
  my (undef,undef,$domain,$user)=&Apache::lonxml::whichuser();  
  my $url="/uploaded/$domain/$user/portfolio$file";  
  my $icon=&Apache::loncommon::icon($url);  
  push(@file_list,'<a href="'.$url.'"><img src="'.$icon.  
      '" border="0" />'.$file.'</a>');  
  if (! &Apache::lonnet::stat_file($url)) {  
     &Apache::lonnet::logthis("bad file is $url");  
     push(@bad_file_list,'<a href="'.$url.'"><img src="'.$icon.  
  '" border="0" />'.$file.'</a>');  
  }  
     }  
     my $files = '<span class="LC_filename">'.  
  join('</span>, <span class="LC_filename">',@file_list).  
  '</span>';  
     $result.=&mt("Portfolio files previously selected: [_1]",$files);  
     if (@bad_file_list) {  
  my $bad_files = '<span class="LC_filename">'.  
     join('</span>, <span class="LC_filename">',@bad_file_list).  
     '</span>';  
  $result.='<br />'.&mt('<span class="LC_error">These file(s) don\'t exist:</span> [_1]',$bad_files);  
     }  
  }  
     }      }
     $result.='</td></tr>';       $result.='</td></tr>'; 
     return $result;      return $result;
 }  }
   
   sub show_past_file_submission {
       my ($part,$id) = @_;
       my $uploadedfile= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.uploadedfile"},'<>&"');
   
       return if (!$uploadedfile);
   
       my $url=$Apache::lonhomework::history{"resource.$part.$id.uploadedurl"};
       &Apache::lonxml::extlink($url);
       &Apache::lonnet::allowuploaded('/adm/essayresponse',$url);
       my $icon=&Apache::loncommon::icon($url);
       my $curfile='<a href="'.$url.'"><img src="'.$icon.
    '" border="0" />'.$uploadedfile.'</a>';
       return &mt('Currently submitted: <tt>[_1]</tt>',$curfile);
   
   }
   
   sub show_past_portfile_submission {
       my ($part,$id) = @_;
       if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"}!~/[^\s]/){
    return;
       }
       my (@file_list,@bad_file_list);
       foreach my $file (split(/\s*,\s*/,&unescape($Apache::lonhomework::history{"resource.$part.$id.portfiles"}))) {
    my (undef,undef,$domain,$user)=&Apache::lonxml::whichuser();
    my $url="/uploaded/$domain/$user/portfolio$file";
    my $icon=&Apache::loncommon::icon($url);
    push(@file_list,'<a href="'.$url.'"><img src="'.$icon.
        '" border="0" />'.$file.'</a>');
    if (! &Apache::lonnet::stat_file($url)) {
       &Apache::lonnet::logthis("bad file is $url");
       push(@bad_file_list,'<a href="'.$url.'"><img src="'.$icon.
    '" border="0" />'.$file.'</a>');
    }
       }
       my $files = '<span class="LC_filename">'.
    join('</span>, <span class="LC_filename">',@file_list).
    '</span>';
       my $result = &mt("Portfolio files previously selected: [_1]",$files);
       if (@bad_file_list) {
    my $bad_files = '<span class="LC_filename">'.
       join('</span>, <span class="LC_filename">',@bad_file_list).
       '</span>';
    $result.='<br />'.&mt('<span class="LC_error">These file(s) don\'t exist:</span> [_1]',$bad_files);
       }
       return $result;
   
   }
   
 sub checkstatus {  sub checkstatus {
     my ($value,$awardref,$msgref)=@_;      my ($value,$awardref,$msgref)=@_;
     for (my $i=0;$i<=$#$awardref;$i++) {      for (my $i=0;$i<=$#$awardref;$i++) {

Removed from v.1.204  
changed lines
  Added in v.1.205


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