--- loncom/homework/default_homework.lcpm 2014/06/25 10:48:39 1.167 +++ loncom/homework/default_homework.lcpm 2014/06/25 15:43:04 1.168 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # used by lonxml::xmlparse() as input variable $safeinit to Apache::run::run() # -# $Id: default_homework.lcpm,v 1.167 2014/06/25 10:48:39 raeburn Exp $ +# $Id: default_homework.lcpm,v 1.168 2014/06/25 15:43:04 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1233,13 +1233,27 @@ sub submission { if ($subnumber) { $sub=$subnumber.':'; } my $output = &EXT('user.resource.'.$sub.'resource.'.$partid.'.'.$responseid.'.submission'); - if ($encode) { - $output =~ s/&/&/g; - $output =~ s//>/g; - $output =~ s/"/"/g; + if (ref($output) eq 'ARRAY') { + my @items = @{$output}; + if ($encode) { + @items = map { &encode_response($_); } @items; + } + return \@items; + } else { + if ($encode) { + $output = &encode_response($output); + } + return $output; } - return $output; +} + +sub encode_response { + my ($value) = @_; + $value =~ s/&/&/g; + $value =~ s//>/g; + $value =~ s/"/"/g; + return $value; } sub currentpart {