Diff for /loncom/homework/essayresponse.pm between versions 1.19 and 1.25

version 1.19, 2003/01/23 22:28:55 version 1.25, 2003/02/27 21:20:48
Line 31 Line 31
 package Apache::essayresponse;  package Apache::essayresponse;
 use strict;  use strict;
 use Apache::lonxml;  use Apache::lonxml;
   use Apache::lonnet;
   
 BEGIN {  BEGIN {
     &Apache::lonxml::register('Apache::essayresponse',('essayresponse'));      &Apache::lonxml::register('Apache::essayresponse',('essayresponse'));
Line 48  sub start_essayresponse { Line 49  sub start_essayresponse {
  my $ncol= &Apache::lonnet::EXT("resource.$part".'_'."$id.maxcollaborators");   my $ncol= &Apache::lonnet::EXT("resource.$part".'_'."$id.maxcollaborators");
  my $coll= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.collaborators"});   my $coll= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.collaborators"});
  my $uploadedfiletypes= &Apache::lonnet::EXT("resource.$part".'_'."$id.uploadedfiletypes");   my $uploadedfiletypes= &Apache::lonnet::EXT("resource.$part".'_'."$id.uploadedfiletypes");
           $uploadedfiletypes=~s/[^\w\,]//g;
  my $uploadedfile= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.uploadedfile"});   my $uploadedfile= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.uploadedfile"});
  $result='<br /><table border="1">';   $result='<br /><table border="1">';
    $result.='<tr><td>'.
       '<input type="radio" name="HWDRAFT'.$part.'_'.$id.'" value="yes" checked>'.
       ' Submit entries below as answer to receive credit <br />'.
       '<input type="radio" name="HWDRAFT'.$part.'_'.$id.'" value="no">'.
       ' Save entries below as a draft answer (not submitting them for credit yet) '.
       '</td></tr>';
  if ($ncol > 0) {   if ($ncol > 0) {
     $result .='<tr><td>'.      $result .='<tr><td>'.
  'Collaborators: <input type="text" size="70" max="80" name="HWCOL'.   'Collaborators: <input type="text" size="70" max="80" name="HWCOL'.
Line 65  sub start_essayresponse { Line 73  sub start_essayresponse {
  $part.'_'.$id.'" onFocus="this.form.enctype='.   $part.'_'.$id.'" onFocus="this.form.enctype='.
 "'multipart/form-data'".';" /><br />Allowed filetypes: <b>'.$uploadedfiletypes.'</b><br />';  "'multipart/form-data'".';" /><br />Allowed filetypes: <b>'.$uploadedfiletypes.'</b><br />';
            if ($uploadedfile) {             if ($uploadedfile) {
        $result.='Currently submitted: <tt>'.$uploadedfile.'</tt>';         $result.='Currently submitted: <tt><a href="'.
                   &Apache::lonnet::tokenwrapper($Apache::lonhomework::history{"resource.$part.$id.uploadedurl"}).'"><img src="/adm/lonIcons/unknown.gif" border=0"> '.$uploadedfile.'</a></tt>';
            } else {             } else {
               $result.='(Hand in a file you have prepared on your computer)';                $result.='(Hand in a file you have prepared on your computer)';
            }             }
            $result.='</td></tr>';              $result.='</td></tr>'; 
         }          }
  $result.='<tr><td>'.          $result.='</table>';
     '<input type="radio" name="HWDRAFT'.$part.'_'.$id.'" value="yes" checked>'.  
     ' Submit text below as answer to receive credit <br />'.  
     '<input type="radio" name="HWDRAFT'.$part.'_'.$id.'" value="no">'.  
     ' Save text below as a draft answer (not submitting it for credit yet) '.  
     '</td></tr></table>';  
     }      }
     return $result;      return $result;
 }  }
