/** * Is the section passed in the current section? * * @param stdClass $section The course_section entry from the DB * @param stdClass $course The course entry from DB * @return bool true if the section is current */ protected function is_section_current($section, $course) { if ($section->section < 1) { return false; } $timenow = time(); $dates = format_weeks_get_section_dates($section, $course); return $timenow >= $dates->start && $timenow < $dates->end; }
/** * Gets the name for the provided section. * * @param stdClass $course * @param stdClass $section * @return string */ function callback_weeks_get_section_name($course, $section) { // We can't add a node without text if (!empty($section->name)) { // Return the name the user set. return format_string($section->name, true, array('context' => context_course::instance($course->id))); } else { if ($section->section == 0) { // Return the general section. return get_string('section0name', 'format_weeks'); } else { $dates = format_weeks_get_section_dates($section, $course); // We subtract 24 hours for display purposes. $dates->end = $dates->end - 86400; $dateformat = ' ' . get_string('strftimedateshort'); $weekday = userdate($dates->start, $dateformat); $endweekday = userdate($dates->end, $dateformat); return $weekday . ' - ' . $endweekday; } } }