--- loncom/homework/response.pm	2006/06/19 16:32:35	1.140
+++ loncom/homework/response.pm	2006/06/28 21:12:50	1.142
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # various response type definitons response definition
 #
-# $Id: response.pm,v 1.140 2006/06/19 16:32:35 www Exp $
+# $Id: response.pm,v 1.142 2006/06/28 21:12:50 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -128,11 +128,13 @@ sub setrandomnumber {
 	}
 	$shift_amt=scalar(@Apache::inputtags::responselist);
     } elsif ($Apache::lonhomework::parsing_a_task) {
-	$id1=$Apache::bridgetask::dimension;
-	if (!$ignore_id2 && defined($Apache::bridgetask::instance[-1])) {
-	    $id2=$Apache::bridgetask::instance[-1];
+	$id1=&Apache::bridgetask::get_dim_id();
+	if (!$ignore_id2 && ref($Apache::bridgetask::instance{$id1})) {
+	    $id2=$Apache::bridgetask::instance{$id1}[-1];
+	    $shift_amt=scalar(@{$Apache::bridgetask::instance{$id1}});
+	} else {
+	    $shift_amt=0;
 	}
-	$shift_amt=scalar(@Apache::bridgetask::instance);
     } 
     &Apache::lonxml::debug("id1: $id1, id2: $id2, shift_amt: $shift_amt");
     if (!$rand_alg || $rand_alg eq '32bit' || $rand_alg eq '64bit' ||