[LON-CAPA-cvs] cvs: loncom /homework imageresponse.pm optionresponse.pm rankresponse.pm response.pm

raeburn raeburn at source.lon-capa.org
Fri Oct 12 08:45:46 EDT 2012


raeburn		Fri Oct 12 12:45:46 2012 EDT

  Modified files:              
    /loncom/homework	imageresponse.pm optionresponse.pm rankresponse.pm 
                    	response.pm 
  Log:
  - For perl 5.16 use of deprecated defined(@array) generates warnings.
    - eliminate use.
  
  
Index: loncom/homework/imageresponse.pm
diff -u loncom/homework/imageresponse.pm:1.103 loncom/homework/imageresponse.pm:1.104
--- loncom/homework/imageresponse.pm:1.103	Mon Nov 14 03:08:01 2011
+++ loncom/homework/imageresponse.pm	Fri Oct 12 12:45:46 2012
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # image click response style
 #
-# $Id: imageresponse.pm,v 1.103 2011/11/14 03:08:01 raeburn Exp $
+# $Id: imageresponse.pm,v 1.104 2012/10/12 12:45:46 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -212,8 +212,11 @@
 
 sub whichfoils {
     my ($max)=@_;
-    return if (!defined(@{ $Apache::response::foilgroup{'names'} }));
-    my @names = @{ $Apache::response::foilgroup{'names'} };
+    my @names;
+    if (ref($Apache::response::foilgroup{'names'}) eq 'ARRAY') {
+        @names = @{ $Apache::response::foilgroup{'names'} };
+    }
+    return if (!@names);
     my @whichopt;
     while ((($#whichopt+1) < $max) && ($#names > -1)) {
 	&Apache::lonxml::debug("Have $#whichopt max is $max");
@@ -473,9 +476,11 @@
 	my ($x,$y) = split(':',$env{"form.HWVAL_$id:$temp"});
 	$response{$name} = $env{"form.HWVAL_$id:$temp"};
 	&Apache::lonxml::debug("Got a x of $x and a y of $y for $name");
-	if (defined($x) && defined($y) &&
-	    defined(@{ $Apache::response::foilgroup{"$name.area"} })) {
-	    my @areas = @{ $Apache::response::foilgroup{"$name.area"} };
+        my @areas; 
+        if (ref($Apache::response::foilgroup{"$name.area"}) eq 'ARRAY') {
+            @areas = @{ $Apache::response::foilgroup{"$name.area"} };
+        }
+	if (defined($x) && defined($y) && @areas) {
 	    my $grade="INCORRECT";
 	    foreach my $area (@areas) {
 		&Apache::lonxml::debug("Area is $area for $name");
Index: loncom/homework/optionresponse.pm
diff -u loncom/homework/optionresponse.pm:1.186 loncom/homework/optionresponse.pm:1.187
--- loncom/homework/optionresponse.pm:1.186	Mon Jun 25 10:36:00 2012
+++ loncom/homework/optionresponse.pm	Fri Oct 12 12:45:46 2012
@@ -1,7 +1,7 @@
 # LearningOnline Network with CAPA
 # option list style responses
 #
-# $Id: optionresponse.pm,v 1.186 2012/06/25 10:36:00 foxr Exp $
+# $Id: optionresponse.pm,v 1.187 2012/10/12 12:45:46 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -427,8 +427,11 @@
 
 sub displayanswers {
     my ($max,$randomize, at opt)=@_;
-    if (!defined(@{ $Apache::response::foilgroup{'names'} })) {return;}
-    my @names = @{ $Apache::response::foilgroup{'names'} };
+    my @names;
+    if (ref($Apache::response::foilgroup{'names'}) eq 'ARRAY') {
+        @names = @{ $Apache::response::foilgroup{'names'} };
+    }
+    return if (!@names);
     my @whichopt = &whichfoils($max,$randomize);
     my $result;
     if ($Apache::lonhomework::type eq 'exam') {
Index: loncom/homework/rankresponse.pm
diff -u loncom/homework/rankresponse.pm:1.67 loncom/homework/rankresponse.pm:1.68
--- loncom/homework/rankresponse.pm:1.67	Fri Sep 16 22:23:54 2011
+++ loncom/homework/rankresponse.pm	Fri Oct 12 12:45:46 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # rank style response
 #
-# $Id: rankresponse.pm,v 1.67 2011/09/16 22:23:54 raeburn Exp $
+# $Id: rankresponse.pm,v 1.68 2012/10/12 12:45:46 raeburn Exp $
 # Copyright Michigan State University Board of Trustees
 #
 # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
@@ -186,8 +186,11 @@
 
 sub displayanswers {
     my ($max,$randomize,$tol, at opt)=@_;
-    if (!defined(@{ $Apache::response::foilgroup{'names'} })) { return; }
-    my @names = @{ $Apache::response::foilgroup{'names'} };
+    my @names;
+    if (ref($Apache::response::foilgroup{'names'}) eq 'ARRAY') {
+        @names = @{ $Apache::response::foilgroup{'names'} };
+    }
+    return if (!@names);
     my @whichfoils = &whichfoils($max,$randomize);
     my @correctorder=&get_correct_order($tol, at whichfoils);
     my $result;
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.230 loncom/homework/response.pm:1.231
--- loncom/homework/response.pm:1.230	Thu Dec 15 01:21:28 2011
+++ loncom/homework/response.pm	Fri Oct 12 12:45:46 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # various response type definitons response definition
 #
-# $Id: response.pm,v 1.230 2011/12/15 01:21:28 raeburn Exp $
+# $Id: response.pm,v 1.231 2012/10/12 12:45:46 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1136,7 +1136,11 @@
     my ($max,$randomize,$showall,$hash,$rndseed)=@_;
     #&Apache::lonxml::debug("man $max randomize $randomize");
     if (!defined(@{ $$hash{'names'} })) { return; }
-    my @names = @{ $$hash{'names'} };
+    my @names;
+    if (ref($hash->{'names'}) eq 'ARRAY') {
+        @names = @{$hash->{'names'}};
+    }
+    return if (!@names);
     my @whichopt =();
     my (%top, at toplist,%bottom, at bottomlist);
     if (!($showall || ($randomize eq 'no'))) {
@@ -1223,8 +1227,11 @@
 
 sub pick_foil_for_concept {
     my ($target,$attrs,$hinthash,$parstack,$safeeval)=@_;
-    if (not defined(@{ $Apache::response::conceptgroup{'names'} })) { return; }
-    my @names = @{ $Apache::response::conceptgroup{'names'} };
+    my @names;
+    if (ref($Apache::response::conceptgroup{'names'}) eq 'ARRAY') {
+        @names = @{ $Apache::response::conceptgroup{'names'} };
+    }
+    return if (!@names);
     my $pick=int(&Math::Random::random_uniform() * ($#names+1));
     my $name=$names[$pick];
     push @{ $Apache::response::foilgroup{'names'} }, $name;




More information about the LON-CAPA-cvs mailing list