Skip to content

Commit

Permalink
Fixed issue: Response browsing failing when using filtered view from …
Browse files Browse the repository at this point in the history
…statistics and setting an additional filter

Dev Fixed also confusing mischanged filter fieldnames in statistics
  • Loading branch information
c-schmitz committed Nov 8, 2021
1 parent 137eefa commit d4bbfbc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions application/helpers/admin/statistics_helper.php
Expand Up @@ -471,12 +471,12 @@ function buildSelects($allfields, $surveyid, $language)
$selects[] = Yii::app()->db->quoteColumnName(substr($pv, 1, strlen($pv) - 3)) . " = " . App()->db->quoteValue($_POST[$pv]);
} else {
//date less than
if (substr($pv, -4) == "less") {
if (substr($pv, -4) == "more") {
$selects[] = Yii::app()->db->quoteColumnName(substr($pv, 1, strlen($pv) - 5)) . " >= " . App()->db->quoteValue($_POST[$pv]);
}

//date greater than
if (substr($pv, -4) == "more") {
if (substr($pv, -4) == "less") {
$selects[] = Yii::app()->db->quoteColumnName(substr($pv, 1, strlen($pv) - 5)) . " <= " . App()->db->quoteValue($_POST[$pv]);
}
}
Expand Down
8 changes: 4 additions & 4 deletions application/models/SurveyDynamic.php
Expand Up @@ -684,7 +684,7 @@ public function search()
// When selection of responses come from statistics
// TODO: This provide a first step to enable the old jQgrid selector system, and could be use for users and tokens
if (Yii::app()->user->getState('sql_' . self::$sid) != null) {
$criteria->condition .= Yii::app()->user->getState('sql_' . self::$sid);
$criteria->addCondition(Yii::app()->user->getState('sql_' . self::$sid));
}

$this->filterColumns($criteria);
Expand Down Expand Up @@ -851,7 +851,7 @@ public function getQuestionArray($oQuestion, $oResponses, $bHonorConditions, $su
"title" => "other",
), false);
$oOtherQuestion->questionl10ns = [$sLanguage => $oOtherQuestionL10n];

$aQuestionAttributes['subquestions']["other"] = $this->getQuestionArray($oOtherQuestion, $oResponses, $bHonorConditions, true, false, $sLanguage);
if ($oQuestion->type == "P") {
$aQuestionAttributes['subquestions']["other"]['comment'] = $this->getQuestionArray($oOtherQuestion, $oResponses, $bHonorConditions, true, true, $sLanguage);
Expand Down Expand Up @@ -934,7 +934,7 @@ public function getQuestionArray($oQuestion, $oResponses, $bHonorConditions, $su
)
);

foreach($aAnswers as $key=>$value){
foreach ($aAnswers as $key => $value) {
$aAnswerText[$value['scale_id']][$value['code']] = Answer::model()->getAnswerFromCode($value->qid, $value->code, $sLanguage, $value->scale_id);
}

Expand Down Expand Up @@ -994,7 +994,7 @@ public function getQuestionArray($oQuestion, $oResponses, $bHonorConditions, $su
$aQuestionAttributes['answervalueslabels'][$oScaleSubquestion->title] = isset($oScaleSubquestion->questionl10ns[$sLanguage]->question) ? $oScaleSubquestion->questionl10ns[$sLanguage]->question : null;
}
}

if ($oQuestion->type == 'N' || ($oQuestion->parent_qid != 0 && $oQuestion->parent['type'] === "K")) {
if (strpos($aQuestionAttributes['answervalue'], ".") !== false) { // Remove last 0 and last . ALWAYS (see \SurveyObj\getShortAnswer)
$aQuestionAttributes['answervalue'] = rtrim(rtrim($aQuestionAttributes['answervalue'], "0"), ".");
Expand Down
Expand Up @@ -252,8 +252,8 @@
*/
$myfield2="D$myfield";
$myfield3=$myfield2."eq";
$myfield4=$myfield2."less";
$myfield5=$myfield2."more";
$myfield4=$myfield2."more";
$myfield5=$myfield2."less";
echo '<div class="statistics-responses-label-group ls-space padding bottom-5 top-15 ls-flex-item">';
echo "<input type='checkbox' name='summary[]' value='$myfield2'";

Expand Down

0 comments on commit d4bbfbc

Please sign in to comment.