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

banghart lon-capa-cvs@mail.lon-capa.org
Tue, 12 Apr 2005 16:54:52 -0000


banghart		Tue Apr 12 12:54:52 2005 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  
  	Seems to create portfolio file versions appropriately, record
  	the answer, and unlock submitted files, doubtless needs more testing.
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.262 loncom/homework/grades.pm:1.263
--- loncom/homework/grades.pm:1.262	Fri Apr  8 16:12:58 2005
+++ loncom/homework/grades.pm	Tue Apr 12 12:54:52 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.262 2005/04/08 20:12:58 banghart Exp $
+# $Id: grades.pm,v 1.263 2005/04/12 16:54:52 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2178,12 +2178,10 @@
 	}
     }
     if (scalar(keys(%newrecord)) > 0) {
-        if (scalar @v_flag) {
-            foreach my $part_flagged (@v_flag) {
-                &Apache::lonnet::unmark_as_readonly($domain,$stuname,$symb.$env{'request.course.id'});
-                &version_portfiles(\%record, \@parts_graded, $env{'request.course.id'}, $symb, $domain, $stuname);
-            }
+        if (scalar(@v_flag)) {
+            &version_portfiles(\%record, \@parts_graded, $env{'request.course.id'}, $symb, $domain, $stuname, \@v_flag);
         }
+        &Apache::lonnet::unmark_as_readonly($domain,$stuname,$symb.$env{'request.course.id'});
 	&Apache::lonnet::cstore(\%newrecord,$symb,
 				$env{'request.course.id'},$domain,$stuname);
     }
@@ -2192,7 +2190,8 @@
 
 # ----------- Handles creating versions for portfolio files as answers
 sub version_portfiles {
-    my ($record, $parts_graded, $courseid, $symb, $domain, $stuname) = @_;
+    my ($record, $parts_graded, $courseid, $symb, $domain, $stuname, $v_flag) = @_;
+    my $version_parts = join('|',@$v_flag);
     my $parts = join('|', @$parts_graded);
     my $portfolio_root = &Apache::loncommon::propath($domain,
 						 $stuname).
@@ -2200,7 +2199,7 @@
     foreach my $key(keys %$record) {
         #&Apache::lonnet::logthis("key is $key, value is $$record{$key}");
         my $new_portfiles;
-        if ($key =~ /^resource\.($parts)\./ && $key =~ /\.portfiles$/) {
+        if ($key =~ /^resource\.($version_parts)\./ && $key =~ /\.portfiles$/ ) {
             my @v_portfiles;
             my @portfiles = split(/,/,$$record{$key});
             foreach my $file (@portfiles) {