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 - 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
 * Display information about all the mod_h5pactivity modules in the requested course.
19
 *
20
 * @package     mod_h5pactivity
21
 * @copyright   2020 Ferran Recio <ferran@moodle.com>
22
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
require(__DIR__.'/../../config.php');
26
require_once(__DIR__.'/lib.php');
27
 
28
$id = required_param('id', PARAM_INT);
29
 
30
$course = $DB->get_record('course', ['id' => $id], '*', MUST_EXIST);
31
require_course_login($course);
32
 
33
$coursecontext = context_course::instance($course->id);
34
 
35
$event = \mod_h5pactivity\event\course_module_instance_list_viewed::create(['context' => $coursecontext]);
36
$event->add_record_snapshot('course', $course);
37
$event->trigger();
38
 
39
$PAGE->set_url('/mod/h5pactivity/index.php', ['id' => $id]);
40
$PAGE->set_title(format_string($course->fullname));
41
$PAGE->set_heading(format_string($course->fullname));
42
$PAGE->set_context($coursecontext);
43
 
44
echo $OUTPUT->header();
45
 
46
$modulenameplural = get_string('modulenameplural', 'mod_h5pactivity');
47
echo $OUTPUT->heading($modulenameplural);
48
 
49
$h5pactivities = get_all_instances_in_course('h5pactivity', $course);
50
 
51
if (empty($h5pactivities)) {
52
    notice(get_string('thereareno', 'moodle'), new moodle_url('/course/view.php', ['id' => $course->id]));
53
    exit;
54
}
55
 
56
$table = new html_table();
57
$table->attributes['class'] = 'generaltable mod_index';
58
 
59
$align = ['center', 'left'];
60
if ($course->format == 'weeks' || $course->format == 'topics') {
61
    $table->head  = [get_string('section'), get_string('name')];
62
    $table->align = ['center', 'left'];
63
} else {
64
    $table->head  = [get_string('name')];
65
    $table->align = ['left'];
66
}
67
 
68
foreach ($h5pactivities as $h5pactivity) {
69
    $attributes = [];
70
    if (!$h5pactivity->visible) {
71
        $attributes['class'] = 'dimmed';
72
    }
73
    $link = html_writer::link(
74
        new moodle_url('/mod/h5pactivity/view.php', ['id' => $h5pactivity->coursemodule]),
75
        format_string($h5pactivity->name, true),
76
        $attributes);
77
 
78
    if ($course->format == 'weeks' or $course->format == 'topics') {
79
        $table->data[] = [$h5pactivity->section, $link];
80
    } else {
81
        $table->data[] = [$link];
82
    }
83
}
84
 
85
echo html_writer::table($table);
86
echo $OUTPUT->footer();