Advertisement
Guest User

Untitled

a guest
Jul 5th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. function get_sessions_complete($user_id, $currentprogram) {
  2.  
  3. $taskscomplete = 0;
  4. $totaltasks = 0;
  5. $sessioncompletecount = 0;
  6. global $wpdb;
  7.  
  8. while ( have_rows('program') ) : the_row();
  9.  
  10. $sessioncompletecount++;
  11.  
  12. $theprogramid = get_sub_field('program_id');
  13.  
  14. if($theprogramid == $currentprogram) {
  15.  
  16. $taskresults = $wpdb->get_results('QUERY HERE');
  17.  
  18. while( have_rows('program_sessions') ): the_row();
  19.  
  20. while( have_rows('session_tasks') ): the_row();
  21.  
  22. foreach ( $taskresults as $result ) {
  23.  
  24. $currenttaskid = get_sub_field('task_id');
  25.  
  26. if ($result->task_Id == $currenttaskid) {
  27.  
  28. $taskscomplete++;
  29.  
  30. }
  31.  
  32. $totaltasks++;
  33. }
  34.  
  35. endwhile;
  36.  
  37. if($taskscomplete >= $totaltasks && $totaltasks > 0) {
  38. $sessioncompletecount++;
  39. }
  40.  
  41. endwhile;
  42.  
  43. }
  44.  
  45. endwhile;
  46.  
  47. return $sessioncompletecount;
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement