| @@ 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 |
|
| @@ 1476-1503 (lines=28) @@ | ||
| 1473 | * |
|
| 1474 | * @return array |
|
| 1475 | */ |
|
| 1476 | public static function getLatestHotPotatoResult( |
|
| 1477 | $exercisePath, |
|
| 1478 | $userId, |
|
| 1479 | $courseId, |
|
| 1480 | $sessionId |
|
| 1481 | ) { |
|
| 1482 | $table = Database:: get_main_table( |
|
| 1483 | TABLE_STATISTIC_TRACK_E_HOTPOTATOES |
|
| 1484 | ); |
|
| 1485 | ||
| 1486 | $courseInfo = api_get_course_info_by_id($courseId); |
|
| 1487 | $exercisePath = Database::escape_string($exercisePath); |
|
| 1488 | $userId = intval($userId); |
|
| 1489 | ||
| 1490 | $sql = "SELECT * FROM $table |
|
| 1491 | WHERE |
|
| 1492 | c_id = $courseId AND |
|
| 1493 | exe_name LIKE '$exercisePath%' AND |
|
| 1494 | exe_user_id = $userId |
|
| 1495 | ORDER BY id |
|
| 1496 | LIMIT 1"; |
|
| 1497 | $result = Database::query($sql); |
|
| 1498 | $attempt = array(); |
|
| 1499 | if (Database::num_rows($result)) { |
|
| 1500 | $attempt = Database::fetch_array($result, 'ASSOC'); |
|
| 1501 | } |
|
| 1502 | return $attempt; |
|
| 1503 | } |
|
| 1504 | ||
| 1505 | /** |
|
| 1506 | * Gets the exam'data results |
|
| @@ 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 |
|
| @@ 4814-4835 (lines=22) @@ | ||
| 4811 | * @param int $courseId |
|
| 4812 | * @return array |
|
| 4813 | */ |
|
| 4814 | public static function getCoachesByCourseSession($sessionId, $courseId) |
|
| 4815 | { |
|
| 4816 | $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
| 4817 | $sessionId = intval($sessionId); |
|
| 4818 | $courseId = intval($courseId); |
|
| 4819 | ||
| 4820 | $sql = "SELECT user_id FROM $table |
|
| 4821 | WHERE |
|
| 4822 | session_id = '$sessionId' AND |
|
| 4823 | c_id = '$courseId' AND |
|
| 4824 | status = 2"; |
|
| 4825 | $result = Database::query($sql); |
|
| 4826 | ||
| 4827 | $coaches = array(); |
|
| 4828 | if (Database::num_rows($result) > 0) { |
|
| 4829 | while ($row = Database::fetch_row($result)) { |
|
| 4830 | $coaches[] = $row[0]; |
|
| 4831 | } |
|
| 4832 | } |
|
| 4833 | ||
| 4834 | return $coaches; |
|
| 4835 | } |
|
| 4836 | ||
| 4837 | /** |
|
| 4838 | * @param int $sessionId |
|
| @@ 2295-2313 (lines=19) @@ | ||
| 2292 | * @param array $courseInfo |
|
| 2293 | * @return array with the post info |
|
| 2294 | */ |
|
| 2295 | public function getAttachmentList($eventId, $courseInfo) |
|
| 2296 | { |
|
| 2297 | $tableAttachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
| 2298 | $courseId = intval($courseInfo['real_id']); |
|
| 2299 | $eventId = intval($eventId); |
|
| 2300 | ||
| 2301 | $sql = "SELECT id, path, filename, comment |
|
| 2302 | FROM $tableAttachment |
|
| 2303 | WHERE |
|
| 2304 | c_id = $courseId AND |
|
| 2305 | agenda_id = $eventId"; |
|
| 2306 | $result = Database::query($sql); |
|
| 2307 | $list = array(); |
|
| 2308 | if (Database::num_rows($result) != 0) { |
|
| 2309 | $list = Database::store_result($result, 'ASSOC'); |
|
| 2310 | } |
|
| 2311 | ||
| 2312 | return $list; |
|
| 2313 | } |
|
| 2314 | ||
| 2315 | ||
| 2316 | /** |
|
| @@ 2323-2344 (lines=22) @@ | ||
| 2320 | * @param array $courseInfo |
|
| 2321 | * @return array with the post info |
|
| 2322 | */ |
|
| 2323 | public function getAttachment($attachmentId, $eventId, $courseInfo) |
|
| 2324 | { |
|
| 2325 | $tableAttachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
| 2326 | $courseId = intval($courseInfo['real_id']); |
|
| 2327 | $eventId = intval($eventId); |
|
| 2328 | $attachmentId = intval($attachmentId); |
|
| 2329 | ||
| 2330 | $row = array(); |
|
| 2331 | $sql = "SELECT id, path, filename, comment |
|
| 2332 | FROM $tableAttachment |
|
| 2333 | WHERE |
|
| 2334 | c_id = $courseId AND |
|
| 2335 | agenda_id = $eventId AND |
|
| 2336 | id = $attachmentId |
|
| 2337 | "; |
|
| 2338 | $result = Database::query($sql); |
|
| 2339 | if (Database::num_rows($result) != 0) { |
|
| 2340 | $row = Database::fetch_array($result, 'ASSOC'); |
|
| 2341 | } |
|
| 2342 | ||
| 2343 | return $row; |
|
| 2344 | } |
|
| 2345 | ||
| 2346 | /** |
|
| 2347 | * Add an attachment file into agenda |
|
| @@ 2883-2898 (lines=16) @@ | ||
| 2880 | * @param integer course id |
|
| 2881 | * @return integer Number of interactions |
|
| 2882 | */ |
|
| 2883 | public static function get_interactions_count_from_db($lp_iv_id, $course_id) |
|
| 2884 | { |
|
| 2885 | $table = Database :: get_course_table(TABLE_LP_IV_INTERACTION); |
|
| 2886 | $lp_iv_id = intval($lp_iv_id); |
|
| 2887 | $course_id = intval($course_id); |
|
| 2888 | ||
| 2889 | $sql = "SELECT count(*) FROM $table |
|
| 2890 | WHERE c_id = $course_id AND lp_iv_id = $lp_iv_id"; |
|
| 2891 | $res = Database::query($sql); |
|
| 2892 | $num = 0; |
|
| 2893 | if (Database::num_rows($res)) { |
|
| 2894 | $row = Database::fetch_array($res); |
|
| 2895 | $num = $row[0]; |
|
| 2896 | } |
|
| 2897 | return $num; |
|
| 2898 | } |
|
| 2899 | ||
| 2900 | /** |
|
| 2901 | * Return the interactions as an array for the given lp_iv_id. |
|
| @@ 2957-2973 (lines=17) @@ | ||
| 2954 | * @param integer Item View ID |
|
| 2955 | * @return integer Number of objectives |
|
| 2956 | */ |
|
| 2957 | public static function get_objectives_count_from_db($lp_iv_id, $course_id) |
|
| 2958 | { |
|
| 2959 | $table = Database :: get_course_table(TABLE_LP_IV_OBJECTIVE); |
|
| 2960 | $course_id = intval($course_id); |
|
| 2961 | $lp_iv_id = intval($lp_iv_id); |
|
| 2962 | $sql = "SELECT count(*) FROM $table |
|
| 2963 | WHERE c_id = $course_id AND lp_iv_id = $lp_iv_id"; |
|
| 2964 | //@todo seems that this always returns 0 |
|
| 2965 | $res = Database::query($sql); |
|
| 2966 | $num = 0; |
|
| 2967 | if (Database::num_rows($res)) { |
|
| 2968 | $row = Database :: fetch_array($res); |
|
| 2969 | $num = $row[0]; |
|
| 2970 | } |
|
| 2971 | ||
| 2972 | return $num; |
|
| 2973 | } |
|
| 2974 | ||
| 2975 | /** |
|
| 2976 | * Return the objectives as an array for the given lp_iv_id. |
|