Skip to content

Commit

Permalink
Fixed issue #07805: Comparaison String and Numeric is different in sa…
Browse files Browse the repository at this point in the history
…me page and other page (second time)

Dev: keep the + for sum is 2 are numeric except if explicit STRING, then join
Dev: comparaison of Question result return allways false if one can be numerci and the other not
Dev: then if need compare string, better use ""+QCODE > ""+QCODE2
  • Loading branch information
Shnoulle committed Nov 21, 2013
1 parent 153f602 commit fa699d0
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions application/helpers/expressions/em_core_helper.php
Expand Up @@ -270,22 +270,26 @@ private function RDP_EvaluateBinary(array $token)
}
// Set bothnumeric only if set to numeric
// Not sure if needed to test if [2] is set. : TODO review
$bNumericArg1 = (is_numeric($arg1[0]) || $arg1[0] == '');
$bNumericArg2 = (is_numeric($arg2[0]) || $arg2[0] == '');
$aForceStringArray=array('DQ_STRING','DS_STRING','STRING');// Question can return NUMERIC or WORD : DQ and DS is string entered by user, STRING is a result of a String function
$bNumericArg1 = ((is_numeric($arg1[0]) || $arg1[0] == '') && (!isset($arg1[2]) || !in_array($arg1[2],$aForceStringArray)) );
$bNumericArg2 = ((is_numeric($arg2[0]) || $arg2[0] == '') && (!isset($arg2[2]) || !in_array($arg2[2],$aForceStringArray)) );

$bStringArg1 = !$bNumericArg1 || $arg1[0] == '';
$bStringArg2 = !$bNumericArg2 || $arg2[0] == '';
$bBothNumeric = ($bNumericArg1 && $bNumericArg2);

$bBothString = ($bStringArg1 && $bStringArg2);
$bMismatchType=(!$bBothNumeric && !$bBothString);
if($bMismatchType){
if(!((isset($arg2[2]) && $arg2[2]=='NUMBER') || (isset($arg1[2]) && $arg1[2]=='NUMBER')))
{
$bBothString=true;
$bMismatchType=false;
$arg1[0]=strval($arg1[0]);
$arg2[0]=strval($arg2[0]);
}
}
// In javascript : qCode are forced to numeric if possible: then compare code A3 with 3 allways return false. Mimic this in PHP
# if($bMismatchType){// If mismatch type : test if arg1 and arg2 is forced to be a number (entred by user, numeric question return)
# if(!((isset($arg2[2]) && $arg2[2]=='NUMBER') || (isset($arg1[2]) && $arg1[2]=='NUMBER')))
# {
# $bBothString=true;
# $bMismatchType=false;
# $arg1[0]=strval($arg1[0]);
# $arg2[0]=strval($arg2[0]);
# }
# }
switch(strtolower($token[0]))
{
case 'or':
Expand All @@ -306,7 +310,7 @@ private function RDP_EvaluateBinary(array $token)
break;
case '<':
case 'lt':
if ($bMismatchType && false) {
if ($bMismatchType) {
$result = array(false,$token[1],'NUMBER');
}
else {
Expand Down Expand Up @@ -345,7 +349,7 @@ private function RDP_EvaluateBinary(array $token)
break;
case '>=';
case 'ge':
if ($bMismatchType && false) {
if ($bMismatchType) {
$result = array(false,$token[1],'NUMBER');
}
else {
Expand Down

0 comments on commit fa699d0

Please sign in to comment.