Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 69... Línea 69...
69
        $courseid = $page->course->id;
69
        $courseid = $page->course->id;
70
        parent::__construct($page, $target);
70
        parent::__construct($page, $target);
71
    }
71
    }
Línea 72... Línea 72...
72
 
72
 
73
    /**
-
 
74
     * @deprecated since 3.2
-
 
75
     */
-
 
76
    protected function add_modchoosertoggle() {
-
 
77
        throw new coding_exception('core_course_renderer::add_modchoosertoggle() can not be used anymore.');
-
 
78
    }
-
 
79
 
-
 
80
    /**
73
    /**
81
     * Renders course info box.
74
     * Renders course info box.
82
     *
75
     *
83
     * @param stdClass $course
76
     * @param stdClass $course
84
     * @return string
77
     * @return string
Línea 92... Línea 85...
92
        $content .= $this->output->box_end();
85
        $content .= $this->output->box_end();
93
        return $content;
86
        return $content;
94
    }
87
    }
Línea 95... Línea 88...
95
 
88
 
-
 
89
    /**
-
 
90
     * Renders course info box.
-
 
91
     *
-
 
92
     * @param stdClass $course course object
-
 
93
     * @param string[] $widgets array of enrolment widgets
-
 
94
     * @param \core\url|null $returnurl return url
-
 
95
     * @return string
-
 
96
     */
-
 
97
    public function enrolment_options(stdClass $course, array $widgets, ?\core\url $returnurl = null): string {
-
 
98
        if (!$widgets) {
-
 
99
            if (isguestuser()) {
-
 
100
                $message = get_string('noguestaccess', 'enrol');
-
 
101
                $continuebutton = $this->output->continue_button(get_login_url());
-
 
102
            } else if ($returnurl) {
-
 
103
                $message = get_string('notenrollable', 'enrol');
-
 
104
                $continuebutton = $this->output->continue_button($returnurl);
-
 
105
            } else {
-
 
106
                $url = get_local_referer(false);
-
 
107
                if (empty($url)) {
-
 
108
                    $url = new moodle_url('/index.php');
-
 
109
                }
-
 
110
                $message = get_string('notenrollable', 'enrol');
-
 
111
                $continuebutton = $this->output->continue_button($url);
-
 
112
            }
-
 
113
        }
-
 
114
 
-
 
115
        $courseinfobox = $this->course_info_box($course);
-
 
116
 
-
 
117
        $templatecontext = [
-
 
118
            'heading' => get_string('enrolmentoptions', 'enrol'),
-
 
119
            'courseinfobox' => $courseinfobox,
-
 
120
            'widgets' => array_values($widgets),
-
 
121
            'message' => $message ?? '',
-
 
122
            'continuebutton' => $continuebutton ?? '',
-
 
123
        ];
-
 
124
        return $this->render_from_template('core_enrol/enrolment_options', $templatecontext);
-
 
125
    }
-
 
126
 
96
    /**
127
    /**
97
     * Renderers a structured array of courses and categories into a nice XHTML tree structure.
128
     * Renderers a structured array of courses and categories into a nice XHTML tree structure.
98
     *
129
     *
99
     * @deprecated since 2.5
130
     * @deprecated since 2.5
100
     *
131
     *
Línea 129... Línea 160...
129
    public function render_modchooser(renderable $modchooser) {
160
    public function render_modchooser(renderable $modchooser) {
130
        return $this->render_from_template('core_course/modchooser', $modchooser->export_for_template($this));
161
        return $this->render_from_template('core_course/modchooser', $modchooser->export_for_template($this));
131
    }
162
    }
Línea 132... Línea 163...
132
 
163
 
133
    /**
-
 
134
     * @deprecated since 3.9
-
 
135
     */
-
 
136
    public function course_modchooser() {
-
 
137
        throw new coding_exception('course_modchooser() can not be used anymore, please use course_activitychooser() instead.');
-
 
138
    }
-
 
139
 
-
 
