Revision: 1157
http://sourceforge.net/p/gemstracker/code/1157
Author: mennodekker
Date: 2013-02-27 12:26:06 +0000 (Wed, 27 Feb 2013)
Log Message:
-----------
Improved filtering for empty values (leave more 0 values in)
Modified Paths:
--------------
trunk/library/classes/Gems/Event/Survey/Display/OnlyAnswered.php
Modified: trunk/library/classes/Gems/Event/Survey/Display/OnlyAnswered.php
===================================================================
--- trunk/library/classes/Gems/Event/Survey/Display/OnlyAnswered.php 2013-02-26 12:52:26 UTC (rev 1156)
+++ trunk/library/classes/Gems/Event/Survey/Display/OnlyAnswered.php 2013-02-27 12:26:06 UTC (rev 1157)
@@ -71,7 +71,7 @@
while ($row = $repeater->__next()) {
// Add the keys that contain values.
// We don't care about the values in the array.
- $keys += array_filter($row->getArrayCopy());
+ $keys += $this->array_filter($row->getArrayCopy(), $model);
}
$results = array_intersect($currentNames, array_keys($keys), array_keys($this->token->getRawAnswers()));
@@ -95,4 +95,33 @@
{
return $this->translate->_('Display only the questions with an answer.');
}
+
+ /**
+ * Strip elements from the array that are considered empty
+ *
+ * Empty is NULL or empty string, values of 0 are NOT empty unless they are a checkbox
+ *
+ * @param type $inputArray
+ * @param type $model
+ * @return boolean
+ */
+ public function array_filter($inputArray, $model)
+ {
+ $outputArray = array();
+ foreach ($inputArray as $key => $value) {
+ // Null and empty string are skipped
+ if (is_null($value) || $value === '') {
+ continue;
+ }
+ // Maybe do a check on multiOptions for checkboxes etc. to disable some 0 values $model->get($key, 'multiOptions');
+ if ($value == '0' && $options = $model->get($key, 'multiOptions')) {
+ if (count($options) == 2) {
+ // Probably a checkbox (multi flexi in limesurvey)
+ continue;
+ }
+ }
+ $outputArray[$key] = $value;
+ }
+ return $outputArray;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|