From e0abd45dc194f7ede2b460c6e9c2c303d4321bd7 Mon Sep 17 00:00:00 2001 From: Jean-Michel Vedrine Date: Sun, 24 Jan 2016 13:18:38 +0100 Subject: Solve display using MathJax for all websites --- README.txt | 2 +- displayformula.php | 9 ++++++++- lib.php | 5 ++--- parser.php | 12 +++++++++++- question.php | 1 + questiontype.php | 1 + version.php | 4 ++-- 7 files changed, 26 insertions(+), 8 deletions(-) diff --git a/README.txt b/README.txt index 932eb51..d371985 100644 --- a/README.txt +++ b/README.txt @@ -26,7 +26,7 @@ Updated to Moodle 2.0 by Stefan Raffeiner Updated to Moodle 2.1 by Jean-Michel VĂ©drine 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); Formula 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 ""; } ?> diff --git a/lib.php b/lib.php index f14538d..29cb75f 100644 --- a/lib.php +++ b/lib.php @@ -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 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/parser.php b/parser.php index 6a81fe6..8a21bc3 100644 --- a/parser.php +++ b/parser.php @@ -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; -- cgit v1.2.3