[LON-CAPA-cvs] cvs: loncom /homework matchresponse.pm
raeburn
raeburn at source.lon-capa.org
Mon Nov 7 20:33:14 EST 2011
raeburn Tue Nov 8 01:33:14 2011 EDT
Modified files:
/loncom/homework matchresponse.pm
Log:
- Check if items are refs for hashes and arrays.
- Use of defined on aggregates (hashes and arrays) is deprecated.
Index: loncom/homework/matchresponse.pm
diff -u loncom/homework/matchresponse.pm:1.83 loncom/homework/matchresponse.pm:1.84
--- loncom/homework/matchresponse.pm:1.83 Fri Oct 7 22:39:59 2011
+++ loncom/homework/matchresponse.pm Tue Nov 8 01:33:14 2011
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Full matching style response
#
-# $Id: matchresponse.pm,v 1.83 2011/10/07 22:39:59 raeburn Exp $
+# $Id: matchresponse.pm,v 1.84 2011/11/08 01:33:14 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -131,7 +131,11 @@
my $result;
if ($target eq 'edit') { $result=&Apache::edit::end_table(); }
- if (!defined(@{ $Apache::response::itemgroup{'names'} })) { return; }
+ if (ref($Apache::response::itemgroup{'names'}) eq 'ARRAY') {
+ if(!@{ $Apache::response::itemgroup{'names'} }) { return; }
+ } else {
+ return;
+ }
my @names=@{ $Apache::response::itemgroup{'names'} };
my $randomize =&Apache::lonxml::get_param('randomize',$parstack,$safeeval);
if ($randomize ne 'no' ) {
@@ -345,16 +349,22 @@
sub displayanswers {
my ($max,$randomize, at opt)=@_;
- if (!defined(@{ $Apache::response::foilgroup{'names'} })) { return; }
+ if (ref($Apache::response::foilgroup{'names'}) eq 'ARRAY') {
+ if (!@{ $Apache::response::foilgroup{'names'} }) { return; }
+ } else {
+ return;
+ }
my @names = @{ $Apache::response::foilgroup{'names'} };
my @whichfoils = &Apache::response::whichorder(&getfoilcounts($max),
$randomize,
&Apache::response::showallfoils(),
\%Apache::response::foilgroup);
my %name_letter_map;
- if (defined(%{ $Apache::response::itemgroup{'name_letter_map'} })) {
- %name_letter_map=
- %{ $Apache::response::itemgroup{'name_letter_map'} };
+ if (ref($Apache::response::itemgroup{'name_letter_map'}) eq 'HASH') {
+ if (%{$Apache::response::itemgroup{'name_letter_map'}}) {
+ %name_letter_map=
+ %{ $Apache::response::itemgroup{'name_letter_map'} };
+ }
}
my $result;
if ($Apache::lonhomework::type eq 'exam') {
@@ -391,9 +401,11 @@
my %answerhash;
my ($temp,$right,$wrong,$ignored)=(1,0,0,0);
my %letter_name_map;
- if (defined(%{ $Apache::response::itemgroup{'letter_name_map'} })) {
- %letter_name_map=
- %{ $Apache::response::itemgroup{'letter_name_map'} };
+ if (ref($Apache::response::itemgroup{'letter_name_map'}) eq 'HASH') {
+ if (%{$Apache::response::itemgroup{'letter_name_map'}}) {
+ %letter_name_map=
+ %{ $Apache::response::itemgroup{'letter_name_map'} };
+ }
}
my @items;
my $numitems = scalar(@{ $Apache::response::itemgroup{'names'} });
@@ -564,14 +576,18 @@
my $part=$Apache::inputtags::part;
my $solved=$Apache::lonhomework::history{"resource.$part.solved"};
my %letter_name_map;
- if (defined(%{ $Apache::response::itemgroup{'letter_name_map'} })) {
- %letter_name_map=
- %{ $Apache::response::itemgroup{'letter_name_map'} };
+ if (ref($Apache::response::itemgroup{'letter_name_map'}) eq 'HASH') {
+ if (%{$Apache::response::itemgroup{'letter_name_map'}}) {
+ %letter_name_map=
+ %{ $Apache::response::itemgroup{'letter_name_map'} };
+ }
}
my %name_letter_map;
- if (defined(%{ $Apache::response::itemgroup{'name_letter_map'} })) {
- %name_letter_map=
- %{ $Apache::response::itemgroup{'name_letter_map'} };
+ if (ref($Apache::response::itemgroup{'name_letter_map'}) eq 'HASH') {
+ if (%{$Apache::response::itemgroup{'name_letter_map'}}) {
+ %name_letter_map=
+ %{ $Apache::response::itemgroup{'name_letter_map'} };
+ }
}
if ( &Apache::response::show_answer() && ($target ne 'tex')) {
foreach my $name (@whichfoils) {
@@ -835,8 +851,10 @@
if ($$tagstack[-2] eq 'conceptgroup') { $level = '-3'; }
$result.=&Apache::edit::text_arg('Name:','name',$token);
my @names;
- if (defined(@{ $Apache::response::itemgroup{'names'} })) {
- @names=@{ $Apache::response::itemgroup{'names'} };
+ if (ref($Apache::response::itemgroup{'names'}) eq 'ARRAY') {
+ if (@{ $Apache::response::itemgroup{'names'} }) {
+ @names=@{ $Apache::response::itemgroup{'names'} };
+ }
}
$result.= &Apache::edit::select_or_text_arg('Correct Option:','value',['unused', at names],$token,'15');
my $randomize=&Apache::lonxml::get_param('randomize',$parstack,
More information about the LON-CAPA-cvs
mailing list