Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.
16
 
17
/**
18
 * Display information about all the mod_stickynotes modules in the requested course.
19
 *
20
 * @package     mod_stickynotes
21
 * @copyright   2021 Olivier VALENTIN
22
 * @license     https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
require(__DIR__.'/../../config.php');
26
 
27
require_once(__DIR__.'/lib.php');
28
 
29
$id = required_param('id', PARAM_INT);
30
 
31
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
32
require_course_login($course);
33
 
34
$coursecontext = context_course::instance($course->id);
35
 
36
$event = \mod_stickynotes\event\course_module_instance_list_viewed::create(array(
37
    'context' => $coursecontext
38
));
39
$event->add_record_snapshot('course', $course);
40
$event->trigger();
41
 
42
$PAGE->set_url('/mod/stickynotes/index.php', array('id' => $id));
43
$PAGE->set_title(format_string($course->fullname));
44
$PAGE->set_heading(format_string($course->fullname));
45
$PAGE->set_pagelayout('incourse');
46
$PAGE->set_context($coursecontext);
47
 
48
echo $OUTPUT->header();
49
 
50
$modulenameplural = get_string('modulenameplural', 'mod_stickynotes');
51
echo $OUTPUT->heading($modulenameplural);
52
 
53
$stickynotess = get_all_instances_in_course('stickynotes', $course);
54
 
55
if (empty($stickynotess)) {
56
    notice(get_string('no$stickynotesinstances', 'mod_stickynotes'),
57
        new moodle_url('/course/view.php', array('id' => $course->id)));
58
}
59
 
60
$table = new html_table();
61
$table->attributes['class'] = 'generaltable mod_index';
62
 
63
if ($course->format == 'weeks') {
64
    $table->head  = array(get_string('week'), get_string('name'));
65
    $table->align = array('center', 'left');
66
} else if ($course->format == 'topics') {
67
    $table->head  = array(get_string('topic'), get_string('name'));
68
    $table->align = array('center', 'left', 'left', 'left');
69
} else {
70
    $table->head  = array(get_string('name'));
71
    $table->align = array('left', 'left', 'left');
72
}
73
 
74
foreach ($stickynotess as $stickynotes) {
75
    if (!$stickynotes->visible) {
76
        $link = html_writer::link(
77
            new moodle_url('/mod/stickynotes/view.php', array('id' => $stickynotes->coursemodule)),
78
            format_string($stickynotes->name, true),
79
            array('class' => 'dimmed'));
80
    } else {
81
        $link = html_writer::link(
82
            new moodle_url('/mod/stickynotes/view.php', array('id' => $stickynotes->coursemodule)),
83
            format_string($stickynotes->name, true));
84
    }
85
 
86
    if (course_format_uses_sections($course->format)) {
87
        $table->data[] = array(get_section_name($course, $stickynotes->section), $link);
88
    } else {
89
        $table->data[] = array($link);
90
    }
91
}
92
 
93
echo html_writer::table($table);
94
echo $OUTPUT->footer();