140
    /**
164
    /**
141
     * Build the HTML for the module chooser javascript popup.
165
     * Build the HTML for the module chooser javascript popup.
142
     *
166
     *
143
     * @param int $courseid The course id to fetch modules for.
167
     * @param int $courseid The course id to fetch modules for.
144
     * @return string
168
     * @return string
Línea 193... Línea 217...
193
            'see core_course_renderer::render_modchooser().', DEBUG_DEVELOPER);
217
            'see core_course_renderer::render_modchooser().', DEBUG_DEVELOPER);
194
        return '';
218
        return '';
195
    }
219
    }
Línea 196... Línea 220...
196
 
220
 
197
    /**
-
 
198
     * @deprecated since 4.0 - please do not use this function any more.
-
 
199
     */
-
 
200
    public function course_section_cm_edit_actions($actions, cm_info $mod = null, $displayoptions = array()) {
-
 
201
 
-
 
202
        throw new coding_exception(
-
 
203
            'course_section_cm_edit_actions can not be used any more. Please, use ' .
-
 
204
            'core_courseformat\\output\\local\\content\\cm\\controlmenu instead.'
-
 
205
        );
-
 
206
    }
-
 
207
 
-
 
208
    /**
221
    /**
209
     * Renders HTML for the menus to add activities and resources to the current course
222
     * Renders HTML for the menus to add activities and resources to the current course
210
     *
223
     *
211
     * Renders the ajax control (the link which when clicked produces the activity chooser modal). No noscript fallback.
224
     * Renders the ajax control (the link which when clicked produces the activity chooser modal). No noscript fallback.
212
     *
225
     *
Línea 222... Línea 235...
222
        if (!has_capability('moodle/course:manageactivities', context_course::instance($course->id))
235
        if (!has_capability('moodle/course:manageactivities', context_course::instance($course->id))
223
                || !$this->page->user_is_editing()) {
236
                || !$this->page->user_is_editing()) {
224
            return '';
237
            return '';
225
        }
238
        }
Línea 226... Línea -...
226
 
-
 
227
        $data = [
-
 
228
            'sectionid' => $section,
239
 
229
            'sectionreturn' => $sectionreturn
240
        $sectioninfo = get_fast_modinfo($course)->get_section_info($section);
230
        ];
241
 
Línea 231... Línea 242...
231
        $ajaxcontrol = $this->render_from_template('course/activitychooserbutton', $data);
242
        $activitychooserbutton = new \core_course\output\activitychooserbutton($sectioninfo, null, $sectionreturn);
232
 
243
 
Línea 233... Línea 244...
233
        // Load the JS for the modal.
244
        // Load the JS for the modal.
-
 
245
        $this->course_activitychooser($course->id);
-
 
246
 
-
 
247
        return $this->render_from_template(
-
 
248
            'core_courseformat/local/content/divider',
-
 
249
            [
-
 
250
                'content' => $this->render($activitychooserbutton),
234
        $this->course_activitychooser($course->id);
251
                'extraclasses' => 'always-visible my-3',
Línea 235... Línea 252...
235
 
252
            ]
236
        return $ajaxcontrol;
253
        );
237
    }
254
    }
Línea 254... Línea 271...
254
        ];
271
        ];
255
        return $this->render_from_template('core/search_input', $data);
272
        return $this->render_from_template('core/search_input', $data);
256
    }
273
    }
Línea 257... Línea 274...
257
 
274
 
258
    /**
-
 
259
     * @deprecated since Moodle 3.11
-
 
260
     */
-
 
261
    public function course_section_cm_completion() {
-
 
262
        throw new coding_exception(__FUNCTION__ . ' is deprecated. Use the activity_completion output component instead.');
-
 
263
    }
-
 
264
 
-
 
265
    /**
-
 
266
     * @deprecated since 4.0 - please do not use this function any more.
-
 
267
     */
-
 
268
    public function is_cm_conditionally_hidden(cm_info $mod) {
-
 
269
 
-
 
270
        throw new coding_exception(
-
 
271
            'is_cm_conditionally_hidden can not be used any more. Please, use ' .
-
 
272
            '\core_availability\info_module::is_available_for_all instead'
-
 
273
        );
-
 
274
    }
-
 
275
 
-
 
276
    /**
-
 
277
     * @deprecated since 4.0 - please do not use this function any more.
-
 
278
     */
-
 
279
    public function course_section_cm_name(cm_info $mod, $displayoptions = array()) {
-
 
280
 
-
 
281
        throw new coding_exception(
-
 
282
            'course_section_cm_name can not be used any more. Please, use ' .
-
 
283
            'core_courseformat\\output\\local\\content\\cm\\cmname class instead.'
-
 
284
        );
-
 
285
    }
