Proyectos de Subversion Moodle

Rev

Rev 870 | Rev 872 | 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
 
102
if ($draweropenright && $hasblocks) {
103
    $extraclasses[] = 'drawer-open-right';
104
}
105
 
106
if ($PAGE->course->showactivitydates == '1') {
107
    $extraclasses[] = 'rui-course--showactivitydates';
108
}
109
 
110
if ($PAGE->course->visible == '1') {
111
    $extraclasses[] = 'rui-course--visible';
112
}
113
 
114
// Moodle 4.
115
$forceblockdraweropen = $OUTPUT->firstview_fakeblocks();
116
 
117
$secondarynavigation = false;
118
$overflow = '';
119
if ($PAGE->has_secondary_navigation()) {
120
    $tablistnav = $PAGE->has_tablist_secondary_navigation();
121
    $moremenu = new \core\navigation\output\more_menu($PAGE->secondarynav, 'nav-tabs', true, $tablistnav);
122
    $secondarynavigation = $moremenu->export_for_template($OUTPUT);
123
    $overflowdata = $PAGE->secondarynav->get_overflow_menu_data();
124
    if (!is_null($overflowdata)) {
125
        $overflow = $overflowdata->export_for_template($OUTPUT);
126
    }
127
}
128
 
129
$primary = new core\navigation\output\primary($PAGE);
130
$renderer = $PAGE->get_renderer('core');
131
$primarymenu = $primary->export_for_template($renderer);
132
$buildregionmainsettings = !$PAGE->include_region_main_settings_in_header_actions() && !$PAGE->has_secondary_navigation();
133
// If the settings menu will be included in the header then don't add it here.
134
$regionmainsettingsmenu = $buildregionmainsettings ? $OUTPUT->region_main_settings_menu() : false;
135
 
871 ariadna 136
$category = '';
137
$title = '';
138
$summary = '';
139
$completed = false;
140
if ($PAGE->pagelayout == 'incourse' && !empty($COURSE->id)) {
141
 
142
    $record = $DB->get_record('course_categories', array('id' => $COURSE->category));
143
    if ($record) {
144
        $category = $record->name;
145
    }
146
 
147
    $title = $COURSE->fullname;
148
    $summary = format_text($COURSE->summary, $COURSE->summaryformat);
149
 
150
    if (!empty($USER->id)) {
151
 
152
        $course_context = \context_course::instance($COURSE->id);
153
        $roles = get_user_roles($course_context, $USER->id, true);
154
 
155
        $completion_visible = true;
156
        foreach ($roles as $role) {
157
 
158
            if ($role->shortname != 'student') {
159
                $completion_visible  = false;
160
            } else {
161
                $completion_visible = true;
162
                break;
163
            }
164
        }
165
 
166
        if ($completion_visible) {
167
            $page_context = $PAGE->cm;
168
 
169
            $modules = get_fast_modinfo($COURSE->id)->get_cms();
170
 
171
            $mods = [];
172
            foreach ($modules as $module) {
173
                if (!$module->uservisible || $module->is_stealth() || empty($module->url)) {
174
                    continue;
175
                }
176
                $mods[$module->id] = $module;
177
            }
178
 
179
 
180
 
181
 
182
            $nummods = count($mods);
183
 
184
            if ($nummods >= 1) {
185
                $modids = array_keys($mods);
186
                $position = array_search($page_context->id, $modids);   //array_search($this->page->cm->id, $modids);
187
                $currentmod = $mods[$modids[$position]];
188
            } else {
189
                $currentmod = null;
190
            }
191
 
192
 
193
            $module_type = '';
194
            if ($currentmod) {
195
 
196
                $sql = 'SELECT md.name, cm.instance  FROM {modules} md  ' .
197
                    ' JOIN {course_modules} cm ON cm.module = md.id ' .
198
                    ' WHERE cm.id = '  . $currentmod->id . ' LIMIT 1 ';
199
 
200
                $recordCourseModule = $DB->get_record_sql($sql);
201
 
202
 
203
                if ($recordCourseModule) {
204
                    $module_type = $recordCourseModule->name;
205
                }
206
            }
207
 
208
            // If there is only one mod then do nothing.
209
            if ($nummods > 1 && $currentmod) {
210
 
211
 
212
 
213
 
214
                $completioninfo = new \completion_info($COURSE);
215
                $completiondata = $completioninfo->get_data($currentmod, true);
216
 
217
                // if (!$currentmod->completionview==1){
218
                if ($currentmod->completionview != 1 && $currentmod->completion != 2) {
219
                    // var_dump($currentmod->completionview);
220
 
221
                    if ($completiondata->completionstate == COMPLETION_COMPLETE || $completiondata->completionstate == COMPLETION_COMPLETE_PASS) {
222
                        $completed = true;
223
                    }
224
                }
225
            }
226
        }
227
    }
228
}
229
 