Line 93  sub end_essayresponse { Line 97  sub end_essayresponse {
     $Apache::lonhomework::results{"resource.$part.$id.collaborators"}=$collaborators      $Apache::lonhomework::results{"resource.$part.$id.collaborators"}=$collaborators
  if ($collaborators ne $previous_list);   if ($collaborators ne $previous_list);
  }   }
         my $filename= $ENV{'form.HWFILE'.$part.'_'.$id.'.filename'};  
         if ($filename =~ /[^\s]/) {  
     $Apache::lonhomework::results{"resource.$part.$id.uploadedfile"}=$filename;  
         }  
  if ( defined $ENV{'form.submitted'}) {   if ( defined $ENV{'form.submitted'}) {
     my $response      = $ENV{'form.HWVAL'.$id};      my $response      = $ENV{'form.HWVAL'.$id};
     if ( $response =~ /[^\s]/) {              my $filename= $ENV{'form.HWFILE'.$part.'_'.$id.'.filename'};
  my $award;      if (( $response =~ /[^\s]/) || ($filename =~ /[^\s]/)) {
     my $award;
  if ($ENV{'form.HWDRAFT'.$part.'_'.$id} eq 'yes') {   if ($ENV{'form.HWDRAFT'.$part.'_'.$id} eq 'yes') {
     $award='SUBMITTED';      $award='SUBMITTED';
  } else {   } else {
     $award='DRAFT';      $award='DRAFT';
  }   }
                   my $uploadedflag=0;
                   if ($filename =~ /[^\s]/) {
               my $uploadedfiletypes= &Apache::lonnet::EXT("resource.$part".'_'."$id.uploadedfiletypes");
                      $uploadedfiletypes=~s/[^\w\,]//g;
                      $uploadedfiletypes=','.$uploadedfiletypes.',';
                      my ($extension)=($filename=~/\.(\w+)$/);
              if ($uploadedfiletypes=~/\,$extension\,/i) {
                 $Apache::lonhomework::results{"resource.$part.$id.uploadedfile"}=$filename;
                         $Apache::lonhomework::results{"resource.$part.$id.uploadedurl"}=
                            &Apache::lonnet::userfileupload('HWFILE'.$part.'_'.$id);
                         $uploadedflag=1;
      } else {
         $award='INVALID_FILETYPE';
                      }
           }
  $Apache::lonhomework::results{"resource.$part.$id.submission"}=$response;   $Apache::lonhomework::results{"resource.$part.$id.submission"}=$response;
  $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$award;   $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$award;
  my %previous=&Apache::response::check_for_previous($response,$part,$id);   my %previous=&Apache::response::check_for_previous($response,$part,$id);
  &Apache::response::handle_previous(\%previous,$award);   unless ($uploadedflag) { &Apache::response::handle_previous(\%previous,$award); }
     }      }
  }   }
     } elsif ($target eq 'edit') {      } elsif ($target eq 'edit') {
  $result.=&Apache::edit::end_table();   $result.=&Apache::edit::end_table();
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  if ($Apache::lonhomework::type eq 'exam') {   if ($Apache::lonhomework::type eq 'exam') {
     $result.='\begin{enumerate}\item[\textbf{'.$Apache::lonxml::counter.'}.]\textit{Live blank on scoring form}\vskip 0 mm';      my $id = $Apache::inputtags::part;
     &Apache::lonxml::increment_counter();      my $weight = &Apache::lonnet::EXT("resource.$id.weight");
     $result.= '\item[\textbf{'.$Apache::lonxml::counter.'}.]\textit{Leave blank on scoring form}\vskip 0 mm \end{enumerate}';              my $repetition = int $weight/9;
     &Apache::lonxml::increment_counter();      if ($weight % 9 != 0) {$repetition++;} 
       $result.='\begin{enumerate}';
       for (my $i=0;$i<$repetition;$i++) {
    $result.='\item[\textbf{'.$Apache::lonxml::counter.'}.]\textit{Leave blank on scoring form}\vskip 0 mm';
    &Apache::lonxml::increment_counter();
       }
       $result.= '\end{enumerate}';
  }   }
     }      }
   

Removed from v.1.19  
changed lines
  Added in v.1.25


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