$query = "SELECT * FROM `evaluations_lu_question_responses`\n WHERE `equestion_id` = " . $db->qstr($evaluation_question["equestion_id"]) . "\n ORDER BY `response_order` ASC"; $question_responses = $db->getAll($query); 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(); }
public static function getQuestionParents($equestion_id) { global $db; $question_parents = array(); $query = "SELECT * FROM `evaluations_lu_questions` WHERE `equestion_id` = " . $db->qstr($equestion_id); $evaluation_questions = $db->GetAll($query); foreach ($evaluation_questions as $evaluation_question) { $question_parents[$evaluation_question["equestion_id"]] = $evaluation_question; $question_grandparents = Models_Evaluation::getQuestionParents($evaluation_question["question_parent_id"]); foreach ($question_grandparents as $question_grandparent) { $question_parents[$question_grandparent["equestion_id"]] = $question_grandparent; } } return $question_parents; }