/** * This function returns a string containing all of the courses which * are attached to the selected competency. * * @param $objective_id * @param $objective_ids_string * @return $objective_ids_string */ function objectives_competency_courses($competency_id = 0) { global $db, $ENTRADA_USER; $query = "\tSELECT a.*, MIN(b.`importance`) AS `importance`\n\t\t\t\tFROM `courses` AS a\n\t\t\t\tJOIN `course_objectives` AS b\n\t\t\t\tON a.`course_id` = b.`course_id`\n\t\t\t\tAND `objective_id` IN (" . objectives_build_objective_descendants_id_string($competency_id) . ")\n\t\t\t\tAND a.`course_active` = 1\n\t\t\t\tAND a.`organisation_id` = " . $db->qstr($ENTRADA_USER->getActiveOrganisation()) . "\n AND b.`active` = '1'\n\t\t\t\tGROUP BY a.`course_id`"; $courses = $db->GetAll($query); if ($courses) { $courses_array = false; foreach ($courses as $course) { $courses_array[$course["course_id"]] = $course; } } return $courses_array; }
if (isset($COURSE_ID) && $COURSE_ID && (isset($COMPETENCY_ID) && $COMPETENCY_ID)) { $BREADCRUMB[] = array("url" => "", "title" => "Course Objectives by Competency"); ?> <style type="text/css"> li.pad-top { margin-bottom: 10px; } ul.pad { padding-top: 10px; padding-bottom: 10px; } </style> <?php $objective_ids_string = objectives_build_course_objectives_id_string($COURSE_ID); $competency_ids_string = objectives_build_objective_descendants_id_string($COMPETENCY_ID); $primary = $secondary = $tertiary = array(); $query = "\tSELECT * FROM `course_objectives` AS a\n\t\t\t\t\tJOIN `global_lu_objectives` AS b\n\t\t\t\t\tON a.`objective_id` = b.`objective_id`\n\t\t\t\t\tJOIN `objective_organisation` AS c\n\t\t\t\t\tON b.`objective_id` = c.`objective_id`\n\t\t\t\t\tAND c.`organisation_id` = " . $db->qstr($ENTRADA_USER->getActiveOrganisation()) . "\n\t\t\t\t\tWHERE a.`course_id` = " . $db->qstr($COURSE_ID) . "\n\t\t\t\t\tAND (\n\t\t\t\t\t\tb.`objective_id` IN (" . $competency_ids_string . ")\n\t\t\t\t\t\tAND b.`objective_parent` NOT IN (" . $objective_ids_string . ")\n\t\t\t\t\t)\n\t\t\t\t\tAND a.`objective_type` = 'course'\n AND a.`active` = '1'\n\t\t\t\t\tAND b.`objective_active` = 1\n\t\t\t\t\tORDER BY a.`importance` ASC"; $objectives = $db->GetAll($query); if ($objectives) { foreach ($objectives as $objective) { $query = "\tSELECT a.*, b.`objective_details` FROM `global_lu_objectives` AS a\n\t\t\t\t\t\t\tLEFT JOIN `course_objectives` AS b\n\t\t\t\t\t\t\tON a.`objective_id` = b.`objective_id`\n AND b.`course_id` = " . $db->qstr($COURSE_ID) . "\n\t\t\t\t\t\t\tAND b.`objective_type` = 'course'\n AND b.`active` = '1'\n\t\t\t\t\t\t\tJOIN `objective_organisation` AS c\n\t\t\t\t\t\t\tON a.`objective_id` = c.`objective_id`\n\t\t\t\t\t\t\tAND c.`organisation_id` = " . $db->qstr($ENTRADA_USER->getActiveOrganisation()) . "\n\t\t\t\t\t\t\tWHERE a.`objective_parent` = " . $db->qstr($objective["objective_id"]) . "\n\t\t\t\t\t\t\tAND a.`objective_active` = 1\n\t\t\t\t\t\t\tORDER BY a.`objective_order` ASC"; $child_objectives = $db->GetAll($query); if ($objective["importance"] == 1) { $primary[$objective["objective_id"]]["children"] = array(); } elseif ($objective["importance"] == 2) { $secondary[$objective["objective_id"]]["children"] = array(); } elseif ($objective["importance"] == 3) { $tertiary[$objective["objective_id"]]["children"] = array(); } foreach ($child_objectives as $child_objective) {