[LON-CAPA-cvs] cvs: loncom /homework default_homework.lcpm

raeburn raeburn at source.lon-capa.org
Wed Jun 25 11:43:04 EDT 2014


raeburn		Wed Jun 25 15:43:04 2014 EDT

  Modified files:              
    /loncom/homework	default_homework.lcpm 
  Log:
  - Bug 6693
    - submission can be ref to an array if there are multiple <value></value>
      items within an <answer> tag.
  
  
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.167 loncom/homework/default_homework.lcpm:1.168
--- loncom/homework/default_homework.lcpm:1.167	Wed Jun 25 10:48:39 2014
+++ loncom/homework/default_homework.lcpm	Wed Jun 25 15:43:04 2014
@@ -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 @@
    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;
-       $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;
+    $value =~ s/"/"/g;
+    return $value;
 }
 
 sub currentpart {




More information about the LON-CAPA-cvs mailing list