Proyectos de Subversion Moodle

Rev

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