/** * * @params array question list * @params bool expand or not question list (true show all questions, false show media question id instead of the question ids) * **/ public function transformQuestionListWithMedias($question_list, $expand_media_questions = false) { $new_question_list = array(); if (!empty($question_list)) { $media_questions = $this->getMediaList(); $media_active = $this->mediaIsActivated($media_questions); if ($media_active) { $counter = 1; foreach ($question_list as $question_id) { $add_question = true; foreach ($media_questions as $media_id => $question_list_in_media) { if ($media_id != 999 && in_array($question_id, $question_list_in_media)) { $add_question = false; if (!in_array($media_id, $new_question_list)) { $new_question_list[$counter] = $media_id; $counter++; } break; } } if ($add_question) { $new_question_list[$counter] = $question_id; $counter++; } } if ($expand_media_questions) { $media_key_list = array_keys($media_questions); foreach ($new_question_list as &$question_id) { if (in_array($question_id, $media_key_list)) { $question_id = $media_questions[$question_id]; } } $new_question_list = ArrayClass::array_flatten($new_question_list); } } else { $new_question_list = $question_list; } } return $new_question_list; }