diff --git a/application/controllers/admin/responses.php b/application/controllers/admin/responses.php index a33f1416534..d3b285aa75d 100644 --- a/application/controllers/admin/responses.php +++ b/application/controllers/admin/responses.php @@ -281,6 +281,7 @@ public function view($iSurveyID, $iId, $sBrowseLang = '') $answervalue = "Y"; } } else { + // File upload question type. if (isset($fnames[$i]['type']) && $fnames[$i]['type'] == "|") { $index = $fnames[$i]['index']; $metadata = $fnames[$i]['metadata']; @@ -302,7 +303,7 @@ public function view($iSurveyID, $iId, $sBrowseLang = '') } $aData['bHasFile'] = true; } else { - $answervalue = ""; + $answervalue = ""; } } else { $answervalue = htmlspecialchars(strip_tags(stripJavaScript(getExtendedAnswer($iSurveyID, $fnames[$i][0], $iIdrow[$fnames[$i][0]], $sBrowseLanguage))), ENT_QUOTES); diff --git a/application/models/Response.php b/application/models/Response.php index 757d8076c00..c44b341ad09 100644 --- a/application/models/Response.php +++ b/application/models/Response.php @@ -39,12 +39,21 @@ public static function create($surveyId, $scenario = 'insert') /** * Get all files related to this response and (optionally) question ID. * + * @param int $qid * @return array */ - public function getFiles() + public function getFiles($qid = null) { $survey = Survey::model()->findByPk($this->dynamicId); - $questions = Question::model()->findAllByAttributes(array('sid' => $this->dynamicId, 'type' => '|', 'language'=>$survey->language)); + $conditions = [ + 'sid' => $this->dynamicId, + 'type' => '|', + 'language'=>$survey->language + ]; + if ($qid !== null) { + $conditions['qid'] = $qid; + } + $questions = Question::model()->findAllByAttributes($conditions); $files = array(); foreach ($questions as $question) { $field = $question->sid.'X'.$question->gid.'X'.$question->qid;