[LON-CAPA-cvs] cvs: loncom /homework lonhomework.pm optionresponse.pm structuretags.pm /xml lonxml.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 29 Mar 2002 18:32:46 -0000


This is a MIME encoded message

--albertel1017426766
Content-Type: text/plain

albertel		Fri Mar 29 13:32:46 2002 EDT

  Modified files:              
    /loncom/homework	lonhomework.pm structuretags.pm optionresponse.pm 
    /loncom/xml	lonxml.pm 
  Log:
  - added new target anaylze addresses BUG#189
  - need to support more response types
  
  
--albertel1017426766
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20020329133246.txt"

Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.73 loncom/homework/lonhomework.pm:1.74
--- loncom/homework/lonhomework.pm:1.73	Fri Mar 22 15:11:00 2002
+++ loncom/homework/lonhomework.pm	Fri Mar 29 13:32:46 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.73 2002/03/22 20:11:00 albertel Exp $
+# $Id: lonhomework.pm,v 1.74 2002/03/29 18:32:46 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -61,6 +61,9 @@
       return ('web');
     }
   } elsif ($ENV{'request.state'} eq "construct") {
+    if ( defined($ENV{'form.grade_target'}) ) {
+      return ($ENV{'form.grade_target'});
+    }
     if ( defined($ENV{'form.preview'})) {
       if ( defined($ENV{'form.submitted'})) {
 	return ('grade', 'web');
@@ -270,6 +273,16 @@
   return $error;
 }
 
+sub analyze {
+  my ($request,$file) = @_;
+  &Apache::lonxml::debug("Analyze");
+  my $result=&Apache::lonnet::ssi($request->uri,('grade_target' => 'analyze'));
+  &Apache::lonxml::debug(":$result:");
+  (my $garbage,$result)=split(/_HASH_REF__/,$result,2);
+  &showhash(&Apache::lonnet::str2hash($result));
+  return $result;
+}
+
 sub editxmlmode {
   my ($request,$file) = @_;
   my $result;
@@ -319,6 +332,7 @@
     my $result = '';
     &Apache::inputtags::initialize_inputtags;
     &Apache::edit::initialize_edit;
+    if ($target eq 'analyze') { %Apache::lonhomework::anaylze=(); }
     if ($target eq 'web') {
       if (&Apache::lonnet::symbread() eq '') {
 	if ($ENV{'request.state'} eq "construct") {
@@ -343,6 +357,9 @@
     if ($target eq 'modified') {
       &handle_save_or_undo($request,\$problem,\$result);
     } else {
+      if ($target eq 'analyze') {
+	$result=&Apache::lonnet::hashref2str(\%Apache::lonhomework::analyze);
+      }
       #my $td=&tv_interval($t0);
       #if ( $Apache::lonxml::debug) {
 	#$result =~ s:</body>::;
@@ -454,7 +471,6 @@
   # the last one
   if ( defined($ENV{'form.problemmode'}) &&
        defined(@{ $ENV{'form.problemmode'} })) {
-    &Apache::lonxml::debug("3Problem Modes ".$ENV{'form.problemmode'});
     my $mode=$ENV{'form.problemmode'}->[-1];
     undef $ENV{'form.problemmode'};
     $ENV{'form.problemmode'}=$mode;
@@ -484,6 +500,8 @@
 	&renderpage($request,$file);
       } elsif ($ENV{'form.problemmode'} eq 'EditXML') {
 	&editxmlmode($request,$file);
+      } elsif ($ENV{'form.problemmode'} eq 'Answer Distribution') {
+	&analyze($request,$file);
       } else {
 	&renderpage($request,$file);
       }
@@ -493,6 +511,7 @@
     }
   } else {
     # just render the page normally outside of construction space
+    &Apache::lonxml::debug("not construct");
     &renderpage($request,$file);
   }
   #my $td=&tv_interval($t0);
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.86 loncom/homework/structuretags.pm:1.87
--- loncom/homework/structuretags.pm:1.86	Thu Mar 28 17:53:55 2002
+++ loncom/homework/structuretags.pm	Fri Mar 29 13:32:46 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.86 2002/03/28 22:53:55 albertel Exp $
+# $Id: structuretags.pm,v 1.87 2002/03/29 18:32:46 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -174,12 +174,14 @@
   $Apache::inputtags::part='0';
   @Apache::inputtags::responselist = ();
   @Apache::inputtags::previous=();
-  &initialize_storage();
-  if ($target eq 'web') {
-    &Apache::lonhomework::showhash(%Apache::lonhomework::history);
+  if ($target ne 'analyze') {
+    &initialize_storage();
+    if ($target eq 'web') {
+      &Apache::lonhomework::showhash(%Apache::lonhomework::history);
+    }
+    $Apache::lonhomework::type=&Apache::lonnet::EXT('resource.0.type');
+    &Apache::lonxml::debug("Found this to be of type :$Apache::lonhomework::type:");
   }
-  $Apache::lonhomework::type=&Apache::lonnet::EXT('resource.0.type');
-  &Apache::lonxml::debug("Found this to be of type :$Apache::lonhomework::type:");
   if ($Apache::lonhomework::type eq '') {
     my $uri=$ENV{'request.uri'};
     if ($uri=~/\.(\w+)$/) {
Index: loncom/homework/optionresponse.pm
diff -u loncom/homework/optionresponse.pm:1.33 loncom/homework/optionresponse.pm:1.34
--- loncom/homework/optionresponse.pm:1.33	Fri Jan 25 11:12:18 2002
+++ loncom/homework/optionresponse.pm	Fri Mar 29 13:32:46 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # option list style responses
 #
-# $Id: optionresponse.pm,v 1.33 2002/01/25 16:12:18 albertel Exp $
+# $Id: optionresponse.pm,v 1.34 2002/03/29 18:32:46 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -53,14 +53,15 @@
     $result.=&Apache::edit::text_arg('Max Number Of Shown Foils:','max',$token,'4').
         &Apache::edit::end_row().
 	&Apache::edit::start_spanning_row();
-  }
-  if ($target eq 'modified') {
+  } elsif ($target eq 'modified') {
     my $constructtag=&Apache::edit::get_new_args($token,$parstack,
 						 $safeeval,'max');
     if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
-  }
-  if ($target eq 'meta') {
+  } elsif ($target eq 'meta') {
     $result=&Apache::response::meta_package_write('optionresponse');
+  } elsif ($target eq 'analyze') {
+    my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
+    push (@{ $Apache::lonhomework::analyze{"parts"} },$part_id);
   }
 #  if ($target eq 'tex') {$result .= '\begin{itemize}';}
   return $result;
@@ -159,6 +160,16 @@
       $result.=&displayfoils($target,$count,@opt);
     } elsif ( $target eq 'answer') {
       $result.=&displayanswers($count,@opt);
+    } elsif ( $target eq 'analyze') {
+      my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
+      foreach my $name (@{ $Apache::response::foilgroup{'names'} }) {
+	if (defined($Apache::lonhomework::analyze{"$part_id.foil.value.$name"})) { next; }
+	push (@{ $Apache::lonhomework::analyze{"$part_id.foils"} },$name);
+	$Apache::lonhomework::analyze{"$part_id.foil.value.$name"} =
+	  $Apache::response::conceptgroup{"$name.value"};
+	$Apache::lonhomework::analyze{"$part_id.foil.text.$name"} =
+	  $Apache::response::conceptgroup{"$name.text"};
+      }
     } elsif ( $target eq 'grade') {
       if ( defined $ENV{'form.submitted'}) {
 	my @whichopt = &whichfoils($count);
@@ -171,8 +182,8 @@
 	  my $response = $ENV{'form.HWVAL_'.$Apache::inputtags::response['-1'].":$temp"};
 	  $responsehash{$name}=$response;
 	  if ( $response =~ /[^\s]/) {
-	    &Apache::lonxml::debug("submitted a $response<br />\n");
 	    my $value=$Apache::response::foilgroup{$name.'.value'};
+	    &Apache::lonxml::debug("submitted a $response for $value<br />\n");
 	    if ($value eq $response) {$right++;} else {$wrong++;}
 	  } else {
 	    $ignored++;
@@ -342,9 +353,21 @@
       $Apache::response::foilgroup{"$name.concept"} = $concept;
       &Apache::lonxml::debug("Selecting $name in $concept");
     }
-  }
-  if ($target eq 'edit') {
+  } elsif ($target eq 'edit') {
     $result=&Apache::edit::end_table();
+  } elsif ($target eq 'analyze') {
+    my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
+    my $concept = &Apache::lonxml::get_param('concept',$parstack,$safeeval);
+    push (@{ $Apache::lonhomework::analyze{"$part_id.concepts"} },$concept);
+    $Apache::lonhomework::analyze{"$part_id.concept.$concept"}=
+      $Apache::response::conceptgroup{'names'};
+    foreach my $name (@{ $Apache::response::conceptgroup{'names'} }) {
+      push (@{ $Apache::lonhomework::analyze{"$part_id.foils"} },$name);
+      $Apache::lonhomework::analyze{"$part_id.foil.value.$name"} =
+	$Apache::response::conceptgroup{"$name.value"};
+      $Apache::lonhomework::analyze{"$part_id.foil.text.$name"} =
+	$Apache::response::conceptgroup{"$name.text"};
+    }
   }
   return $result;
 }
@@ -357,7 +380,7 @@
 sub start_foil {
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   my $result='';
-  if ($target eq 'web' || $target eq 'tex') {
+  if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze' ) {
     &Apache::lonxml::startredirection;
   } elsif ($target eq 'edit') {
     $result=&Apache::edit::tag_start($target,$token,"Foil");
@@ -384,7 +407,7 @@
       $text=&Apache::lonxml::endredirection; 
   }
   if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' 
-      || $target eq 'tex') {
+      || $target eq 'tex' || $target eq 'analyze') {
     my $value = &Apache::lonxml::get_param('value',$parstack,$safeeval);
     if ($value ne 'unused') {
       my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.162 loncom/xml/lonxml.pm:1.163
--- loncom/xml/lonxml.pm:1.162	Mon Mar 25 15:06:08 2002
+++ loncom/xml/lonxml.pm	Fri Mar 29 13:32:46 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.162 2002/03/25 20:06:08 matthew Exp $
+# $Id: lonxml.pm,v 1.163 2002/03/29 18:32:46 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -630,7 +630,7 @@
 	  $finaloutput .= &Apache::run::evaluate($result,$safeeval,'');
 	}
 	$result = '';
-      } 
+      }
       if ($token->[0] eq 'E') { 
 	&end_tag($stack,$parstack,$token);
       }
@@ -814,6 +814,11 @@
     $Apache::lonxml::metamode = 0;
     $Apache::lonxml::evaluate = 0;
     $Apache::lonxml::import = 0;
+  } elsif ($target eq 'analyze') {
+    $Apache::lonxml::redirection = 0;
+    $Apache::lonxml::metamode = 0;
+    $Apache::lonxml::evaluate = 1;
+    $Apache::lonxml::import = 1;
   } else {
     $Apache::lonxml::redirection = 0;
     $Apache::lonxml::metamode = 0;
@@ -989,6 +994,7 @@
   my ($parser,$contentref,$dir) = @_;
   push (@$parser,HTML::TokeParser->new($contentref));
   $$parser['-1']->xml_mode('1');
+#  $$parser['-1']->attr_encoded('1');
   if ( $dir eq '' ) {
     push (@Apache::lonxml::pwd, $Apache::lonxml::pwd[$#Apache::lonxml::pwd]);
   } else {

--albertel1017426766--