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

banghart lon-capa-cvs@mail.lon-capa.org
Tue, 28 Mar 2006 00:46:22 -0000


banghart		Mon Mar 27 19:46:22 2006 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  	Improve some variable names. 
  	Needs more testing, but seems to work. Versions porfolio files,
  	saves appropriately to cstore, hands back instructor upload
  	to student portfolio.
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.341 loncom/homework/grades.pm:1.342
--- loncom/homework/grades.pm:1.341	Sat Mar 25 18:54:07 2006
+++ loncom/homework/grades.pm	Mon Mar 27 19:46:20 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.341 2006/03/25 23:54:07 banghart Exp $
+# $Id: grades.pm,v 1.342 2006/03/28 00:46:20 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2269,7 +2269,7 @@
 #---- Save the score and award for each student, if changed
 sub saveHandGrade {
     my ($request,$symb,$stuname,$domain,$newflg,$submitter,$part) = @_;
-    my @v_flag;
+    my @version_parts;
     my $usec = &Apache::lonnet::getsection($domain,$stuname,
 					   $env{'request.course.id'});
     if (!&canmodify($usec)) { return('not_allowed'); }
@@ -2356,15 +2356,15 @@
 	        $record{'resource.'.$new_part.'.solved'} eq 'incorrect_by_override' ||
 	        $dropMenu eq 'reset status')
 	   {
-	    push (@v_flag,$new_part);
+	    push (@version_parts,$new_part);
 	}
     }
     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
 
     if (scalar(keys(%newrecord)) > 0) {
-        if (scalar(@v_flag)) {
-            &version_portfiles(\%record, \@parts_graded, $env{'request.course.id'}, $symb, $domain, $stuname, \@v_flag);
+        if (scalar(@version_parts)) {
+            &version_portfiles(\%record, \%newrecord, \@parts_graded, $env{'request.course.id'}, $symb, $domain, $stuname, \@version_parts);
         }
 	&Apache::lonnet::cstore(\%newrecord,$symb,
 				$env{'request.course.id'},$domain,$stuname);
@@ -2504,7 +2504,7 @@
 
 # ----------- Handles creating versions for portfolio files as answers
 sub version_portfiles {
-    my ($record, $parts_graded, $courseid, $symb, $domain, $stu_name, $v_flag) = @_;
+    my ($record, $newrecord, $parts_graded, $courseid, $symb, $domain, $stu_name, $v_flag) = @_;
     my $version_parts = join('|',@$v_flag);
     my $parts = join('|', @$parts_graded);
     my $portfolio_root = &Apache::loncommon::propath($domain,
@@ -2513,26 +2513,24 @@
     foreach my $key (keys(%$record)) {
         my $new_portfiles;
         if ($key =~ /^resource\.($version_parts)\./ && $key =~ /\.portfiles$/ ) {
-            my @v_portfiles;
+            my @versioned_portfiles;
             my @portfiles = split(/,/,$$record{$key});
             foreach my $file (@portfiles) {
                 &Apache::lonnet::unmark_as_readonly($domain,$stu_name,[$symb,$env{'request.course.id'}],$file);
                 my ($directory,$answer_file) =($file =~ /^(.*?)([^\/]*)$/);
-                my $version = 0;
 		my ($answer_name,$answer_ver,$answer_ext) =
 		    &file_name_version_ext($answer_file);
                 my @dir_list = &Apache::lonnet::dirlist($directory,$domain,$stu_name,$portfolio_root);
-                $version = &get_next_version($answer_name, $answer_ext, \@dir_list);
+                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(@v_portfiles, $directory.$new_answer);
+                    push(@versioned_portfiles, $directory.$new_answer);
                     &Apache::lonnet::mark_as_readonly($domain,$stu_name,
                         ['/portfolio'.$directory.$new_answer],
                         [$symb,$env{'request.course.id'},'graded']);
                 }
-                
             }
-            $$record{$key} = join(',',@v_portfiles);
+            $$newrecord{$key} = join(',',@versioned_portfiles);
         }
     } 
     return 'ok';