Proyectos de Subversion Moodle

Rev

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