[LON-CAPA-cvs] cvs: loncom /homework essayresponse.pm

raeburn raeburn@source.lon-capa.org
Tue, 09 Dec 2008 00:23:22 -0000


raeburn		Tue Dec  9 00:23:22 2008 EDT

  Modified files:              
    /loncom/homework	essayresponse.pm 
  Log:
  - Bug 5839 (Ability to disable About-Me page and Portfolio)
    - set $which arg in &inputtags::file_selector() to "uploadonly" if Portfolio unavailable
      for student.
  - Bug 5719 (Size limits for File Upload in Essayresponse)
    - send $maxfilesize as additional arg to &inputtags::file_selector()
  
  
Index: loncom/homework/essayresponse.pm
diff -u loncom/homework/essayresponse.pm:1.92 loncom/homework/essayresponse.pm:1.93
--- loncom/homework/essayresponse.pm:1.92	Thu Nov 20 14:37:37 2008
+++ loncom/homework/essayresponse.pm	Tue Dec  9 00:23:22 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # essay (ungraded) style responses
 #
-# $Id: essayresponse.pm,v 1.92 2008/11/20 14:37:37 jms Exp $
+# $Id: essayresponse.pm,v 1.93 2008/12/09 00:23:22 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -51,6 +51,10 @@
 	my $coll= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.collaborators"},'<>&"');
 	my $uploadedfiletypes= &Apache::lonnet::EXT("resource.$part".'_'."$id.uploadedfiletypes");
         $uploadedfiletypes=~s/[^\w\,]//g;
+        my $maxfilesize=&Apache::lonnet::EXT("resource.$part".'_'."$id.maxfilesize");
+        if (!defined($maxfilesize)) {
+            $maxfilesize = 10.0; #FIXME This should become a domain configuration 
+        }
 	if ( $Apache::lonhomework::type eq 'survey' ) {
 	    $result.= '<input type="hidden" name="HWDRAFT'.$part.'_'.$id.'" value="yes" /> ';
 	}
@@ -80,8 +84,14 @@
 	    $result .= &check_collaborators($ncol,$coll) if ($coll =~ /\w+/);
 	    $result .='</td></tr>';
 	}
-	$result.=&Apache::inputtags::file_selector($part,$id,
-						   $uploadedfiletypes,'both');
+        my $filesfrom = 'both';
+        my $stuname = &Apache::lonnet::EXT('user.name');
+        my $studom = &Apache::lonnet::EXT('user.domain');
+        if (!&Apache::lonnet::usertools_access($stuname,$studom,'portfolio')) {
+            $filesfrom = 'uploadonly';
+        }
+	$result.=&Apache::inputtags::file_selector($part,$id,$uploadedfiletypes,
+						   $filesfrom,undef,$maxfilesize);
         $result.='</table>';
     } elsif ($target eq 'web' &&
 	     $Apache::inputtags::status[-1] ne 'CAN_ANSWER') {
@@ -273,7 +283,7 @@
         }
         my $maxfilesize=&Apache::lonnet::EXT("resource.$part".'_'."$id.maxfilesize");
         if (!$maxfilesize) {
-            $maxfilesize = 100.0; #FIXME This should become a domain configuration
+            $maxfilesize = 10.0; #FIXME This should become a domain configuration
         }
         my %dirlist;
         foreach my $file (@acceptable_files) {
@@ -433,4 +443,4 @@
 
 =back
 
-=cut
\ No newline at end of file
+=cut