From cd5af0a39cf71fd9c53886badf3ea0384d51fa22 Mon Sep 17 00:00:00 2001
From: Jean-Michel Vedrine <vedrine@vedrine.org>
Date: Sat, 27 Jan 2018 10:35:50 +0100
Subject: svg icon, multiply setting

---
 displayformula.php | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

(limited to 'displayformula.php')

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>
-- 
cgit v1.2.3