fix_total_attendances.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. require '../../main/inc/global.inc.php';
  3. require '../../main/inc/lib/attendance.lib.php';
  4. $a = new Attendance();
  5. $sessions_list = SessionManager::get_sessions_list();
  6. $min = 90000;
  7. $max = 999999;
  8. // Get sessions
  9. foreach ($sessions_list as $session) {
  10. if ($session['id'] < $min) { continue; }
  11. echo "Session ".$session['id']."\n";
  12. // Get users in session to build users list
  13. $users = SessionManager::get_users_by_session($session['id']);
  14. $u = array();
  15. foreach ($users as $user) {
  16. $u[] = $user['user_id'];
  17. }
  18. // Get courses list to get the right course (only one in each session)
  19. $courses = SessionManager::get_course_list_by_session_id($session['id']);
  20. if (count($courses)>0) {
  21. foreach ($courses as $course) {
  22. $course_id = $course['id'];
  23. break;
  24. }
  25. echo "-- Course ".$course_id."\n";
  26. // Get attendances sheets from course (only one in each course)
  27. $att = $a->get_attendances_list($course_id,$session['id']);
  28. if (count($att)>0) {
  29. foreach ($att as $at) {
  30. $at_id = $at['id'];
  31. break; //get out after first result
  32. }
  33. echo "---- Attendance ".$at_id."\n";
  34. $a->set_course_int_id($course_id);
  35. $a->update_users_results($u,$at_id);
  36. } else {
  37. var_dump($att);
  38. }
  39. }
  40. if ($session['id']>$max) { die('Finished processing '.$max."\n"); }
  41. }