@@ 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 |
@@ 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 |
@@ 4825-4846 (lines=22) @@ | ||
4822 | * @param int $courseId |
|
4823 | * @return array |
|
4824 | */ |
|
4825 | public static function getCoachesByCourseSession($sessionId, $courseId) |
|
4826 | { |
|
4827 | $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
4828 | $sessionId = intval($sessionId); |
|
4829 | $courseId = intval($courseId); |
|
4830 | ||
4831 | $sql = "SELECT user_id FROM $table |
|
4832 | WHERE |
|
4833 | session_id = '$sessionId' AND |
|
4834 | c_id = '$courseId' AND |
|
4835 | status = 2"; |
|
4836 | $result = Database::query($sql); |
|
4837 | ||
4838 | $coaches = array(); |
|
4839 | if (Database::num_rows($result) > 0) { |
|
4840 | while ($row = Database::fetch_row($result)) { |
|
4841 | $coaches[] = $row[0]; |
|
4842 | } |
|
4843 | } |
|
4844 | ||
4845 | return $coaches; |
|
4846 | } |
|
4847 | ||
4848 | /** |
|
4849 | * @param int $sessionId |
@@ 2887-2902 (lines=16) @@ | ||
2884 | * @param integer course id |
|
2885 | * @return integer Number of interactions |
|
2886 | */ |
|
2887 | public static function get_interactions_count_from_db($lp_iv_id, $course_id) |
|
2888 | { |
|
2889 | $table = Database :: get_course_table(TABLE_LP_IV_INTERACTION); |
|
2890 | $lp_iv_id = intval($lp_iv_id); |
|
2891 | $course_id = intval($course_id); |
|
2892 | ||
2893 | $sql = "SELECT count(*) FROM $table |
|
2894 | WHERE c_id = $course_id AND lp_iv_id = $lp_iv_id"; |
|
2895 | $res = Database::query($sql); |
|
2896 | $num = 0; |
|
2897 | if (Database::num_rows($res)) { |
|
2898 | $row = Database::fetch_array($res); |
|
2899 | $num = $row[0]; |
|
2900 | } |
|
2901 | return $num; |
|
2902 | } |
|
2903 | ||
2904 | /** |
|
2905 | * Return the interactions as an array for the given lp_iv_id. |
|
@@ 2961-2977 (lines=17) @@ | ||
2958 | * @param integer Item View ID |
|
2959 | * @return integer Number of objectives |
|
2960 | */ |
|
2961 | public static function get_objectives_count_from_db($lp_iv_id, $course_id) |
|
2962 | { |
|
2963 | $table = Database :: get_course_table(TABLE_LP_IV_OBJECTIVE); |
|
2964 | $course_id = intval($course_id); |
|
2965 | $lp_iv_id = intval($lp_iv_id); |
|
2966 | $sql = "SELECT count(*) FROM $table |
|
2967 | WHERE c_id = $course_id AND lp_iv_id = $lp_iv_id"; |
|
2968 | //@todo seems that this always returns 0 |
|
2969 | $res = Database::query($sql); |
|
2970 | $num = 0; |
|
2971 | if (Database::num_rows($res)) { |
|
2972 | $row = Database :: fetch_array($res); |
|
2973 | $num = $row[0]; |
|
2974 | } |
|
2975 | ||
2976 | return $num; |
|
2977 | } |
|
2978 | ||
2979 | /** |
|
2980 | * Return the objectives as an array for the given lp_iv_id. |
@@ 1500-1527 (lines=28) @@ | ||
1497 | * |
|
1498 | * @return array |
|
1499 | */ |
|
1500 | public static function getLatestHotPotatoResult( |
|
1501 | $exercisePath, |
|
1502 | $userId, |
|
1503 | $courseId, |
|
1504 | $sessionId |
|
1505 | ) { |
|
1506 | $table = Database:: get_main_table( |
|
1507 | TABLE_STATISTIC_TRACK_E_HOTPOTATOES |
|
1508 | ); |
|
1509 | ||
1510 | $courseInfo = api_get_course_info_by_id($courseId); |
|
1511 | $exercisePath = Database::escape_string($exercisePath); |
|
1512 | $userId = intval($userId); |
|
1513 | ||
1514 | $sql = "SELECT * FROM $table |
|
1515 | WHERE |
|
1516 | c_id = $courseId AND |
|
1517 | exe_name LIKE '$exercisePath%' AND |
|
1518 | exe_user_id = $userId |
|
1519 | ORDER BY id |
|
1520 | LIMIT 1"; |
|
1521 | $result = Database::query($sql); |
|
1522 | $attempt = array(); |
|
1523 | if (Database::num_rows($result)) { |
|
1524 | $attempt = Database::fetch_array($result, 'ASSOC'); |
|
1525 | } |
|
1526 | return $attempt; |
|
1527 | } |
|
1528 | ||
1529 | /** |
|
1530 | * Gets the exam'data results |
@@ 6284-6301 (lines=18) @@ | ||
6281 | return $question_count; |
|
6282 | } |
|
6283 | ||
6284 | function get_exercise_list_ordered() |
|
6285 | { |
|
6286 | $table_exercise_order = Database::get_course_table(TABLE_QUIZ_ORDER); |
|
6287 | $course_id = api_get_course_int_id(); |
|
6288 | $session_id = api_get_session_id(); |
|
6289 | $sql = "SELECT exercise_id, exercise_order |
|
6290 | FROM $table_exercise_order |
|
6291 | WHERE c_id = $course_id AND session_id = $session_id |
|
6292 | ORDER BY exercise_order"; |
|
6293 | $result = Database::query($sql); |
|
6294 | $list = array(); |
|
6295 | if (Database::num_rows($result)) { |
|
6296 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
6297 | $list[$row['exercise_order']] = $row['exercise_id']; |
|
6298 | } |
|
6299 | } |
|
6300 | return $list; |
|
6301 | } |
|
6302 | ||
6303 | /** |
|
6304 | * Get categories added in the exercise--category matrix |
|
@@ 8185-8207 (lines=23) @@ | ||
8182 | * @param int $sessionId |
|
8183 | * @return array exercises |
|
8184 | */ |
|
8185 | public function getExercisesByCouseSession($courseId, $sessionId) |
|
8186 | { |
|
8187 | $courseId = intval($courseId); |
|
8188 | $sessionId = intval($sessionId); |
|
8189 | ||
8190 | $tbl_quiz = Database::get_course_table(TABLE_QUIZ_TEST); |
|
8191 | $sql = "SELECT * FROM $tbl_quiz cq |
|
8192 | WHERE |
|
8193 | cq.c_id = %s AND |
|
8194 | (cq.session_id = %s OR cq.session_id = 0) AND |
|
8195 | cq.active = 0 |
|
8196 | ORDER BY cq.id"; |
|
8197 | $sql = sprintf($sql, $courseId, $sessionId); |
|
8198 | ||
8199 | $result = Database::query($sql); |
|
8200 | ||
8201 | $rows = array(); |
|
8202 | while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
8203 | $rows[] = $row; |
|
8204 | } |
|
8205 | ||
8206 | return $rows; |
|
8207 | } |
|
8208 | ||
8209 | /** |
|
8210 | * |