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

banghart lon-capa-cvs@mail.lon-capa.org
Thu, 10 Feb 2005 22:43:15 -0000


banghart		Thu Feb 10 17:43:15 2005 EDT

  Modified files:              
    /loncom/homework	essayresponse.pm 
  Log:
  	Fix bug 3881: accept only specified file types in response to essay
  
  
Index: loncom/homework/essayresponse.pm
diff -u loncom/homework/essayresponse.pm:1.58 loncom/homework/essayresponse.pm:1.59
--- loncom/homework/essayresponse.pm:1.58	Mon Jan 31 17:00:40 2005
+++ loncom/homework/essayresponse.pm	Thu Feb 10 17:43:15 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # essay (ungraded) style responses
 #
-# $Id: essayresponse.pm,v 1.58 2005/01/31 22:00:40 albertel Exp $
+# $Id: essayresponse.pm,v 1.59 2005/02/10 22:43:15 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -143,11 +143,22 @@
                     $portfiles =~s/,$//;
                     $Apache::lonhomework::results{"resource.$part.$id.portfiles"}=$portfiles;
                     my @submitted_files = split /,/,$portfiles;
-		    my ($dsymb,$crsid,$domain,$name)=&Apache::lonxml::whichuser();
-		    &Apache::lonnet::unmark_as_readonly($domain,$name,$dsymb.$crsid);
-                    &Apache::lonnet::mark_as_readonly($domain,$name,\@submitted_files,$dsymb.$crsid);
-                    &Apache::lonnet::clear_selected_files($name);
-                    $uploadedflag=1;
+ 	            my $uploadedfiletypes= &Apache::lonnet::EXT("resource.$part".'_'."$id.uploadedfiletypes");
+                    $uploadedfiletypes=~s/[^\w\,]//g;
+                    $uploadedfiletypes=','.$uploadedfiletypes.',';
+                    foreach (@submitted_files) {
+                        my ($extension)=($_=~/\.(\w+)$/);
+	                unless ($uploadedfiletypes=~/\,$extension\,/i) {
+	                    $award='INVALID_FILETYPE';
+                        }
+                    }
+                    if ($award ne 'INVALID_FILETYPE'){
+        		my ($dsymb,$crsid,$domain,$name)=&Apache::lonxml::whichuser();
+        		&Apache::lonnet::unmark_as_readonly($domain,$name,$dsymb.$crsid);
+                        &Apache::lonnet::mark_as_readonly($domain,$name,\@submitted_files,$dsymb.$crsid);
+                        &Apache::lonnet::clear_selected_files($name);
+                        $uploadedflag=1;
+                    }
     	        } else {
 		    my ($dsymb,$crsid,$domain,$name)=&Apache::lonxml::whichuser();
     	            &Apache::lonnet::unmark_as_readonly($domain,$name,$dsymb.$crsid);