mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-33307 format_weeks - highlight current week
This commit is contained in:
parent
5744ea3682
commit
2ea6533a36
@ -92,7 +92,7 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
|
||||
|
||||
if ($section->section != 0) {
|
||||
// Only in the non-general sections.
|
||||
if ($course->marker == $section->section) {
|
||||
if ($this->is_section_current($section, $course)) {
|
||||
$o = get_accesshide(get_string('currentsection', 'format_'.$course->format));
|
||||
}
|
||||
}
|
||||
@ -121,7 +121,7 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
|
||||
// Only in the non-general sections.
|
||||
if (!$section->visible) {
|
||||
$sectionstyle = ' hidden';
|
||||
} else if ($course->marker == $section->section) {
|
||||
} else if ($this->is_section_current($section, $course)) {
|
||||
$sectionstyle = ' current';
|
||||
}
|
||||
$linktitle = ($course->coursedisplay == COURSE_DISPLAY_MULTIPAGE);
|
||||
@ -669,4 +669,16 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
|
||||
$options->overflowdiv = true;
|
||||
return format_text($summarytext, $section->summaryformat, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the section passed in the current section? (Note this isn't strictly
|
||||
* a renderering method, but neater here).
|
||||
*
|
||||
* @param stdClass $course The course entry from DB
|
||||
* @param stdClass $section The course_section entry from the DB
|
||||
* @return bool true if the section is current
|
||||
*/
|
||||
protected function is_section_current($section, $course) {
|
||||
return ($course->marker == $section->section);
|
||||
}
|
||||
}
|
||||
|
@ -58,4 +58,24 @@ class format_weeks_renderer extends format_section_renderer_base {
|
||||
protected function page_title() {
|
||||
return get_string('weeklyoutline');
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the section passed in the current section?
|
||||
*
|
||||
* @param stdClass $course The course entry from DB
|
||||
* @param stdClass $section The course_section entry from the DB
|
||||
* @return bool true if the section is current
|
||||
*/
|
||||
protected function is_section_current($section, $course) {
|
||||
if ($section->section < 1) {
|
||||
return false;
|
||||
}
|
||||
$oneweekseconds = 604800;
|
||||
$startdate = $course->startdate + ($oneweekseconds * ($section->section - 1));
|
||||
$enddate = $startdate + $oneweekseconds;
|
||||
|
||||
$timenow = time();
|
||||
|
||||
return (($timenow >= $startdate) && ($timenow < $enddate));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user