diff options
author | Jean-Michel Vedrine <vedrine@vedrine.org> | 2016-01-24 13:18:38 +0100 |
---|---|---|
committer | Jean-Michel Vedrine <vedrine@vedrine.org> | 2016-01-24 13:20:41 +0100 |
commit | e0abd45dc194f7ede2b460c6e9c2c303d4321bd7 (patch) | |
tree | ca54f942ddac9c4cce62db73a8ee90c074331590 | |
parent | ab2016462cb7204f8e5e7fb6e5b9bdf1f4db68c6 (diff) |
Solve display using MathJax for all websites
-rw-r--r-- | README.txt | 2 | ||||
-rw-r--r-- | displayformula.php | 9 | ||||
-rw-r--r-- | lib.php | 5 | ||||
-rw-r--r-- | parser.php | 12 | ||||
-rw-r--r-- | question.php | 1 | ||||
-rw-r--r-- | questiontype.php | 1 | ||||
-rw-r--r-- | version.php | 4 |
7 files changed, 26 insertions, 8 deletions
@@ -26,7 +26,7 @@ Updated to Moodle 2.0 by Stefan Raffeiner <stefan.raffeiner@gmail.com> Updated to Moodle 2.1 by Jean-Michel VĂ©drine <vedrine@univ-st-etienne.fr> This plugin is now maintained by Jean-Michel VĂ©drine. This version is upgraded to -work with Moodle 2.5. +work with Moodle 2.8 and ulteriors versions. For support use the Moodle quiz forum at https://moodle.org/mod/forum/view.php?id=737 Enjoy. diff --git a/displayformula.php b/displayformula.php index 788304b..58723f1 100644 --- a/displayformula.php +++ b/displayformula.php @@ -62,8 +62,15 @@ $text = format_text($texexp, FORMAT_MOODLE, $formatoptions); <title>Formula</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <?php + if (!empty($CFG->additionalhtmlhead) && stripos($CFG->additionalhtmlhead, 'MathJax') !== false) { - echo $CFG->additionalhtmlhead; + // For website where Mathjax is enabled using additional HTML in head. + echo $CFG->additionalhtmlhead; +} else { + // For other website directly include MathJax. + echo "<script type=\"text/javascript\" async + src=\"https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML\"> +</script>"; } ?> </head> @@ -17,9 +17,8 @@ /** * Serve question type files * - * @since 2.0 - * @package qtype - * @subpackage algebra + * @since Moodle 2.0 + * @package qtype_algebra * @copyright Dongsheng Cai <dongsheng@moodle.com> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -1336,10 +1336,20 @@ class qtype_algebra_parser_bracket extends qtype_algebra_parser_term { * @return the numerical value of the term given the provided values for the variables */ function evaluate($params) { + if($this->_sign=='-') { + $mult=-1; + } else { + $mult=1; + } if(count($this->_arguments)!=$this->_nargs) { return 0; } - return $this->_arguments[0]->evaluate($params); + return $mult*$this->_arguments[0]->evaluate($params); + } + + function set_negative() { + // Set the sign to be a '-' + $this->_sign='-'; } /** diff --git a/question.php b/question.php index 7d585bb..52eea54 100644 --- a/question.php +++ b/question.php @@ -25,6 +25,7 @@ defined('MOODLE_INTERNAL') || die(); +require_once($CFG->dirroot . '/question/type/questionbase.php'); require_once($CFG->dirroot . '/question/type/algebra/questiontype.php'); require_once($CFG->dirroot . '/question/type/algebra/parser.php'); require_once($CFG->dirroot . '/question/type/algebra/xmlrpc-utils.php'); diff --git a/questiontype.php b/questiontype.php index d8672b9..a49698a 100644 --- a/questiontype.php +++ b/questiontype.php @@ -24,6 +24,7 @@ defined('MOODLE_INTERNAL') || die(); +require_once($CFG->dirroot . '/question/type/questiontypebase.php'); require_once($CFG->dirroot . '/question/type/algebra/question.php'); require_once($CFG->dirroot . '/question/type/algebra/parser.php'); require_once($CFG->dirroot . '/question/type/algebra/xmlrpc-utils.php'); diff --git a/version.php b/version.php index 2f734d9..0b2f746 100644 --- a/version.php +++ b/version.php @@ -23,8 +23,8 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qtype_algebra'; -$plugin->version = 2014110800; +$plugin->version = 2016012400; $plugin->requires = 2013050100; -$plugin->release = '1.33 for Moodle 2.5, 2.6 and 2.7'; +$plugin->release = '1.4 for Moodle 2.8, 2.9 and 3.0'; $plugin->maturity = MATURITY_STABLE; |