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') { 61 $table->head = [get_string('week'), get_string('name')]; 62 $table->align = ['center', 'left']; 63 } else if ($course->format == 'topics') { 64 $table->head = [get_string('topic'), get_string('name')]; 65 $table->align = ['center', 'left']; 66 } else { 67 $table->head = [get_string('name')]; 68 $table->align = ['left']; 69 } 70 71 foreach ($h5pactivities as $h5pactivity) { 72 $attributes = []; 73 if (!$h5pactivity->visible) { 74 $attributes['class'] = 'dimmed'; 75 } 76 $link = html_writer::link( 77 new moodle_url('/mod/h5pactivity/view.php', ['id' => $h5pactivity->coursemodule]), 78 format_string($h5pactivity->name, true), 79 $attributes); 80 81 if ($course->format == 'weeks' or $course->format == 'topics') { 82 $table->data[] = [$h5pactivity->section, $link]; 83 } else { 84 $table->data[] = [$link]; 85 } 86 } 87 88 echo html_writer::table($table); 89 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body