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

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


raeburn		Tue Dec  9 00:27:20 2008 EDT

  Modified files:              
    /loncom/homework	inputtags.pm 
  Log:
  - Bug 5719 (Size limits for File Upload in Essayresponse)
    - &file_selector() accepts additional maxfilesize argument.
    - Display message about limit to combined size of files which will be accepted.
  
  
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.251 loncom/homework/inputtags.pm:1.252
--- loncom/homework/inputtags.pm:1.251	Sun Dec  7 23:40:57 2008
+++ loncom/homework/inputtags.pm	Tue Dec  9 00:27:20 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.251 2008/12/07 23:40:57 www Exp $
+# $Id: inputtags.pm,v 1.252 2008/12/09 00:27:20 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -461,16 +461,17 @@
 $part -> partid
 $id -> responseid
 $uploadefiletypes -> comma seperated list of extensions allowed or * for any
-$which -> 'uploadedonly'  -> only newly uploaded files
+$which -> 'uploadonly'  -> only newly uploaded files
           'portfolioonly' -> only allow files from portfolio
           'both' -> allow files from either location
 $extratext -> additional text to go between the link and the input box
+$maxfilesize -> maximum cumulative filesize for submitted files (in MB).
 returns a table row <tr> 
 
 =cut
 
 sub file_selector {
-    my ($part,$id,$uploadedfiletypes,$which,$extratext)=@_;
+    my ($part,$id,$uploadedfiletypes,$which,$extratext,$maxfilesize)=@_;
     if (!$uploadedfiletypes) { return ''; }
 
     my $jspart=$part;
@@ -479,9 +480,16 @@
     my $result;
     
     $result.='<tr><td>';
-    if ($uploadedfiletypes ne '*') {
-	$result.=
-	    &mt('Allowed filetypes: [_1]','<b>'.$uploadedfiletypes.'</b>').'<br />';
+    if (($uploadedfiletypes ne '*') || ($maxfilesize)) {
+        if ($uploadedfiletypes ne '*') {
+	    $result.=
+	        &mt('Allowed filetypes: [_1]','<b>'.$uploadedfiletypes.'</b>').'<br />';
+        }
+        if ($maxfilesize) {
+            $result.=&mt('Combined size of files not to exceed: [_1] MB[_2].',
+                         '<b>'.$maxfilesize.'</b>').'<br />';
+        }
+        $result .= '<br />';
     }
     if ($which eq 'uploadonly' || $which eq 'both') { 
 	$result.=&mt('Submit a file: (only one file can be uploaded)').
@@ -498,7 +506,6 @@
 	    '<input type="text" size="50" name="HWPORT'.$jspart.'_'.$id.'" value="" />'.
 	    '<br />';
 	$result .= &show_past_portfile_submission($part,$id);
-
     }
     $result.='</td></tr>'; 
     return $result;