} if ($tmp_sortby == 'q_type' and isset($_GET['type'])) { $tmp_sortby = 'leadin'; } //SL 05-02-2015 changed to look at leadin column instead of leadin_plain column if ($_GET['module'] == '0') { $sql = "SELECT DISTINCT NULL AS extra_field, NULL AS p, NULL AS d, questions.q_id, theme, leadin AS leadin, q_type, last_edited, DATE_FORMAT(last_edited, '{$configObject->get('cfg_long_date')}') AS modified, locked, status, bloom FROM (users, questions) LEFT JOIN questions_modules ON questions.q_id = questions_modules.q_id WHERE users.id = questions.ownerID AND ownerID = " . $userObject->get_user_ID() . " AND idMod IS NULL GROUP BY q_id"; } elseif ($_GET['type'] == 'performance') { $sql = "SELECT DISTINCT NULL AS extra_field, p, d, questions.q_id, theme, leadin AS leadin, q_type, last_edited, DATE_FORMAT(last_edited, '{$configObject->get('cfg_long_date')}') AS modified, locked, status, bloom FROM (questions, performance_main, performance_details, questions_modules) WHERE questions.q_id = performance_main.q_id AND performance_main.id = performance_details.perform_id AND questions.q_id = questions_modules.q_id AND idMod = {$module}"; } elseif ($_GET['type'] == 'keyword') { $sql = "SELECT DISTINCT keyword AS extra_field, keywordID AS p, NULL AS d, questions.q_id, theme, leadin AS leadin, q_type, last_edited, DATE_FORMAT(last_edited, '{$configObject->get('cfg_long_date')}') AS modified, locked, status, bloom FROM (questions, questions_modules, keywords_question, keywords_user) WHERE questions.q_id = keywords_question.q_id AND keywords_question.keywordID = keywords_user.id AND questions.q_id = questions_modules.q_id AND idMod = {$module} AND deleted IS NULL AND status NOT IN ({$retired_in})"; } elseif ($_GET['type'] == 'bloom') { $sql = "SELECT DISTINCT bloom AS extra_field, NULL AS p, NULL AS d, questions.q_id, theme, leadin AS leadin, q_type, last_edited, DATE_FORMAT(last_edited, '{$configObject->get('cfg_long_date')}') AS modified, locked, status, bloom FROM (questions, questions_modules) WHERE questions.q_id = questions_modules.q_id {$module_sql} {$staff_modules_sql} {$statusSQL} AND deleted IS NULL AND status NOT IN ({$retired_in})"; } elseif ($_GET['type'] == 'objective') { $vle_api_cache = array(); $vle_api_data = MappingUtils::get_vle_api($module, date_utils::get_current_academic_year(), $vle_api_cache, $mysqli); $sql = "SELECT DISTINCT GROUP_CONCAT(obj_id SEPARATOR ' ') AS extra_field, NULL AS p, NULL AS d, questions.q_id, theme, leadin AS leadin, q_type, last_edited, DATE_FORMAT(last_edited, '{$configObject->get('cfg_long_date')}') AS modified, locked, status, bloom FROM (questions, questions_modules, relationships) WHERE questions.q_id = questions_modules.q_id AND questions.q_id = relationships.question_id AND relationships.vle_api = '{$vle_api_data['api']}' AND relationships.map_level = '{$vle_api_data['level']}' {$module_sql} {$staff_modules_sql} {$statusSQL} AND deleted IS NULL AND status NOT IN ({$retired_in}) GROUP BY question_id"; } else { $sql = "SELECT DISTINCT NULL AS extra_field, NULL AS p, NULL AS d, questions.q_id, theme, leadin AS leadin, q_type, last_edited, DATE_FORMAT(last_edited, '{$configObject->get('cfg_long_date')}') AS modified, locked, status, bloom FROM (questions, questions_modules) WHERE questions.q_id = questions_modules.q_id {$module_sql} {$staff_modules_sql} {$statusSQL} {$keyword} AND deleted IS NULL"; if ($_GET['type'] != 'status') { $sql .= " AND status NOT IN ({$retired_in})"; } } $search_results = $mysqli->prepare($sql); $search_results->execute(); $search_results->bind_result($extra_field, $p, $d, $q_id, $theme, $leadin, $q_type, $last_edited, $modified, $locked, $status, $bloom); $search_results->store_result(); if ($type == 'keyword') { $table_order = array($string['question'] => 800, $string['type'] => 100, 'Keyword' => 100, $string['modified'] => 70, $string['status'] => 70); } elseif ($type == 'bloom') { $table_order = array($string['question'] => 800, $string['type'] => 100, 'Bloom\'s Taxonomy' => 100, $string['modified'] => 70, $string['status'] => 70);
public function get_outcomes($ac_year = 'all', $vle_api_data = null) { $outcomes = array(); $vle_api_cache = array(); // Get the VLE API we're using currently if (is_null($vle_api_data)) { $vle_api_data = MappingUtils::get_vle_api($this->idMod, date_utils::get_current_academic_year(), $vle_api_cache, $this->db); } // Get years for which there are mappings for the current mapping source if ($ac_year == 'all') { $all_years = getYearsForModules($vle_api_data['api'], array($this->idMod => $this->module_id), $this->db); } else { $all_years = array($ac_year); } foreach ($all_years as $ac_year) { $obs = getObjectives(array($this->idMod => $this->module_id), $ac_year, '', '', $this->db); if (is_array($obs) and isset($obs[$this->module_id])) { foreach ($obs[$this->module_id] as $session) { if (isset($session['objectives'])) { foreach ($session['objectives'] as $objective) { if (isset($objective['guid'])) { $uid = $objective['guid']; } elseif (isset($objective['id'])) { $uid = $objective['id']; } else { $uid = ''; } if ($uid != '') { // Build list of IDs but use the latest text $ids = isset($outcomes[$uid]) ? $outcomes[$uid]['ids'] : array(); $ids[] = $objective['id']; $outcomes[$uid] = array('ids' => $ids, 'label' => $objective['content']); } } } } } } if (count($outcomes) > 0) { uasort($outcomes, function ($a, $b) { if ($a['label'] == $b['label']) { return 0; } return $a['label'] < $b['label'] ? -1 : 1; }); } // Filter local mappings to remove duplicates $last_id = -1; $last_text = ''; if ($vle_api_data['api'] == '') { foreach ($outcomes as $id => $outcome) { if ($last_id != -1) { if ($outcome['label'] == $last_text) { $outcomes[$last_id]['ids'][] = $id; unset($outcomes[$id]); } else { $last_id = $id; $last_text = $outcome['label']; } } else { $last_id = $id; } } } return $outcomes; }