moodle/course/format/weeks/renderer.php

82 lines
2.5 KiB
PHP
Raw Normal View History

<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Renderer for outputting the weeks course format.
*
* @package format_weeks
* @copyright 2012 Dan Poltawski
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.3
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot.'/course/format/renderer.php');
/**
* Basic renderer for weeks format.
*
* @copyright 2012 Dan Poltawski
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class format_weeks_renderer extends format_section_renderer_base {
/**
* Generate the starting container html for a list of sections
* @return string HTML to output.
*/
protected function start_section_list() {
return html_writer::start_tag('ul', array('class' => 'weeks'));
}
/**
* Generate the closing container html for a list of sections
* @return string HTML to output.
*/
protected function end_section_list() {
return html_writer::end_tag('ul');
}
/**
* Generate the title for this section page
* @return string the page title
*/
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));
}
}