/** * Default handler. Called on initial load and whenever the view needs to refresh. */ function action_default() { if (isset($_GET['showmonth']) && preg_match('/^2\\d{3}\\-[01][0-9]$/', $_GET['showmonth'])) { list($year, $month) = explode('-', $_GET['showmonth']); if ($month < 1 || $month > 12) { $year = date('Y'); $month = date('m'); } } else { $year = date('Y'); $month = date('m'); } $tpl = new tpl('main'); $tpl->set('year', $year); $tpl->set('month', $month); $tpl->set('course_data', get_course_enrollment(LOADED_COURSE_ID)); $tpl->set('active_modules', get_active_modules(LOADED_COURSE_ID)); $tpl->set('entries', get_sessions_for_month(LOADED_COURSE_ID, $year, $month)); $tpl->set('not_fully_booked', get_not_fully_booked_modules(LOADED_COURSE_ID)); echo $tpl->render(); }
/** * Gets list of all modules that are not fully booked for the supplied course_id * * @param $course_id * * @throws RuntimeException * @return Module[] */ function get_not_fully_booked_modules($course_id) { $course_enrollment = get_course_enrollment($course_id); $modules = []; foreach ($course_enrollment->modules as $m) { if (!$m->completed && $m->spent_hours + $m->booked_hours < $m->estimated_hours) { $modules[] = $m; } } return $modules; }