Formulas and JSXGraph

Formulas and JSXGraph

de Matthias Giger -
Number of replies: 8
Imachen de Particularly helpful Moodlers

When I try to use the example provided on the Github JSXGraph plugin for Formulas (https://github.com/jsxgraph/moodleformulas_jsxgraph) I don't get the expected view.

screen2

All I get is a JavaScript error in the console:

Uncaught TypeError: Cannot read properties of null (reading 'querySelectorAll')
    at new JSXQuestion (JSXQuestion.js:102:25)
    at preview.php?id=75240&restartversion=0&courseid=158:2247:5

Can anybody confirm that that Example is working with Moodle 4.4.3?

JSXGraph is installed and the filter activated. In fact JSXGraph questions work, as long as I don't use the var jsxCode = function (question) construct.

 
Promeyo de puntuacions: -
In reply to Matthias Giger

Re: Formulas and JSXGraph

de Dominique Bauer -
Imachen de Documentation writers Imachen de Particularly helpful Moodlers Imachen de Plugin developers

Matthias,

On a fresh installation of Moodle 4.4.3+ on my Windows computer, this example question functions perfectly.

I used the latest version of the plugins:

  • Formulas question type: Release 5.3.3 for Moodle 3.9+
  • JSXGraph: Release v1.9.1

Don't forget to:

  • Activate "question type formulas" in Site adminstration / Plugins / Plugins overview / JSXGraph / Settings
  • Enable JSXGraph in Site administration / Filters / Manage filters
In reply to Dominique Bauer

Re: Formulas and JSXGraph

de Matthias Giger -
Imachen de Particularly helpful Moodlers
Thanks a lot for your reply. Unfortunatelly my plugin versions and the setting are all as suggested but the question is still not working.

Could you provide me with a link to an example where I can download the whole question (just to make sure I don't have a silly mistake in my version)?
In reply to Dominique Bauer

Re: Formulas and JSXGraph

de Matthias Giger -
Imachen de Particularly helpful Moodlers
I found the problem: The question only works if you put the JSXGraph code (as described) in part 1.

That begs the question: Is there any way you can put the code into the main part and then ask several questions about it in parts 1 to n?
In reply to Matthias Giger

Re: Formulas and JSXGraph

de Dominique Bauer -
Imachen de Documentation writers Imachen de Particularly helpful Moodlers Imachen de Plugin developers

Hello Matthias,

Is there any way you can put the code into the main part and then ask several questions about it in parts 1 to n?

Absolutely. A big thank you to Andreas Walter from GSXGraph for showing us how to do it. In fact, it's quite simple. Note that although excellent, the GSXGraph Formulas extension is not used here.

I will provide an example later with questions in parts 1 to n about a graph in the main part.

For now, please consider the following example, which demonstrates how easy it is to transfer data from a GSXGraph graph to the Formulas question using a few simple lines of JavaScript. You can try it at DynamicCourseware.org / Tools / Graphs and calculations / (x, y) coordinates➚.

MoodleForum_20241008_1510.png?time=1728416444693

MoodleForum_20241008_1512.png

In reply to Matthias Giger

Re: Formulas and JSXGraph

de Dominique Bauer -
Imachen de Documentation writers Imachen de Particularly helpful Moodlers Imachen de Plugin developers

Matthias,

Here is the GitHub example with the graph in the main section and related questions in two parts. We can have questions in as many parts as we want. The JavaScript code is really simple. Although excellent, the GSXGraph Formulas extension is not used here. In this example, the input boxes are displayed but they only serve to show the values transferred from the GSXGraph plot. With a bit of formatting, the question becomes a true masterpiece of simplicity and elegance.

You can try it at DynamicCourseware.org / Tools / Graphs and calculations / Position points on a line➚.

MoodleForum_20241009_0032.png

MoodleForum_20241009_0033.png

In reply to Dominique Bauer

Re: Formulas and JSXGraph

de Matthias Giger -
Imachen de Particularly helpful Moodlers
Thanks a lot for your examples, they are most helpful.

In the meantime, I've written a bar graph question which uses different scales.
The main problem I had was to make sure the entered values are graded correctly within a reasonable range. Please feel free to use it.
In reply to Matthias Giger

Re: Formulas and JSXGraph

de Dominique Bauer -
Imachen de Documentation writers Imachen de Particularly helpful Moodlers Imachen de Plugin developers

Hello Matthias,

Thank you for your bar graph question.

The height adjustment of the bars is continuous, which indeed makes the task more challenging both for its development and for students. It would have been easier to "snap" the height adjustment. Was it intentional that you did not implement the snap feature? If yes, could you explain in what context this is necessary, for example if snapping would have made the question too easy for students.