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

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 10 Jan 2007 22:46:23 -0000


albertel		Wed Jan 10 17:46:23 2007 EDT

  Modified files:              
    /loncom/homework	bridgetask.pm 
  Log:
  - dealing with some other fallout from extending the lock recors to include the time of locking
  
  
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.216 loncom/homework/bridgetask.pm:1.217
--- loncom/homework/bridgetask.pm:1.216	Wed Jan 10 16:46:24 2007
+++ loncom/homework/bridgetask.pm	Wed Jan 10 17:46:22 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: bridgetask.pm,v 1.216 2007/01/10 21:46:24 albertel Exp $
+# $Id: bridgetask.pm,v 1.217 2007/01/10 22:46:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -98,7 +98,7 @@
 	&check_in_sequence($user,$domain,$slot_name);
     } else {
 	&create_new_version($type,$user,$domain,$slot_name);
-	&Apache::structuretags::finalize_storage($res->symb);
+	&Apache::structuretags::finalize_storage();
     }
     return 1;
 }
@@ -1579,17 +1579,16 @@
 		my $ekey=&escape($key);
 		my ($action,$description,$status)=('select',&mt('Select'));
 		if (exists($queue{"$key\0locked"})) {
-		    my $locker = $queue{"$key\0locked"};
-		    my $time;
-		    if (ref($queue{"$key\0locked"}) eq 'ARRAY') {
-			($locker, $time) = @{$queue{"$key\0locked"}};
+		    my ($locker,$time) = 
+			&get_lock_info($queue{"$key\0locked"});
+		    if ($time) {
 			$time = 
 			    &Apache::lonnavmaps::timeToHumanString($time,
 								   'start');
 		    }
 		    my $me=$env{'user.name'}.':'.$env{'user.domain'};
 		    $status=&mt('Locked by <tt>[_1]</tt> [_2]',$locker,$time);
-		    if ($me eq $queue{"$key\0locked"}) {
+		    if ($me eq $locker) {
 			($action,$description)=('resume',&mt('Resume'));
 		    } else {
 			($action,$description)=('unlock',&mt('Unlock'));
@@ -1699,7 +1698,7 @@
     my ($key_locked,$value)=
 	&Apache::lonnet::get($queue,["$key\0locked"],$cdom,$cnum);
     if ($key_locked eq "$key\0locked") {
-	return $value;
+	return &get_lock_info($value);
     }
     return undef;
 }
@@ -1780,6 +1779,24 @@
     return undef;
 }
 
+sub get_lock_info {
+    my ($lock_info) = @_;
+    if (wantarray) {
+	if (ref($lock_info) eq 'ARRAY') {
+	    return @{$lock_info};
+	} else {
+	    return ($lock_info);
+	}
+    } else {
+	if (ref($lock_info) eq 'ARRAY') {
+	    return $lock_info->[0];
+	} else {
+	    return $lock_info;
+	}
+    }
+    return;
+}
+
 sub find_mid_grade {
     my ($queue,$symb,$cdom,$cnum)=@_;
     my $todo=&unescape($env{'form.gradingkey'});
@@ -1791,7 +1808,7 @@
     my $regexp="^$symb\0.*\0locked\$";
     my %locks=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
     foreach my $key (keys(%locks)) {
-	my $who=$locks{$key};
+	my $who= &get_lock_info($locks{$key});
 	if ($who eq $me) {
 	    $todo=$key;
 	    $todo=~s/\0locked$//;