maths / moodle-qtype_stack

Stack question type for Moodle
GNU General Public License v3.0
138 stars 147 forks source link

Geogebra Block example for creating new objects not working #1167

Open bgailer opened 2 months ago

bgailer commented 2 months ago

Hello, I recently started playing around with the new Geogebra Block. I wanted to try out an example from the docs on using commands inside [[geogebra]][[/geogebra]] blocks to define geogebra objects (https://docs.stack-assessment.org/en/Authoring/GeoGebra/#example-using-some-advanced-features). In the example, the following code is given:

[[geogebra]]
params["appletOnLoad"]=function(){appletObject.evalCommand("f(x):=x^3")}; 
[[/geogebra]]

However, this does not create the function in the Geogebra applet. I looked at the code for the Geogebra block and I think that the problem might be the variable appletObject but I could not figure out why. When I use applet.getAppletObject() in my code instead of the variable, the function gets plotted. Here is what works for me:

[[geogebra]]
params["appletOnLoad"]=function(){
//console.log(appletObject);
console.log(applet.getAppletObject());
applet.getAppletObject().evalCommand("f(x)=x^3");
}; 
[[/geogebra]]