-
 
286
 
-
 
287
    /**
-
 
288
     * @deprecated since 4.0 - please do not use this function any more.
-
 
289
     */
-
 
290
    protected function course_section_cm_classes(cm_info $mod) {
-
 
291
 
-
 
292
        throw new coding_exception(
-
 
293
            'course_section_cm_classes can not be used any more. Now it is part of core_courseformat\\output\\local\\content\\cm'
-
 
294
        );
-
 
295
    }
-
 
296
 
-
 
297
    /**
-
 
298
     * @deprecated since 4.0 - please do not use this function any more.
-
 
299
     */
-
 
300
    public function course_section_cm_name_title(cm_info $mod, $displayoptions = array()) {
-
 
301
 
-
 
302
        throw new coding_exception(
-
 
303
            'course_section_cm_name_title can not be used any more. Please, use ' .
-
 
304
            'core_courseformat\\output\\local\\cm\\title class instead'
-
 
305
        );
-
 
306
    }
-
 
307
 
-
 
308
    /**
-
 
309
     * @deprecated since 4.0 - please do not use this function any more.
-
 
310
     */
-
 
311
    public function course_section_cm_text(cm_info $mod, $displayoptions = array()) {
-
 
312
 
-
 
313
        throw new coding_exception(
-
 
314
            'course_section_cm_text can not be used any more. Now it is part of core_courseformat\\output\\local\\content\\cm'
-
 
315
        );
-
 
316
    }
-
 
317
 
-
 
318
    /**
-
 
319
     * @deprecated since 4.0 - please do not use this function any more.
-
 
320
     */
-
 
321
    public function availability_info($text, $additionalclasses = '') {
-
 
322
 
-
 
323
        throw new coding_exception(
-
 
324
            'availability_info can not be used any more. Please, use ' .
-
 
325
            'core_courseformat\\output\\local\\content\\section\\availability instead'
-
 
326
        );
-
 
327
    }
-
 
328
 
-
 
329
    /**
-
 
330
     * @deprecated since 4.0 - please do not use this function any more.
-
 
331
     */
-
 
332
    public function course_section_cm_availability(cm_info $mod, $displayoptions = array()) {
-
 
333
 
-
 
334
        throw new coding_exception(
-
 
335
            'course_section_cm_availability can not be used any more. Please, use ' .
-
 
336
            'core_courseformat\\output\\local\\content\\cm\\availability instead'
-
 
337
        );
-
 
338
    }
-
 
339
 
-
 
340
    /**
-
 
341
     * @deprecated since 4.0 - use core_course output components or course_format::course_section_updated_cm_item instead.
-
 
342
     */
-
 
343
    public function course_section_cm_list_item($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = []) {
-
 
344
 
-
 
345
        throw new coding_exception(
-
 
346
            'course_section_cm_list_item can not be used any more. Please, use renderer course_section_updated_cm_item instead'
-
 
347
        );
-
 
348
    }
-
 
349
 
-
 
350
    /**
-
 
351
     * @deprecated since 4.0 - use core_course output components instead.
-
 
352
     */
-
 
353
    public function course_section_cm($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = []) {
-
 
354
 
-
 
355
        throw new coding_exception(
-
 
356
            'course_section_cm can not be used any more. Please, use core_courseformat\\output\\content\\cm output class instead'
-
 
357
        );
-
 
358
    }
-
 
359
 
-
 
