Commit | Line | Data |
---|---|---|
7d2a0492 | 1 | <?php |
2 | // This file is part of Moodle - http://moodle.org/ | |
3 | // | |
4 | // Moodle is free software: you can redistribute it and/or modify | |
5 | // it under the terms of the GNU General Public License as published by | |
6 | // the Free Software Foundation, either version 3 of the License, or | |
7 | // (at your option) any later version. | |
8 | // | |
9 | // Moodle is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | // | |
14 | // You should have received a copy of the GNU General Public License | |
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | |
16 | ||
17 | /** | |
18 | * This file contains general functions for the course format Week | |
19 | * | |
20 | * @since 2.0 | |
21 | * @package moodlecore | |
22 | * @copyright 2009 Sam Hemelryk | |
23 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | |
24 | */ | |
25 | ||
26 | /** | |
27 | * Used to display the course structure for a course where format=weeks | |
28 | * | |
29 | * This is called automatically by {@link load_course()} if the current course | |
30 | * format = weeks. | |
31 | * | |
47c96a77 | 32 | * @param navigation_node $navigation The course node |
33 | * @param array $path An array of keys to the course node | |
34 | * @param stdClass $course The course we are loading the section for | |
7d2a0492 | 35 | */ |
3406acde | 36 | function callback_weeks_load_content(&$navigation, $course, $coursenode) { |
0f4ab67d | 37 | return $navigation->load_generic_course_sections($course, $coursenode, 'weeks'); |
7d2a0492 | 38 | } |
39 | ||
40 | /** | |
41 | * The string that is used to describe a section of the course | |
42 | * e.g. Topic, Week... | |
43 | * | |
44 | * @return string | |
45 | */ | |
46 | function callback_weeks_definition() { | |
47 | return get_string('week'); | |
48 | } | |
49 | ||
50 | /** | |
51 | * The GET argument variable that is used to identify the section being | |
52 | * viewed by the user (if there is one) | |
53 | * | |
54 | * @return string | |
55 | */ | |
56 | function callback_weeks_request_key() { | |
57 | return 'week'; | |
58 | } | |
aa6c1ced | 59 | |
0f4ab67d SH |
60 | function callback_weeks_get_section_name($course, $section, $sections) { |
61 | // We can't add a node without text | |
62 | if (!empty($section->name)) { | |
63 | // Return the name the user set | |
64 | return $section->name; | |
65 | } else if ($section->section == 0) { | |
66 | // Return the section0name | |
67 | return get_string('section0name', 'format_weeks'); | |
68 | } else { | |
69 | // Got to work out the date of the week so that we can show it | |
70 | $weekdate = $course->startdate+7200; | |
71 | foreach ($sections as $sec) { | |
72 | if ($sec->id == $section->id) { | |
73 | break; | |
74 | } else if ($sec->visible && $sec->section != 0) { | |
75 | $weekdate += 604800; | |
76 | } | |
77 | } | |
78 | $strftimedateshort = ' '.get_string('strftimedateshort'); | |
79 | $weekday = userdate($weekdate, $strftimedateshort); | |
80 | $endweekday = userdate($weekdate+518400, $strftimedateshort); | |
81 | return $weekday.' - '.$endweekday; | |
82 | } | |
83 | } |