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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 31 May 2005 16:27:44 -0000


albertel		Tue May 31 12:27:44 2005 EDT

  Modified files:              
    /loncom/homework	bridgetask.pm 
  Log:
  - add more info about the grading queue status
  
  
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.33 loncom/homework/bridgetask.pm:1.34
--- loncom/homework/bridgetask.pm:1.33	Fri May 27 17:13:46 2005
+++ loncom/homework/bridgetask.pm	Tue May 31 12:27:43 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: bridgetask.pm,v 1.33 2005/05/27 21:13:46 albertel Exp $
+# $Id: bridgetask.pm,v 1.34 2005/05/31 16:27:43 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -146,11 +146,17 @@
     $result.='<input type="hidden" name="grade_target" value="webgrade" />';
     if ( 1) {
 	#need a permissions for limitng this to 'powerful users'
-	#check if review queue has items
-	$result.=' <input type="submit" name="reviewasubmission" value="'.
-	    &mt("Select an entry from the review queue").'" />'."\n";
+
+	my ($entries,$ready,$locks)=&get_queue_counts('gradingqueue');
+	$result.='<p>'.&mt("Grading Queue has [_1] entries. [_2] of them are ready to be graded and [_3] of them are currently being graded",$entries,$ready,$locks);
+
 	$result.=' <input type="submit" name="reviewagrading" value="'.
-	    &mt("Select an entry from the grading queue").'" />'."\n";
+	    &mt("Select an entry from the grading queue").'" /> </p>'."\n";
+
+	($entries,$ready,$locks)=&get_queue_counts('reviewqueue');
+	$result.='<p>'.&mt("Review Queue has [_1] entries. [_2] of them are ready to be graded and [_3] of them are currently being graded",$entries,$ready,$locks);
+	$result.=' <input type="submit" name="reviewasubmission" value="'.
+	    &mt("Select an entry from the review queue").'" /> </p>'."\n";
     }
     return $result;
 }
@@ -691,6 +697,37 @@
     return $result;
 }
 
+sub get_queue_counts {
+    my ($queue)=@_;
+    my $result;
+    my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
+    my $cnum=$env{'course.'.$cid.'.num'};
+    my $cdom=$env{'course.'.$cid.'.domain'};
+    my $regexp="^$symb\0";
+    my %queue=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
+    my ($tmp)=%queue;
+    if ($tmp=~/^error: 2 /) {
+	return (0,0,0);
+    }
+    my ($entries,$ready_to_grade,$locks)=(0,0,0);
+    foreach my $key (sort(keys(%queue))) {
+	if ($key=~/locked$/) {
+	    $locks++;
+	} elsif ($key=~/timestamp$/) {
+	    #ignore
+	} elsif ($key!~/(timestamp|locked)$/) {
+	    my ($symb,$uname,$udom) = &decode_queue_key($key);
+	    $entries++;
+	    my $slot=$queue{$key}->[0];
+	    my %slot_data=&Apache::lonnet::get_slot($slot);
+	    if (time > $slot_data{'endtime'}) {
+		$ready_to_grade++;
+	    }
+	}
+    }
+    return ($entries,$ready_to_grade,$locks);
+}
+
 sub decode_queue_key {
     my ($key)=@_;
     my ($symb,undef,$user) = split("\0",$key);