--- loncom/homework/functionplotresponse.pm 2010/11/23 23:14:20 1.45
+++ loncom/homework/functionplotresponse.pm 2010/11/24 15:30:45 1.48
@@ -1,7 +1,7 @@
# LearningOnline Network with CAPA
# option list style responses
#
-# $Id: functionplotresponse.pm,v 1.45 2010/11/23 23:14:20 www Exp $
+# $Id: functionplotresponse.pm,v 1.48 2010/11/24 15:30:45 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -161,9 +161,11 @@ sub update_register {
# Set a point coordinate variable
#
sub set_point_coordinate {
- my ($id,$variable,$x,$y)=@_;
+ my ($id,$variable,$x,$y,$fixed)=@_;
+ my $mult=($fixed?'a*':'');
return (<'.
&Apache::edit::select_arg('Grid visible:','gridvisible',
- ['yes','no'],$token).
+ ['yes','no'],$token).'
'.
+ &Apache::edit::text_arg('Background plot(s) for answer (function:xmin:xmax,function:xmin:xmax,...):',
+ 'answerdisplay',$token,'50');
+
&Apache::edit::end_row().&Apache::edit::start_spanning_row();
} elsif ($target eq 'modified') {
my $constructtag=&Apache::edit::get_new_args($token,$parstack,
$safeeval,'xlabel','xmin','xmax','ylabel','ymin','ymax',
- 'xaxisvisible','yaxisvisible','gridvisible');
+ 'xaxisvisible','yaxisvisible','gridvisible','answerdisplay');
if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
} elsif ($target eq 'meta') {
@@ -1147,10 +1178,27 @@ sub end_functionplotelements {
if ($target eq 'edit' ) {
$result=&Apache::edit::end_table();
} elsif ($target eq 'web') {
-# Now is the time to render all of the stored splines
my ($xmin,$xmax,$ymin,$ymax)=&boundaries($parstack,$safeeval,-2);
+
+# Are we in show answer mode?
+ my $showanswer=&Apache::response::show_answer();
+ if ($showanswer) {
+# Render answerdisplay
+ my $answerdisplay=&Apache::lonxml::get_param('answerdisplay',$parstack,$safeeval,-2);
+ if ($answerdisplay=~/\S/s) {
+ foreach my $plot (split(/\s*\,\s*/,$answerdisplay)) {
+ my ($func,$xl,$xh)=split(/\s*\:\s*/,$plot);
+ if ((!defined($xl)) || ($xl eq '')) { $xl=$xmin; }
+ if ((!defined($xh)) || ($xh eq '')) { $xh=$xmax; }
+ $result.=&plot_script($internalid,$func,1,'','00aa00',$xl,$xh,6);
+ }
+ }
+ }
+ my $fixed=0;
+ if (($showanswer) || (&Apache::response::check_status()>=2)) { $fixed=1; }
+# Now is the time to render all of the stored splines
foreach my $label (keys(%Apache::functionplotresponse::splineorder)) {
- $result.=&generate_spline($internalid,$label,$xmin,$xmax,$ymin,$ymax);
+ $result.=&generate_spline($internalid,$label,$xmin,$xmax,$ymin,$ymax,$fixed);
}
# close the init script
$result.=&end_init_script();