[LON-CAPA-cvs] cvs: loncom /homework chemresponse.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 21 Jan 2005 22:11:00 -0000


albertel		Fri Jan 21 17:11:00 2005 EDT

  Modified files:              
    /loncom/homework	chemresponse.pm 
  Log:
  - after correct, show the instructor's structure.
  
  
Index: loncom/homework/chemresponse.pm
diff -u loncom/homework/chemresponse.pm:1.43 loncom/homework/chemresponse.pm:1.44
--- loncom/homework/chemresponse.pm:1.43	Fri Jan  7 22:54:32 2005
+++ loncom/homework/chemresponse.pm	Fri Jan 21 17:10:59 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # chemical equation style response
 #
-# $Id: chemresponse.pm,v 1.43 2005/01/08 03:54:32 albertel Exp $
+# $Id: chemresponse.pm,v 1.44 2005/01/21 22:10:59 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -136,17 +136,34 @@
     if ($target eq 'meta') {
 	$result=&Apache::response::meta_package_write('organicresponse');
     } elsif ($target eq 'web') {
-	my $molecule;
-	if (defined($Apache::lonhomework::history{"resource.$partid.$id.molecule"})) {
-	    $molecule=$Apache::lonhomework::history{"resource.$partid.$id.molecule"};
+	if (  &Apache::response::show_answer() ) {
+	    my $jmeanswer=&Apache::lonxml::get_param('jmeanswer',$parstack,
+						     $safeeval);
+	    my $options=&Apache::lonxml::get_param('options',$parstack,
+						   $safeeval);
+	    my $width=&Apache::lonxml::get_param('width',$parstack,
+						   $safeeval);
+	    my $id=&Apache::loncommon::get_cgi_id();
+	    $result="<img src='/cgi-bin/convertjme.pl?$id'";
+	    if ($options =~ /border/) { $result.= ' border="1"'; }
+	    $result.=' />';
+	    &Apache::lonnet::appenv('cgi.'.$id.'.JME'   =>
+				           &Apache::lonnet::escape($jmeanswer),
+				    'cgi.'.$id.'.PNG'   => 1,
+				    'cgi.'.$id.'.WIDTH' => $width);
 	} else {
-	    $molecule=&Apache::lonxml::get_param('molecule',$parstack,
-						 $safeeval);
+	    my $molecule;
+	    if (defined($Apache::lonhomework::history{"resource.$partid.$id.molecule"})) {
+		$molecule=$Apache::lonhomework::history{"resource.$partid.$id.molecule"};
+	    } else {
+		$molecule=&Apache::lonxml::get_param('molecule',$parstack,
+						     $safeeval);
+	    }
+	    my $options=&Apache::lonxml::get_param('options',$parstack,
+						   $safeeval);
+	    $result=&separate_jme_window("HWVAL_$id","MOLECULE_$id",$molecule,$options);
+	    $result.= '<input type="hidden" name="MOLECULE_'.$id.'" value="" />';
 	}
-	my $options=&Apache::lonxml::get_param('options',$parstack,
-					       $safeeval);
-	$result=&separate_jme_window("HWVAL_$id","MOLECULE_$id",$molecule,$options);
-	$result.= '<input type="hidden" name="MOLECULE_'.$id.'" value="" />';
     } elsif ($target eq 'edit') {
 	$result .=&Apache::edit::tag_start($target,$token);
 	my $options=&Apache::lonxml::get_param('options',$parstack,
@@ -178,12 +195,14 @@
 				      ['reaction','Is a reaction'],
 				      ['number','Able to number atoms'] ],
 					     ,$token);
+	$result .=&Apache::edit::text_arg('Width of correct answer image:',
+					  'width',$token,10);
 	$result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
     } elsif ($target eq 'modified') {
 	my $constructtag=&Apache::edit::get_new_args($token,$parstack,
 						     $safeeval,'molecule',
 						     'answer','jmeanswer',
-						     'options');
+						     'options','width');
 	if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
     }
     return $result;