aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2021-11-10 15:05:27 -0700
committerJohn Denker <jsd@av8n.com>2021-11-10 15:05:27 -0700
commit00f7ed380b90cc003c3f99a6ce116b885a7469ec (patch)
treea5c5803fa5ec643bac9559e5e48da36d91fa5d00
parentd8e30f21278e2326b09097f99a8e5423112a8e8e (diff)
display more-informative error message;
required stripping off two layers of concealment
-rw-r--r--displayformula.php9
-rw-r--r--lang/en/qtype_algebra.php6
2 files changed, 8 insertions, 7 deletions
diff --git a/displayformula.php b/displayformula.php
index 6ba12fb..9890ea5 100644
--- a/displayformula.php
+++ b/displayformula.php
@@ -34,7 +34,7 @@ global $PAGE, $CFG;
require_login();
$p = new qtype_algebra_parser;
-$validanswer = true;
+$errmsg = '';
try {
$query = urldecode($_SERVER['QUERY_STRING']);
@@ -66,16 +66,15 @@ try {
}
} catch (Exception $e) {
- $validanswer = false;
- $texexp = get_string('parseerror', 'qtype_algebra', $e->getMessage());
+ $errmsg = $e->getMessage();
}
$formatoptions = new stdClass;
$formatoptions->para = false;
$PAGE->set_context(context_system::instance());
-if ($validanswer) {
+if ($errmsg == '') {
$text = format_text($texexp, FORMAT_MOODLE, $formatoptions);
} else {
- $text = get_string('invalidanswer', 'qtype_algebra');
+ $text = get_string('trivial_1', 'qtype_algebra', $errmsg);
}
?>
<html>
diff --git a/lang/en/qtype_algebra.php b/lang/en/qtype_algebra.php
index 81baad5..b29682e 100644
--- a/lang/en/qtype_algebra.php
+++ b/lang/en/qtype_algebra.php
@@ -23,6 +23,8 @@
*/
// Parser lang strings.
+$string['deprecatedlog'] = 'log() is deprecated; use ln() or log10() instead';
+$string['trivial_1'] = '{$a}';
$string['badclosebracket'] = 'Invalid close bracket found';
$string['badequivtype'] = 'Invalid type: can only compare parser terms with other parser terms';
$string['badfuncargs'] = 'Invalid arguments for the function \'{$a}\'';
@@ -111,7 +113,7 @@ $string['notenoughvars'] = 'You must enter at least one variable.';
$string['novarmax'] = 'No maximum bound specified for variable.';
$string['novarmin'] = 'No minimum bound specified for variable.';
$string['options'] = 'Options';
-$string['parseerror'] = 'Error parsing function: \'{$a}\'';
+$string['parseerror'] = 'Error parsing function: \'{$a}\''; /* not used at the moment */
$string['restoreqdbfailed'] = 'Restoring algebra question failed: database write error';
$string['restorevardbfailed'] = 'Restoring algebra question variable failed: database write error';
$string['tolerance'] = 'Tolerance for Evaluation Checks';
@@ -146,7 +148,7 @@ $string['dollars'] = '$$...$$';
$string['brackets'] = '\[...\]';
$string['braces'] = '\\(...\\)';
$string['dollar'] = '$...$';
-$string['invalidanswer'] = 'Invalid or unrecongnized answer';
+$string['invalidanswer'] = 'Invalid or unrecognized answer:<br>{$a}'; /* not used at the moment */
$string['multiplyoperator'] = 'TeX operator for multiplication';
$string['times'] = '\\times';
$string['cdot'] = '\\cdot';