| @@ 868-893 (lines=26) @@ | ||
| 865 | * @param string $keyword |
|
| 866 | * @return array|null |
|
| 867 | */ |
|
| 868 | public static function searchCategoryByKeyword($keyword) |
|
| 869 | { |
|
| 870 | if (empty($keyword)) { |
|
| 871 | return null; |
|
| 872 | } |
|
| 873 | ||
| 874 | $tableCategory = Database::get_main_table(TABLE_MAIN_CATEGORY); |
|
| 875 | ||
| 876 | $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY); |
|
| 877 | $conditions = " INNER JOIN $table a ON (c.id = a.course_category_id)"; |
|
| 878 | $whereCondition = " AND a.access_url_id = ".api_get_current_access_url_id(); |
|
| 879 | ||
| 880 | $keyword = Database::escape_string($keyword); |
|
| 881 | ||
| 882 | $sql = "SELECT c.*, c.name as text |
|
| 883 | FROM $tableCategory c $conditions |
|
| 884 | WHERE |
|
| 885 | ( |
|
| 886 | c.code LIKE '%$keyword%' OR name LIKE '%$keyword%' |
|
| 887 | ) AND |
|
| 888 | auth_course_child = 'TRUE' |
|
| 889 | $whereCondition "; |
|
| 890 | $result = Database::query($sql); |
|
| 891 | ||
| 892 | return Database::store_result($result, 'ASSOC'); |
|
| 893 | } |
|
| 894 | ||
| 895 | /** |
|
| 896 | * @param array $list |
|
| @@ 228-249 (lines=22) @@ | ||
| 225 | * @param int access url id |
|
| 226 | * @return array Database::store_result of the result |
|
| 227 | **/ |
|
| 228 | public static function get_url_rel_course_data($access_url_id = null) |
|
| 229 | { |
|
| 230 | $where = ''; |
|
| 231 | $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
|
| 232 | $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE); |
|
| 233 | ||
| 234 | if (!empty($access_url_id)) { |
|
| 235 | $where = " WHERE uc.access_url_id = ".intval($access_url_id); |
|
| 236 | } |
|
| 237 | ||
| 238 | $sql = "SELECT u.id, c_id, title, uc.access_url_id |
|
| 239 | FROM $tbl_course u |
|
| 240 | INNER JOIN $table_url_rel_course uc |
|
| 241 | ON uc.c_id = u.id |
|
| 242 | $where |
|
| 243 | ORDER BY title, code"; |
|
| 244 | ||
| 245 | $result = Database::query($sql); |
|
| 246 | $courses = Database::store_result($result); |
|
| 247 | ||
| 248 | return $courses; |
|
| 249 | } |
|
| 250 | ||
| 251 | /** |
|
| 252 | * Gets the number of rows with a specific course_code in access_url_rel_course table |
|
| @@ 278-298 (lines=21) @@ | ||
| 275 | * @return array Database::store_result of the result |
|
| 276 | * |
|
| 277 | **/ |
|
| 278 | public static function get_url_rel_session_data($access_url_id = null) |
|
| 279 | { |
|
| 280 | $where =''; |
|
| 281 | $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
|
| 282 | $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); |
|
| 283 | ||
| 284 | if (!empty($access_url_id)) |
|
| 285 | $where ="WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id); |
|
| 286 | ||
| 287 | $sql = "SELECT id, name, access_url_id |
|
| 288 | FROM $tbl_session u |
|
| 289 | INNER JOIN $table_url_rel_session |
|
| 290 | ON $table_url_rel_session.session_id = id |
|
| 291 | $where |
|
| 292 | ORDER BY name, id"; |
|
| 293 | ||
| 294 | $result = Database::query($sql); |
|
| 295 | $sessions = Database::store_result($result); |
|
| 296 | ||
| 297 | return $sessions; |
|
| 298 | } |
|
| 299 | ||
| 300 | /** |
|
| 301 | * Gets the inner join of access_url and the usergroup table |
|
| @@ 308-329 (lines=22) @@ | ||
| 305 | * |
|
| 306 | * @return array Database::store_result of the result |
|
| 307 | **/ |
|
| 308 | public static function get_url_rel_usergroup_data($access_url_id = null) |
|
| 309 | { |
|
| 310 | $where = ''; |
|
| 311 | $table_url_rel_usergroup = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP); |
|
| 312 | $table_user_group = Database::get_main_table(TABLE_USERGROUP); |
|
| 313 | ||
| 314 | if (!empty($access_url_id)) { |
|
| 315 | $where ="WHERE $table_url_rel_usergroup.access_url_id = ".intval($access_url_id); |
|
| 316 | } |
|
| 317 | ||
| 318 | $sql = "SELECT id, name, access_url_id |
|
| 319 | FROM $table_user_group u |
|
| 320 | INNER JOIN $table_url_rel_usergroup |
|
| 321 | ON $table_url_rel_usergroup.usergroup_id = u.id |
|
| 322 | $where |
|
| 323 | ORDER BY name"; |
|
| 324 | ||
| 325 | $result = Database::query($sql); |
|
| 326 | $courses = Database::store_result($result); |
|
| 327 | ||
| 328 | return $courses; |
|
| 329 | } |
|
| 330 | ||
| 331 | /** |
|
| 332 | * Gets the inner join of access_url and the usergroup table |
|
| @@ 1252-1276 (lines=25) @@ | ||
| 1249 | * @param int $exe_id |
|
| 1250 | * @return array |
|
| 1251 | */ |
|
| 1252 | public static function get_exercise_track_exercise_info($exe_id) |
|
| 1253 | { |
|
| 1254 | $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); |
|
| 1255 | $TBL_TRACK_EXERCICES = Database::get_main_table( |
|
| 1256 | TABLE_STATISTIC_TRACK_E_EXERCISES |
|
| 1257 | ); |
|
| 1258 | $TBL_COURSE = Database::get_main_table(TABLE_MAIN_COURSE); |
|
| 1259 | $exe_id = intval($exe_id); |
|
| 1260 | $result = array(); |
|
| 1261 | if (!empty($exe_id)) { |
|
| 1262 | $sql = " SELECT q.*, tee.* |
|
| 1263 | FROM $TBL_EXERCICES as q |
|
| 1264 | INNER JOIN $TBL_TRACK_EXERCICES as tee |
|
| 1265 | ON q.id = tee.exe_exo_id |
|
| 1266 | INNER JOIN $TBL_COURSE c |
|
| 1267 | ON c.id = tee.c_id |
|
| 1268 | WHERE tee.exe_id = $exe_id |
|
| 1269 | AND q.c_id = c.id"; |
|
| 1270 | ||
| 1271 | $res_fb_type = Database::query($sql); |
|
| 1272 | $result = Database::fetch_array($res_fb_type, 'ASSOC'); |
|
| 1273 | } |
|
| 1274 | ||
| 1275 | return $result; |
|
| 1276 | } |
|
| 1277 | ||
| 1278 | /** |
|
| 1279 | * Validates the time control key |
|