diff --git a/mod/scorm/classes/output/actionbar.php b/mod/scorm/classes/output/actionbar.php index ae2c278c18d..cac0f8a672a 100644 --- a/mod/scorm/classes/output/actionbar.php +++ b/mod/scorm/classes/output/actionbar.php @@ -107,8 +107,10 @@ class actionbar implements renderable, templatable { $url = new moodle_url('/mod/scorm/report.php', $PAGE->url->remove_params('attemptsmode')); $urlselect = new url_select($reportmenu, $url->out(false), null, 'selectscormreports'); + $heading = $reportmenu[$url->out(false)] ?? null; $data = [ + 'heading' => $heading, 'scormreports' => $urlselect->export_for_template($output), 'candownload' => $this->download, 'downloadods' => ($this->download) ? $downloadodslink->out(false) : '', diff --git a/mod/scorm/classes/output/userreportsactionbar.php b/mod/scorm/classes/output/userreportsactionbar.php index 443128124f3..89cfca5ed9b 100644 --- a/mod/scorm/classes/output/userreportsactionbar.php +++ b/mod/scorm/classes/output/userreportsactionbar.php @@ -94,6 +94,7 @@ class userreportsactionbar implements renderable, templatable { } $urlselect = new url_select($reportmenu, $userreporturl, [], 'userscormreport'); $data ['userreport'] = $urlselect->export_for_template($output); + $data ['heading'] = $reportmenu[$userreporturl] ?? null; } return $data; diff --git a/mod/scorm/index.php b/mod/scorm/index.php index 214b94c04c7..45212d342a5 100644 --- a/mod/scorm/index.php +++ b/mod/scorm/index.php @@ -48,9 +48,6 @@ $PAGE->set_title($strscorms); $PAGE->set_heading($course->fullname); $PAGE->navbar->add($strscorms); echo $OUTPUT->header(); -if (!$PAGE->has_secondary_navigation()) { - echo $OUTPUT->heading($strscorms); -} $usesections = course_format_uses_sections($course->format); diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php index 9508df7252b..5ebdde57dad 100644 --- a/mod/scorm/locallib.php +++ b/mod/scorm/locallib.php @@ -936,7 +936,7 @@ function scorm_print_launch ($user, $scorm, $action, $cm) { $organization = optional_param('organization', '', PARAM_INT); if ($scorm->displaycoursestructure == 1) { - echo $OUTPUT->box_start('generalbox boxaligncenter toc container', 'toc'); + echo $OUTPUT->box_start('generalbox boxaligncenter toc', 'toc'); echo html_writer::div(get_string('contents', 'scorm'), 'structurehead'); } if (empty($organization)) { @@ -992,31 +992,29 @@ function scorm_print_launch ($user, $scorm, $action, $cm) { echo html_writer::start_div('scorm-center'); echo html_writer::start_tag('form', array('id' => 'scormviewform', 'method' => 'post', - 'action' => $CFG->wwwroot.'/mod/scorm/player.php', - 'class' => 'container')); + 'action' => $CFG->wwwroot.'/mod/scorm/player.php')); if ($scorm->hidebrowse == 0) { - echo html_writer::empty_tag('button', - [ - 'class' => 'btn btn-secondary mr-1', 'name' => 'mode', - 'type' => 'submit', 'id' => 'b', 'value' => 'browse']) . - get_string('browse', 'scorm') . html_writer::end_tag('button'); - echo html_writer::empty_tag('button', - [ - 'class' => 'btn btn-primary mx-1', 'name' => 'mode', - 'type' => 'submit', 'id' => 'n', 'value' => 'normal']) . - get_string('enter', 'scorm') . html_writer::end_tag('button'); + echo html_writer::tag('button', get_string('browse', 'scorm'), + ['class' => 'btn btn-secondary mr-1', 'name' => 'mode', + 'type' => 'submit', 'id' => 'b', 'value' => 'browse']) + . html_writer::end_tag('button'); } else { echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'mode', 'value' => 'normal')); } + echo html_writer::tag('button', get_string('enter', 'scorm'), + ['class' => 'btn btn-primary mx-1', 'name' => 'mode', + 'type' => 'submit', 'id' => 'n', 'value' => 'normal']) + . html_writer::end_tag('button'); if (!empty($scorm->forcenewattempt)) { if ($scorm->forcenewattempt == SCORM_FORCEATTEMPT_ALWAYS || ($scorm->forcenewattempt == SCORM_FORCEATTEMPT_ONCOMPLETE && $incomplete === false)) { echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'newattempt', 'value' => 'on')); } } else if (!empty($attemptcount) && ($incomplete === false) && (($result->attemptleft > 0)||($scorm->maxattempt == 0))) { - echo html_writer::empty_tag('br'); - echo html_writer::checkbox('newattempt', 'on', false, '', array('id' => 'a')); - echo html_writer::label(get_string('newattempt', 'scorm'), 'a'); + echo html_writer::start_div('pt-1'); + echo html_writer::checkbox('newattempt', 'on', false, '', array('id' => 'a')); + echo html_writer::label(get_string('newattempt', 'scorm'), 'a', true, ['class' => 'pl-1']); + echo html_writer::end_div(); } if (!empty($scorm->popup)) { echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'display', 'value' => 'popup')); diff --git a/mod/scorm/mod_form.php b/mod/scorm/mod_form.php index ad6892a8422..0df6856fea8 100644 --- a/mod/scorm/mod_form.php +++ b/mod/scorm/mod_form.php @@ -276,7 +276,9 @@ class mod_scorm_mod_form extends moodleform_mod { $this->standard_coursemodule_elements(); // A SCORM module should define this within itself and is not needed here. - $mform->removeElement('completionpassgrade'); + if ($mform->elementExists('completionpassgrade')) { + $mform->removeElement('completionpassgrade'); + } // Buttons. $this->add_action_buttons(); diff --git a/mod/scorm/player.php b/mod/scorm/player.php index dcad9235939..9dfef70a56b 100644 --- a/mod/scorm/player.php +++ b/mod/scorm/player.php @@ -160,7 +160,8 @@ $SESSION->scorm->attempt = $attempt; $completion = new completion_info($course); $completion->set_module_viewed($cm); -// Print the page header. +// Generate the exit button. +$exiturl = ""; if (empty($scorm->popup) || $displaymode == 'popup') { if ($course->format == 'singleactivity' && $scorm->skipview == SCORM_SKIPVIEW_ALWAYS && !has_capability('mod/scorm:viewreport', context_module::instance($cm->id))) { @@ -168,13 +169,11 @@ if (empty($scorm->popup) || $displaymode == 'popup') { $exiturl = $CFG->wwwroot; } else { // Redirect back to the correct section if one section per page is being used. - $exiturl = course_get_url($course, $cm->sectionnum); + $exiturl = course_get_url($course, $cm->sectionnum)->out(); } - - $exitlink = html_writer::link($exiturl, $strexit, array('title' => $strexit, 'class' => 'btn btn-secondary')); - $PAGE->set_button($exitlink); } +// Print the page header. $PAGE->requires->data_for_js('scormplayerdata', Array('launch' => false, 'currentorg' => '', 'sco' => 0, @@ -191,11 +190,16 @@ if (file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.js')) { } else { $PAGE->requires->js('/mod/scorm/datamodels/scorm_12.js', true); } - -echo $OUTPUT->header(); -if (!empty($scorm->displayactivityname) && !$PAGE->has_secondary_navigation()) { - echo $OUTPUT->heading(format_string($scorm->name)); +$activityheader = $PAGE->activityheader; +$headerconfig = [ + 'description' => '', + 'hidecompletion' => true +]; +if ($activityheader->is_title_allowed() && empty($scorm->displayactivityname)) { + $headerconfig['title'] = ''; } +$activityheader->set_attrs($headerconfig); +echo $OUTPUT->header(); $PAGE->requires->string_for_js('navigation', 'scorm'); $PAGE->requires->string_for_js('toc', 'scorm'); @@ -205,19 +209,22 @@ $PAGE->requires->string_for_js('popupsblocked', 'scorm'); $name = false; -$scrompagestyle = "margin-top: 1em"; -if ($mode === 'normal') { - $scrompagestyle = "margin-top: 3em"; +// Exit button should ONLY be displayed when in the current window. +if ($displaymode !== 'popup') { + $renderer = $PAGE->get_renderer('mod_scorm'); + echo $renderer->generate_exitbar($exiturl); } -echo html_writer::start_div('', array('id' => 'scormpage', 'style' => $scrompagestyle)); + +echo html_writer::start_div('', array('id' => 'scormpage')); echo html_writer::start_div('', array('id' => 'tocbox')); echo html_writer::div(html_writer::tag('script', '', array('id' => 'external-scormapi', 'type' => 'text/JavaScript')), '', array('id' => 'scormapi-parent')); if ($scorm->hidetoc == SCORM_TOC_POPUP or $mode == 'browse' or $mode == 'review') { - echo html_writer::start_div('', array('id' => 'scormtop')); - echo $mode == 'browse' ? html_writer::div(get_string('browsemode', 'scorm'), 'scorm-left', array('id' => 'scormmode')) : ''; - echo $mode == 'review' ? html_writer::div(get_string('reviewmode', 'scorm'), 'scorm-left', array('id' => 'scormmode')) : ''; + echo html_writer::start_div('mb-3', array('id' => 'scormtop')); + if ($mode == 'browse' || $mode == 'review') { + echo html_writer::div(get_string("{$mode}mode", 'scorm'), 'scorm-left h3', ['id' => 'scormmode']); + } if ($scorm->hidetoc == SCORM_TOC_POPUP) { echo html_writer::div($result->tocmenu, 'scorm-right', array('id' => 'scormnav')); } diff --git a/mod/scorm/renderer.php b/mod/scorm/renderer.php index a3355873101..632bd1d00d5 100644 --- a/mod/scorm/renderer.php +++ b/mod/scorm/renderer.php @@ -95,6 +95,16 @@ class mod_scorm_renderer extends plugin_renderer_base { public function user_report_actionbar(\mod_scorm\output\userreportsactionbar $userreportsactionbar): string { return $this->render_from_template('mod_scorm/user_report_actionbar', $userreportsactionbar->export_for_template($this)); } + + /** + * Generate the SCORM's "Exit activity" button + * + * @param string $url The url to be hooked up to the exit button + * @return string + */ + public function generate_exitbar(string $url): string { + return $this->render_from_template('mod_scorm/player_exitbar', ['action' => $url]); + } } /** diff --git a/mod/scorm/report/userreport.php b/mod/scorm/report/userreport.php index 922a845f879..b16d26862bd 100644 --- a/mod/scorm/report/userreport.php +++ b/mod/scorm/report/userreport.php @@ -77,11 +77,12 @@ $PAGE->set_title("$course->shortname: ".format_string($scorm->name)); $PAGE->set_heading($course->fullname); $PAGE->navbar->add($strreport, new moodle_url('/mod/scorm/report.php', array('id' => $cm->id))); $PAGE->navbar->add(fullname($user). " - $strattempt $attempt"); - +$PAGE->activityheader->set_attrs([ + 'hidecompletion' => true, + 'description' => '' +]); echo $OUTPUT->header(); -if (!$PAGE->has_secondary_navigation()) { - echo $OUTPUT->heading(format_string($scorm->name)); -} + // End of Print the page header. $currenttab = 'scoes'; diff --git a/mod/scorm/report/userreportinteractions.php b/mod/scorm/report/userreportinteractions.php index d03a5a66749..8016d5e726e 100644 --- a/mod/scorm/report/userreportinteractions.php +++ b/mod/scorm/report/userreportinteractions.php @@ -94,8 +94,13 @@ if (!$table->is_downloading($download, $exportfilename)) { $PAGE->navbar->add(fullname($user). " - $strattempt $attempt"); + $PAGE->activityheader->set_attrs([ + 'hidecompletion' => true, + 'description' => '' + ]); + echo $OUTPUT->header(); - echo $OUTPUT->heading(format_string($scorm->name)); + // End of Print the page header. $currenttab = 'interactions'; diff --git a/mod/scorm/report/userreporttracks.php b/mod/scorm/report/userreporttracks.php index 5b115756491..08c15d1e643 100644 --- a/mod/scorm/report/userreporttracks.php +++ b/mod/scorm/report/userreporttracks.php @@ -97,10 +97,11 @@ $exportfilename = $courseshortname . '-' . format_string($scorm->name, true) . ' $table = new flexible_table('mod_scorm-userreporttracks'); if (!$table->is_downloading($download, $exportfilename)) { + $PAGE->activityheader->set_attrs([ + 'hidecompletion' => true, + 'description' => '' + ]); echo $OUTPUT->header(); - if (!$PAGE->has_secondary_navigation()) { - echo $OUTPUT->heading(format_string($scorm->name)); - } $currenttab = ''; $renderer = $PAGE->get_renderer('mod_scorm'); $useractionreport = new \mod_scorm\output\userreportsactionbar($id, $userid, $attempt, 'attempt', $mode, $scoid); diff --git a/mod/scorm/templates/player_exitbar.mustache b/mod/scorm/templates/player_exitbar.mustache new file mode 100644 index 00000000000..c73865949bf --- /dev/null +++ b/mod/scorm/templates/player_exitbar.mustache @@ -0,0 +1,32 @@ +{{! + 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 . +}} +{{! + @template mod_scorm/player_exitbar + Actions bar for the user reports page UI. + Classes required for JS: + * none + Data attributes required for JS: + * none + Context variables required for this template: + * action + Example context (json): + { + "action": "http://localhost/moodle/mod/scorm/report.php?id=70&mode=interactions" + } +}} +
+ + {{#str}}exitactivity, mod_scorm{{/str}} + +
diff --git a/mod/scorm/templates/report_actionbar.mustache b/mod/scorm/templates/report_actionbar.mustache index 78dc0ef49fe..c5b195425a5 100644 --- a/mod/scorm/templates/report_actionbar.mustache +++ b/mod/scorm/templates/report_actionbar.mustache @@ -22,6 +22,7 @@ * see mod/scorm/classes/output/actionbar.php Example context (json): { + "heading": "Heading", "scormreports": { "id": "url_select_test", "options": [ @@ -39,25 +40,26 @@ }}
-
- {{#scormreports}} - {{>core/url_select}} - {{/scormreports}} + {{#scormreports}} +
+ {{>core/url_select}}
-
+{{#heading}}

{{heading}}

{{/heading}} diff --git a/mod/scorm/templates/user_report_actionbar.mustache b/mod/scorm/templates/user_report_actionbar.mustache index 5c81cb17841..c7608758922 100644 --- a/mod/scorm/templates/user_report_actionbar.mustache +++ b/mod/scorm/templates/user_report_actionbar.mustache @@ -29,7 +29,8 @@ {"name": "Interactions", "value": "/mod/scorm/report/userreportinteractions.php?id=70&user=13&attempt=1"} ] }, - "backurl": "http://localhost/moodle/mod/scorm/report.php?id=70&mode=interactions" + "backurl": "http://localhost/moodle/mod/scorm/report.php?id=70&mode=interactions", + "heading": "Sub page heading" } }}
@@ -40,3 +41,4 @@ {{/userreport}}
+{{#heading}}

{{heading}}

{{/heading}} diff --git a/mod/scorm/view.js b/mod/scorm/view.js index a80ddd0c30c..6060daf4ee9 100644 --- a/mod/scorm/view.js +++ b/mod/scorm/view.js @@ -64,11 +64,9 @@ M.mod_scormform.init = function(Y) { } // Set mode and newattempt correctly. - var setlaunchoptions = function() { - var mode = Y.one('#scormviewform input[name=mode]:checked'); + var setlaunchoptions = function(mode) { if (mode) { - var modevalue = mode.get('value'); - launch_url += '&mode=' + (modevalue ? modevalue : 'normal'); + launch_url += '&mode=' + (mode ? mode : 'normal'); } else { launch_url += '&mode=normal'; } @@ -86,13 +84,13 @@ M.mod_scormform.init = function(Y) { } // Listen for view form submit and generate popup on user interaction. if (scormform) { - Y.on('submit', function(e) { - setlaunchoptions(); + scormform.delegate('click', function(e) { + setlaunchoptions(e.currentTarget.getAttribute('value')); winobj = window.open(launch_url, 'Popup', poptions); this.target = 'Popup'; scormredirect(winobj); winobj.opener = null; e.preventDefault(); - }, scormform); + }, 'button[name=mode]'); } } diff --git a/mod/scorm/view.php b/mod/scorm/view.php index 6728929ec93..d285c7d1a62 100644 --- a/mod/scorm/view.php +++ b/mod/scorm/view.php @@ -137,7 +137,12 @@ if (empty($preventskip) && empty($launch) && (has_capability('mod/scorm:skipview $PAGE->set_title($pagetitle); $PAGE->set_heading($course->fullname); // Let the module handle the display. -$PAGE->activityheader->set_description(''); +if (!empty($action) && $action == 'delete' && confirm_sesskey() && has_capability('mod/scorm:deleteownresponses', $contextmodule)) { + $PAGE->activityheader->disable(); +} else { + $PAGE->activityheader->set_description(''); +} + echo $OUTPUT->header(); if (!empty($action) && confirm_sesskey() && has_capability('mod/scorm:deleteownresponses', $contextmodule)) { if ($action == 'delete') { @@ -159,7 +164,7 @@ if (empty($launch) && ($scorm->displayattemptstatus == SCORM_DISPLAY_ATTEMPTSTAT $scorm->displayattemptstatus == SCORM_DISPLAY_ATTEMPTSTATUS_ENTRY)) { $attemptstatus = scorm_get_attempt_status($USER, $scorm, $cm); } -echo $OUTPUT->box(format_module_intro('scorm', $scorm, $cm->id), 'container', 'intro'); +echo $OUTPUT->box(format_module_intro('scorm', $scorm, $cm->id), '', 'intro'); // Check if SCORM available. No need to display warnings because activity dates are displayed at the top of the page. list($available, $warnings) = scorm_get_availability_status($scorm); @@ -168,10 +173,10 @@ if ($available && empty($launch)) { scorm_print_launch($USER, $scorm, 'view.php?id='.$cm->id, $cm); } -echo $OUTPUT->box($attemptstatus, 'container'); +echo $OUTPUT->box($attemptstatus); if (!empty($forcejs)) { - $message = $OUTPUT->box(get_string("forcejavascriptmessage", "scorm"), "container forcejavascriptmessage"); + $message = $OUTPUT->box(get_string("forcejavascriptmessage", "scorm"), "forcejavascriptmessage"); echo html_writer::tag('noscript', $message); }