mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 19:50:14 +01:00
Merge branch 'MDL-79543-main' of https://github.com/sarjona/moodle
This commit is contained in:
commit
4dd70667d1
File diff suppressed because one or more lines are too long
@ -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>
|
||||
|
@ -215,6 +215,7 @@ class icon_system_fontawesome extends icon_system_font {
|
||||
'core:i/contentbank' => 'fa-paint-brush',
|
||||
'core:i/dashboard' => 'fa-tachometer',
|
||||
'core:i/categoryevent' => 'fa-cubes',
|
||||
'core:i/chartbar' => 'fa-chart-bar',
|
||||
'core:i/course' => 'fa-graduation-cap',
|
||||
'core:i/courseevent' => 'fa-graduation-cap',
|
||||
'core:i/customfield' => 'fa-hand-o-right',
|
||||
|
@ -127,7 +127,6 @@ $string['result_other'] = 'Unknown interaction type';
|
||||
$string['result_sequencing_choice'] = 'Positions';
|
||||
$string['result_sequencing_answer'] = 'Position value';
|
||||
$string['result_sequencing_position'] = '#{$a}';
|
||||
$string['review_all_attempts'] = 'View all attempts ({$a} submitted)';
|
||||
$string['review_mode'] = 'Review attempts';
|
||||
$string['review_my_attempts'] = 'View my attempts';
|
||||
$string['review_user_attempts'] = 'View user attempts ({$a})';
|
||||
@ -147,4 +146,5 @@ $string['tracking_messages'] = 'Some H5P provide attempt tracking data for advan
|
||||
$string['true'] = 'True';
|
||||
$string['usecontentbank'] = 'Use the <a href="{$a}" target="_blank">content bank (opens in new window)</a> to manage your H5P files';
|
||||
$string['view'] = 'View';
|
||||
$string['viewattempts'] = 'View attempts ({$a})';
|
||||
$string['view_report'] = 'View report';
|
||||
|
@ -8,6 +8,7 @@ Feature: Attempts review settings.
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| student1 | Student | 1 | student1@example.com |
|
||||
| student2 | Student | 2 | student2@example.com |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
| teacher2 | Teacher | 2 | teacher2@example.com |
|
||||
And the following "courses" exist:
|
||||
@ -16,6 +17,7 @@ Feature: Attempts review settings.
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
| student2 | C1 | student |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| teacher2 | C1 | teacher |
|
||||
|
||||
@ -28,7 +30,45 @@ Feature: Attempts review settings.
|
||||
| idnumber | h5ppackage |
|
||||
| enabletracking | <enabletracking> |
|
||||
| reviewmode | <reviewmode> |
|
||||
And the following "mod_h5pactivity > attempt" exists:
|
||||
And the following "mod_h5pactivity > attempts" exist:
|
||||
| user | h5pactivity | attempt | interactiontype | rawscore | maxscore | duration | completion | success |
|
||||
| student1 | H5P package | 1 | compound | 0 | 2 | 6 | 1 | 0 |
|
||||
| student1 | H5P package | 2 | compound | 2 | 2 | 4 | 1 | 1 |
|
||||
| student2 | H5P package | 1 | compound | 1 | 2 | 8 | 1 | 0 |
|
||||
When I am on the "H5P package" "h5pactivity activity" page logged in as <user>
|
||||
Then "Attempts report" "link" should <attemptsreportlink> in current page administration
|
||||
And I should <previewmode> "You are in preview mode."
|
||||
And I should <attempttracking> "Attempt tracking is not enabled for this activity."
|
||||
And I should <attempttrackingsettings> "You can enable it in Settings."
|
||||
And I should <viewattempts> "View attempts (3)"
|
||||
|
||||
Examples:
|
||||
| user | enabletracking | reviewmode | attemptsreportlink | previewmode | attempttracking | attempttrackingsettings | viewattempts |
|
||||
| student1 | 1 | 1 | exist | not see | not see | not see | not see |
|
||||
| student1 | 1 | 0 | not exist | not see | not see | not see | not see |
|
||||
| student1 | 0 | 1 | not exist | not see | not see | not see | not see |
|
||||
| teacher1 | 1 | 1 | exist | see | not see | not see | see |
|
||||
| teacher1 | 1 | 0 | exist | see | not see | not see | see |
|
||||
| teacher1 | 0 | 1 | not exist | see | see | see | not see |
|
||||
| teacher2 | 0 | 1 | not exist | see | see | not see | not see |
|
||||
# TODO: The non-editing teachers will be able to see attempts when MDL-80028 is fixed.
|
||||
| teacher2 | 1 | 1 | not exist | see | not see | not see | not see |
|
||||
|
||||
Scenario: View attempts link behaviour
|
||||
Given the following "activity" exists:
|
||||
| activity | h5pactivity |
|
||||
| name | H5P package |
|
||||
| intro | Test H5P description |
|
||||
| course | C1 |
|
||||
| idnumber | h5ppackage |
|
||||
| enabletracking | 1 |
|
||||
| reviewmode | 1 |
|
||||
When I am on the "H5P package" "h5pactivity activity" page logged in as teacher1
|
||||
# The link is displayed with the correct number of attempts (in that case 0 because there are no attempts yet).
|
||||
Then I should see "View attempts (0)"
|
||||
Then I follow "View attempts (0)"
|
||||
And I should not see "View user attempts"
|
||||
But the following "mod_h5pactivity > attempt" exists:
|
||||
| user | student1 |
|
||||
| h5pactivity | H5P package |
|
||||
| attempt | 1 |
|
||||
@ -38,18 +78,6 @@ Feature: Attempts review settings.
|
||||
| duration | 4 |
|
||||
| completion | 1 |
|
||||
| success | 1 |
|
||||
When I am on the "H5P package" "h5pactivity activity" page logged in as <user>
|
||||
Then "Attempts report" "link" should <attemptsreportlink> in current page administration
|
||||
And I should <previewmode> "You are in preview mode."
|
||||
And I should <attempttracking> "Attempt tracking is not enabled for this activity."
|
||||
And I should <attempttrackingsettings> "You can enable it in Settings."
|
||||
|
||||
Examples:
|
||||
| user | enabletracking | reviewmode | attemptsreportlink | previewmode | attempttracking | attempttrackingsettings |
|
||||
| student1 | 1 | 1 | exist | not see | not see | not see |
|
||||
| student1 | 1 | 0 | not exist | not see | not see | not see |
|
||||
| student1 | 0 | 1 | not exist | not see | not see | not see |
|
||||
| teacher1 | 1 | 1 | exist | see | not see | not see |
|
||||
| teacher1 | 1 | 0 | exist | see | not see | not see |
|
||||
| teacher1 | 0 | 1 | not exist | see | see | see |
|
||||
| teacher2 | 0 | 1 | not exist | see | see | not see |
|
||||
And I am on the "H5P package" "h5pactivity activity" page
|
||||
And I follow "View attempts (1)"
|
||||
And I should see "View user attempts"
|
||||
|
@ -87,9 +87,20 @@ if (!$manager->can_submit()) {
|
||||
}
|
||||
echo $OUTPUT->notification($message, \core\output\notification::NOTIFY_WARNING);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo player::display($fileurl, $config, true, 'mod_h5pactivity', true);
|
||||
$extraactions = [];
|
||||
|
||||
if ($manager->can_view_all_attempts() && $manager->is_tracking_enabled()) {
|
||||
$extraactions[] = new action_link(
|
||||
new moodle_url('/mod/h5pactivity/report.php', ['id' => $cm->id]),
|
||||
get_string('viewattempts', 'mod_h5pactivity', $manager->count_attempts()),
|
||||
null,
|
||||
null,
|
||||
new pix_icon('i/chartbar', '', 'core')
|
||||
);
|
||||
}
|
||||
|
||||
echo player::display($fileurl, $config, true, 'mod_h5pactivity', true, $extraactions);
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
1
pix/i/chartbar.svg
Normal file
1
pix/i/chartbar.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M24 32c13.3 0 24 10.7 24 24V408c0 13.3 10.7 24 24 24H488c13.3 0 24 10.7 24 24s-10.7 24-24 24H72c-39.8 0-72-32.2-72-72V56C0 42.7 10.7 32 24 32zM128 136c0-13.3 10.7-24 24-24l208 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-208 0c-13.3 0-24-10.7-24-24zm24 72H296c13.3 0 24 10.7 24 24s-10.7 24-24 24H152c-13.3 0-24-10.7-24-24s10.7-24 24-24zm0 96H424c13.3 0 24 10.7 24 24s-10.7 24-24 24H152c-13.3 0-24-10.7-24-24s10.7-24 24-24z"/></svg>
|
After Width: | Height: | Size: 649 B |
Loading…
x
Reference in New Issue
Block a user