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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 01 Dec 2005 18:19:17 -0000


albertel		Thu Dec  1 13:19:17 2005 EDT

  Modified files:              
    /loncom/homework	bridgetask.pm 
  Log:
  - modfying standard queue routines to handle problem and task style queu enteries
  
  
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.85 loncom/homework/bridgetask.pm:1.86
--- loncom/homework/bridgetask.pm:1.85	Tue Nov 22 15:01:12 2005
+++ loncom/homework/bridgetask.pm	Thu Dec  1 13:19:17 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.85 2005/11/22 20:01:12 albertel Exp $
+# $Id: bridgetask.pm,v 1.86 2005/12/01 18:19:17 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -956,13 +956,17 @@
 }
 
 sub remove_from_queue {
-    my ($queue)=@_;
+    my ($queue,$symb,$cdom,$cnum,$udom,$uname)=@_;
     if ($queue eq 'none') { return 'ok'; }
-    my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
-    my $cnum=$env{'course.'.$cid.'.num'};
-    my $cdom=$env{'course.'.$cid.'.domain'};
-    my $key="$symb\0queue\0$uname\@$udom";
+    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 @keys=($key,"$key\0locked");
+    &Apache::lonnet::logthis("removing @keys");
     return &Apache::lonnet::del($queue,\@keys,$cdom,$cnum);
 }
 
@@ -1001,10 +1005,17 @@
 	if (defined($results{"$todo\0locked"})) {
 	    return 'locked';
 	}
-	my $slot=$results{$todo}->[0];
-	my %slot_data=&Apache::lonnet::get_slot($slot);
-	if ($slot_data{'endtime'} > time) { 
-	    return 'in_progress';
+	my $slot;
+	if (ref($results{$todo}) eq 'ARRAY')  {
+	    $slot = $results{$todo}[0];
+	} elsif (ref($results{$todo}) eq 'HASH')  {
+	    $slot = $results{$todo}{'slot'};
+	}
+	if (defined($slot)) {
+	    my %slot_data=&Apache::lonnet::get_slot($slot);
+	    if ($slot_data{'endtime'} > time) { 
+		return 'in_progress';
+	    }
 	}
 	return 'enqueued';
     }
@@ -1048,7 +1059,7 @@
     if ($tmp=~/^error: 2 /) {
 	return "\n<h3>Current Queue - $queue</h3><table border='1'><tr><td>Empty</td></tr></table>";
     }
-    $result.="\n<h3>Current Queue - $queue </h3><table border='1'><tr>";
+    $result.="\n<h3>Current Queue - $symb $queue </h3><table border='1'><tr>";
     if ($with_selects) { $result.="<th></th>"; }
     $result.="<th>resource</th><th>user</th><th>type</th><th>data</th></tr>";
     foreach my $key (sort(keys(%queue))) {
@@ -1236,7 +1247,7 @@
     return 0;
 }
 
-sub get_users_in_queue {
+sub get_queue_symb_status {
     my ($queue,$symb,$cdom,$cnum) = @_;
     if (!defined($cdom) || !defined($cnum)) {
 	my (undef,$cid)=&Apache::lonxml::whichuser();
@@ -1421,17 +1432,23 @@
 }
 
 sub get_student_status {
-    my ($symb,$cdom,$cnum,$udom,$uname)=@_;
-    my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},
-					  $udom,$uname);
+    my ($symb,$cdom,$cnum,$udom,$uname,$type)=@_;
+
     my %status;
-    $status{'status'}=$record{'resource.status'};
-    $status{'version'}=$record{'resource.version'};
-    $status{'grader'}=$record{'resource.grader'};
-    $status{'reviewqueue'}=&check_queue_for_key($cdom,$cnum,'reviewqueue',
-				       &encode_queue_key($symb,$udom,$uname));
-    $status{'gradingqueue'}=&check_queue_for_key($cdom,$cnum,'gradingqueue',
-				       &encode_queue_key($symb,$udom,$uname));
+
+    if ($type eq 'Task') {
+	my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},
+					  $udom,$uname);
+	$status{'status'}=$record{'resource.status'};
+	$status{'version'}=$record{'resource.version'};
+	$status{'grader'}=$record{'resource.grader'};
+    }
+    $status{'reviewqueue'}=
+	&check_queue_for_key($cdom,$cnum,'reviewqueue',
+			     &encode_queue_key($symb,$udom,$uname));
+    $status{'gradingqueue'}=
+	&check_queue_for_key($cdom,$cnum,'gradingqueue',
+			     &encode_queue_key($symb,$udom,$uname));
     return %status;
 }