[LON-CAPA-cvs] cvs: loncom /interface lonhelper.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Mon, 17 Oct 2005 20:21:32 -0000
albertel Mon Oct 17 16:21:32 2005 EDT
Modified files:
/loncom/interface lonhelper.pm
Log:
- handles better the case where defaultvalue doesn't return anything of note
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.124 loncom/interface/lonhelper.pm:1.125
--- loncom/interface/lonhelper.pm:1.124 Mon Oct 17 15:46:12 2005
+++ loncom/interface/lonhelper.pm Mon Oct 17 16:21:31 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# .helper XML handler to implement the LON-CAPA helper
#
-# $Id: lonhelper.pm,v 1.124 2005/10/17 19:46:12 albertel Exp $
+# $Id: lonhelper.pm,v 1.125 2005/10/17 20:21:31 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2017,18 +2017,19 @@
$mapUrl = $self->{MAP_URL};
}
- my @defaultSymbs;
+ my %defaultSymbs;
if (defined($self->{DEFAULT_VALUE})) {
my $valueFunc = eval($self->{DEFAULT_VALUE});
die 'Error in default value code for variable ' .
$self->{'variable'} . ', Perl said: ' . $@ if $@;
- @defaultSymbs = &$valueFunc($helper, $self);
- if (!$multichoice) { # only allowed 1
+ my @defaultSymbs = &$valueFunc($helper, $self);
+ if (!$multichoice && @defaultSymbs) { # only allowed 1
@defaultSymbs = ($defaultSymbs[0]);
}
+ %defaultSymbs = map { if ($_) {($_,1) } } @defaultSymbs;
+ delete($defaultSymbs{''});
}
-
# Create the composite function that renders the column on the nav map
# have to admit any language that lets me do this can't be all bad
# - Jeremy (Pythonista) ;-)
@@ -2076,9 +2077,9 @@
}
$col .= "<td align='center'><input type='$inputType' name='${var}.forminput' ";
- if (@defaultSymbs) {
+ if (%defaultSymbs) {
my $symb=$resource->symb();
- if (grep(/\Q$symb\E/,@defaultSymbs)) {
+ if (exists($defaultSymbs{$symb})) {
$col .= "checked='checked' ";
$checked = 1;
}