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

banghart lon-capa-cvs@mail.lon-capa.org
Fri, 29 Apr 2005 17:02:07 -0000


banghart		Fri Apr 29 13:02:07 2005 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  	Seems to work versioning files, unlocking original, locking
  	new version, handling multiple parts. More testing still
  	a good idea.
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.263 loncom/homework/grades.pm:1.264
--- loncom/homework/grades.pm:1.263	Tue Apr 12 12:54:52 2005
+++ loncom/homework/grades.pm	Fri Apr 29 13:02:06 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.263 2005/04/12 16:54:52 banghart Exp $
+# $Id: grades.pm,v 1.264 2005/04/29 17:02:06 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2181,7 +2181,6 @@
         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);
     }
@@ -2197,12 +2196,13 @@
 						 $stuname).
 						'/userfiles/portfolio';
     foreach my $key(keys %$record) {
-        #&Apache::lonnet::logthis("key is $key, value is $$record{$key}");
         my $new_portfiles;
         if ($key =~ /^resource\.($version_parts)\./ && $key =~ /\.portfiles$/ ) {
             my @v_portfiles;
             my @portfiles = split(/,/,$$record{$key});
+            # &Apache::lonnet::logthis("should be unmarking and remarking");
             foreach my $file (@portfiles) {
+                &Apache::lonnet::unmark_as_readonly($domain,$stuname,[$symb,$env{'request.course.id'}],$file);
                 my ($directory,$answer_file) =($file =~ /^(.*?)([^\/]*$)/);
                 my $version = 0;
                 my @answer_file_parts = split(/\./, $answer_file);
@@ -2231,6 +2231,9 @@
                    my $copy_result = &Apache::lonnet::finishuserfileupload($stuname,$domain,$home_server,'copy',
                                     '/portfolio'.$directory.$answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]);
                     push(@v_portfiles, $answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]);
+                    &Apache::lonnet::mark_as_readonly($domain,$stuname,
+                                ['/portfolio'.$directory.$answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]],
+                                [$symb,$env{'request.course.id'},'graded']);
                 }
             }
             $$record{$key} = join(',',@v_portfiles);