864 ariadna 230
if ($PAGE->course->enablecompletion == '1') {
231
    $extraclasses[] = 'rui-course--enablecompletion';
871 ariadna 232
    $header = $PAGE->activityheader;
233
    $headercontent = $header->export_for_template($renderer);
867 ariadna 234
    $completed = false;
864 ariadna 235
}
236
 
256 ariadna 237
// RUI.
238
$iscoursepage = true;
239
 
240
if ($hassidecourseblocks) {
241
    $extraclasses[] = 'page-has-blocks';
242
}
243
 
244
if (!isloggedin() || isguestuser()) {
245
    $isnotloggedin = true;
246
} else {
247
    $isnotloggedin = false;
248
}
249
 
250
// Check if guest user.
251
if (isguestuser()) {
252
    $extraclasses[] = 'moodle-guest-user';
253
}
254
 
255
if (theme_universe_get_setting('backtotop') == '1') {
256
    $extraclasses[] = 'back-to-top-on';
257
}
258
 
259
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
260
 
261
$templatecontext = [
262
    'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
263
    'output' => $OUTPUT,
264
    'bodyattributes' => $bodyattributes,
265
    'darkmodeon' => !empty($darkmodeon),
266
    'darkmodetheme' => !empty($darkmodetheme),
267
    'siteurl' => $siteurl,
268
    'staticblocks' => $staticblocks,
269
    'sidepreblocks' => $blockshtml,
270
    'hasblocks' => true,
271
    'navdraweropen' => $navdraweropen,
272
    'draweropenright' => $draweropenright,
273
    'isnotloggedin' => $isnotloggedin,
274
    'iscoursepage' => $iscoursepage,
275
    // Moodle 4.
276
    'courseindexopen' => $courseindexopen,
277
    'blockdraweropen' => $blockdraweropen,
278
    'courseindex' => $courseindex,
279
    'primarymoremenu' => $primarymenu['moremenu'],
280
    'secondarymoremenu' => $secondarynavigation ?: false,
281
    'forceblockdraweropen' => $forceblockdraweropen,
282
    'regionmainsettingsmenu' => $regionmainsettingsmenu,
283
    'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
284
    'overflow' => $overflow,
285
    'headercontent' => $headercontent,
286
    'addblockbutton' => $addblockbutton,
287
    'hidecourseindexnav' => $hidecourseindexnav,
863 ariadna 288
    'completed' => $completed
256 ariadna 289
];
290
 
291
// Get and use the course page information banners HTML code, if any course page hints are configured.
292
$coursepageinformationbannershtml = theme_universe_get_course_information_banners();
293
if ($coursepageinformationbannershtml) {
294
    $templatecontext['coursepageinformationbanners'] = $coursepageinformationbannershtml;
295
}
296
// End.
297
 
298
// Load theme settings.
532 ariadna 299
$themesettings = new \theme_universe\util\theme_settings();
256 ariadna 300
 
301
$templatecontext = array_merge($templatecontext, $themesettings->global_settings());
302
 
544 ariadna 303
$PAGE->requires->js_call_amd('theme_universe/rui', 'init');
256 ariadna 304
if (theme_universe_get_setting('backtotop') == '1') {
544 ariadna 305
    $PAGE->requires->js_call_amd('theme_universe/backtotop', 'init');
256 ariadna 306
}
307
 
315 ariadna 308
echo $OUTPUT->render_from_template('theme_universe_child/tmpl-incourse', $templatecontext);