aboutsummaryrefslogtreecommitdiff
path: root/displayformula.php
diff options
context:
space:
mode:
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>