diff --git a/vle_specific.php b/vle_specific.php index 24953878dcb83ae44ba4349aff05b73dac526fec..516a56f25505f2fb0d62b714cafa932032774fce 100644 --- a/vle_specific.php +++ b/vle_specific.php @@ -189,8 +189,27 @@ function stack_cors_link(string $filename): string { * Gets the URL used for MathJax, might be VLE local. */ function stack_get_mathjax_url(): string { - // TODO: figure out how to support VLE local with CORS. - return 'https://cdn.jsdelivr.net/npm/mathjax@2.7.9/MathJax.js?config=TeX-AMS-MML_HTMLorMML'; + // HSH patch - 2024.05.31: Elke Kreim - elke.kreim@hs-hannover.de + // include fix https://github.com/maths/moodle-qtype_stack/pull/1194/files + // to use local installation of MathHax configured in plugin filter_mathjaxloader + $mathjaxconfigurl = get_config('filter_mathjaxloader', 'httpsurl'); + if ($mathjaxconfigurl) { + $questionpos = strpos($mathjaxconfigurl, '?'); + if ($questionpos !== false) { + $querystring = substr($mathjaxconfigurl, $questionpos + 1); + $urlstring = substr($mathjaxconfigurl, 0, $questionpos); + parse_str($querystring, $queryparams); + $queryparams = array_merge(['config' => 'TeX-AMS-MML_HTMLorMML'], $queryparams); + $querystring = http_build_query($queryparams, null, '&', PHP_QUERY_RFC3986); + $url = $urlstring . '?' . $querystring; + } else { + $url = $mathjaxconfigurl . '?config=TeX-AMS-MML_HTMLorMML'; + } + + return $url; + } else { + return 'https://cdn.jsdelivr.net/npm/mathjax@2.7.9/MathJax.js?config=TeX-AMS-MML_HTMLorMML'; + } } /*