version 1.47, 2010/11/24 02:53:13
|
version 1.56, 2011/03/30 14:47:55
|
Line 75 sub geogebra_default_parameters {
|
Line 75 sub geogebra_default_parameters {
|
<param name="boxborder" value="false" /> |
<param name="boxborder" value="false" /> |
<param name="centerimage" value="true" /> |
<param name="centerimage" value="true" /> |
<param name="cache_archive" value="geogebra.jar, geogebra_main.jar, geogebra_gui.jar, geogebra_cas.jar, geogebra_algos.jar, geogebra_export.jar, geogebra_javascript.jar, jlatexmath.jar, jlm_greek.jar, jlm_cyrillic.jar, geogebra_properties.jar" /> |
<param name="cache_archive" value="geogebra.jar, geogebra_main.jar, geogebra_gui.jar, geogebra_cas.jar, geogebra_algos.jar, geogebra_export.jar, geogebra_javascript.jar, jlatexmath.jar, jlm_greek.jar, jlm_cyrillic.jar, geogebra_properties.jar" /> |
<param name="cache_version" value="3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0, 3.9.115.0" /> |
<param name="cache_version" value="3.9.214.0, 3.9.214.0, 3.9.214.0, 3.9.214.0, 3.9.214.0, 3.9.214.0, 3.9.214.0, 3.9.214.0, 3.9.214.0, 3.9.214.0, 3.9.214.0" /> |
<param name="framePossible" value="false" /> |
<param name="framePossible" value="false" /> |
|
|
<param name="showResetIcon" value="false" /> |
<param name="showResetIcon" value="false" /> |
Line 108 sub init_script {
|
Line 108 sub init_script {
|
$script.="if (param=='applet_$id') { loaded_$id=true; }\n"; |
$script.="if (param=='applet_$id') { loaded_$id=true; }\n"; |
} |
} |
$script.="if (".join(' && ',map { "loaded_$_" } (@Apache::functionplotresponse::callscripts)). |
$script.="if (".join(' && ',map { "loaded_$_" } (@Apache::functionplotresponse::callscripts)). |
") { setTimeout('ggbInitAll()',20) }"; |
") { setTimeout('ggbInitAll()',200) }"; |
my $calls=join("\n",map { "ggbInit_$_();" } (@Apache::functionplotresponse::callscripts)); |
my $calls=join("\n",map { "ggbInit_$_();" } (@Apache::functionplotresponse::callscripts)); |
return (<<ENDGGBINIT); |
return (<<ENDGGBINIT); |
<script type="text/javascript"> |
<script type="text/javascript"> |
Line 161 sub update_register {
|
Line 161 sub update_register {
|
# Set a point coordinate variable |
# Set a point coordinate variable |
# |
# |
sub set_point_coordinate { |
sub set_point_coordinate { |
my ($id,$variable,$x,$y)=@_; |
my ($id,$variable,$x,$y,$fixed)=@_; |
|
my $mult=($fixed?'a*':''); |
return (<<ENDSETVARIABLE); |
return (<<ENDSETVARIABLE); |
document.ggbApplet_$id.evalCommand("$variable=($x,$y)"); |
document.ggbApplet_$id.evalCommand("a=1"); |
|
document.ggbApplet_$id.evalCommand("$variable=$mult($x,$y)"); |
document.ggbApplet_$id.setLabelVisible("$variable",false); |
document.ggbApplet_$id.setLabelVisible("$variable",false); |
ENDSETVARIABLE |
ENDSETVARIABLE |
} |
} |
Line 172 ENDSETVARIABLE
|
Line 174 ENDSETVARIABLE
|
# Set a slope coordinate variable |
# Set a slope coordinate variable |
# |
# |
sub set_slope_coordinate { |
sub set_slope_coordinate { |
my ($id,$variable,$xrel,$yrel,$xmin,$xmax,$ymin,$ymax,$pointname)=@_; |
my ($id,$variable,$xrel,$yrel,$xmin,$xmax,$ymin,$ymax,$pointname,$fixed)=@_; |
my $xvariable=$variable.'x'; |
my $xvariable=$variable.'x'; |
my $yvariable=$variable.'y'; |
my $yvariable=$variable.'y'; |
my $domain=$xmax-$xmin; |
my $domain=$xmax-$xmin; |
my $range=$ymax-$ymin; |
my $range=$ymax-$ymin; |
my $xinterval=$domain/100.; |
my $xinterval=$domain/100.; |
my $yinterval=$range/200.; |
my $yinterval=$range/200.; |
|
my $mult=($fixed?'a*':''); |
return (<<ENDSETSVARIABLE); |
return (<<ENDSETSVARIABLE); |
document.ggbApplet_$id.evalCommand("$xvariable=Slider[0,$domain,$xinterval]"); |
document.ggbApplet_$id.evalCommand("a=1"); |
|
document.ggbApplet_$id.evalCommand("$xvariable=Slider[$xinterval,$domain,$xinterval]"); |
document.ggbApplet_$id.setVisible("$xvariable", false); |
document.ggbApplet_$id.setVisible("$xvariable", false); |
document.ggbApplet_$id.evalCommand("$xvariable=$xrel"); |
document.ggbApplet_$id.evalCommand("$xvariable=$xrel"); |
document.ggbApplet_$id.evalCommand("$yvariable=Slider[-$range,$range,$yinterval]"); |
document.ggbApplet_$id.evalCommand("$yvariable=Slider[-$range,$range,$yinterval]"); |
document.ggbApplet_$id.setVisible("$yvariable", false); |
document.ggbApplet_$id.setVisible("$yvariable", false); |
document.ggbApplet_$id.evalCommand("$yvariable=$yrel"); |
document.ggbApplet_$id.evalCommand("$yvariable=$yrel"); |
document.ggbApplet_$id.evalCommand("$variable=($xvariable+x($pointname),$yvariable+y($pointname))"); |
document.ggbApplet_$id.evalCommand("$variable=$mult($xvariable+x($pointname),$yvariable+y($pointname))"); |
document.ggbApplet_$id.setLabelVisible("$variable", false); |
document.ggbApplet_$id.setLabelVisible("$variable", false); |
ENDSETSVARIABLE |
ENDSETSVARIABLE |
} |
} |
Line 215 sub generate_input_field {
|
Line 219 sub generate_input_field {
|
# Initialize a new point coordinate variable at set a listener on it |
# Initialize a new point coordinate variable at set a listener on it |
# |
# |
sub new_point_coordinate { |
sub new_point_coordinate { |
my ($id,$variable,$x,$y)=@_; |
my ($id,$variable,$x,$y,$fixed)=@_; |
if (defined($Apache::functionplotresponse::previous{&field_name($id,$variable,'x')})) { |
if (defined($Apache::functionplotresponse::previous{&field_name($id,$variable,'x')})) { |
$x=$Apache::functionplotresponse::previous{&field_name($id,$variable,'x')}; |
$x=$Apache::functionplotresponse::previous{&field_name($id,$variable,'x')}; |
} |
} |
Line 223 sub new_point_coordinate {
|
Line 227 sub new_point_coordinate {
|
$y=$Apache::functionplotresponse::previous{&field_name($id,$variable,'y')}; |
$y=$Apache::functionplotresponse::previous{&field_name($id,$variable,'y')}; |
} |
} |
&generate_input_field($id,$variable,$x,$y); |
&generate_input_field($id,$variable,$x,$y); |
return &set_point_coordinate($id,$variable,$x,$y).&update_register($id,$variable); |
return &set_point_coordinate($id,$variable,$x,$y,$fixed).&update_register($id,$variable); |
} |
} |
|
|
# |
# |
# Initialize a new slope coordinate variable at set a listener on it |
# Initialize a new slope coordinate variable at set a listener on it |
# |
# |
sub new_slope_coordinate { |
sub new_slope_coordinate { |
my ($id,$variable,$x,$y,$pointname,$xp,$yp,$xmin,$xmax,$ymin,$ymax)=@_; |
my ($id,$variable,$x,$y,$pointname,$xp,$yp,$xmin,$xmax,$ymin,$ymax,$fixed)=@_; |
# |
# |
# $variable: name of the slope point |
# $variable: name of the slope point |
# $x, $y: coordinates of the slope point |
# $x, $y: coordinates of the slope point |
Line 253 sub new_slope_coordinate {
|
Line 257 sub new_slope_coordinate {
|
&generate_input_field($id,$variable,$x,$y); |
&generate_input_field($id,$variable,$x,$y); |
my $xrel=$x-$xp; |
my $xrel=$x-$xp; |
my $yrel=$y-$yp; |
my $yrel=$y-$yp; |
return &set_slope_coordinate($id,$variable,$xrel,$yrel,$xmin,$xmax,$ymin,$ymax,$pointname).&update_register($id,$variable); |
return &set_slope_coordinate($id,$variable,$xrel,$yrel,$xmin,$xmax,$ymin,$ymax,$pointname,$fixed).&update_register($id,$variable); |
} |
} |
|
|
# |
# |
Line 366 sub plot_script {
|
Line 370 sub plot_script {
|
# |
# |
|
|
sub generate_spline { |
sub generate_spline { |
my ($id,$label,$xmin,$xmax,$ymin,$ymax)=@_; |
my ($id,$label,$xmin,$xmax,$ymin,$ymax,$fixed)=@_; |
my $result=''; |
my $result=''; |
my $order=$Apache::functionplotresponse::splineorder{$label}; |
my $order=$Apache::functionplotresponse::splineorder{$label}; |
my $x=$Apache::functionplotresponse::splineinitx{$label}; |
my $x=$Apache::functionplotresponse::splineinitx{$label}; |
Line 375 sub generate_spline {
|
Line 379 sub generate_spline {
|
my $sy=$Apache::functionplotresponse::splinescaley{$label}; |
my $sy=$Apache::functionplotresponse::splinescaley{$label}; |
my @coords=(); |
my @coords=(); |
foreach my $i (1..$order) { |
foreach my $i (1..$order) { |
$result.=&new_point_coordinate($id,$label.'P'.$i,$x,$y); |
$result.=&new_point_coordinate($id,$label.'P'.$i,$x,$y,$fixed); |
my $xp=$x; |
my $xp=$x; |
$x+=$sx/(2.*($order-1)); |
$x+=$sx/(2.*($order-1)); |
push(@coords,$label.'P'.$i); |
push(@coords,$label.'P'.$i); |
$result.=&new_slope_coordinate($id,$label.'S'.$i,$x,$y+$sy,$label.'P'.$i,$xp,$y,$xmin,$xmax,$ymin,$ymax); |
$result.=&new_slope_coordinate($id,$label.'S'.$i,$x,$y+$sy,$label.'P'.$i,$xp,$y,$xmin,$xmax,$ymin,$ymax,$fixed); |
$x+=$sx/(2.*($order-1)); |
$x+=$sx/(2.*($order-1)); |
push(@coords,$label.'S'.$i); |
push(@coords,$label.'S'.$i); |
} |
} |
Line 532 sub start_functionplotrule {
|
Line 536 sub start_functionplotrule {
|
$token,'8'). |
$token,'8'). |
&Apache::edit::end_row(); |
&Apache::edit::end_row(); |
} elsif ($target eq 'modified') { |
} elsif ($target eq 'modified') { |
|
if (($env{'form.'.&Apache::edit::html_element_name('xinitial')} ne '') && ($env{'form.'.&Apache::edit::html_element_name('xinitiallabel')} eq 'start')) { |
|
$env{'form.'.&Apache::edit::html_element_name('xinitiallabel')}=''; |
|
} |
|
if (($env{'form.'.&Apache::edit::html_element_name('xfinal')} ne '') && ($env{'form.'.&Apache::edit::html_element_name('xfinallabel')} eq 'end')) { |
|
$env{'form.'.&Apache::edit::html_element_name('xfinallabel')}=''; |
|
} |
my $constructtag=&Apache::edit::get_new_args($token,$parstack, |
my $constructtag=&Apache::edit::get_new_args($token,$parstack, |
$safeeval,'index','derivativeorder', |
$safeeval,'index','derivativeorder', |
'xinitial','xinitiallabel','xfinal','xfinallabel', |
'xinitial','xinitiallabel','xfinal','xfinallabel', |
Line 812 sub start_functionplotresponse {
|
Line 822 sub start_functionplotresponse {
|
.'<tr><td><span class="LC_nobreak">'.&mt('Function Plot Question').'</span></td>' |
.'<tr><td><span class="LC_nobreak">'.&mt('Function Plot Question').'</span></td>' |
.'<td><span class="LC_nobreak">'.&mt('Delete?').' ' |
.'<td><span class="LC_nobreak">'.&mt('Delete?').' ' |
.&Apache::edit::deletelist($target,$token).' ' |
.&Apache::edit::deletelist($target,$token).' ' |
.&Apache::edit::insertlist($target,$token) |
.&Apache::edit::insertlist($target,$token).' ' |
|
.&Apache::loncommon::help_open_topic('Function_Plot_Response_Question','Function Plot Responses') |
.'</span></td>' |
.'</span></td>' |
."<td> " |
."<td> " |
.&Apache::edit::end_row() |
.&Apache::edit::end_row() |
Line 939 sub functionplotrulecheck {
|
Line 950 sub functionplotrulecheck {
|
$percent=($percent>0?$percent:5); |
$percent=($percent>0?$percent:5); |
&addlog("================="); |
&addlog("================="); |
&addlog("Rule $label for ".($derivative<0?'integral':('function itself','first derivative','second derivative')[$derivative])." $relationship $value"); |
&addlog("Rule $label for ".($derivative<0?'integral':('function itself','first derivative','second derivative')[$derivative])." $relationship $value"); |
|
if ((defined($minimumlength)) || (defined($maximumlength))) { |
|
&addlog("Minimumlength $minimumlength Maximumlength $maximumlength"); |
|
} |
my $li=0; |
my $li=0; |
my $lh=400; |
my $lh=400; |
|
|
Line 1033 sub functionplotrulecheck {
|
Line 1047 sub functionplotrulecheck {
|
&addlog("Actual value ".(defined($val)?$val:'undef').", expected $value, tolerance $tol"); |
&addlog("Actual value ".(defined($val)?$val:'undef').", expected $value, tolerance $tol"); |
&addlog("Condition not fulfilled at x=".&actualval($i,$xmin,$xmax)." (".$Apache::functionplotresponse::actualxval[$i]."; index $i)"); |
&addlog("Condition not fulfilled at x=".&actualval($i,$xmin,$xmax)." (".$Apache::functionplotresponse::actualxval[$i]."; index $i)"); |
if (($findupper) && ($i>$li)) { |
if (($findupper) && ($i>$li)) { |
# check for minimum and maximum lengths |
# Check lengths |
my $length=&actualval($i,$xmin,$xmax)-&actualval($li,$xmin,$xmax); |
unless (&checklength($i,$li,$minimumlength,$maximumlength,$xmin,$xmax,$label)) { return 0; } |
if ($minimumlength) { |
# Successfully found a new label, set it |
if ($length<$minimumlength) { |
|
&addlog("Rule $label failed, actual length $length, minimum length $minimumlength"); |
|
return 0; |
|
} |
|
} |
|
if ($maximumlength) { |
|
if ($length>$maximumlength) { |
|
&addlog("Rule $label failed, actual length $length, maximum length $maximumlength"); |
|
return 0; |
|
} |
|
} |
|
$Apache::functionplotresponse::functionplotrulelabels{$xfinallabel}=$i; |
$Apache::functionplotresponse::functionplotrulelabels{$xfinallabel}=$i; |
&addlog("Rule $label passed, setting label $xfinallabel"); |
&addlog("Rule $label passed, setting label $xfinallabel"); |
return 1; |
return 1; |
} else { |
} else { |
&addlog("Rule $label failed."); |
&addlog("Rule $label failed."); |
my $hintlabel=$label; |
&setfailed($label); |
$hintlabel=~s/^R//; |
|
push(@Apache::functionplotresponse::failedrules,$hintlabel); |
|
&addlog("Set hint condition $hintlabel"); |
|
return 0; |
return 0; |
} |
} |
} |
} |
} |
} |
} |
} |
|
# Corner case where this makes sense: using start or stop as defined labels |
|
unless (&checklength($lh,$li,$minimumlength,$maximumlength,$xmin,$xmax,$label)) { return 0; } |
&addlog("Rule $label passed."); |
&addlog("Rule $label passed."); |
return 1; |
return 1; |
} |
} |
|
|
|
# |
|
# check for minimum and maximum lengths |
|
# |
|
|
|
sub checklength { |
|
my ($i,$li,$minimumlength,$maximumlength,$xmin,$xmax,$label)=@_; |
|
unless (($minimumlength) || ($maximumlength)) { return 1; } |
|
my $length=&actualval($i,$xmin,$xmax)-&actualval($li,$xmin,$xmax); |
|
if ($minimumlength) { |
|
if ($length<$minimumlength) { |
|
&addlog("Rule $label failed, actual length $length, minimum length $minimumlength"); |
|
&setfailed($label); |
|
return 0; |
|
} |
|
} |
|
if ($maximumlength) { |
|
if ($length>$maximumlength) { |
|
&addlog("Rule $label failed, actual length $length, maximum length $maximumlength"); |
|
&setfailed($label); |
|
return 0; |
|
} |
|
} |
|
return 1; |
|
} |
|
|
|
sub setfailed { |
|
my ($label)=@_; |
|
my $hintlabel=$label; |
|
$hintlabel=~s/^R//; |
|
push(@Apache::functionplotresponse::failedrules,$hintlabel); |
|
&addlog("Set hint condition $hintlabel"); |
|
} |
|
|
sub start_functionplotruleset { |
sub start_functionplotruleset { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
if ($target eq 'edit') { |
if ($target eq 'edit') { |
Line 1072 sub start_functionplotruleset {
|
Line 1107 sub start_functionplotruleset {
|
'<tr><td><span class="LC_nobreak">'.&mt('Function Plot Rule Set').'</span></td>' |
'<tr><td><span class="LC_nobreak">'.&mt('Function Plot Rule Set').'</span></td>' |
.'<td><span class="LC_nobreak">'.&mt('Delete?').' ' |
.'<td><span class="LC_nobreak">'.&mt('Delete?').' ' |
.&Apache::edit::deletelist($target,$token).' '. |
.&Apache::edit::deletelist($target,$token).' '. |
&Apache::edit::insertlist($target,$token) |
&Apache::edit::insertlist($target,$token).' ' |
|
.&Apache::loncommon::help_open_topic('Function_Plot_Response_Rule_Set','Function Plot Rules') |
.'</span></td>' |
.'</span></td>' |
."<td> " |
."<td> " |
.&Apache::edit::end_row() |
.&Apache::edit::end_row() |
Line 1190 sub end_functionplotelements {
|
Line 1226 sub end_functionplotelements {
|
} |
} |
} |
} |
} |
} |
|
my $fixed=0; |
|
if (($showanswer) || (&Apache::response::check_status()>=2)) { $fixed=1; } |
# Now is the time to render all of the stored splines |
# Now is the time to render all of the stored splines |
foreach my $label (keys(%Apache::functionplotresponse::splineorder)) { |
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 |
# close the init script |
$result.=&end_init_script(); |
$result.=&end_init_script(); |
Line 1249 sub start_functionplotelements {
|
Line 1286 sub start_functionplotelements {
|
'<tr><td><span class="LC_nobreak">'.&mt('Function Plot Elements').'</span></td>' |
'<tr><td><span class="LC_nobreak">'.&mt('Function Plot Elements').'</span></td>' |
.'<td><span class="LC_nobreak">'.&mt('Delete?').' ' |
.'<td><span class="LC_nobreak">'.&mt('Delete?').' ' |
.&Apache::edit::deletelist($target,$token).' '. |
.&Apache::edit::deletelist($target,$token).' '. |
&Apache::edit::insertlist($target,$token) |
&Apache::edit::insertlist($target,$token).' ' |
|
.&Apache::loncommon::help_open_topic('Function_Plot_Response_Elements','Function Plot Elements') |
.'</span></td>' |
.'</span></td>' |
."<td> " |
."<td> " |
.&Apache::edit::end_row() |
.&Apache::edit::end_row() |