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

matthew lon-capa-cvs@mail.lon-capa.org
Thu, 16 Oct 2003 15:24:49 -0000


matthew		Thu Oct 16 11:24:49 2003 EDT

  Modified files:              
    /loncom/interface/statistics	lonproblemanalysis.pm 
  Log:
  Removed code which strips leading and tailing whitespace from problem data
  because Guy told me to.  Minor changes otherwise.
  
  
Index: loncom/interface/statistics/lonproblemanalysis.pm
diff -u loncom/interface/statistics/lonproblemanalysis.pm:1.40 loncom/interface/statistics/lonproblemanalysis.pm:1.41
--- loncom/interface/statistics/lonproblemanalysis.pm:1.40	Thu Oct 16 09:23:13 2003
+++ loncom/interface/statistics/lonproblemanalysis.pm	Thu Oct 16 11:24:49 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 #
 
-# $Id: lonproblemanalysis.pm,v 1.40 2003/10/16 13:23:13 matthew Exp $
+# $Id: lonproblemanalysis.pm,v 1.41 2003/10/16 15:24:49 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -49,7 +49,8 @@
     #
     my @Students = @Apache::lonstatistics::Students;
     #
-    if (exists($ENV{'form.updatecaches'}) ||
+    if (exists($ENV{'form.ClearCache'}) || 
+        exists($ENV{'form.updatecaches'}) ||
         (exists($ENV{'form.firstanalysis'}) &&
          $ENV{'form.firstanalysis'} ne 'no')) {
         &Apache::lonstatistics::Gather_Full_Student_Data($r);
@@ -85,6 +86,7 @@
         #
         my $resource = &get_resource_from_symb($symb);
         if (defined($resource)) {
+            $r->print('<h3>'.$resource->{'src'}.'</h3>');
             my %Data = &get_problem_data($resource->{'src'});
             my $ORdata = $Data{$part.'.'.$resid};
             ##
@@ -149,6 +151,7 @@
 #########################################################
 sub build_foil_index {
     my ($ORdata) = @_;
+    return if (! exists($ORdata->{'Foils'}));
     my %Foildata = %{$ORdata->{'Foils'}};
     my @Foils = sort(keys(%Foildata));
     my %Concepts;
@@ -264,7 +267,7 @@
     my $table = "<table>\n";
     my $optionindex = 0;
     my @Rows;
-    foreach my $option ('correct',@{$ORdata->{'Options'}}) {
+    foreach my $option (&mt('correct option chosen'),@{$ORdata->{'Options'}}) {
         push (@Rows,
               '<tr>'.
               '<td bgcolor="'.$plotcolors->[$optionindex++].'">'.
@@ -307,7 +310,7 @@
     if ($ENV{'form.AnalyzeAs'} eq 'Foils') {
         $extrakey = &build_option_index($ORdata);
         $xlabel = 'Foil Number';
-        $ylabel = 'Option Chosen';
+        $ylabel = 'Percent Choosing Option';
         foreach my $foilid (@$Foils) {
             for (my $i=$mintries;$i<=$maxtries;$i++) {
                 foreach my $option ('_correct',@{$ORdata->{'Options'}}) {
@@ -415,8 +418,7 @@
                 for (my $i=0;$i<=$#Foilgrades;$i++) {
                     my ($foilid,$correct)  = split('=',$Foilgrades[$i]);
                     my (undef,$submission) = split('=',$Foilsubs[$i]);
-                    $submission = &HTML::Entities::decode($submission);
-                    $submission =~ s/\%20/ /g;
+                    $submission = &Apache::lonnet::unescape($submission);
                     if ($correct) {
                         $Trydata{$foilid}->[$numtries]->{'_correct'}++;
                     } else {
@@ -765,30 +767,23 @@
             $key =~ s/^$part\.//;
             if (ref($value) eq 'ARRAY') {
                 if ($key eq 'options') {
-                    for(my $i=0;$i<scalar(@$value);$i++) {
-                        $value->[$i]=~ s/(\s*$|^\s*)//g;
-                    }
                     $Partdata{$part}->{'Options'}=$value;
                 } elsif ($key eq 'concepts') {
                     $Partdata{$part}->{'Concepts'}=$value;
                 } elsif ($key =~ /^concept\.(.*)$/) {
                     my $concept = $1;
                     foreach my $foil (@$value) {
-                        $foil =~ s/(\s*$|^\s*)//g;
                         $Partdata{$part}->{'Foils'}->{$foil}->{'Concept'}=
                                                                       $concept;
                     }
                 }
             } else {
-                $value =~ s/(\s*$|^\s*)//g;
                 if ($key=~ /^foil\.text\.(.*)$/) {
                     my $foil = $1;
-                    $foil =~ s/(\s*$|^\s*)//g;
                     $Partdata{$part}->{'Foils'}->{$foil}->{'name'}=$foil;
                     $Partdata{$part}->{'Foils'}->{$foil}->{'text'}=$value;
                 } elsif ($key =~ /^foil\.value\.(.*)$/) {
                     my $foil = $1;
-                    $foil =~ s/(\s*$|^\s*)//g;
                     $Partdata{$part}->{'Foils'}->{$foil}->{'value'}=$value;
                 }
             }