Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
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 * Prints an instance of mod_h5pactivity. 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 use mod_h5pactivity\local\manager; 26 use core_h5p\factory; 27 use core_h5p\player; 28 use core_h5p\helper; 29 30 require(__DIR__.'/../../config.php'); 31 require_once (__DIR__.'/lib.php'); 32 33 $id = required_param('id', PARAM_INT); 34 35 list ($course, $cm) = get_course_and_cm_from_cmid($id, 'h5pactivity'); 36 37 require_login($course, true, $cm); 38 39 $manager = manager::create_from_coursemodule($cm); 40 41 $moduleinstance = $manager->get_instance(); 42 43 $context = $manager->get_context(); 44 45 // Trigger module viewed event and completion. 46 $manager->set_module_viewed($course); 47 48 // Convert display options to a valid object. 49 $factory = new factory(); 50 $core = $factory->get_core(); 51 $config = core_h5p\helper::decode_display_options($core, $moduleinstance->displayoptions); 52 53 // Instantiate player. 54 $fs = get_file_storage(); 55 $files = $fs->get_area_files($context->id, 'mod_h5pactivity', 'package', 0, 'id', false); 56 $file = reset($files); 57 $fileurl = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), 58 $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), 59 $file->get_filename(), false); 60 61 $PAGE->set_url('/mod/h5pactivity/view.php', ['id' => $cm->id]); 62 63 $shortname = format_string($course->shortname, true, ['context' => $context]); 64 $pagetitle = strip_tags($shortname.': '.format_string($moduleinstance->name)); 65 $PAGE->set_title(format_string($pagetitle)); 66 67 $PAGE->set_heading(format_string($course->fullname)); 68 $PAGE->set_context($context); 69 70 echo $OUTPUT->header(); 71 echo $OUTPUT->heading(format_string($moduleinstance->name)); 72 73 // Render the activity information. 74 $completiondetails = \core_completion\cm_completion_details::get_instance($cm, $USER->id); 75 $activitydates = \core\activity_dates::get_dates_for_module($cm, $USER->id); 76 echo $OUTPUT->activity_information($cm, $completiondetails, $activitydates); 77 78 $instance = $manager->get_instance(); 79 if (!empty($instance->intro)) { 80 echo $OUTPUT->box(format_module_intro('h5pactivity', $instance, $cm->id), 'generalbox', 'intro'); 81 } 82 83 // Attempts review. 84 if ($manager->can_view_all_attempts()) { 85 $reviewurl = new moodle_url('report.php', ['a' => $cm->instance]); 86 $reviewmessage = get_string('review_all_attempts', 'mod_h5pactivity', $manager->count_attempts()); 87 } else if ($manager->can_view_own_attempts() && $manager->count_attempts($USER->id)) { 88 $reviewurl = new moodle_url('report.php', ['a' => $cm->instance, 'userid' => $USER->id]); 89 $reviewmessage = get_string('review_my_attempts', 'mod_h5pactivity'); 90 } 91 if (isset($reviewurl)) { 92 $widget = new mod_h5pactivity\output\reportlink($reviewurl, $reviewmessage); 93 echo $OUTPUT->render($widget); 94 } 95 96 if (!$manager->is_tracking_enabled()) { 97 $message = get_string('previewmode', 'mod_h5pactivity'); 98 echo $OUTPUT->notification($message, \core\output\notification::NOTIFY_WARNING); 99 } 100 101 echo player::display($fileurl, $config, true, 'mod_h5pactivity'); 102 103 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body