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

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 12 Jun 2006 18:45:35 -0000


albertel		Mon Jun 12 14:45:35 2006 EDT

  Modified files:              
    /loncom/homework	bridgetask.pm lonhomework.pm 
  Log:
  - regrading not allowed to grade a task that is still open
  
  
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.164 loncom/homework/bridgetask.pm:1.165
--- loncom/homework/bridgetask.pm:1.164	Fri Jun  9 19:09:01 2006
+++ loncom/homework/bridgetask.pm	Mon Jun 12 14:45:35 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: bridgetask.pm,v 1.164 2006/06/09 23:09:01 albertel Exp $
+# $Id: bridgetask.pm,v 1.165 2006/06/12 18:45:35 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -618,6 +618,11 @@
 		    $result.='<b>'.
 			&mt("Requested user has never accessed the task.").
 			'</b>'.$back;
+		} elsif ($status_code =~ /still_open:(.*)/) {
+		    my $date = &Apache::lonlocal::locallocaltime($1);
+		    $result.='<b>'.
+			&mt("Task is still open, will close at [_1].",$date).
+			'</b>'.$back;
 		} elsif ($status_code eq 'lock_failed') {
 		    $result.='<b>'.&mt("Failed to lock the requested record.")
 			.'</b>'.$back;
@@ -682,6 +687,20 @@
     return $result;
 }
 
+sub get_task_end_time {
+    my ($queue_entry,$symb,$udom,$uname) = @_;
+
+    my $end_time;
+    if (my $slot = &slotted_access($queue_entry)) {
+	my %slot_data=&Apache::lonnet::get_slot($slot);
+	$end_time = $slot_data{'endtime'};
+    } else {
+	$end_time = &Apache::lonhomework::due_date('0',$symb,
+						   $udom,$uname);
+    }
+    return $end_time;
+}
+
 sub get_key_todo {
     my ($target)=@_;
     my $todo;
@@ -737,6 +756,16 @@
 	    return ($gradingkey);
 	}
 
+	if ($queue) {
+	    my $queue_entry = &get_queue_data($queue,$udom,$uname);
+	
+	    my $end_time = &get_task_end_time($queue_entry,$symb,
+					      $udom,$uname);
+	    if ($end_time > time) {
+		return (undef,"still_open:$end_time");
+	    }
+	}
+
 	my $who=&queue_key_locked($queue,$gradingkey);
 	if ($who eq $me) {
 	    #already have the lock
@@ -1190,8 +1219,12 @@
 }
 
 sub get_queue_data {
-    my ($queue)=@_;
-    my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
+    my ($queue,$udom,$uname)=@_;
+    my ($symb,$cid,$other_udom,$other_uname)=&Apache::lonxml::whichuser();
+    if (!$uname || !$udom) {
+	$uname=$other_uname;
+	$udom =$other_udom;
+    }
     my $cnum=$env{'course.'.$cid.'.num'};
     my $cdom=$env{'course.'.$cid.'.domain'};
     my $todo="$symb\0queue\0$uname:$udom";
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.249 loncom/homework/lonhomework.pm:1.250
--- loncom/homework/lonhomework.pm:1.249	Thu Jun  8 18:33:57 2006
+++ loncom/homework/lonhomework.pm	Mon Jun 12 14:45:35 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.249 2006/06/08 22:33:57 albertel Exp $
+# $Id: lonhomework.pm,v 1.250 2006/06/12 18:45:35 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -486,11 +486,13 @@
 }
 # this should work exactly like the copy in lonnavmaps.pm
 sub due_date {
-    my ($part_id,$symb)=@_;
+    my ($part_id,$symb,$udom,$uname)=@_;
     my $date;
-    my $interval= &Apache::lonnet::EXT("resource.$part_id.interval",$symb);
+    my $interval= &Apache::lonnet::EXT("resource.$part_id.interval",$symb,
+				       $udom,$uname);
     &Apache::lonxml::debug("looking for interval $part_id $symb $interval");
-    my $due_date= &Apache::lonnet::EXT("resource.$part_id.duedate",$symb);
+    my $due_date= &Apache::lonnet::EXT("resource.$part_id.duedate",$symb,
+				       $udom,$uname);
     &Apache::lonxml::debug("looking for due_date $part_id $symb $due_date");
     if (defined($interval)) {
 	my $first_access=&Apache::lonnet::get_first_access('map',$symb);