[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /homework grades.pm

raeburn raeburn at source.lon-capa.org
Wed May 2 10:23:35 EDT 2012


raeburn		Wed May  2 14:23:35 2012 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/homework	grades.pm 
  Log:
  - Backport 1.662.
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.596.2.12.2.1 loncom/homework/grades.pm:1.596.2.12.2.2
--- loncom/homework/grades.pm:1.596.2.12.2.1	Wed May  2 14:01:32 2012
+++ loncom/homework/grades.pm	Wed May  2 14:23:34 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.596.2.12.2.1 2012/05/02 14:01:32 raeburn Exp $
+# $Id: grades.pm,v 1.596.2.12.2.2 2012/05/02 14:23:34 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3006,8 +3006,10 @@
 		        &file_name_version_ext($answer_file);
 		    my ($portfolio_path) = ($directory =~ /^.+$stuname\/portfolio(.*)/);
                     my $getpropath = 1;
-		    my @dir_list = &Apache::lonnet::dirlist($portfolio_root.$portfolio_path,$domain,$stuname,$getpropath);
-		    my $version = &get_next_version($answer_name, $answer_ext, \@dir_list);
+                    my ($dir_list,$listerror) =
+                        &Apache::lonnet::dirlist($portfolio_root.$portfolio_path,
+                                                 $domain,$stuname,$getpropath);
+		    my $version = &get_next_version($answer_name,$answer_ext,$dir_list);
                     # fix file name
                     my ($save_file_name) = (($directory.$answer_name.".$version.".$answer_ext) =~ /^.+\/${stuname}\/(.*)/);
                     my $result=&Apache::lonnet::finishuserfileupload($stuname,$domain,
@@ -3167,9 +3169,11 @@
                 my ($directory,$answer_file) =($file =~ /^(.*?)([^\/]*)$/);
 		my ($answer_name,$answer_ver,$answer_ext) =
 		    &file_name_version_ext($answer_file);
-                my $getpropath = 1;    
-                my @dir_list = &Apache::lonnet::dirlist($portfolio_root.$directory,$domain,$stu_name,$getpropath);
-                my $version = &get_next_version($answer_name, $answer_ext, \@dir_list);
+                my $getpropath = 1;
+                my ($dir_list,$listerror) =
+                    &Apache::lonnet::dirlist($portfolio_root.$directory,$domain,
+                                             $stu_name,$getpropath);
+                my $version = &get_next_version($answer_name,$answer_ext,$dir_list);
                 my $new_answer = &version_selected_portfile($domain, $stu_name, $directory, $answer_file, $version);
                 if ($new_answer ne 'problem getting file') {
                     push(@versioned_portfiles, $directory.$new_answer);
@@ -3188,21 +3192,24 @@
 sub get_next_version {
     my ($answer_name, $answer_ext, $dir_list) = @_;
     my $version;
-    foreach my $row (@$dir_list) {
-        my ($file) = split(/\&/,$row,2);
-        my ($file_name,$file_version,$file_ext) =
-	    &file_name_version_ext($file);
-        if (($file_name eq $answer_name) && 
-	    ($file_ext eq $answer_ext)) {
-                # gets here if filename and extension match, regardless of version
+    if (ref($dir_list) eq 'ARRAY') {
+        foreach my $row (@{$dir_list}) {
+            my ($file) = split(/\&/,$row,2);
+            my ($file_name,$file_version,$file_ext) =
+	        &file_name_version_ext($file);
+            if (($file_name eq $answer_name) && 
+	        ($file_ext eq $answer_ext)) {
+                # gets here if filename and extension match, 
+                # regardless of version
                 if ($file_version ne '') {
-                # a versioned file is found  so save it for later
-                if ($file_version > $version) {
-		    $version = $file_version;
+                    # a versioned file is found  so save it for later
+                    if ($file_version > $version) {
+		        $version = $file_version;
+                    }
 	        }
             }
         }
-    } 
+    }
     $version ++;
     return($version);
 }
@@ -5161,14 +5168,16 @@
     my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
     my $cname=$env{'course.'.$env{'request.course.id'}.'.num'};
     my $getpropath = 1;
-    my @files=&Apache::lonnet::dirlist('userfiles',$cdom,$cname,
-                                       $getpropath);
+    my ($dirlist,$listerror) = &Apache::lonnet::dirlist('userfiles',$cdom,
+                                                        $cname,$getpropath);
     my @possiblenames;
-    foreach my $filename (sort(@files)) {
-	($filename)=split(/&/,$filename);
-	if ($filename!~/^scantron_orig_/) { next ; }
-	$filename=~s/^scantron_orig_//;
-	push(@possiblenames,$filename);
+    if (ref($dirlist) eq 'ARRAY') {
+        foreach my $filename (sort(@{$dirlist})) {
+	    ($filename)=split(/&/,$filename);
+	    if ($filename!~/^scantron_orig_/) { next ; }
+	    $filename=~s/^scantron_orig_//;
+	    push(@possiblenames,$filename);
+        }
     }
     return @possiblenames;
 }




More information about the LON-CAPA-cvs mailing list