Skip to content

Commit

Permalink
Fixed issue #17512: Survey Logic File Syntax Error Summary Displays I…
Browse files Browse the repository at this point in the history
…ncorrect Error Count (#2035)

Co-authored-by: encuestabizdevgit <devgit@encuesta.biz>
  • Loading branch information
gabrieljenik and encuestabizdevgit committed Sep 21, 2021
1 parent 9451ad6 commit 49257e1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions application/helpers/expressions/em_core_helper.php
Expand Up @@ -579,16 +579,19 @@ private function RDP_EvaluateUnary(array $token)
* Main entry function
* @param string $expr
* @param boolean $onlyparse - if true, then validate the syntax without computing an answer
* @param boolean $resetErrorsAndWarnings - if true (default), EM errors and warnings will be cleared before evaluation
* @return boolean - true if success, false if any error occurred
*/
public function RDP_Evaluate($expr, $onlyparse = false)
public function RDP_Evaluate($expr, $onlyparse = false, $resetErrorsAndWarnings = true)
{
$this->RDP_expr = $expr;
$this->RDP_tokens = $this->RDP_Tokenize($expr);
$this->RDP_count = count($this->RDP_tokens);
$this->RDP_pos = -1; // starting position within array (first act will be to increment it)
$this->RDP_errs = array();
$this->RDP_warnings = array();
if ($resetErrorsAndWarnings) {
$this->RDP_errs = array();
$this->RDP_warnings = array();
}
$this->RDP_onlyparse = $onlyparse;
$this->RDP_stack = array();
$this->RDP_evalStatus = false;
Expand Down Expand Up @@ -1975,14 +1978,15 @@ public function sProcessStringContainingExpressionsHelper($src, $questionNum, $s
$stringParts = $this->asSplitStringOnExpressions($src);
$resolvedParts = array();
$prettyPrintParts = array();
$this->ResetErrorsAndWarnings();
foreach ($stringParts as $stringPart) {
if ($stringPart[2] == 'STRING') {
$resolvedParts[] = $stringPart[0];
$prettyPrintParts[] = $stringPart[0];
} else {
++$this->substitutionNum;
$expr = $this->ExpandThisVar(substr($stringPart[0], 1, -1));
if ($this->RDP_Evaluate($expr)) {
if ($this->RDP_Evaluate($expr, false, false)) { // We call RDP_Evaluate with $resetErrorsAndWarnings = false because, if $src has more than one expression, error information could be lost
$resolvedPart = $this->GetResult();
} else {
// show original and errors in-line only if user have the rigth to update survey content
Expand Down

0 comments on commit 49257e1

Please sign in to comment.