| @@ 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 |
|
| @@ 4495-4510 (lines=16) @@ | ||
| 4492 | * @param integer $user_id |
|
| 4493 | * @return int the value of the highest sort of the user_course_category |
|
| 4494 | */ |
|
| 4495 | function api_max_sort_value($user_course_category, $user_id) |
|
| 4496 | { |
|
| 4497 | $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
| 4498 | $sql = "SELECT max(sort) as max_sort FROM $tbl_course_user |
|
| 4499 | WHERE |
|
| 4500 | user_id='".intval($user_id)."' AND |
|
| 4501 | relation_type<>".COURSE_RELATION_TYPE_RRHH." AND |
|
| 4502 | user_course_cat='".intval($user_course_category)."'"; |
|
| 4503 | $result_max = Database::query($sql); |
|
| 4504 | if (Database::num_rows($result_max) == 1) { |
|
| 4505 | $row_max = Database::fetch_array($result_max); |
|
| 4506 | return $row_max['max_sort']; |
|
| 4507 | } |
|
| 4508 | return 0; |
|
| 4509 | } |
|
| 4510 | ||
| 4511 | /** |
|
| 4512 | * Transforms a number of seconds in hh:mm:ss format |
|
| 4513 | * @author Julian Prud'homme |
|
| @@ 4655-4669 (lines=15) @@ | ||
| 4652 | * @param int $user_id The user id |
|
| 4653 | * @return boolean |
|
| 4654 | */ |
|
| 4655 | public static function is_user_certified($cat_id, $user_id) |
|
| 4656 | { |
|
| 4657 | $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); |
|
| 4658 | $sql = 'SELECT path_certificate FROM '.$table_certificate.' |
|
| 4659 | WHERE |
|
| 4660 | cat_id="'.intval($cat_id).'" AND |
|
| 4661 | user_id="'.intval($user_id).'"'; |
|
| 4662 | $rs = Database::query($sql); |
|
| 4663 | $row = Database::fetch_array($rs); |
|
| 4664 | if ($row['path_certificate'] == '' || is_null($row['path_certificate'])) { |
|
| 4665 | return false; |
|
| 4666 | } else { |
|
| 4667 | return true; |
|
| 4668 | } |
|
| 4669 | } |
|
| 4670 | ||
| 4671 | /** |
|
| 4672 | * Gets the info about a gradebook certificate for a user by course |
|