if ($question_responses) { $evaluation_question["question_responses"] = array(); foreach ($question_responses as $question_response) { $query = "SELECT * FROM `evaluation_responses` \n WHERE `eqresponse_id` = " . $db->qstr($question_response["eqresponse_id"]) . "\n AND `eprogress_id` IN (" . $evaluation_question["eprogress_ids"] . ")"; $responses = $db->GetAll($query); if ($responses) { $question_response["chosen"] = count($responses); } else { $question_response["chosen"] = 0; } $evaluation_question["flat_responses"][$question_response["response_order"]] = $responses ? count($responses) : 0; $evaluation_question["question_responses"][$question_response["eqresponse_id"]] = $question_response; } $evaluation_question["question_parents"] = Models_Evaluation::getQuestionParents($evaluation_question["question_parent_id"]); $evaluation_question["question_parent_ids"] = array_keys($evaluation_question["question_parents"]); $evaluation_question["question_objectives"] = Models_Evaluation::getQuestionObjectives($evaluation_question["equestion_id"]); $evaluation_question["question_objective_ids"] = array_keys($evaluation_question["question_objectives"]); if (@count($evaluation_question["question_objectives"])) { $hidden_question_ids[] = $evaluation_question["equestion_id"]; foreach ($evaluation_question["question_objectives"] as $objective) { if (!array_key_exists($objective["top_parent"]["objective_id"], $top_level_objectives)) { $top_level_objectives[$objective["top_parent"]["objective_id"]] = $objective["top_parent"]; $top_level_objectives[$objective["top_parent"]["objective_id"]]["evaluation_question_ids"] = array($evaluation_question["equestion_id"]); $top_level_objectives[$objective["top_parent"]["objective_id"]]["evaluation_dates"] = $evaluation_question["evaluation_dates"]; } elseif (!in_array($evaluation_question["equestion_id"], $top_level_objectives[$objective["top_parent"]["objective_id"]]["evaluation_question_ids"])) { if ($objective["objective_id"] == $objective["top_parent"]["objective_id"] && isset($objective["equestion_ids"]) && @count($objective["equestion_ids"])) { if (!isset($top_level_objectives[$objective["top_parent"]["objective_id"]]["equestion_ids"])) { $top_level_objectives[$objective["top_parent"]["objective_id"]]["equestion_ids"] = array(); } foreach ($objective["equestion_ids"] as $question_id) { $top_level_objectives[$objective["top_parent"]["objective_id"]]["equestion_ids"][] = $question_id;