// =2)) { $fixed=1; }
+ $result.=&plotvector_script($internalid,$label,$tailx,$taily,$tipx,$tipy,$xmin,$xmax,$fixed);
} elsif ($target eq 'edit') {
$result=&Apache::edit::tag_start($target,$token,'Plot Vector').
&Apache::edit::text_arg('Label on Plot:','label',
@@ -589,6 +649,95 @@ sub end_plotvector {
}
+#
+# Vector sum - have GeoGebra draw a sum of specified vectors to help students draw
+#
+
+sub start_drawvectorsum {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ my $result='';
+ my $internalid = $Apache::inputtags::part.'_'.$Apache::inputtags::response[-1];
+ my $tailx=&Apache::lonxml::get_param('tailx',$parstack,$safeeval);
+ my $taily=&Apache::lonxml::get_param('taily',$parstack,$safeeval);
+ my $showvalue=&Apache::lonxml::get_param('showvalue',$parstack,$safeeval);
+ my $vectorlist=&Apache::lonxml::get_param('vectorlist',$parstack,$safeeval);
+ my $label=&Apache::lonxml::get_param('label',$parstack,$safeeval);
+ $label=~s/\W//gs;
+ $label=ucfirst($label);
+ unless ($label) { $label="NewVector"; }
+ if ($target eq 'web') {
+ my ($xmin,$xmax,$ymin,$ymax)=&boundaries($parstack,$safeeval,-3);
+ unless (defined($tailx)) { $tailx=$xmin; }
+ unless (defined($taily)) { $taily=$ymin; }
+ unless (defined($vectorlist)) { $vectorlist=''; }
+ my @vectors=split(/\,/,$vectorlist);
+ if ($#vectors>0) {
+ my @sumx=();
+ my @sumy=();
+ foreach my $thisvector (@vectors) {
+ $thisvector=~s/\W//gs;
+ $thisvector=ucfirst($thisvector);
+ unless ($thisvector) { next; }
+ unless ($Apache::functionplotresponse::vectorlabels{$thisvector}) {
+ &Apache::lonxml::warning(&mt('Vectors must be defined before using them for drawing vector sums: [_1]',$thisvector));
+ next;
+ }
+ my $vectorx=$thisvector.'X';
+ my $vectory=$thisvector.'Y';
+ $result.=(<'.
+ &Apache::edit::text_arg('Vector List:','vectorlist',
+ $token,'40').
+ &Apache::edit::end_row();
+ } elsif ($target eq 'modified') {
+ $env{'form.'.&Apache::edit::html_element_name('label')}=ucfirst($env{'form.'.&Apache::edit::html_element_name('label')});
+ my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,'label','tailx','taily','showvalue','vectorlist');
+ if ($constructtag) { $result=&Apache::edit::rebuild_tag($token); }
+ }
+ return $result;
+}
+
+
+sub end_drawvectorsum {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ my $result='';
+ if ($target eq 'edit') {
+ $result=&Apache::edit::end_table();
+ }
+ return $result;
+}
+
+
#
#
@@ -1216,6 +1365,8 @@ sub start_functionplotresponse {
undef %Apache::functionplotresponse::previous;
$Apache::functionplotresponse::inputfields='';
$Apache::functionplotresponse::counter=0;
+# Remember vectors
+ undef %Apache::functionplotresponse::vectorlabels;
# Remember rules
undef @Apache::functionplotresponse::functionplotrules;
undef @Apache::functionplotresponse::functionplotvectorrules;
@@ -1289,27 +1440,16 @@ sub start_functionplotresponse {
($env{'form.answer_output_mode'} ne 'tex') &&
($Apache::lonhomework::viewgrades == 'F')) {
my (undef,undef,$udom,$uname)=&Apache::lonnet::whichuser();
- my $windowopen=&Apache::lonhtmlcommon::javascript_docopen();
- my $start_page = &Apache::loncommon::start_page('Rules Log', undef,
- {'only_body' => 1,
- 'bgcolor' => '#FFFFFF',
- 'js_ready' => 1,});
- my $end_page = &Apache::loncommon::end_page({'js_ready' => 1,});
$uname =~s/\W//g;
$udom =~s/\W//g;
my $function_name =
join('_','LONCAPA_scriptvars',$uname,$udom,
$env{'form.counter'},$Apache::lonxml::curdepth);
- my $rules_var ="".&mt('Rules Log')."
";
- &Apache::lonxml::add_script_result($rules_var);
- }
-
+ &Apache::lonxml::add_script_result(
+ &Apache::loncommon::modal_adhoc_window($function_name,700,500,
+ ''.$Apache::functionplotresponse::ruleslog.'
',
+ &mt('Rules Log'))."
");
+ }
return $result;
}
@@ -1680,7 +1820,7 @@ sub functionplotrulecheck {
#
# Evaluate the value
#
- if ($value=~/\D/) {
+ if (($value=~/\D/) && ($value ne 'undef')) {
$Apache::functionplotresponse::fpr_xmin=$xmin;
$Apache::functionplotresponse::fpr_xmax=$xmax;
$value=&Apache::run::run($value,$safeeval);
@@ -1997,8 +2137,6 @@ sub end_functionplotelements {
$result.=&geogebra_startcode($internalid,
&Apache::lonxml::get_param('width',$parstack,$safeeval,-2),
&Apache::lonxml::get_param('height',$parstack,$safeeval,-2));
-# load the spline bytecode
- $result.=&geogebra_spline_program();
# set default parameters
$result.=&geogebra_default_parameters($internalid);
# close the