Proyectos de Subversion Moodle

Rev

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

Rev Autor Línea Nro. Línea
256 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
 
25
defined('MOODLE_INTERNAL') || die();
26
 
27
require_once($CFG->libdir . '/behat/lib.php');
28
require_once($CFG->dirroot . '/course/lib.php');
29
 
30
$draweropenright = false;
31
$extraclasses = [];
32
 
33
// Moodle 4. - Add block button in editing mode.
34
$addblockbutton = $OUTPUT->addblockbutton();
35
if (isloggedin()) {
36
    $courseindexopen = (get_user_preferences('drawer-open-index', true) == true);
37
    $blockdraweropen = (get_user_preferences('drawer-open-block') == true);
38
} else {
39
    $courseindexopen = false;
40
    $blockdraweropen = false;
41
}
42
 
43
if (defined('BEHAT_SITE_RUNNING')) {
44
    $blockdraweropen = true;
45
}
46
 
47
$extraclasses = ['uses-drawers'];
48
// End.
49
 
50
// Dark mode.
51
if (isloggedin()) {
52
    $navdraweropen = get_user_preferences('drawer-open-nav', true);
53
    $draweropenright = (get_user_preferences('sidepre-open', 'true') == 'true');
54
 
55
    if (theme_universe_get_setting('darkmodetheme') == '1') {
56
        $darkmodeon = get_user_preferences('darkmode-on');
57
        if ($darkmodeon) {
58
            $extraclasses[] = 'theme-dark';
59
        }
60
    } else {
61
        $darkmodeon = false;
62
    }
63
} else {
64
    $navdraweropen = false;
65
}
66
 
67
if (theme_universe_get_setting('darkmodefirst') == '1') {
68
    $extraclasses[] = 'theme-dark';
69
    $darkmodetheme = false;
70
    $darkmodeon = true;
71
}
72
 
73
$siteurl = $CFG->wwwroot;
74
 
75
$blockshtml = $OUTPUT->render_statics_blocks();
76
$blockdraweropen = false;
77
 
78
if (theme_universe_get_setting('hidecourseindexnav') == true) {
79
    $hidecourseindexnav = true;
80
} else {
81
    $hidecourseindexnav = false;
82
}
83
 
84
if (theme_universe_get_setting('hidecourseindexnav') == false) {
85
    $courseindex = core_course_drawer();
86
    if (!$courseindex) {
87
        $courseindexopen = false;
88
    }
89
    if ($courseindexopen == false) {
90
        $extraclasses[] = 'drawer-open-index--closed';
91
    } else {
92
        $extraclasses[] = 'drawer-open-index--open';
93
    }
94
} else {
95
    $courseindex = false;
96
    $courseindexopen = false;
97
}
98
 
99
$sidecourseblocks = $OUTPUT->blocks('sidecourseblocks');
100
$hassidecourseblocks = strpos($sidecourseblocks, 'data-block=') !== false;
101
 
886 ariadna 102
if ($PAGE->course->enablecompletion == '1') {
103
    $extraclasses[] = 'rui-course--enablecompletion';
104
}
105
 
256 ariadna 106
if ($draweropenright && $hasblocks) {
107
    $extraclasses[] = 'drawer-open-right';
108
}
109
 
110
if ($PAGE->course->showactivitydates == '1') {
111
    $extraclasses[] = 'rui-course--showactivitydates';
112
}
113
 
114
if ($PAGE->course->visible == '1') {
115
    $extraclasses[] = 'rui-course--visible';
116
}
117
 
118
// Moodle 4.
119
$forceblockdraweropen = $OUTPUT->firstview_fakeblocks();
120
 
121
$secondarynavigation = false;
122
$overflow = '';
123
if ($PAGE->has_secondary_navigation()) {
124
    $tablistnav = $PAGE->has_tablist_secondary_navigation();
125
    $moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs', true, $tablistnav);
126
    $secondarynavigation = $moremenu->export_for_template($OUTPUT);
127
    $overflowdata = $PAGE->secondarynav->get_overflow_menu_data();
128
    if (!is_null($overflowdata)) {
129
        $overflow = $overflowdata->export_for_template($OUTPUT);
130
    }
131
}
132
 
133
$primary = new core\navigation\output\primary($PAGE);
134
$renderer = $PAGE->get_renderer('core');
135
$primarymenu = $primary->export_for_template($renderer);
136
$buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions() && !$PAGE->has_secondary_navigation();
137
// If the settings menu will be included in the header then don't add it here.
138
$regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false;
139
 
876 ariadna 140
$header = $PAGE->activityheader;
141
$headercontent = $header->export_for_template($renderer);
885 ariadna 142
$completed = false;
876 ariadna 143
 
