--- loncom/homework/chemresponse.pm 2006/04/13 18:57:51 1.65
+++ loncom/homework/chemresponse.pm 2006/07/03 01:16:04 1.68
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# chemical equation style response
#
-# $Id: chemresponse.pm,v 1.65 2006/04/13 18:57:51 albertel Exp $
+# $Id: chemresponse.pm,v 1.68 2006/07/03 01:16:04 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -31,6 +31,9 @@ use strict;
use Apache::lonxml;
use Apache::lonnet;
use Apache::lonlocal;
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
+
BEGIN {
&Apache::lonxml::register('Apache::chemresponse',('organicresponse','organicstructure','reactionresponse','chem'));
@@ -174,7 +177,7 @@ sub jme_img {
if ($options =~ /border/) { $result.= ' border="1"'; }
$result.=' />';
&Apache::lonnet::appenv('cgi.'.$id.'.JME' =>
- &Apache::lonnet::escape($jme),
+ &escape($jme),
'cgi.'.$id.'.PNG' => 1,
'cgi.'.$id.'.WIDTH' => $width);
return $result;
@@ -232,7 +235,8 @@ sub start_organicresponse {
$result .='
';
$result .=&Apache::edit::text_arg('Correct Answer:','answer',
$token,40);
- $result .=&Apache::edit::hidden_arg('jmeanswer',$token);
+ $result .=&Apache::edit::text_arg('JME string of the answer (automatically updated when using the Draw Molecule button):',
+ 'jmeanswer',$token);
my $jmeanswer=&Apache::lonxml::get_param('jmeanswer',$parstack,
$safeeval);
$result .=&separate_jme_window(
@@ -333,7 +337,7 @@ sub start_organicstructure {
if ($options =~ /border/) { $result.= ' border="1"'; }
$result.=' />';
&Apache::lonnet::appenv(
- 'cgi.'.$id.'.JME' => &Apache::lonnet::escape($molecule),
+ 'cgi.'.$id.'.JME' => &escape($molecule),
'cgi.'.$id.'.PNG' => 1,
'cgi.'.$id.'.WIDTH' => $width );
} elsif ($target eq 'tex') {
@@ -349,10 +353,10 @@ sub start_organicstructure {
'_'.time.'_'.$$.int(rand(1000)).'_organicstructure';
my $id=$filename;
&Apache::lonnet::appenv(
- 'cgi.'.$id.'.JME' => &Apache::lonnet::escape($molecule),
+ 'cgi.'.$id.'.JME' => &escape($molecule),
'cgi.'.$id.'.PS' => 1,
'cgi.'.$id.'.WIDTH' => $texwidth );
- $id=&Apache::lonnet::escape($id);
+ $id=&escape($id);
&Apache::lonxml::register_ssi("/cgi-bin/convertjme.pl?$id");
if ($options =~ /border/) { $result.= '\fbox{'; }
$result .= '\graphicspath{{/home/httpd/perl/tmp/}}\includegraphics[width='.$texwidth.' mm]{'.$filename.'.eps}';
@@ -401,16 +405,16 @@ sub end_organicstructure {
sub edit_reaction_button {
my ($id,$field,$reaction)=@_;
- my $id_es=&Apache::lonnet::escape($id);
- my $field_es=&Apache::lonnet::escape($field);
- my $reaction_es=&Apache::lonnet::escape($reaction);
+ my $id_es=&escape($id);
+ my $field_es=&escape($field);
+ my $reaction_es=&escape($reaction);
my $docopen=&Apache::lonhtmlcommon::javascript_docopen();
my $start_page =
&Apache::loncommon::start_page('LON-CAPA Reaction Editor',undef,
{'frameset' => 1,
'js_ready' => 1,
'add_entries' => {
- 'rows' => "30%",
+ 'rows' => "30%,*",
'border' => "0",}},);
my $end_page =
&Apache::loncommon::end_page({'frameset' => 1,
@@ -422,6 +426,7 @@ sub edit_reaction_button {
editor=window.open('','','width=500,height=270,scrollbars=no,resizable=yes');
editor.$docopen;
editor.document.writeln('$start_page $end_page');
+ editor.document.close();
}
// -->