forked from gjbarnard/moodle-format_topcoll
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathformat.php
More file actions
176 lines (152 loc) · 8.06 KB
/
Copy pathformat.php
File metadata and controls
176 lines (152 loc) · 8.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
/**
* Collapsed Topics Information
*
* A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics
* except zero have a toggle that displays that topic. One or more topics can be displayed at any given time.
* Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small
* code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file.
*
* @package course/format
* @subpackage topcoll
* @version See the value of '$plugin->version' in version.php.
* @copyright © 2009-onwards G J Barnard in respect to modifications of standard topics format.
* @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195}
* @link http://docs.moodle.org/en/Collapsed_Topics_course_format
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* This program 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.
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/filelib.php');
require_once($CFG->libdir . '/completionlib.php');
// Horrible backwards compatible parameter aliasing..
if ($ctopic = optional_param('ctopics', 0, PARAM_INT)) { // Collapsed Topics old section parameter.
$url = $PAGE->url;
$url->param('section', $ctopic);
debugging('Outdated collapsed topic param passed to course/view.php', DEBUG_DEVELOPER);
redirect($url);
}
if ($topic = optional_param('topic', 0, PARAM_INT)) { // Topics and Grid old section parameter.
$url = $PAGE->url;
$url->param('section', $topic);
debugging('Outdated topic / grid param passed to course/view.php', DEBUG_DEVELOPER);
redirect($url);
}
if ($week = optional_param('week', 0, PARAM_INT)) { // Weeks old section parameter.
$url = $PAGE->url;
$url->param('section', $week);
debugging('Outdated week param passed to course/view.php', DEBUG_DEVELOPER);
redirect($url);
}
// End backwards-compatible aliasing..
$context = context_course::instance($course->id);
if (($marker >= 0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
$course->marker = $marker;
course_set_marker($course->id, $marker);
}
$tcscreenreader = false;
if ($USER->screenreader == 1) {
$tcscreenreader = true; // CONTRIB-3225 - If screenreader default back to a non-toggle based topics type format.
}
$renderer = $PAGE->get_renderer('format_topcoll');
if (!empty($displaysection) && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
$renderer->print_single_section_page($course, $sections, $mods, $modnames, $modnamesused, $displaysection);
} else {
require_once($CFG->dirroot . '/course/format/topcoll/config.php');
user_preference_allow_ajax_update('topcoll_toggle_' . $course->id, PARAM_ALPHANUM);
$PAGE->requires->js_init_call('M.format_topcoll.init', array($CFG->wwwroot,
$course->id,
get_user_preferences('topcoll_toggle_' . $course->id)));
global $tcsetting;
if (empty($tcsetting) == true) {
$tcsetting = get_topcoll_setting($course->id); // CONTRIB-3378
}
?>
<style type="text/css" media="screen">
/* <![CDATA[ */
/* -- Images here as need to know the full url due to [[pix:****]] not working with course formats in the css file and the relative position changes between theme designer mode on / off. -- */
/* -- The clickable element of the Toggle -- */
.course-content ul.topics li.section .content .toggle a.cps_a {
background: transparent url(<?php echo $CFG->wwwroot ?>/course/format/topcoll/images/arrow_up.png) no-repeat 5px 45%; /* Position the arrow roughly in the centre of the Toggle. This is shown by default when JavaScript is disabled. */
}
body.jsenabled .course-content ul.topics li.section .content .toggle a.cps_a {
background: transparent url(<?php echo $CFG->wwwroot ?>/course/format/topcoll/images/arrow_down.png) no-repeat 5px 45%; /* Position the arrow roughly in the centre of the Toggle. This is shown by default when JavaScript is enabled. */
}
#toggle-all .content .sectionbody h4 a.on {
background: transparent url(<?php echo $CFG->wwwroot ?>/course/format/topcoll/images/arrow_down.png) no-repeat 0px 45%;
}
#toggle-all .content .sectionbody h4 a.off {
background: transparent url(<?php echo $CFG->wwwroot ?>/course/format/topcoll/images/arrow_up.png) no-repeat 0px 45%;
}
/* Set settings */
#tc-set-settings {
background: transparent url(<?php echo $CFG->wwwroot ?>/course/format/topcoll/images/tc_logo_spanner.png) no-repeat 0px 0px;
width: 96px;
height: 75px;
float: right;
margin: 4px;
vertical-align: text-top;
}
/* -- Toggle -- */
.course-content ul.topics li.section .content .toggle {
background-color: #<?php echo $tcsetting->tgbgcolour; ?>;
color: #<?php echo $tcsetting->tgfgcolour; ?>; /* 'Topic x' text colour */
}
/* -- Toggle text -- */
.course-content ul.topics li.section .content .toggle a {
color: #<?php echo $tcsetting->tgfgcolour; ?>;
}
/* -- What happens when a toggle is hovered over -- */
.course-content ul.topics li.section .content div.toggle:hover,body.jsenabled tr.cps td a:hover
{
background-color: #<?php echo $tcsetting->tgbghvrcolour; ?>;
}
/* Dynamically changing widths with language */
.course-content ul.topics li.section .content, .course-content ul.topics li.tcsection .content {
<?php
if ((!$PAGE->user_is_editing()) && ($PAGE->theme->name != 'mymobile')) {
echo 'margin: 0 ' . get_string('topcollsidewidth', 'format_topcoll');
}
?>;
}
.course-content ul.topics li.section .left, .course-content ul.topics li.tcsection .left {
<?php
if (!$PAGE->user_is_editing()) {
echo 'width: ' . get_string('topcollsidewidth', 'format_topcoll');
}
?>;
}
.course-content ul.topics li.section .right, .course-content ul.topics li.tcsection .right {
<?php
if (!$PAGE->user_is_editing()) {
echo 'width: ' . get_string('topcollsidewidth', 'format_topcoll');
}
?>;
}
/* ]]> */
</style>
<?php
$thecurrentsection = 0; // The section that will be the current section - manipulated in section_header in the renderer.
$renderer->print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused);
//print ($thecurrentsection);
// Only toggle if no Screen Reader
if ($tcscreenreader == false) {
// Establish persistance when we have loaded.
// Reload the state of the toggles from the data contained within the cookie.
// Restore the state of the toggles from the cookie.
echo $PAGE->requires->js_init_call('M.format_topcoll.set_current_section', array($thecurrentsection)); // If thecurrentsection is 0 because it has not been changed from the defualt, then as section 0 is never tested so can be used to set none.
echo $PAGE->requires->js_init_call('M.format_topcoll.reload_toggles', array($course->numsections)); // reload_toggles uses the value set above.
}
}
// Include course format js module
$PAGE->requires->js('/course/format/topcoll/format.js');