[LON-CAPA-cvs] cvs: loncom /interface/statistics lonstathelpers.pm

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 04 Oct 2004 19:11:38 -0000


matthew		Mon Oct  4 15:11:38 2004 EDT

  Modified files:              
    /loncom/interface/statistics	lonstathelpers.pm 
  Log:
  get_problem_data:
     Added detection of 'str_type' and 'answercomputed' fields.
     Added debugging code (disabled).
  
  
Index: loncom/interface/statistics/lonstathelpers.pm
diff -u loncom/interface/statistics/lonstathelpers.pm:1.27 loncom/interface/statistics/lonstathelpers.pm:1.28
--- loncom/interface/statistics/lonstathelpers.pm:1.27	Thu Sep 30 09:44:07 2004
+++ loncom/interface/statistics/lonstathelpers.pm	Mon Oct  4 15:11:38 2004
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstathelpers.pm,v 1.27 2004/09/30 13:44:07 matthew Exp $
+# $Id: lonstathelpers.pm,v 1.28 2004/10/04 19:11:38 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1108,13 +1108,15 @@
                     $Partdata{$part}->{'_Options'}=$value;
                 } elsif ($key eq 'concepts') {
                     $Partdata{$part}->{'_Concepts'}=$value;
+                } elsif ($key eq 'items') {
+                    $Partdata{$part}->{'_Items'}=$value;
                 } elsif ($key =~ /^concept\.(.*)$/) {
                     my $concept = $1;
                     foreach my $foil (@$value) {
                         $Partdata{$part}->{'_Foils'}->{$foil}->{'_Concept'}=
                                                                       $concept;
                     }
-                } elsif ($key =~ /^(incorrect|answer|ans_low|ans_high)$/) {
+                } elsif ($key =~ /^(incorrect|answer|ans_low|ans_high|str_type)$/) {
                     $Partdata{$part}->{$key}=$value;
                 }
             } else {
@@ -1126,13 +1128,51 @@
                 } elsif ($key =~ /^foil\.value\.(.*)$/) {
                     my $foil = $1;
                     $Partdata{$part}->{'_Foils'}->{$foil}->{'value'}=$value;
+                } elsif ($key eq 'answercomputed') {
+                    $Partdata{$part}->{'answercomputed'} = $value;
                 }
             }
         }
     }
+    # Further debugging code
+    if (0) {
+        &Apache::lonnet::logthis('lonstathelpers::get_problem_data');
+        &log_hash_ref(\%Partdata);
+    }
     return %Partdata;
 }
 
+sub log_array_ref {
+    my ($arrayref,$prefix) = @_;
+    return if (ref($arrayref) ne 'ARRAY');
+    if (! defined($prefix)) { $prefix = ''; };
+    foreach my $v (@$arrayref) {
+        if (ref($v) eq 'ARRAY') {
+            &log_array_ref($v,$prefix.'  ');
+        } elsif (ref($v) eq 'HASH') {
+            &log_hash_ref($v,$prefix.'  ');
+        } else {
+            &Apache::lonnet::logthis($prefix.'"'.$v.'"');
+        }
+    }
+}
+
+sub log_hash_ref {
+    my ($hashref,$prefix) = @_;
+    return if (ref($hashref) ne 'HASH');
+    if (! defined($prefix)) { $prefix = ''; };
+    while (my ($k,$v) = each(%$hashref)) {
+        if (ref($v) eq 'ARRAY') {
+            &Apache::lonnet::logthis($prefix.'"'.$k.'" = array');
+            &log_array_ref($v,$prefix.'  ');
+        } elsif (ref($v) eq 'HASH') {
+            &Apache::lonnet::logthis($prefix.'"'.$k.'" = hash');
+            &log_hash_ref($v,$prefix.'  ');
+        } else {
+            &Apache::lonnet::logthis($prefix.'"'.$k.'" => "'.$v.'"');
+        }
+    }
+}
 ####################################################
 ####################################################