aboutsummaryrefslogtreecommitdiff
path: root/displayformula.php
diff options
context:
space:
mode:
authorJean-Michel Vedrine <vedrine@vedrine.org>2018-01-27 10:35:50 +0100
committerJean-Michel Vedrine <vedrine@vedrine.org>2018-01-27 10:35:50 +0100
commitcd5af0a39cf71fd9c53886badf3ea0384d51fa22 (patch)
tree30e89940dbe9c74d23ba98297395b064534182fd /displayformula.php
parent1bff8fd7cbd3904afda224ab1555e1e435528314 (diff)
svg icon, multiply setting
Diffstat (limited to 'displayformula.php')
-rw-r--r--displayformula.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/displayformula.php b/displayformula.php
index 8c4cf8c..09f4cff 100644
--- a/displayformula.php
+++ b/displayformula.php
@@ -26,13 +26,16 @@
* the mathJax filter to be present.
*/
+
require_once('../../../config.php');
require_once("$CFG->dirroot/question/type/algebra/parser.php");
-global $PAGE, $CFG;
+global $PAGE;
require_login();
$p = new qtype_algebra_parser;
+$validanswer = true;
+
try {
$query = urldecode($_SERVER['QUERY_STRING']);
$m = array();
@@ -52,12 +55,17 @@ try {
}
}
} catch (Exception $e) {
+ $validanswer = false;
$texexp = get_string('parseerror', 'qtype_algebra', $e->getMessage());
}
$formatoptions = new stdClass;
$formatoptions->para = false;
$PAGE->set_context(context_system::instance());
-$text = format_text($texexp, FORMAT_MOODLE, $formatoptions);
+if ($validanswer) {
+ $text = format_text($texexp, FORMAT_MOODLE, $formatoptions);
+} else {
+ $text = get_string('invalidanswer', 'qtype_algebra');
+}
?>
<html>
<head>