jsxgraph / moodle-filter_jsxgraph

moodle plug-in for JSXGraph
https://jsxgraph.org
1 stars 6 forks source link

Can't include image → error ? #44

Closed ebugnet closed 1 month ago

ebugnet commented 1 month ago

Hi, I try to include picture like described in jsxGraph website using the Moodle Filter on a page on my Moodle 4.1.

My exemple code is :

<jsxgraph width="500" aspect-ratio="1/1">
    var brd = JXG.JSXGraph.initBoard(BOARDID, {boundingbox:[-5,5,5,-5], axis:true});
    var p = brd.create('point', [1,2]);
    var im = brd.create('image', ['https://jsxgraph.org/docs/symbols/static/logo.png', [-3,-2], [3,3] ]);
</jsxgraph>

Using ATTO in HTML mode, Firefox, Moodle 4.1, Boost Union theme.

When I do that, the jsxGraph place is blank, I got an error on the console linked to the view.php

Uncaught SyntaxError: missing ] after element list 
note: [ opened at line 1317, column 34

In fact, if I look at the source code of the generated moodle page, I can find this :

var im = brd.create('image', ['<a href="https://jsxgraph.org/docs/symbols/static/logo.png'" class="_blanktarget">https://jsxgraph.org/docs/symbols/static/logo.png'</a>, [-3,-2], [3,3] ]);

Like if Moodle change my picture reference and add a link.

Same effect using Chrome.

I don't know if it's a plugin effect, if this is the reason for blank graph, or only my Moodle instance...

Thanks for your tests.

Éric

andreas-web commented 1 month ago

Dear @ebugnet,

Thank you for your report. I tested your example and found that Moodle has a standard filter “Convert URLs into links and images”. This should be executed after JSXGraph. Otherwise, the link to the image is converted to HTML, which causes the board to crash. The order of the filters can be adjusted by the admins of your Moodle installation. I will also document the correct order in our README.md.

If the error still occurs after this change, please contact me again here and reopen the issue.

Andreas

ebugnet commented 1 month ago

It works, thanks !