[LON-CAPA-cvs] cvs: loncom /homework chemresponse.pm grades.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Thu, 26 May 2005 21:26:27 -0000
albertel Thu May 26 17:26:27 2005 EDT
Modified files:
/loncom/homework grades.pm chemresponse.pm
Log:
- teach PGRD about <organicresponse>
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.267 loncom/homework/grades.pm:1.268
--- loncom/homework/grades.pm:1.267 Thu May 26 17:15:04 2005
+++ loncom/homework/grades.pm Thu May 26 17:26:24 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.267 2005/05/26 21:15:04 albertel Exp $
+# $Id: grades.pm,v 1.268 2005/05/26 21:26:24 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -284,6 +284,11 @@
}
$answer =~ s-\n-<br />-g;
return '<br /><br /><blockquote><tt>'.&keywords_highlight($answer).'</tt></blockquote>';
+ } elsif ( $response eq 'organic') {
+ my $result='Smile representation: "<tt>'.$answer.'</tt>"';
+ my $jme=$record->{$version."resource.$partid.$respid.molecule"};
+ $result.=&Apache::chemresponse::jme_img($jme,$answer,400);
+ return $result;
}
return $answer;
}
Index: loncom/homework/chemresponse.pm
diff -u loncom/homework/chemresponse.pm:1.55 loncom/homework/chemresponse.pm:1.56
--- loncom/homework/chemresponse.pm:1.55 Thu May 26 16:59:47 2005
+++ loncom/homework/chemresponse.pm Thu May 26 17:26:25 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# chemical equation style response
#
-# $Id: chemresponse.pm,v 1.55 2005/05/26 20:59:47 albertel Exp $
+# $Id: chemresponse.pm,v 1.56 2005/05/26 21:26:25 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -132,6 +132,19 @@
return $result;
}
+sub jme_img {
+ my ($jme,$smile,$width,$options)=@_;
+ my $id=&Apache::loncommon::get_cgi_id();
+ my $result='<img alt="'.$smile.'" src="/cgi-bin/convertjme.pl?'.$id.'"';
+ if ($options =~ /border/) { $result.= ' border="1"'; }
+ $result.=' />';
+ &Apache::lonnet::appenv('cgi.'.$id.'.JME' =>
+ &Apache::lonnet::escape($jme),
+ 'cgi.'.$id.'.PNG' => 1,
+ 'cgi.'.$id.'.WIDTH' => $width);
+ return $result;
+}
+
sub start_organicresponse {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $result;
@@ -147,14 +160,9 @@
$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);
+ my (@answers)=&Apache::lonxml::get_param_var('answer',$parstack,
+ $safeeval);
+ $result.=&jme_img($jmeanswer,$answers[0],$width,$options);
} else {
my $molecule;
if (defined($Apache::lonhomework::history{"resource.$partid.$id.molecule"})) {