360
    /**
275
    /**
361
     * Message displayed to the user when they try to access unavailable activity following URL
276
     * Message displayed to the user when they try to access unavailable activity following URL
362
     *
277
     *
363
     * This method is a very simplified version of {@link course_section_cm()} to be part of the error
278
     * This method is a very simplified version of {@link course_section_cm()} to be part of the error
364
     * notification only. It also does not check if module is visible on course page or not.
279
     * notification only. It also does not check if module is visible on course page or not.
Línea 375... Línea 290...
375
        if (!$cm->availableinfo) {
290
        if (!$cm->availableinfo) {
376
            return get_string('activityiscurrentlyhidden');
291
            return get_string('activityiscurrentlyhidden');
377
        }
292
        }
Línea 378... Línea 293...
378
 
293
 
379
        $altname = get_accesshide(' ' . $cm->modfullname);
294
        $altname = get_accesshide(' ' . $cm->modfullname);
380
        $name = html_writer::empty_tag('img', array('src' => $cm->get_icon_url(),
295
        $name = html_writer::empty_tag('img', ['src' => $cm->get_icon_url(),
381
                'class' => 'iconlarge activityicon', 'alt' => '')) .
296
                'class' => 'activityicon', 'alt' => '']) .
382
            html_writer::tag('span', ' '.$cm->get_formatted_name() . $altname, array('class' => 'instancename'));
297
            html_writer::tag('span', ' '.$cm->get_formatted_name() . $altname, array('class' => 'instancename'));
383
        $formattedinfo = \core_availability\info::format_info($cm->availableinfo, $cm->get_course());
298
        $formattedinfo = \core_availability\info::format_info($cm->availableinfo, $cm->get_course());
384
        return html_writer::div($name, 'activityinstance-error') .
299
        return html_writer::div($name, 'activityinstance-error') .
385
        html_writer::div($formattedinfo, 'availabilityinfo-error');
300
        html_writer::div($formattedinfo, 'availabilityinfo-error');
Línea 386... Línea 301...
386
    }
301
    }
387
 
-
 
388
    /**
-
 
389
     * @deprecated since 4.0 - use core_course output components instead.
-
 
390
     */
-
 
391
    public function course_section_cm_list($course, $section, $sectionreturn = null, $displayoptions = []) {
-
 
392
 
-
 
393
        throw new coding_exception(
-
 
394
            'course_section_cm_list can not be used any more. Please, use ' .
-
 
395
            'core_courseformat\\output\\local\\content\\section\\cmlist class instead'
-
 
396
        );
-
 
397
    }
-
 
398
 
302
 
399
    /**
303
    /**
400
     * Displays a custom list of courses with paging bar if necessary
304
     * Displays a custom list of courses with paging bar if necessary
401
     *
305
     *
402
     * If $paginationurl is specified but $totalcount is not, the link 'View more'
306
     * If $paginationurl is specified but $totalcount is not, the link 'View more'
Línea 574... Línea 478...
574
            $content .= html_writer::start_tag('ul', ['class' => 'teachers']);
478
            $content .= html_writer::start_tag('ul', ['class' => 'teachers']);
575
            foreach ($course->get_course_contacts() as $coursecontact) {
479
            foreach ($course->get_course_contacts() as $coursecontact) {
576
                $rolenames = array_map(function ($role) {
480
                $rolenames = array_map(function ($role) {
577
                    return $role->displayname;
481
                    return $role->displayname;
578
                }, $coursecontact['roles']);
482
                }, $coursecontact['roles']);
579
                $name = html_writer::tag('span', implode(", ", $rolenames).': ', ['class' => 'font-weight-bold']);
483
                $name = html_writer::tag('span', implode(", ", $rolenames).': ', ['class' => 'fw-bold']);
580
                $name .= html_writer::link(
484
                $name .= html_writer::link(
581
                   \core_user::get_profile_url($coursecontact['user'], context_system::instance()),
485
                   \core_user::get_profile_url($coursecontact['user'], context_system::instance()),
582
                   $coursecontact['username']
486
                   $coursecontact['username']
583
                );
487
                );
584
                $content .= html_writer::tag('li', $name);
488
                $content .= html_writer::tag('li', $name);
Línea 630... Línea 534...
630
        $content = '';
534
        $content = '';
631
        // Display course category if necessary (for example in search results).
535
        // Display course category if necessary (for example in search results).
632
        if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT) {
536
        if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT) {
633
            if ($cat = core_course_category::get($course->category, IGNORE_MISSING)) {
537
            if ($cat = core_course_category::get($course->category, IGNORE_MISSING)) {
634
                $content .= html_writer::start_tag('div', ['class' => 'coursecat']);
538
                $content .= html_writer::start_tag('div', ['class' => 'coursecat']);
635
                $content .= html_writer::tag('span', get_string('category').': ', ['class' => 'font-weight-bold']);
539
                $content .= html_writer::tag('span', get_string('category').': ', ['class' => 'fw-bold']);
636
                $content .= html_writer::link(new moodle_url('/course/index.php', ['categoryid' => $cat->id]),
540
                $content .= html_writer::link(new moodle_url('/course/index.php', ['categoryid' => $cat->id]),
637
                        $cat->get_formatted_name(), ['class' => $cat->visible ? '' : 'dimmed']);
541
                        $cat->get_formatted_name(), ['class' => $cat->visible ? '' : 'dimmed']);
638
                $content .= html_writer::end_tag('div');
542
                $content .= html_writer::end_tag('div');
639
            }
543
            }
640
        }
544
        }
Línea 1154... Línea 1058...
1154
            return $this->coursecat_category_content($chelper, $category, $depth);
1058
            return $this->coursecat_category_content($chelper, $category, $depth);
1155
        } else if ($type === self::COURSECAT_TYPE_COURSE) {
1059
        } else if ($type === self::COURSECAT_TYPE_COURSE) {
1156
            // This is a request for the course information.
1060
            // This is a request for the course information.
1157
            $courseid = required_param('courseid', PARAM_INT);
1061
            $courseid = required_param('courseid', PARAM_INT);
Línea 1158... Línea 1062...
1158
 
1062
 
-
 
1063
            $course = $DB->get_record('course', ['id' => $courseid], '*', IGNORE_MISSING);
-
 
1064
            if ($course === false) {
-
 
1065
                throw new \moodle_exception('invalidcourseid');
-
 
1066
            }
-
 
1067
            $coursecontext = context_course::instance($course->id, MUST_EXIST);
-
 
1068
            if ($course->visible == 0 && !has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
-
 
1069
                throw new \moodle_exception('invalidcourseid');
Línea 1159... Línea 1070...
1159
            $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
1070
            }
1160
 
1071
 
1161
            $chelper = new coursecat_helper();
1072
            $chelper = new coursecat_helper();
1162
            $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED);
1073
            $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED);
Línea 1499... Línea 1410...
1499
                set_attributes(array('class' => 'frontpage-category-names'));
1410
                set_attributes(array('class' => 'frontpage-category-names'));
1500
        return $this->coursecat_tree($chelper, $tree);
1411
        return $this->coursecat_tree($chelper, $tree);
1501
    }
1412
    }
Línea 1502... Línea 1413...
1502
 
1413
 
1503
    /**
-
 
1504
     * Renders the activity information.
-
 
1505
     *
-
 
1506
     * Defer to template.
-
 
1507
     *
1414
    /**
1508
     * @deprecated since Moodle 4.3 MDL-78744
-
 
1509
     * @todo MDL-78926 This method will be deleted in Moodle 4.7
-
 
1510
     * @param \core_course\output\activity_information $page
-
 
1511
     * @return string html for the page
1415
     * @deprecated since Moodle 4.3 MDL-78744
1512
     */
