mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 19:06:41 +02:00
MDL-79543 h5p: Include attempts info and link
Co-authored-by: Ferran Recio <ferran@moodle.com>
This commit is contained in:
parent
6e8d1454ba
commit
ec8f84d8af
5 changed files with 105 additions and 31 deletions
|
@ -158,11 +158,17 @@ class player {
|
|||
* @param bool $preventredirect Set to true in scripts that can not redirect (CLI, RSS feeds, etc.), throws exceptions
|
||||
* @param string $component optional moodle component to sent xAPI tracking
|
||||
* @param bool $displayedit Whether the edit button should be displayed below the H5P content.
|
||||
* @param \action_link[] $extraactions Extra actions to display above the H5P content.
|
||||
*
|
||||
* @return string The embedable code to display a H5P file.
|
||||
*/
|
||||
public static function display(string $url, \stdClass $config, bool $preventredirect = true,
|
||||
string $component = '', bool $displayedit = false): string {
|
||||
public static function display(
|
||||
string $url, \stdClass $config,
|
||||
bool $preventredirect = true,
|
||||
string $component = '',
|
||||
bool $displayedit = false,
|
||||
array $extraactions = [],
|
||||
): string {
|
||||
global $OUTPUT, $CFG;
|
||||
|
||||
$params = [
|
||||
|
@ -192,6 +198,10 @@ class player {
|
|||
}
|
||||
}
|
||||
|
||||
$template->extraactions = [];
|
||||
foreach ($extraactions as $action) {
|
||||
$template->extraactions[] = $action->export_for_template($OUTPUT);
|
||||
}
|
||||
$result = $OUTPUT->render_from_template('core_h5p/h5pembed', $template);
|
||||
$result .= self::get_resize_code();
|
||||
return $result;
|
||||
|
|
|
@ -28,20 +28,44 @@
|
|||
|
||||
Example context (json):
|
||||
{
|
||||
"embedurl": "http://example.com/h5p/embed.php?url=testurl"
|
||||
"embedurl": "http://example.com/h5p/embed.php?url=testurl",
|
||||
"editurl": "http://example.com/h5p/embed.php?url=testurl&edit=1",
|
||||
"extraactions": [
|
||||
{
|
||||
"text": "View attempts (2)",
|
||||
"url": "http://example.com/mod/h5pactivity/report.php?a=1",
|
||||
"icon": {
|
||||
"key": "i\/chartbar",
|
||||
"component": "core",
|
||||
"title": ""
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
}}
|
||||
{{#editurl}}
|
||||
<div class="d-flex justify-content-end mb-3">
|
||||
<a href="{{editurl}}" class="btn text-primary">
|
||||
{{#pix}}i/edit, core{{/pix}}
|
||||
{{#str}}editcontent, core_h5p{{/str}}
|
||||
</a>
|
||||
{{#extraactions}}
|
||||
<a href="{{url}}" class="btn text-primary">
|
||||
{{#icon}}{{#pix}}{{key}}, {{component}}, {{title}}{{/pix}}{{/icon}}
|
||||
{{text}}
|
||||
</a>
|
||||
{{/extraactions}}
|
||||
{{#editurl}}
|
||||
<a href="{{editurl}}" class="btn text-primary">
|
||||
{{#pix}}i/edit, core{{/pix}}
|
||||
{{#str}}editcontent, core_h5p{{/str}}
|
||||
</a>
|
||||
{{/editurl}}
|
||||
</div>
|
||||
{{/editurl}}
|
||||
|
||||
<iframe src="{{embedurl}}" name="h5player" width=":w" height=":h"
|
||||
allowfullscreen="allowfullscreen" class="h5p-player w-100 border-0"
|
||||
style="height: 0px;" id="{{uniqid}}-h5player">
|
||||
</iframe>
|
||||
<iframe
|
||||
src="{{embedurl}}"
|
||||
name="h5player"
|
||||
width=":w"
|
||||
height=":h"
|
||||
allowfullscreen="allowfullscreen"
|
||||
class="h5p-player w-100 border-0"
|
||||
style="height: 0px;"
|
||||
id="{{uniqid}}-h5player"
|
||||
></iframe>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue