public static function getChildIDs($objective_id) { global $db; $objective_ids = array(); $query = "SELECT `objective_id` FROM `global_lu_objectives` WHERE `objective_parent` = " . $db->qstr($objective_id); $child_ids = $db->GetAll($query); if ($child_ids) { foreach ($child_ids as $child_id) { $objective_ids[] = $child_id["objective_id"]; $grandchild_ids = Models_Objective::getChildIDs($child_id["objective_id"]); if ($grandchild_ids) { foreach ($grandchild_ids as $grandchild_id) { $objective_ids[] = $grandchild_id; } } } } return $objective_ids; }
public function getAllRequiredObjectivesMobile($course_id = false) { global $db; if (!$course_id) { $course_id = $this->getCourseID(); } $objectives = array(); $query = "SELECT `objective_id` FROM `course_objectives`\n " . ($course_id ? "WHERE `course_id` = " . $db->qstr($course_id) : ""); $objective_ids = $db->GetAll($query); if ($objective_ids) { $objective_ids_array = $objective_ids; foreach ($objective_ids as $objective_id) { $objective = Models_Objective::fetchRow($objective_id["objective_id"]); if ($objective) { $descendant_ids = Models_Objective::getChildIDs($objective_id["objective_id"]); foreach ($descendant_ids as $descendant_id) { $descendant = Models_Objective::fetchRow($descendant_id); if ($descendant && $descendant->getLoggable() && !Models_Objective::getChildIDs($descendant_id)) { $objectives[$descendant->getID()] = $descendant->toArray(); } } if (!$descendant_ids && $objective->getLoggable()) { $objectives[$objective->getID()] = $objective->toArray(); } } } } return $objectives; }