1416
     */
1513
    public function render_activity_information(\core_course\output\activity_information $page) {
1417
    #[\core\attribute\deprecated(null, since: '4.3', mdl: 'MDL-78744', final: true)]
1514
        debugging('render_activity_information method is deprecated.', DEBUG_DEVELOPER);
1418
    public function render_activity_information() {
1515
        $data = $page->export_for_template($this->output);
-
 
1516
        return $this->output->render_from_template('core_course/activity_info', $data);
1419
        \core\deprecation::emit_deprecation([self::class, __FUNCTION__]);
Línea 1517... Línea 1420...
1517
    }
1420
    }
1518
 
1421
 
1519
    /**
1422
    /**
Línea 1621... Línea 1524...
1621
                }
1524
                }
1622
            } else {
1525
            } else {
1623
                $subtext = get_string('subscribe', 'forum');
1526
                $subtext = get_string('subscribe', 'forum');
1624
            }
1527
            }
1625
            $suburl = new moodle_url('/mod/forum/subscribe.php', array('id' => $forum->id, 'sesskey' => sesskey()));
1528
            $suburl = new moodle_url('/mod/forum/subscribe.php', array('id' => $forum->id, 'sesskey' => sesskey()));
1626
            $output .= html_writer::tag('div', html_writer::link($suburl, $subtext), array('class' => 'subscribelink'));
1529
            $output .= html_writer::tag('div', html_writer::link($suburl, $subtext), ['class' => 'subscribelink text-end']);
1627
        }
1530
        }
Línea 1628... Línea 1531...
1628
 
1531
 
1629
        $coursemodule = get_coursemodule_from_instance('forum', $forum->id);
1532
        $coursemodule = get_coursemodule_from_instance('forum', $forum->id);