jsxgraph / moodle-filter_jsxgraph

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

Warning: constants are already defined (ALLOWED_DIMS, AR, ALLOWED_DIMS_EXCEPT_AR, WIDTHS) #37

Closed mazitov-az closed 11 months ago

mazitov-az commented 11 months ago

Hello!

I`m using:

Here`s my error log: Type: Warning Error message: Constant ALLOWED_DIMS already defined File: /moodle_path/filter/jsxgraph/filter.php Line: 411

There are same errors with constants:

I tried to preview quiz question, which uses jsgraph filter. During page rendering, function, described below, has been called several times:

    private function get_board_html(...) 
    {
        ...
        define('ALLOWED_DIMS', ["aspect-ratio", "width", "height", "max-width", "max-height"]);
        define('AR', "aspect-ratio");
        define('ALLOWED_DIMS_EXCEPT_AR', ["width", "height", "max-width", "max-height"]);
        define('WIDTHS', ["width", "max-width"]);
        ...

So on it`s second call function tries to define some global constants, that were already defined at previous call. This causes an error.

My suggestion is to move these constants to the class context. #38

andreas-web commented 11 months ago

Closed by #f2fff79d80e93963cd04470c303999867df38c07.

Thank you for your suggestion!