| @@ 1002-1018 (lines=17) @@ | ||
| 999 | * |
|
| 1000 | * @return int is id of test category |
|
| 1001 | */ |
|
| 1002 | public static function get_category_id_for_title($title, $courseId = 0) |
|
| 1003 | { |
|
| 1004 | $out_res = 0; |
|
| 1005 | if (empty($courseId)) { |
|
| 1006 | $courseId = api_get_course_int_id(); |
|
| 1007 | } |
|
| 1008 | $courseId = intval($courseId); |
|
| 1009 | $tbl_cat = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
|
| 1010 | $sql = "SELECT id FROM $tbl_cat |
|
| 1011 | WHERE c_id = $courseId AND title = '".Database::escape_string($title)."'"; |
|
| 1012 | $res = Database::query($sql); |
|
| 1013 | if (Database::num_rows($res) > 0) { |
|
| 1014 | $data = Database::fetch_array($res); |
|
| 1015 | $out_res = $data['id']; |
|
| 1016 | } |
|
| 1017 | return $out_res; |
|
| 1018 | } |
|
| 1019 | ||
| 1020 | /** |
|
| 1021 | * Add a relation between question and category in table c_quiz_question_rel_category |
|
| @@ 5385-5405 (lines=21) @@ | ||
| 5382 | * @author Jhon Hinojosa <[email protected]>, |
|
| 5383 | * @version octubre 2008, dokeos 1.8 |
|
| 5384 | */ |
|
| 5385 | function count_number_of_post_in_thread($thread_id) |
|
| 5386 | { |
|
| 5387 | $table_posts = Database :: get_course_table(TABLE_FORUM_POST); |
|
| 5388 | $course_id = api_get_course_int_id(); |
|
| 5389 | if (empty($course_id)) { |
|
| 5390 | return 0; |
|
| 5391 | } |
|
| 5392 | $sql = "SELECT count(*) count FROM $table_posts |
|
| 5393 | WHERE |
|
| 5394 | c_id = $course_id AND |
|
| 5395 | thread_id='".intval($thread_id)."' "; |
|
| 5396 | $result = Database::query($sql); |
|
| 5397 | ||
| 5398 | $count = 0; |
|
| 5399 | if (Database::num_rows($result) > 0) { |
|
| 5400 | $row = Database::fetch_array($result); |
|
| 5401 | $count = $row['count']; |
|
| 5402 | } |
|
| 5403 | ||
| 5404 | return $count; |
|
| 5405 | } |
|
| 5406 | ||
| 5407 | /** |
|
| 5408 | * This function counts the number of post inside a thread user |
|
| @@ 5414-5431 (lines=18) @@ | ||
| 5411 | * |
|
| 5412 | * @return int the number of post inside a thread user |
|
| 5413 | */ |
|
| 5414 | function count_number_of_post_for_user_thread($thread_id, $user_id) |
|
| 5415 | { |
|
| 5416 | $table_posts = Database::get_course_table(TABLE_FORUM_POST); |
|
| 5417 | $course_id = api_get_course_int_id(); |
|
| 5418 | $sql = "SELECT count(iid) as count |
|
| 5419 | FROM $table_posts |
|
| 5420 | WHERE c_id = $course_id AND |
|
| 5421 | thread_id=".intval($thread_id)." AND |
|
| 5422 | poster_id = ".intval($user_id)." AND visible = 1 "; |
|
| 5423 | $result = Database::query($sql); |
|
| 5424 | $count = 0; |
|
| 5425 | if (Database::num_rows($result) > 0) { |
|
| 5426 | $count = Database::fetch_array($result); |
|
| 5427 | $count = $count['count']; |
|
| 5428 | } |
|
| 5429 | ||
| 5430 | return $count; |
|
| 5431 | } |
|
| 5432 | ||
| 5433 | /** |
|
| 5434 | * This function counts the number of user register in course |
|