. /** * @package qtype_algebra * @copyright Roger Moore * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * Script which converts the given formula text into LaTeX code and then * displays the appropriate image file. It relies on the LaTeX filter to * be present. */ require_once('../../../config.php'); require_once("$CFG->dirroot/question/type/algebra/parser.php"); global $PAGE, $CFG; $p = new qtype_algebra_parser; try { $query=urldecode($_SERVER['QUERY_STRING']); $m=array(); if (!preg_match('/vars=([^&]*)&expr=(.*)$/A', $query, $m)) { throw new Exception('Invalid query string received from http server!'); } $vars=explode(',', $m[1]); if (empty($m[2])) { $texexp=''; } else { $exp = $p->parse($m[2], $vars); $texexp = '$$'.$exp->tex().'$$'; } } catch (Exception $e) { $texexp = get_string('parseerror', 'qtype_algebra', $e->getMessage()); } $formatoptions = new stdClass; $formatoptions->para = false; $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM)); $text = format_text($texexp, FORMAT_MOODLE, $formatoptions); ?> Formula additionalhtmlhead) && stripos($CFG->additionalhtmlhead, 'MathJax') !== false) { echo $CFG->additionalhtmlhead; } ?>