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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 06 Dec 2005 10:13:15 -0000


albertel		Tue Dec  6 05:13:15 2005 EDT

  Modified files:              
    /loncom/homework	bridgetask.pm 
  Log:
  - add ability to check queue status of a specific user
  - remove only removes users that are in the queue
  
  
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.87 loncom/homework/bridgetask.pm:1.88
--- loncom/homework/bridgetask.pm:1.87	Thu Dec  1 13:46:31 2005
+++ loncom/homework/bridgetask.pm	Tue Dec  6 05:13:15 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.87 2005/12/01 18:46:31 albertel Exp $
+# $Id: bridgetask.pm,v 1.88 2005/12/06 10:13:15 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -955,6 +955,25 @@
     return 'not_owner';
 }
 
+sub in_queue {
+    my ($queue,$symb,$cdom,$cnum,$udom,$uname)=@_;
+    if ($queue eq 'none') { return 0; }
+    if (!defined($symb) || !defined($cdom) || !defined($cnum)
+	|| !defined($udom) || !defined($uname)) {
+	($symb,my $cid,$udom,$uname)=&Apache::lonxml::whichuser();
+	$cnum=$env{'course.'.$cid.'.num'};
+	$cdom=$env{'course.'.$cid.'.domain'};
+    }
+
+    my $key=&encode_queue_key($symb,$udom,$uname);
+    my %results = &Apache::lonnet::get($queue,[$key],$cdom,$cnum);
+
+    if (defined($results{$key})) {
+	return 1;
+    }
+    return 0;
+}
+
 sub remove_from_queue {
     my ($queue,$symb,$cdom,$cnum,$udom,$uname)=@_;
     if ($queue eq 'none') { return 'ok'; }
@@ -964,9 +983,11 @@
 	$cnum=$env{'course.'.$cid.'.num'};
 	$cdom=$env{'course.'.$cid.'.domain'};
     }
+    if (!&in_queue($queue,$symb,$cdom,$cnum,$udom,$uname)) {
+	return 'ok';
+    }
     my $key=&encode_queue_key($symb,$udom,$uname);
     my @keys=($key,"$key\0locked");
-    &Apache::lonnet::logthis("removing @keys");
     return &Apache::lonnet::del($queue,\@keys,$cdom,$cnum);
 }
 
@@ -1353,7 +1374,8 @@
 	
 	my $cnum=$env{'course.'.$cid.'.num'};
 	my $cdom=$env{'course.'.$cid.'.domain'};
-	my %status = &get_student_status($symb,$cdom,$cnum,$udom,$uname);
+	my %status = &get_student_status($symb,$cdom,$cnum,$udom,$uname,
+					 'Task');
 	my $queue = 'none';
 	my $cannot_grade;
 	if ($status{'reviewqueue'} =~ /^(in_progress|enqueue)$/) {