| @@ 424-435 (lines=12) @@ | ||
| 421 | * @param int |
|
| 422 | * @return String |
|
| 423 | */ |
|
| 424 | public static function get_course_id_by_link_id($id_link) |
|
| 425 | { |
|
| 426 | $course_table = Database::get_main_table(TABLE_MAIN_COURSE); |
|
| 427 | $tbl_grade_links = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
| 428 | $sql = 'SELECT c.id FROM ' . $course_table . ' c |
|
| 429 | INNER JOIN ' . $tbl_grade_links . ' l |
|
| 430 | ON c.code = l.course_code |
|
| 431 | WHERE l.id=' . intval($id_link) . ' OR l.category_id=' . intval($id_link); |
|
| 432 | $res = Database::query($sql); |
|
| 433 | $array = Database::fetch_array($res, 'ASSOC'); |
|
| 434 | return $array['id']; |
|
| 435 | } |
|
| 436 | ||
| 437 | /** |
|
| 438 | * @param $type |
|
| @@ 1311-1326 (lines=16) @@ | ||
| 1308 | * @param Integer $item_id |
|
| 1309 | * @return array |
|
| 1310 | */ |
|
| 1311 | public static function displayRating($type, $blog_id, $item_id) |
|
| 1312 | { |
|
| 1313 | $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 1314 | $course_id = api_get_course_int_id(); |
|
| 1315 | ||
| 1316 | // Calculate rating |
|
| 1317 | $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating |
|
| 1318 | WHERE |
|
| 1319 | c_id = $course_id AND |
|
| 1320 | blog_id = '".(int) $blog_id."' AND |
|
| 1321 | item_id = '".(int) $item_id."' AND |
|
| 1322 | rating_type = '".Database::escape_string($type)."' "; |
|
| 1323 | $result = Database::query($sql); |
|
| 1324 | $result = Database::fetch_array($result); |
|
| 1325 | ||
| 1326 | return round($result['rating'], 2); |
|
| 1327 | } |
|
| 1328 | ||
| 1329 | /** |
|