Skip to content

Commit

Permalink
Dev Validated that irrelevant mandatories are properly handled
Browse files Browse the repository at this point in the history
Dev Also discovered that in PHP, 'NA' >0 is true - so users will have to be careful how they design tests against 0

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev_tms@11653 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
TMSWhite committed Dec 13, 2011
1 parent 0252349 commit d3e233a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion classes/eval/ExpressionManager.php
Expand Up @@ -1338,7 +1338,13 @@ public function GetPrettyPrintString()
$descriptor = '[' . $token[0] . ']';
}
else {
$displayName = $qcode;
$args = explode('.',$token[0]);
if (count($args) == 2) {
$displayName = $qcode . '.' . $args[1];
}
else {
$displayName = $qcode;
}
}
}
else {
Expand Down Expand Up @@ -1458,6 +1464,9 @@ private function GetVarAttribute($name,$attr,$default)
}
else {
if (isset($_SESSION[$sgqa])) {
// if ($_SESSION[$sgqa] == 'false') {
// return $default; // TODO - is is safe to assume that a value of 'false' means boolean false and should be blanked?
// }
return $_SESSION[$sgqa];
}
if (isset($var['default']) && !is_null($var['default'])) {
Expand Down Expand Up @@ -1761,6 +1770,10 @@ public function ProcessBooleanExpression($expr,$groupSeq=-1,$questionSeq=-1)
if (is_null($result)) {
return false; // if there are errors in the expression, hide it?
}
// if ($result == 'false') {
// return false; // since the string 'false' is not considered boolean false, but an expression in JavaScript can return 'false'
// }
// return !empty($result);
return (boolean) $result;
}

Expand Down Expand Up @@ -2362,6 +2375,9 @@ static function UnitTestEvaluator()
// expectedResult~expression
// if the expected result is an error, use NULL for the expected result
$tests = <<<EOD
0~('NA' > 0 and 4 > 0) or ('' == 'Y')
0~('NA'> 0)
0~(-1 > 0)
0~zero
~empty
1~is_empty(empty)
Expand Down
2 changes: 1 addition & 1 deletion classes/eval/LimeExpressionManager.php
Expand Up @@ -1744,7 +1744,7 @@ static function ProcessString($string, $questionNum=NULL, $replacementFields=arr
$questionSeq = isset($LEM->questionId2questionSeq[$questionNum]) ? $LEM->questionId2questionSeq[$questionNum] : -1;
$groupSeq = isset($LEM->questionId2groupSeq[$questionNum]) ? $LEM->questionId2groupSeq[$questionNum] : -1;
}
$stringToParse = htmlspecialchars_decode($string,ENT_QUOTES);
$stringToParse = $string; // decode called later htmlspecialchars_decode($string,ENT_QUOTES);
$qnum = is_null($questionNum) ? 0 : $questionNum;
$result = $LEM->em->sProcessStringContainingExpressions($stringToParse,$qnum, $numRecursionLevels, $whichPrettyPrintIteration, $groupSeq, $questionSeq);
$hasErrors = $LEM->em->HasErrors();
Expand Down

0 comments on commit d3e233a

Please sign in to comment.