887 ariadna 144
$course_context = context_course::instance($COURSE->id);
145
$roles = get_user_roles($course_context, $USER->id, true);
146
 
147
$completion_visible = true;
148
foreach ($roles as $role) {
149
    if ($role->shortname != 'student') {
150
        $completion_visible  = false;
872 ariadna 151
    }
864 ariadna 152
}
153
 
887 ariadna 154
if (!$completion_visible) {
155
    $completed = false;
156
}
157
 
158
$modules = get_fast_modinfo($COURSE->id)->get_cms();
159
 
160
$mods = [];
161
foreach ($modules as $module) {
162
    if (!$module->uservisible || $module->is_stealth() || empty($module->url)) {
163
        continue;
164
    }
165
    $mods[$module->id] = $module;
166
}
167
 
168
 
169
 
170
$nummods = count($mods);
171
 
172
// If there is only one mod then do nothing.
173
if ($nummods == 1) {
174
    $completed = false;
175
}
176
 
177
$modids = array_keys($mods);
178
$position = array_search($page_context->id, $modids);   //array_search($this->page->cm->id, $modids);
179
 
180
$currentmod = $mods[$modids[$position]];
181
 
182
/*if(!$currentmod->completion) {
183
    return '';
184
}*/
185
 
186
$completioninfo = new \completion_info($COURSE);
187
$completiondata = $completioninfo->get_data($currentmod, true);
188
if ($completiondata->completionstate == COMPLETION_COMPLETE && $completiondata->completionstate == COMPLETION_COMPLETE_PASS) {
189
    $completed = true;
190
}
191
 
192
 
256 ariadna 193
// RUI.
194
$iscoursepage = true;
195
 
196
if ($hassidecourseblocks) {
197
    $extraclasses[] = 'page-has-blocks';
198
}
199
 
200
if (!isloggedin() || isguestuser()) {
201
    $isnotloggedin = true;
202
} else {
203
    $isnotloggedin = false;
204
}
205
 
206
// Check if guest user.
207
if (isguestuser()) {
208
    $extraclasses[] = 'moodle-guest-user';
209
}
210
 
211
if (theme_universe_get_setting('backtotop') == '1') {
212
    $extraclasses[] = 'back-to-top-on';
213
}
214
 
215
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
216
 
217
$templatecontext = [
218
    'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
219
    'output' => $OUTPUT,
220
    'bodyattributes' => $bodyattributes,
221
    'darkmodeon' => !empty($darkmodeon),
222
    'darkmodetheme' => !empty($darkmodetheme),
223
    'siteurl' => $siteurl,
224
    'staticblocks' => $staticblocks,
225
    'sidepreblocks' => $blockshtml,
226
    'hasblocks' => true,
227
    'navdraweropen' => $navdraweropen,
228
    'draweropenright' => $draweropenright,
229
    'isnotloggedin' => $isnotloggedin,
230
    'iscoursepage' => $iscoursepage,
231
    // Moodle 4.
232
    'courseindexopen' => $courseindexopen,
233
    'blockdraweropen' => $blockdraweropen,
234
    'courseindex' => $courseindex,
235
    'primarymoremenu' => $primarymenu['moremenu'],
236
    'secondarymoremenu' => $secondarynavigation ?: false,
237
    'forceblockdraweropen' => $forceblockdraweropen,
238
    'regionmainsettingsmenu' => $regionmainsettingsmenu,
239
    'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
240
    'overflow' => $overflow,
241
    'headercontent' => $headercontent,
242
    'addblockbutton' => $addblockbutton,
243
    'hidecourseindexnav' => $hidecourseindexnav,
863 ariadna 244
    'completed' => $completed
256 ariadna 245
];
246
 
247
// Get and use the course page information banners HTML code, if any course page hints are configured.
248
$coursepageinformationbannershtml = theme_universe_get_course_information_banners();
249
if ($coursepageinformationbannershtml) {
250
    $templatecontext['coursepageinformationbanners'] = $coursepageinformationbannershtml;
251
}
252
// End.
253
 
254
// Load theme settings.
532 ariadna 255
$themesettings = new \theme_universe\util\theme_settings();
256 ariadna 256
 
257
$templatecontext = array_merge($templatecontext, $themesettings->global_settings());
258
 
544 ariadna 259
$PAGE->requires->js_call_amd('theme_universe/rui', 'init');
256 ariadna 260
if (theme_universe_get_setting('backtotop') == '1') {
544 ariadna 261
    $PAGE->requires->js_call_amd('theme_universe/backtotop', 'init');
256 ariadna 262
}
263
 
315 ariadna 264
echo $OUTPUT->render_from_template('theme_universe_child/tmpl-incourse', $templatecontext);