Skip to content

Commit

Permalink
Fixed issue #16175: statCountIf returns nothing for first participant
Browse files Browse the repository at this point in the history
Dev: $result = $result ? $result : false; can never return 0
Dev: php function can return null, false, 0 "" …
Dev: Add test for "0" to be returned
  • Loading branch information
Shnoulle committed May 4, 2020
1 parent aa011ac commit 15477d8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
5 changes: 2 additions & 3 deletions application/helpers/expressions/em_core_helper.php
Expand Up @@ -2120,7 +2120,7 @@ private function RDP_RunFunction($funcNameToken, $params)
if (is_numeric($params[0])) {
$result = $funcName(floatval($params[0]));
} else {
$result = NAN;
$result = NAN; // NAN in PHP …
}
break;
default:
Expand All @@ -2136,12 +2136,11 @@ private function RDP_RunFunction($funcNameToken, $params)
if (is_numeric($params[0]) && is_numeric($params[1])) {
$result = $funcName(floatval($params[0]), floatval($params[1]));
} else {
$result = false;
$result = false; // Not same than other
}
break;
default:
$result = call_user_func($funcName,$params[0], $params[1]);
$result = $result ? $result : false;
break;
}
}
Expand Down
Binary file modified tests/data/surveys/survey_archive_statCountFunctionsTest.lsa
Binary file not shown.
Expand Up @@ -50,6 +50,8 @@ public function testPluginsStats()
$this->assertEquals($textToCompare, "3", 'statCount(self.sgqa) usage broken : «' . $textToCompare ."» vs «3»");
$textToCompare = self::$webDriver->findElement(WebDriverBy::id('statCountQ01'))->getText();
$this->assertEquals($textToCompare, "3", 'statCount(Q01.sgqa) usage broken : «' . $textToCompare ."» vs «3»");
$textToCompare = self::$webDriver->findElement(WebDriverBy::id('statCountIfQ00'))->getText();
$this->assertEquals($textToCompare, "0", 'statCountIfQ00(self.sgqa,"NOT") usage broken : «' . $textToCompare ."» vs «0»");
/** Relevance (and update) check **/
$this->assertFalse(
self::$webDriver->findElement(WebDriverBy::id('question'.$questions['Q01']->qid))->isDisplayed(),
Expand Down

0 comments on commit 15477d8

Please sign in to comment.