@@ 1201-1221 (lines=21) @@ | ||
1198 | * @param int attendance id |
|
1199 | * @return int attendance calendar id |
|
1200 | */ |
|
1201 | public function get_next_attendance_calendar_id($attendance_id) |
|
1202 | { |
|
1203 | $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1204 | $attendance_id = intval($attendance_id); |
|
1205 | $course_id = api_get_course_int_id(); |
|
1206 | ||
1207 | $sql = "SELECT id FROM $tbl_attendance_calendar |
|
1208 | WHERE |
|
1209 | c_id = $course_id AND |
|
1210 | attendance_id = '$attendance_id' AND |
|
1211 | done_attendance = 0 |
|
1212 | ORDER BY date_time |
|
1213 | LIMIT 1"; |
|
1214 | $rs = Database::query($sql); |
|
1215 | $next_calendar_id = 0; |
|
1216 | if (Database::num_rows($rs) > 0) { |
|
1217 | $row = Database::fetch_array($rs); |
|
1218 | $next_calendar_id = $row['id']; |
|
1219 | } |
|
1220 | return $next_calendar_id; |
|
1221 | } |
|
1222 | ||
1223 | /** |
|
1224 | * Get next attendance calendar datetime without presences (done attendances) |
|
@@ 1228-1248 (lines=21) @@ | ||
1225 | * @param int attendance id |
|
1226 | * @return int UNIX time format datetime |
|
1227 | */ |
|
1228 | public function get_next_attendance_calendar_datetime($attendance_id) |
|
1229 | { |
|
1230 | $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1231 | $course_id = api_get_course_int_id(); |
|
1232 | $attendance_id = intval($attendance_id); |
|
1233 | $sql = "SELECT id, date_time FROM $tbl_attendance_calendar |
|
1234 | WHERE |
|
1235 | c_id = $course_id AND |
|
1236 | attendance_id = '$attendance_id' AND |
|
1237 | done_attendance = 0 |
|
1238 | ORDER BY date_time |
|
1239 | LIMIT 1"; |
|
1240 | $rs = Database::query($sql); |
|
1241 | $next_calendar_datetime = 0; |
|
1242 | if (Database::num_rows($rs) > 0) { |
|
1243 | $row = Database::fetch_array($rs); |
|
1244 | $next_calendar_datetime = api_get_local_time($row['date_time']); |
|
1245 | } |
|
1246 | ||
1247 | return $next_calendar_datetime; |
|
1248 | } |
|
1249 | ||
1250 | /** |
|
1251 | * Get user' score from current attendance |
|
@@ 1303-1320 (lines=18) @@ | ||
1300 | * @param int attendance calendar id |
|
1301 | * @return array attendance calendar data |
|
1302 | */ |
|
1303 | public function get_attendance_calendar_by_id($calendar_id) |
|
1304 | { |
|
1305 | $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1306 | $calendar_id = intval($calendar_id); |
|
1307 | $course_id = api_get_course_int_id(); |
|
1308 | $sql = "SELECT * FROM $tbl_attendance_calendar |
|
1309 | WHERE c_id = $course_id AND id = '$calendar_id' "; |
|
1310 | $rs = Database::query($sql); |
|
1311 | $data = array(); |
|
1312 | if (Database::num_rows($rs) > 0) { |
|
1313 | while ($row = Database::fetch_array($rs)) { |
|
1314 | $row['date_time'] = api_get_local_time($row['date_time']); |
|
1315 | $data = $row; |
|
1316 | } |
|
1317 | } |
|
1318 | ||
1319 | return $data; |
|
1320 | } |
|
1321 | ||
1322 | /** |
|
1323 | * Get all attendance calendar data inside current attendance |
|
@@ 1515-1531 (lines=17) @@ | ||
1512 | * @param int $attendance_id |
|
1513 | * @return int count of dates |
|
1514 | */ |
|
1515 | public static function get_count_dates_inside_attendance_calendar($attendance_id) |
|
1516 | { |
|
1517 | $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
1518 | $attendance_id = intval($attendance_id); |
|
1519 | $course_id = api_get_course_int_id(); |
|
1520 | $sql = "SELECT count(id) FROM $tbl_attendance_calendar |
|
1521 | WHERE |
|
1522 | c_id = $course_id AND |
|
1523 | attendance_id = '$attendance_id'"; |
|
1524 | $rs = Database::query($sql); |
|
1525 | $count = 0; |
|
1526 | if (Database::num_rows($rs) > 0) { |
|
1527 | $row = Database::fetch_row($rs); |
|
1528 | $count = $row[0]; |
|
1529 | } |
|
1530 | return $count; |
|
1531 | } |
|
1532 | ||
1533 | /** |
|
1534 | * check if all calendar of an attendance is done |
@@ 67-84 (lines=18) @@ | ||
64 | * |
|
65 | * @return array |
|
66 | */ |
|
67 | public function getUserAcceptedLegal($userId, $courseId, $sessionId) |
|
68 | { |
|
69 | $userId = intval($userId); |
|
70 | $courseId = intval($courseId); |
|
71 | $sessionId = intval($sessionId); |
|
72 | ||
73 | $table = Database::get_main_table('session_rel_course_rel_user_legal'); |
|
74 | $sql = "SELECT * |
|
75 | FROM $table |
|
76 | WHERE user_id = $userId AND c_id = $courseId AND session_id = $sessionId"; |
|
77 | $result = Database::query($sql); |
|
78 | $data = array(); |
|
79 | if (Database::num_rows($result) > 0) { |
|
80 | $data = Database::fetch_array($result, 'ASSOC'); |
|
81 | } |
|
82 | ||
83 | return $data; |
|
84 | } |
|
85 | ||
86 | /** |
|
87 | * @param int $userId |
@@ 4827-4848 (lines=22) @@ | ||
4824 | * @param int $courseId |
|
4825 | * @return array |
|
4826 | */ |
|
4827 | public static function getCoachesByCourseSession($sessionId, $courseId) |
|
4828 | { |
|
4829 | $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
4830 | $sessionId = intval($sessionId); |
|
4831 | $courseId = intval($courseId); |
|
4832 | ||
4833 | $sql = "SELECT user_id FROM $table |
|
4834 | WHERE |
|
4835 | session_id = '$sessionId' AND |
|
4836 | c_id = '$courseId' AND |
|
4837 | status = 2"; |
|
4838 | $result = Database::query($sql); |
|
4839 | ||
4840 | $coaches = array(); |
|
4841 | if (Database::num_rows($result) > 0) { |
|
4842 | while ($row = Database::fetch_row($result)) { |
|
4843 | $coaches[] = $row[0]; |
|
4844 | } |
|
4845 | } |
|
4846 | ||
4847 | return $coaches; |
|
4848 | } |
|
4849 | ||
4850 | /** |
|
4851 | * @param int $sessionId |
@@ 1496-1523 (lines=28) @@ | ||
1493 | * |
|
1494 | * @return array |
|
1495 | */ |
|
1496 | public static function getLatestHotPotatoResult( |
|
1497 | $exercisePath, |
|
1498 | $userId, |
|
1499 | $courseId, |
|
1500 | $sessionId |
|
1501 | ) |
|
1502 | { |
|
1503 | $table = Database:: get_main_table( |
|
1504 | TABLE_STATISTIC_TRACK_E_HOTPOTATOES |
|
1505 | ); |
|
1506 | ||
1507 | $courseInfo = api_get_course_info_by_id($courseId); |
|
1508 | $exercisePath = Database::escape_string($exercisePath); |
|
1509 | $userId = intval($userId); |
|
1510 | ||
1511 | $sql = "SELECT * FROM $table |
|
1512 | WHERE |
|
1513 | c_id = $courseId AND |
|
1514 | exe_name LIKE '$exercisePath%' AND |
|
1515 | exe_user_id = $userId |
|
1516 | ORDER BY id |
|
1517 | LIMIT 1"; |
|
1518 | $result = Database::query($sql); |
|
1519 | $attempt = array(); |
|
1520 | if (Database::num_rows($result)) { |
|
1521 | $attempt = Database::fetch_array($result, 'ASSOC'); |
|
1522 | } |
|
1523 | return $attempt; |
|
1524 | } |
|
1525 | ||
1526 | /** |
@@ 6286-6303 (lines=18) @@ | ||
6283 | return $question_count; |
|
6284 | } |
|
6285 | ||
6286 | function get_exercise_list_ordered() |
|
6287 | { |
|
6288 | $table_exercise_order = Database::get_course_table(TABLE_QUIZ_ORDER); |
|
6289 | $course_id = api_get_course_int_id(); |
|
6290 | $session_id = api_get_session_id(); |
|
6291 | $sql = "SELECT exercise_id, exercise_order |
|
6292 | FROM $table_exercise_order |
|
6293 | WHERE c_id = $course_id AND session_id = $session_id |
|
6294 | ORDER BY exercise_order"; |
|
6295 | $result = Database::query($sql); |
|
6296 | $list = array(); |
|
6297 | if (Database::num_rows($result)) { |
|
6298 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
6299 | $list[$row['exercise_order']] = $row['exercise_id']; |
|
6300 | } |
|
6301 | } |
|
6302 | return $list; |
|
6303 | } |
|
6304 | ||
6305 | /** |
|
6306 | * Get categories added in the exercise--category matrix |
|
@@ 8187-8209 (lines=23) @@ | ||
8184 | * @param int $sessionId |
|
8185 | * @return array exercises |
|
8186 | */ |
|
8187 | public function getExercisesByCouseSession($courseId, $sessionId) |
|
8188 | { |
|
8189 | $courseId = intval($courseId); |
|
8190 | $sessionId = intval($sessionId); |
|
8191 | ||
8192 | $tbl_quiz = Database::get_course_table(TABLE_QUIZ_TEST); |
|
8193 | $sql = "SELECT * FROM $tbl_quiz cq |
|
8194 | WHERE |
|
8195 | cq.c_id = %s AND |
|
8196 | (cq.session_id = %s OR cq.session_id = 0) AND |
|
8197 | cq.active = 0 |
|
8198 | ORDER BY cq.id"; |
|
8199 | $sql = sprintf($sql, $courseId, $sessionId); |
|
8200 | ||
8201 | $result = Database::query($sql); |
|
8202 | ||
8203 | $rows = array(); |
|
8204 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
8205 | $rows[] = $row; |
|
8206 | } |
|
8207 | ||
8208 | return $rows; |
|
8209 | } |
|
8210 | ||
8211 | /** |
|
8212 | * |
@@ 2296-2314 (lines=19) @@ | ||
2293 | * @param array $courseInfo |
|
2294 | * @return array with the post info |
|
2295 | */ |
|
2296 | public function getAttachmentList($eventId, $courseInfo) |
|
2297 | { |
|
2298 | $tableAttachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
2299 | $courseId = intval($courseInfo['real_id']); |
|
2300 | $eventId = intval($eventId); |
|
2301 | ||
2302 | $sql = "SELECT id, path, filename, comment |
|
2303 | FROM $tableAttachment |
|
2304 | WHERE |
|
2305 | c_id = $courseId AND |
|
2306 | agenda_id = $eventId"; |
|
2307 | $result = Database::query($sql); |
|
2308 | $list = array(); |
|
2309 | if (Database::num_rows($result) != 0) { |
|
2310 | $list = Database::store_result($result, 'ASSOC'); |
|
2311 | } |
|
2312 | ||
2313 | return $list; |
|
2314 | } |
|
2315 | ||
2316 | ||
2317 | /** |
|
@@ 2324-2345 (lines=22) @@ | ||
2321 | * @param array $courseInfo |
|
2322 | * @return array with the post info |
|
2323 | */ |
|
2324 | public function getAttachment($attachmentId, $eventId, $courseInfo) |
|
2325 | { |
|
2326 | $tableAttachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
2327 | $courseId = intval($courseInfo['real_id']); |
|
2328 | $eventId = intval($eventId); |
|
2329 | $attachmentId = intval($attachmentId); |
|
2330 | ||
2331 | $row = array(); |
|
2332 | $sql = "SELECT id, path, filename, comment |
|
2333 | FROM $tableAttachment |
|
2334 | WHERE |
|
2335 | c_id = $courseId AND |
|
2336 | agenda_id = $eventId AND |
|
2337 | id = $attachmentId |
|
2338 | "; |
|
2339 | $result = Database::query($sql); |
|
2340 | if (Database::num_rows($result) != 0) { |
|
2341 | $row = Database::fetch_array($result, 'ASSOC'); |
|
2342 | } |
|
2343 | ||
2344 | return $row; |
|
2345 | } |
|
2346 | ||
2347 | /** |
|
2348 | * Add an attachment file into agenda |
@@ 2891-2906 (lines=16) @@ | ||
2888 | * @param integer course id |
|
2889 | * @return integer Number of interactions |
|
2890 | */ |
|
2891 | public static function get_interactions_count_from_db($lp_iv_id, $course_id) |
|
2892 | { |
|
2893 | $table = Database :: get_course_table(TABLE_LP_IV_INTERACTION); |
|
2894 | $lp_iv_id = intval($lp_iv_id); |
|
2895 | $course_id = intval($course_id); |
|
2896 | ||
2897 | $sql = "SELECT count(*) FROM $table |
|
2898 | WHERE c_id = $course_id AND lp_iv_id = $lp_iv_id"; |
|
2899 | $res = Database::query($sql); |
|
2900 | $num = 0; |
|
2901 | if (Database::num_rows($res)) { |
|
2902 | $row = Database::fetch_array($res); |
|
2903 | $num = $row[0]; |
|
2904 | } |
|
2905 | return $num; |
|
2906 | } |
|
2907 | ||
2908 | /** |
|
2909 | * Return the interactions as an array for the given lp_iv_id. |
|
@@ 2965-2981 (lines=17) @@ | ||
2962 | * @param integer Item View ID |
|
2963 | * @return integer Number of objectives |
|
2964 | */ |
|
2965 | public static function get_objectives_count_from_db($lp_iv_id, $course_id) |
|
2966 | { |
|
2967 | $table = Database :: get_course_table(TABLE_LP_IV_OBJECTIVE); |
|
2968 | $course_id = intval($course_id); |
|
2969 | $lp_iv_id = intval($lp_iv_id); |
|
2970 | $sql = "SELECT count(*) FROM $table |
|
2971 | WHERE c_id = $course_id AND lp_iv_id = $lp_iv_id"; |
|
2972 | //@todo seems that this always returns 0 |
|
2973 | $res = Database::query($sql); |
|
2974 | $num = 0; |
|
2975 | if (Database::num_rows($res)) { |
|
2976 | $row = Database :: fetch_array($res); |
|
2977 | $num = $row[0]; |
|
2978 | } |
|
2979 | ||
2980 | return $num; |
|
2981 | } |
|
2982 | ||
2983 | /** |
|
2984 | * Return the objectives as an array for the given lp_iv_id. |