@@ 4007-4024 (lines=18) @@ | ||
4004 | * @param int $ref |
|
4005 | * @return array|resource |
|
4006 | */ |
|
4007 | function api_get_track_item_property_history($tool, $ref) |
|
4008 | { |
|
4009 | $tbl_stats_item_property = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY); |
|
4010 | $course_id = api_get_course_int_id(); //numeric |
|
4011 | $course_code = api_get_course_id(); //alphanumeric |
|
4012 | $item_property_id = api_get_item_property_id($course_code, $tool, $ref); |
|
4013 | $sql = "SELECT * FROM $tbl_stats_item_property |
|
4014 | WHERE item_property_id = $item_property_id AND course_id = $course_id |
|
4015 | ORDER BY lastedit_date DESC"; |
|
4016 | $result = Database::query($sql); |
|
4017 | if ($result == false) { |
|
4018 | $result = array(); |
|
4019 | } else { |
|
4020 | $result = Database::store_result($result,'ASSOC'); |
|
4021 | } |
|
4022 | ||
4023 | return $result; |
|
4024 | } |
|
4025 | ||
4026 | /** |
|
4027 | * Gets item property data from tool of a course id |
|
@@ 2518-2533 (lines=16) @@ | ||
2515 | * @param int $user_id If none provided, will use current user |
|
2516 | * @return int User's status (1 for teacher, 5 for student, etc) |
|
2517 | */ |
|
2518 | function api_get_user_status($user_id = null) |
|
2519 | { |
|
2520 | $user_id = intval($user_id); |
|
2521 | if (empty($user_id)) { |
|
2522 | $user_id = api_get_user_id(); |
|
2523 | } |
|
2524 | $table = Database::get_main_table(TABLE_MAIN_USER); |
|
2525 | $sql = "SELECT status FROM $table WHERE user_id = $user_id "; |
|
2526 | $result = Database::query($sql); |
|
2527 | $status = null; |
|
2528 | if (Database::num_rows($result)) { |
|
2529 | $row = Database::fetch_array($result); |
|
2530 | $status = $row['status']; |
|
2531 | } |
|
2532 | return $status; |
|
2533 | } |
|
2534 | ||
2535 | /** |
|
2536 | * Checks whether current user is allowed to create courses |
@@ 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 |
|
@@ 245-264 (lines=20) @@ | ||
242 | * |
|
243 | * @return array |
|
244 | */ |
|
245 | function get_work_assignment_by_id($id, $courseId = null) |
|
246 | { |
|
247 | if (empty($courseId)) { |
|
248 | $courseId = api_get_course_int_id(); |
|
249 | } else { |
|
250 | $courseId = intval($courseId); |
|
251 | } |
|
252 | $id = intval($id); |
|
253 | ||
254 | $table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); |
|
255 | $sql = "SELECT * FROM $table |
|
256 | WHERE c_id = $courseId AND publication_id = $id"; |
|
257 | $result = Database::query($sql); |
|
258 | $return = array(); |
|
259 | if (Database::num_rows($result)) { |
|
260 | $return = Database::fetch_array($result, 'ASSOC'); |
|
261 | } |
|
262 | ||
263 | return $return; |
|
264 | } |
|
265 | ||
266 | /** |
|
267 | * @param int $id |
@@ 4695-4716 (lines=22) @@ | ||
4692 | * @return bool True if the user is a coach |
|
4693 | * |
|
4694 | */ |
|
4695 | public static function is_session_course_coach($user_id, $courseId, $session_id) |
|
4696 | { |
|
4697 | $tbl_session_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
4698 | // Protect data |
|
4699 | $user_id = intval($user_id); |
|
4700 | $courseId = intval($courseId); |
|
4701 | $session_id = intval($session_id); |
|
4702 | $result = false; |
|
4703 | ||
4704 | $sql = "SELECT session_id FROM $tbl_session_course_rel_user |
|
4705 | WHERE |
|
4706 | session_id = $session_id AND |
|
4707 | c_id = $courseId AND |
|
4708 | user_id = $user_id AND |
|
4709 | status = 2 "; |
|
4710 | $res = Database::query($sql); |
|
4711 | ||
4712 | if (Database::num_rows($res) > 0) { |
|
4713 | $result = true; |
|
4714 | } |
|
4715 | return $result; |
|
4716 | } |
|
4717 | ||
4718 | /** |
|
4719 | * This function returns an icon path that represents the favicon of the website of which the url given. |