Proyectos de Subversion Moodle

Rev

Rev 1125 | Rev 1139 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
533 ariadna 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
 * A two column layout for the universe theme.
19
 *
20
 * @package   theme_universe
21
 * @copyright 2023 Marcin Czaja (https://rosea.io)
22
 * @license   Commercial https://themeforest.net/licenses
23
 */
24
 
1115 efrain 25
 
533 ariadna 26
defined('MOODLE_INTERNAL') || die();
27
 
1119 efrain 28
global $CFG, $PAGE, $OUTPUT;
29
 
533 ariadna 30
require_once($CFG->libdir . '/behat/lib.php');
31
require_once($CFG->dirroot . '/course/lib.php');
32
 
1126 efrain 33
 
34
$linkurl = '';
1125 efrain 35
if(!empty($PAGE->course->id)) {
1126 efrain 36
    $course = get_course($PAGE->course->id);
37
    $course_context = context_course::instance($course->id);
38
    $completioninfo = new \completion_info($course);
39
 
40
 
41
    $modules = get_fast_modinfo($course->id)->get_cms();
1119 efrain 42
    if(!empty($modules))
43
    foreach ($modules as $module)
44
    {
45
        if (!$module->uservisible || $module->is_stealth() || empty($module->url)) {
46
            continue;
47
        }
48
        $linkurl = new \moodle_url($module->url, array('forceview' => 1));
49
 
1126 efrain 50
        $completiondata = $completioninfo->get_data($module, true);
51
        if($completiondata &&  $completiondata->completionstate == COMPLETION_COMPLETE || $completiondata->completionstate == COMPLETION_COMPLETE_PASS) {
52
            continue;
53
        }
54
        break;
1119 efrain 55
    }
1126 efrain 56
}
1119 efrain 57
 
1126 efrain 58
if($linkurl) {
59
    redirect($linkurl);
60
    exit;
1119 efrain 61
}
1116 efrain 62
 
63
 
533 ariadna 64
$draweropenright = false;
65
$extraclasses = [];
66
 
67
$courseindexopen = false;
68
$blockdraweropen = false;
69
 
70
// Moodle 4. - Add block button in editing mode.
71
$addblockbutton = $OUTPUT->addblockbutton();
72
if (isloggedin()) {
73
    $courseindexopen = (get_user_preferences('drawer-open-index', true) == true);
74
    $blockdraweropen = (get_user_preferences('drawer-open-block') == true);
75
} else {
76
    $courseindexopen = false;
77
    $blockdraweropen = false;
78
}
79
 
80
if (defined('BEHAT_SITE_RUNNING')) {
81
    $blockdraweropen = true;
82
}
83
 
84
$extraclasses = ['uses-drawers'];
85
// End.
86
 
87
// Dark mode.
88
if (isloggedin()) {
89
    $navdraweropen = get_user_preferences('drawer-open-nav', true);
90
    $draweropenright = (get_user_preferences('sidepre-open', 'true') == 'true');
91
 
92
    if (theme_universe_get_setting('darkmodetheme') == '1') {
93
        $darkmodeon = get_user_preferences('darkmode-on');
94
        if ($darkmodeon) {
95
            $extraclasses[] = 'theme-dark';
96
        }
97
        $darkmodetheme = true;
98
    } else {
99
        $darkmodeon = false;
100
    }
101
} else {
102
    $navdraweropen = false;
103
}
104
 
105
if (theme_universe_get_setting('darkmodefirst') == '1') {
106
    $extraclasses[] = 'theme-dark';
107
    $darkmodetheme = false;
108
    $darkmodeon = true;
109
}
110
 
111
$siteurl = $CFG->wwwroot;
112
 
113
$blockshtml = $OUTPUT->blocks('side-pre');
114
$hasblocks = (strpos($blockshtml, 'data-block=') !== false || !empty($addblockbutton));
115
if (!$hasblocks) {
116
    $blockdraweropen = false;
117
}
118
 
119
if (theme_universe_get_setting('hidecourseindexnav') == true) {
120
    $hidecourseindexnav = true;
121
} else {
122
    $hidecourseindexnav = false;
123
}
124
 
125
if (theme_universe_get_setting('hidecourseindexnav') == false) {
126
    $courseindex = core_course_drawer();
127
    if (!$courseindex) {
128
        $courseindexopen = false;
129
    }
130
    if ($courseindexopen == false) {
131
        $extraclasses[] = 'drawer-open-index--closed';
132
    } else {
133
        $extraclasses[] = 'drawer-open-index--open';
134
    }
135
} else {
136
    $courseindex = false;
137
    $courseindexopen = false;
138
}
139
 
140
$sidecourseblocks = $OUTPUT->blocks('sidecourseblocks');
141
$hassidecourseblocks = strpos($sidecourseblocks, 'data-block=') !== false;
142
 
143
 
144
if ($draweropenright && $hasblocks) {
145
    $extraclasses[] = 'drawer-open-right';
146
}
147
 
148
$ctopbl = $OUTPUT->blocks('ctopbl');
149
$cbottombl = $OUTPUT->blocks('cbottombl');
150
$cstopbl = $OUTPUT->blocks('cstopbl');
151
$csbottombl = $OUTPUT->blocks('csbottombl');
152
$coursetab1 = $OUTPUT->blocks('coursetab-a');
153
$coursetab2 = $OUTPUT->blocks('coursetab-b');
154
$coursetab3 = $OUTPUT->blocks('coursetab-c');
155
$coursetab4 = $OUTPUT->blocks('coursetab-d');
156
$coursetab5 = $OUTPUT->blocks('coursetab-e');
157
 
158
// Moodle 4.
159
$forceblockdraweropen = $OUTPUT->firstview_fakeblocks();
160
 
161
$secondarynavigation = false;
162
$overflow = '';
163
if ($PAGE->has_secondary_navigation()) {
164
    $tablistnav = $PAGE->has_tablist_secondary_navigation();
165
    $moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs', true, $tablistnav);
166
    $secondarynavigation = $moremenu->export_for_template($OUTPUT);
167
    $overflowdata = $PAGE->secondarynav->get_overflow_menu_data();
168
    if (!is_null($overflowdata)) {
169
        $overflow = $overflowdata->export_for_template($OUTPUT);
170
    }
171
}
172
 
173
$primary = new core\navigation\output\primary($PAGE);
174
$renderer = $PAGE->get_renderer('core');
175
$primarymenu = $primary->export_for_template($renderer);
176
$buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions() && !$PAGE->has_secondary_navigation();
177
// If the settings menu will be included in the header then don't add it here.
178
$regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false;
179
 
180
$header = $PAGE->activityheader;
181
$headercontent = $header->export_for_template($renderer);
182
 
183
// RUI.
184
$iscoursepage = true;
185
 
186
if ($hassidecourseblocks) {
187
    $extraclasses[] = 'page-has-blocks';
188
}
189
 
190
if (!isloggedin() || isguestuser()) {
191
    $isnotloggedin = true;
192
} else {
193
    $isnotloggedin = false;
194
}
195
 
196
// Check if guest user.
197
if (isguestuser()) {
198
    $extraclasses[] = 'moodle-guest-user';
199
}
200
 
201
// Start - Course Image Position (theme settings).
202
$courseimage = theme_universe_get_setting('ipcourseimage');
203
 
204
if ($hassidecourseblocks) {
205
    $extraclasses[] = 'page-has-blocks';
206
}
207
 
208
if ($PAGE->course->enablecompletion == '1') {
209
    $extraclasses[] = 'rui-course--enablecompletion';
210
}
211
 
212
if ($PAGE->course->showactivitydates == '1') {
213
    $extraclasses[] = 'rui-course--showactivitydates';
214
}
215
 
216
if ($PAGE->course->visible == '1') {
217
    $extraclasses[] = 'rui-course--visible';
218
}
219
 
220
$iscoursepage = true;
221
 
222
if (theme_universe_get_setting('backtotop') == '1') {
223
    $extraclasses[] = 'back-to-top-on';
224
}
225
 
226
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
227
 
228
$templatecontext = [
229
    'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
230
    'output' => $OUTPUT,
231
    'bodyattributes' => $bodyattributes,
232
    'darkmodeon' => !empty($darkmodeon),
233
    'darkmodetheme' => !empty($darkmodetheme),
234
    'siteurl' => $siteurl,
235
    'sidepreblocks' => $blockshtml,
236
    'hasblocks' => $hasblocks,
237
    'navdraweropen' => $navdraweropen,
238
    'draweropenright' => $draweropenright,
239
    'isnotloggedin' => $isnotloggedin,
240
    'ctopbl' => $ctopbl,
241
    'cbottombl' => $cbottombl,
242
    'cstopbl' => $cstopbl,
243
    'csbottombl' => $csbottombl,
244
    'coursetab-a' => $coursetab1,
245
    'coursetab-b' => $coursetab2,
246
    'coursetab-c' => $coursetab3,
247
    'coursetab-d' => $coursetab4,
248
    'coursetab-e' => $coursetab5,
249
    'hasctopbl' => !empty($ctopbl),
250
    'hascbottombl' => !empty($cbottombl),
251
    'hascstopbl' => !empty($cstopbl),
252
    'hascsbottombl' => !empty($csbottombl),
253
    'sidecourseblocks' => $sidecourseblocks,
254
    'hassidecourseblocks' => $hassidecourseblocks,
255
    'ipcourseimage' => $courseimage,
256
    'iscoursepage' => $iscoursepage,
257
    // Moodle 4.
258
    'courseindexopen' => $courseindexopen,
259
    'blockdraweropen' => $blockdraweropen,
260
    'courseindex' => $courseindex,
261
    'primarymoremenu' => $primarymenu['moremenu'],
262
    'secondarymoremenu' => $secondarynavigation ?: false,
263
    'headercontent' => $headercontent,
264
    'forceblockdraweropen' => $forceblockdraweropen,
265
    'regionmainsettingsmenu' => $regionmainsettingsmenu,
266
    'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
267
    'overflow' => $overflow,
268
    'addblockbutton' => $addblockbutton,
269
    'hidecourseindexnav' => $hidecourseindexnav,
270
];
271
 
272
// Get and use the course page information banners HTML code, if any course page hints are configured.
273
$coursepageinformationbannershtml = theme_universe_get_course_information_banners();
274
if ($coursepageinformationbannershtml) {
275
    $templatecontext['coursepageinformationbanners'] = $coursepageinformationbannershtml;
276
}
277
// End.
278
 
279
// Load theme settings.
280
$themesettings = new \theme_universe\util\theme_settings();
281
 
282
$templatecontext = array_merge($templatecontext, $themesettings->global_settings());
283
$templatecontext = array_merge($templatecontext, $themesettings->course_settings());
284
 
544 ariadna 285
$PAGE->requires->js_call_amd('theme_universe/rui', 'init');
533 ariadna 286
if (theme_universe_get_setting('backtotop') == '1') {
544 ariadna 287
    $PAGE->requires->js_call_amd('theme_universe/backtotop', 'init');
533 ariadna 288
}
289
 
290
echo $OUTPUT->render_from_template('theme_universe_child/tmpl-course', $templatecontext);