Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 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
namespace core_course\route\controller;
18
 
19
use core\router\route;
20
use core\router\require_login;
21
use navigation_node;
22
use Psr\Http\Message\ResponseInterface;
23
 
24
/**
25
 * Course Management.
26
 *
27
 * @package    core_course
28
 * @copyright  Andrew Lyons <andrew@nicols.co.uk>
29
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 */
31
class course_management {
32
    use \core\router\route_controller;
33
 
34
    /**
35
     * Administer a course.
36
     *
37
     * @param ResponseInterface $response
38
     * @param \stdClass $course
39
     * @return ResponseInterface
40
     */
41
    #[route(
42
        path: '/{course}/manage',
43
        pathtypes: [
44
            new \core\router\parameters\path_course(),
45
        ],
46
        requirelogin: new require_login(
47
            requirelogin: true,
48
            courseattributename: 'course',
49
        ),
50
    )]
51
    public function administer_course(
52
        ResponseInterface $response,
53
        \stdClass $course,
54
    ): ResponseInterface {
55
        global $PAGE, $SITE, $OUTPUT;
56
 
57
        $PAGE->set_pagelayout('incourse');
58
 
59
        if ($course->id == $SITE->id) {
60
            $title = get_string('frontpagesettings');
61
            $node = $PAGE->settingsnav->find('frontpage', navigation_node::TYPE_SETTING);
62
            $PAGE->set_primary_active_tab('home');
63
        } else {
64
            $title = get_string('courseadministration');
65
            $node = $PAGE->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE);
66
        }
67
        $PAGE->set_title($title);
68
        $PAGE->set_heading($course->fullname);
69
        $PAGE->navbar->add($title);
70
        $response->getBody()->write($OUTPUT->header());
71
        $response->getBody()->write($OUTPUT->heading($title));
72
 
73
        if ($node) {
74
            $response->getBody()->write($OUTPUT->render_from_template('core/settings_link_page', ['node' => $node]));
75
        }
76
 
77
        $response->getBody()->write($OUTPUT->footer());
78
 
79
        return $response;
80
    }
81
}