| @@ 126-145 (lines=20) @@ | ||
| 123 | * |
|
| 124 | * @return array |
|
| 125 | */ |
|
| 126 | function get_work_data_by_path($path, $courseId = null) |
|
| 127 | { |
|
| 128 | $path = Database::escape_string($path); |
|
| 129 | if (empty($courseId)) { |
|
| 130 | $courseId = api_get_course_int_id(); |
|
| 131 | } else { |
|
| 132 | $courseId = intval($courseId); |
|
| 133 | } |
|
| 134 | ||
| 135 | $work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); |
|
| 136 | $sql = "SELECT * FROM ".$work_table." |
|
| 137 | WHERE url = '$path' AND c_id = $courseId "; |
|
| 138 | $result = Database::query($sql); |
|
| 139 | $return = array(); |
|
| 140 | if (Database::num_rows($result)) { |
|
| 141 | $return = Database::fetch_array($result, 'ASSOC'); |
|
| 142 | } |
|
| 143 | ||
| 144 | return $return; |
|
| 145 | } |
|
| 146 | ||
| 147 | /** |
|
| 148 | * @param int $id |
|
| @@ 238-257 (lines=20) @@ | ||
| 235 | * |
|
| 236 | * @return array |
|
| 237 | */ |
|
| 238 | function get_work_assignment_by_id($id, $courseId = null) |
|
| 239 | { |
|
| 240 | if (empty($courseId)) { |
|
| 241 | $courseId = api_get_course_int_id(); |
|
| 242 | } else { |
|
| 243 | $courseId = intval($courseId); |
|
| 244 | } |
|
| 245 | $id = intval($id); |
|
| 246 | ||
| 247 | $table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); |
|
| 248 | $sql = "SELECT * FROM $table |
|
| 249 | WHERE c_id = $courseId AND publication_id = $id"; |
|
| 250 | $result = Database::query($sql); |
|
| 251 | $return = array(); |
|
| 252 | if (Database::num_rows($result)) { |
|
| 253 | $return = Database::fetch_array($result, 'ASSOC'); |
|
| 254 | } |
|
| 255 | ||
| 256 | return $return; |
|
| 257 | } |
|
| 258 | ||
| 259 | /** |
|
| 260 | * @param int $id |
|
| @@ 2424-2439 (lines=16) @@ | ||
| 2421 | * @param int $user_id If none provided, will use current user |
|
| 2422 | * @return int User's status (1 for teacher, 5 for student, etc) |
|
| 2423 | */ |
|
| 2424 | function api_get_user_status($user_id = null) |
|
| 2425 | { |
|
| 2426 | $user_id = intval($user_id); |
|
| 2427 | if (empty($user_id)) { |
|
| 2428 | $user_id = api_get_user_id(); |
|
| 2429 | } |
|
| 2430 | $table = Database::get_main_table(TABLE_MAIN_USER); |
|
| 2431 | $sql = "SELECT status FROM $table WHERE user_id = $user_id "; |
|
| 2432 | $result = Database::query($sql); |
|
| 2433 | $status = null; |
|
| 2434 | if (Database::num_rows($result)) { |
|
| 2435 | $row = Database::fetch_array($result); |
|
| 2436 | $status = $row['status']; |
|
| 2437 | } |
|
| 2438 | return $status; |
|
| 2439 | } |
|
| 2440 | ||
| 2441 | /** |
|
| 2442 | * Checks whether current user is allowed to create courses |
|
| @@ 4008-4025 (lines=18) @@ | ||
| 4005 | * @param int $ref |
|
| 4006 | * @return array|resource |
|
| 4007 | */ |
|
| 4008 | function api_get_track_item_property_history($tool, $ref) |
|
| 4009 | { |
|
| 4010 | $tbl_stats_item_property = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY); |
|
| 4011 | $course_id = api_get_course_int_id(); //numeric |
|
| 4012 | $course_code = api_get_course_id(); //alphanumeric |
|
| 4013 | $item_property_id = api_get_item_property_id($course_code, $tool, $ref); |
|
| 4014 | $sql = "SELECT * FROM $tbl_stats_item_property |
|
| 4015 | WHERE item_property_id = $item_property_id AND course_id = $course_id |
|
| 4016 | ORDER BY lastedit_date DESC"; |
|
| 4017 | $result = Database::query($sql); |
|
| 4018 | if ($result == false) { |
|
| 4019 | $result = array(); |
|
| 4020 | } else { |
|
| 4021 | $result = Database::store_result($result,'ASSOC'); |
|
| 4022 | } |
|
| 4023 | ||
| 4024 | return $result; |
|
| 4025 | } |
|
| 4026 | ||
| 4027 | /** |
|
| 4028 | * Gets item property data from tool of a course id |
|
| @@ 4644-4665 (lines=22) @@ | ||
| 4641 | * @return bool True if the user is a coach |
|
| 4642 | * |
|
| 4643 | */ |
|
| 4644 | public static function is_session_course_coach($user_id, $courseId, $session_id) |
|
| 4645 | { |
|
| 4646 | $tbl_session_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
| 4647 | // Protect data |
|
| 4648 | $user_id = intval($user_id); |
|
| 4649 | $courseId = intval($courseId); |
|
| 4650 | $session_id = intval($session_id); |
|
| 4651 | $result = false; |
|
| 4652 | ||
| 4653 | $sql = "SELECT session_id FROM $tbl_session_course_rel_user |
|
| 4654 | WHERE |
|
| 4655 | session_id = $session_id AND |
|
| 4656 | c_id = $courseId AND |
|
| 4657 | user_id = $user_id AND |
|
| 4658 | status = 2 "; |
|
| 4659 | $res = Database::query($sql); |
|
| 4660 | ||
| 4661 | if (Database::num_rows($res) > 0) { |
|
| 4662 | $result = true; |
|
| 4663 | } |
|
| 4664 | return $result; |
|
| 4665 | } |
|
| 4666 | ||
| 4667 | /** |
|
| 4668 | * This function returns an icon path that represents the favicon of the website of which the url given. |
|