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

raeburn raeburn@source.lon-capa.org
Tue, 12 Jan 2010 17:05:12 -0000


raeburn		Tue Jan 12 17:05:12 2010 EDT

  Modified files:              
    /loncom/homework	bridgetask.pm 
  Log:
  - bug 5921.
    - Before calling structuretags::finalize() to store grading, check that username, domain and symb in grading key match those in 
      $env{'form.grade_username'}, $env{'form.grade_domain'},
      $env{'form.grade_symb'}.
  
  
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.249 loncom/homework/bridgetask.pm:1.250
--- loncom/homework/bridgetask.pm:1.249	Wed May  6 16:19:26 2009
+++ loncom/homework/bridgetask.pm	Tue Jan 12 17:05:12 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: bridgetask.pm,v 1.249 2009/05/06 16:19:26 bisitz Exp $
+# $Id: bridgetask.pm,v 1.250 2010/01/12 17:05:12 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1308,8 +1308,25 @@
 		    $Apache::lonhomework::results{"resource.$version.0.solved"};
 	    }
 	    &minimize_storage();
-	    &Apache::structuretags::finalize_storage();
-	    
+            my $canstore;
+            if ($env{'form.gradingkey'}) {
+                my ($symb,$courseid,$domain,$name) =
+                    &Apache::lonnet::whichuser();
+                my $todo=&unescape($env{'form.gradingkey'});
+                my ($keysymb,$uname,$udom)=&decode_queue_key($todo);
+                if ($symb eq $keysymb) {
+                    if (($domain eq $udom) && ($name eq $uname)) {
+                        $canstore = 1;           
+                    }
+                }
+            }
+            if ($canstore) {
+	        &Apache::structuretags::finalize_storage();
+            } else {
+                $result .= '<br /><div class="LC_error">'.
+                           &mt('Information extracted from the current gradingkey was for a different BT or user from those for which grading data are to be stored.').' '.&mt('No grading changes stored.').'</div><br />';  
+            }
+
 	    # data stored, now handle queue
 	    if ($review) {
 		if ($env{'form.queue'} eq 'reviewqueue') {
@@ -1395,6 +1412,13 @@
     }
     &Apache::structuretags::reset_problem_globals('Task');
     undef($Apache::lonhomework::parsing_a_task);
+    if ( ($target eq 'grade' && $env{'form.webgrade'}) ||
+          $target eq 'webgrade') {
+        delete($env{'form.grade_symb'});
+        delete($env{'form.grade_domain'});
+        delete($env{'form.grade_username'});
+        delete($env{'form.grade_courseid'});
+    }
     return $result;
 }