mirror of
https://github.com/moodle/moodle.git
synced 2025-08-10 19:36:41 +02:00

AMOS BEGIN CPY [h5poptions,atto_h5p],[h5pdisplay,mod_h5pactivity] CPY [downloadbutton,atto_h5p],[displayexport,mod_h5pactivity] CPY [embedbutton,atto_h5p],[displayembed,mod_h5pactivity] CPY [copyrightbutton,atto_h5p],[displaycopyright,mod_h5pactivity] AMOS END
74 lines
2.6 KiB
PHP
74 lines
2.6 KiB
PHP
<?php
|
|
// This file is part of Moodle - http://moodle.org/
|
|
//
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
/**
|
|
* Prints an instance of mod_h5pactivity.
|
|
*
|
|
* @package mod_h5pactivity
|
|
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
*/
|
|
|
|
require(__DIR__.'/../../config.php');
|
|
require_once(__DIR__.'/lib.php');
|
|
require_once($CFG->libdir.'/completionlib.php');
|
|
|
|
$id = required_param('id', PARAM_INT);
|
|
|
|
list ($course, $cm) = get_course_and_cm_from_cmid($id, 'h5pactivity');
|
|
|
|
require_login($course, true, $cm);
|
|
|
|
$moduleinstance = $DB->get_record('h5pactivity', ['id' => $cm->instance], '*', MUST_EXIST);
|
|
|
|
$context = context_module::instance($cm->id);
|
|
|
|
$event = \mod_h5pactivity\event\course_module_viewed::create([
|
|
'objectid' => $moduleinstance->id,
|
|
'context' => $context
|
|
]);
|
|
$event->add_record_snapshot('course', $course);
|
|
$event->add_record_snapshot('h5pactivity', $moduleinstance);
|
|
$event->trigger();
|
|
|
|
// Completion.
|
|
$completion = new completion_info($course);
|
|
$completion->set_module_viewed($cm);
|
|
|
|
// Convert display options to a valid object.
|
|
$factory = new \core_h5p\factory();
|
|
$core = $factory->get_core();
|
|
$config = \core_h5p\helper::decode_display_options($core, $moduleinstance->displayoptions);
|
|
|
|
// Instantiate player.
|
|
$fs = get_file_storage();
|
|
$files = $fs->get_area_files($context->id, 'mod_h5pactivity', 'package', 0, 'id', false);
|
|
$file = reset($files);
|
|
$fileurl = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(),
|
|
$file->get_filearea(), $file->get_itemid(), $file->get_filepath(),
|
|
$file->get_filename(), false);
|
|
|
|
$PAGE->set_url('/mod/h5pactivity/view.php', ['id' => $cm->id]);
|
|
$PAGE->set_title(format_string($moduleinstance->name));
|
|
$PAGE->set_heading(format_string($course->fullname));
|
|
$PAGE->set_context($context);
|
|
|
|
echo $OUTPUT->header();
|
|
|
|
// TODO: add component to enable xAPI traking.
|
|
echo \core_h5p\player::display($fileurl, $config, true);
|
|
|
|
echo $OUTPUT->footer();
|