| @@ 449-460 (lines=12) @@ | ||
| 446 | * @param int |
|
| 447 | * @return String |
|
| 448 | */ |
|
| 449 | public static function get_course_id_by_link_id($id_link) |
|
| 450 | { |
|
| 451 | $course_table = Database::get_main_table(TABLE_MAIN_COURSE); |
|
| 452 | $tbl_grade_links = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
| 453 | $sql = 'SELECT c.id FROM ' . $course_table . ' c |
|
| 454 | INNER JOIN ' . $tbl_grade_links . ' l |
|
| 455 | ON c.id = l.c_id |
|
| 456 | WHERE l.id=' . intval($id_link) . ' OR l.category_id=' . intval($id_link); |
|
| 457 | $res = Database::query($sql); |
|
| 458 | $array = Database::fetch_array($res, 'ASSOC'); |
|
| 459 | return $array['id']; |
|
| 460 | } |
|
| 461 | ||
| 462 | /** |
|
| 463 | * @param $type |
|
| @@ 4510-4525 (lines=16) @@ | ||
| 4507 | * @param integer $user_id |
|
| 4508 | * @return int the value of the highest sort of the user_course_category |
|
| 4509 | */ |
|
| 4510 | function api_max_sort_value($user_course_category, $user_id) |
|
| 4511 | { |
|
| 4512 | $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
| 4513 | $sql = "SELECT max(sort) as max_sort FROM $tbl_course_user |
|
| 4514 | WHERE |
|
| 4515 | user_id='".intval($user_id)."' AND |
|
| 4516 | relation_type<>".COURSE_RELATION_TYPE_RRHH." AND |
|
| 4517 | user_course_cat='".intval($user_course_category)."'"; |
|
| 4518 | $result_max = Database::query($sql); |
|
| 4519 | if (Database::num_rows($result_max) == 1) { |
|
| 4520 | $row_max = Database::fetch_array($result_max); |
|
| 4521 | return $row_max['max_sort']; |
|
| 4522 | } |
|
| 4523 | return 0; |
|
| 4524 | } |
|
| 4525 | ||
| 4526 | /** |
|
| 4527 | * Transforms a number of seconds in hh:mm:ss format |
|
| 4528 | * @author Julian Prud'homme |
|
| @@ 4670-4684 (lines=15) @@ | ||
| 4667 | * @param int $user_id The user id |
|
| 4668 | * @return boolean |
|
| 4669 | */ |
|
| 4670 | public static function is_user_certified($cat_id, $user_id) |
|
| 4671 | { |
|
| 4672 | $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); |
|
| 4673 | $sql = 'SELECT path_certificate FROM '.$table_certificate.' |
|
| 4674 | WHERE |
|
| 4675 | cat_id="'.intval($cat_id).'" AND |
|
| 4676 | user_id="'.intval($user_id).'"'; |
|
| 4677 | $rs = Database::query($sql); |
|
| 4678 | $row = Database::fetch_array($rs); |
|
| 4679 | if ($row['path_certificate'] == '' || is_null($row['path_certificate'])) { |
|
| 4680 | return false; |
|
| 4681 | } else { |
|
| 4682 | return true; |
|
| 4683 | } |
|
| 4684 | } |
|
| 4685 | ||
| 4686 | /** |
|
| 4687 | * Gets the info about a gradebook certificate for a user by course |
|