MDL-73448 scorm: Update scorm tertiary navigation
* Left align scorm content * Add headings * Remove exit buttons when in separate window
This commit is contained in:
@@ -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) : '',
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
+14
-16
@@ -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'));
|
||||
|
||||
@@ -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();
|
||||
|
||||
+23
-16
@@ -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'));
|
||||
}
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@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"
|
||||
}
|
||||
}}
|
||||
<div class="d-flex flex-row-reverse mb-2">
|
||||
<a class="btn btn-secondary" href="{{{action}}}" title="{{#str}}exitactivity, mod_scorm{{/str}}">
|
||||
{{#str}}exitactivity, mod_scorm{{/str}}
|
||||
</a>
|
||||
</div>
|
||||
@@ -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 @@
|
||||
}}
|
||||
<div class="container-fluid mb-3">
|
||||
<div class="row justify-content-between">
|
||||
<div class="mr-5">
|
||||
{{#scormreports}}
|
||||
{{>core/url_select}}
|
||||
{{/scormreports}}
|
||||
{{#scormreports}}
|
||||
<div>
|
||||
{{>core/url_select}}
|
||||
</div>
|
||||
<div class="mr-5">
|
||||
{{#candownload}}
|
||||
<div class="dropdown show">
|
||||
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
{{#str}} download {{/str}}
|
||||
</a>
|
||||
{{/scormreports}}
|
||||
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
|
||||
<a class="dropdown-item" href="{{ downloadods }}">{{#str}} downloadods {{/str}}</a>
|
||||
<a class="dropdown-item" href="{{ downloadexcel }}">{{#str}} downloadexcel {{/str}}</a>
|
||||
<a class="dropdown-item" href="{{ downloadtext }}">{{#str}} downloadtext {{/str}}</a>
|
||||
</div>
|
||||
</div>
|
||||
{{/candownload}}
|
||||
{{#candownload}}
|
||||
<div class="dropdown show">
|
||||
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
{{#str}} download {{/str}}
|
||||
</a>
|
||||
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
|
||||
<a class="dropdown-item" href="{{ downloadods }}">{{#str}} downloadods {{/str}}</a>
|
||||
<a class="dropdown-item" href="{{ downloadexcel }}">{{#str}} downloadexcel {{/str}}</a>
|
||||
<a class="dropdown-item" href="{{ downloadtext }}">{{#str}} downloadtext {{/str}}</a>
|
||||
</div>
|
||||
</div>
|
||||
{{/candownload}}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{{#heading}}<h2>{{heading}}</h2>{{/heading}}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}}
|
||||
<div class="container-fluid mb-3">
|
||||
@@ -40,3 +41,4 @@
|
||||
{{/userreport}}
|
||||
</div>
|
||||
</div>
|
||||
{{#heading}}<h2>{{heading}}</h2>{{/heading}}
|
||||
|
||||
+5
-7
@@ -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]');
|
||||
}
|
||||
}
|
||||
|
||||
+9
-4
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user