| @@ 429-440 (lines=12) @@ | ||
| 426 | * @param int |
|
| 427 | * @return String |
|
| 428 | */ |
|
| 429 | public static function get_course_id_by_link_id($id_link) |
|
| 430 | { |
|
| 431 | $course_table = Database::get_main_table(TABLE_MAIN_COURSE); |
|
| 432 | $tbl_grade_links = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
| 433 | $sql = 'SELECT c.id FROM ' . $course_table . ' c |
|
| 434 | INNER JOIN ' . $tbl_grade_links . ' l |
|
| 435 | ON c.code = l.course_code |
|
| 436 | WHERE l.id=' . intval($id_link) . ' OR l.category_id=' . intval($id_link); |
|
| 437 | $res = Database::query($sql); |
|
| 438 | $array = Database::fetch_array($res, 'ASSOC'); |
|
| 439 | return $array['id']; |
|
| 440 | } |
|
| 441 | ||
| 442 | /** |
|
| 443 | * @param $type |
|
| @@ 4559-4573 (lines=15) @@ | ||
| 4556 | * @param int $user_id The user id |
|
| 4557 | * @return boolean |
|
| 4558 | */ |
|
| 4559 | public static function is_user_certified($cat_id, $user_id) |
|
| 4560 | { |
|
| 4561 | $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); |
|
| 4562 | $sql = 'SELECT path_certificate FROM '.$table_certificate.' |
|
| 4563 | WHERE |
|
| 4564 | cat_id="'.intval($cat_id).'" AND |
|
| 4565 | user_id="'.intval($user_id).'"'; |
|
| 4566 | $rs = Database::query($sql); |
|
| 4567 | $row = Database::fetch_array($rs); |
|
| 4568 | if ($row['path_certificate'] == '' || is_null($row['path_certificate'])) { |
|
| 4569 | return false; |
|
| 4570 | } else { |
|
| 4571 | return true; |
|
| 4572 | } |
|
| 4573 | } |
|
| 4574 | ||
| 4575 | /** |
|
| 4576 | * Gets the info about a gradebook certificate for a user by course |
|
| @@ 4358-4373 (lines=16) @@ | ||
| 4355 | * @param integer $user_id |
|
| 4356 | * @return int the value of the highest sort of the user_course_category |
|
| 4357 | */ |
|
| 4358 | function api_max_sort_value($user_course_category, $user_id) |
|
| 4359 | { |
|
| 4360 | $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
| 4361 | $sql = "SELECT max(sort) as max_sort FROM $tbl_course_user |
|
| 4362 | WHERE |
|
| 4363 | user_id='".intval($user_id)."' AND |
|
| 4364 | relation_type<>".COURSE_RELATION_TYPE_RRHH." AND |
|
| 4365 | user_course_cat='".intval($user_course_category)."'"; |
|
| 4366 | $result_max = Database::query($sql); |
|
| 4367 | if (Database::num_rows($result_max) == 1) { |
|
| 4368 | $row_max = Database::fetch_array($result_max); |
|
| 4369 | return $row_max['max_sort']; |
|
| 4370 | } |
|
| 4371 | return 0; |
|
| 4372 | } |
|
| 4373 | ||
| 4374 | /** |
|
| 4375 | * Determines the number of plugins installed for a given location |
|
| 4376 | */ |
|