MDL-71915 mod_scorm: Update tertiary nav

Update the tertiary navigation for this activity.
This commit is contained in:
Sujith Haridasan
2021-12-06 09:27:58 +05:30
parent 222ab7b222
commit b98ea6f547
24 changed files with 477 additions and 235 deletions
+2 -2
View File
@@ -92,8 +92,8 @@ class tracks_viewed extends \core\event\base {
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'scorm', 'userreporttracks', 'report/userreporttracks.php?id=' . $this->contextinstanceid
. '&user=' . $this->relateduserid . '&attempt=' . $this->other['attemptid'] . '&scoid=' . $this->other['scoid'],
$this->other['instanceid'], $this->contextinstanceid);
. '&user=' . $this->relateduserid . '&attempt=' . $this->other['attemptid'] . '&scoid=' . $this->other['scoid']
. '&mode=' . $this->other['mode'], $this->other['instanceid'], $this->contextinstanceid);
}
/**
+120
View File
@@ -0,0 +1,120 @@
<?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/>.
namespace mod_scorm\output;
use renderable;
use renderer_base;
use templatable;
use moodle_url;
use url_select;
/**
* Render HTML elements for tertiary nav for scorm.
*
* @package mod_scorm
* @copyright 2021 Sujith Haridasan <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class actionbar implements renderable, templatable {
/** @var int */
private $id;
/** @var string */
private $download;
/** @var int */
private $attemptsmode;
/**
* actionbar constructor.
*
* @param int $id The course module id.
* @param bool $download Show download button or not.
* @param int $attemptsmode attempts mode for scorm.
*/
public function __construct(int $id, bool $download = false, int $attemptsmode = 0) {
$this->id = $id;
$this->download = $download;
$this->attemptsmode = $attemptsmode;
}
/**
* Provide data for the template
*
* @param renderer_base $output renderer_base object.
* @return array data for the template
*/
public function export_for_template(renderer_base $output): array {
global $PAGE;
$basicreportlink = new moodle_url('/mod/scorm/report.php', ['id' => $this->id, 'mode' => 'basic']);
$graphreportlink = new moodle_url('/mod/scorm/report.php', ['id' => $this->id, 'mode' => 'graphs']);
$interactionreportlink = new moodle_url('/mod/scorm/report.php', ['id' => $this->id, 'mode' => 'interactions']);
$objectivesreportlink = new moodle_url('/mod/scorm/report.php', ['id' => $this->id, 'mode' => 'objectives']);
$reportmenu = [
$basicreportlink->out(false) => get_string('pluginname', 'scormreport_basic'),
$graphreportlink->out(false) => get_string('pluginname', 'scormreport_graphs'),
$interactionreportlink->out(false) => get_string('pluginname', 'scormreport_interactions'),
$objectivesreportlink->out(false) => get_string('pluginname', 'scormreport_objectives'),
];
$sesskey = sesskey();
if ($this->download) {
$mode = $PAGE->url->get_param('mode');
if ($mode === 'basic') {
$options = [
'id' => $this->id, 'mode' => $mode,
'attemptsmode' => $this->attemptsmode, 'sesskey' => $sesskey
];
} else if ($mode === 'interactions') {
$options = [
'id' => $this->id, 'mode' => $mode, 'qtext' => '0',
'resp' => '1', 'right' => '0', 'result' => '0',
'attemptsmode' => $this->attemptsmode, 'sesskey' => $sesskey
];
} else if ($mode === 'objectives') {
$options = [
'id' => $this->id, 'mode' => $mode,
'attemptsmode' => $this->attemptsmode, 'objectivescore' => '0',
'sesskey' => $sesskey
];
}
$options['download'] = 'ODS';
$downloadodslink = new moodle_url($PAGE->url, $options);
$options['download'] = 'Excel';
$downloadexcellink = new moodle_url($PAGE->url, $options);
$options['download'] = 'CSV';
$downloadtextlink = new moodle_url($PAGE->url, $options);
}
$url = new moodle_url('/mod/scorm/report.php', $PAGE->url->remove_params('attemptsmode'));
$urlselect = new url_select($reportmenu, $url->out(false), null, 'selectscormreports');
$data = [
'scormreports' => $urlselect->export_for_template($output),
'candownload' => $this->download,
'downloadods' => ($this->download) ? $downloadodslink->out(false) : '',
'downloadexcel' => ($this->download) ? $downloadexcellink->out(false) : '',
'downloadtext' => ($this->download) ? $downloadtextlink->out(false) : ''
];
return $data;
}
}
@@ -0,0 +1,101 @@
<?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/>.
namespace mod_scorm\output;
use renderable;
use renderer_base;
use templatable;
use moodle_url;
use url_select;
/**
* Render HTML elements for reports page on tertiary nav.
*
* @package mod_scorm
* @copyright 2021 Sujith Haridasan <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class userreportsactionbar implements renderable, templatable {
/** @var int */
private $id;
/** @var int */
private $userid;
/** @var int */
private $attempt;
/** @var string */
private $reporttype;
/** @var string */
private $mode;
/** @var int */
private $scoid;
/**
* userreportsactionbar constructor
*
* @param int $id Course module id.
* @param int $userid User id.
* @param int $attempt Number of attempts.
* @param string $reporttype The report type can be either learning/interact.
* @param string $mode The mode view to set the back button.
* @param int|null $scoid The scorm id.
*/
public function __construct(int $id, int $userid, int $attempt, string $reporttype, string $mode, ?int $scoid = null) {
$this->id = $id;
$this->userid = $userid;
$this->attempt = $attempt;
$this->reporttype = $reporttype;
$this->mode = $mode;
$this->scoid = $scoid;
}
/**
* Provide data for the template
*
* @param renderer_base $output renderer_base object.
* @return array data for the template.
*/
public function export_for_template(renderer_base $output): array {
$data = [
'backurl' => (new moodle_url('/mod/scorm/report.php', ['id' => $this->id, 'mode' => $this->mode]))->out(false)
];
if (!$this->scoid) {
$learnobjects = new moodle_url('/mod/scorm/report/userreport.php',
['id' => $this->id, 'user' => $this->userid, 'attempt' => $this->attempt, 'mode' => $this->mode]);
$interactions = new moodle_url('/mod/scorm/report/userreportinteractions.php',
['id' => $this->id, 'user' => $this->userid, 'attempt' => $this->attempt, 'mode' => $this->mode]);
$reportmenu[$learnobjects->out(false)] = get_string('scoes', 'scorm');
$reportmenu[$interactions->out(false)] = get_string('interactions', 'scorm');
if ($this->reporttype === 'learning') {
$userreporturl = $learnobjects->out(false);
} else {
$userreporturl = $interactions->out(false);
}
$urlselect = new url_select($reportmenu, $userreporturl, [], 'userscormreport');
$data ['userreport'] = $urlselect->export_for_template($output);
}
return $data;
}
}
+3 -1
View File
@@ -48,7 +48,9 @@ $PAGE->set_title($strscorms);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add($strscorms);
echo $OUTPUT->header();
echo $OUTPUT->heading($strscorms);
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading($strscorms);
}
$usesections = course_format_uses_sections($course->format);
+2 -1
View File
@@ -1 +1,2 @@
duedate,mod_scorm
duedate,mod_scorm
info,mod_scorm
+4 -1
View File
@@ -213,7 +213,7 @@ $string['indicator:socialbreadth_help'] = 'This indicator is based on the social
$string['indicator:socialbreadthdef'] = 'SCORM social';
$string['indicator:socialbreadthdef_help'] = 'The participant has reached this percentage of the social engagement offered by the SCORM activities during this analysis interval (Levels = No participation, Participant alone)';
$string['indicator:socialbreadthdef_link'] = 'Learning_analytics_indicators#Social_breadth';
$string['info'] = 'Info';
$string['interactions'] = 'Interactions';
$string['masteryoverride'] = 'Mastery score overrides status';
$string['masteryoverride_help'] = 'If enabled and a mastery score is provided, when LMSFinish is called and a raw score has been set, status will be recalculated using the raw score and mastery score and any status provided by the SCORM (including "incomplete") will be overridden.';
@@ -458,3 +458,6 @@ $string['youmustselectastatus'] = 'You must select a status to require';
// Deprecated since Moodle 3.8.
$string['duedate'] = 'Due date';
// Deprecated since Moodle 4.0.
$string['info'] = 'Info';
+19
View File
@@ -1828,3 +1828,22 @@ function mod_scorm_core_calendar_get_event_action_string(string $eventtype): str
return get_string($identifier, 'scorm', $modulename);
}
/**
* This function extends the settings navigation block for the site.
*
* It is safe to rely on PAGE here as we will only ever be within the module
* context when this is called
*
* @param navigation_node $settings navigation_node object.
* @param navigation_node $scormnode navigation_node object.
* @return void
*/
function scorm_extend_settings_navigation(navigation_node $settings, navigation_node $scormnode): void {
global $PAGE;
if (has_capability('mod/scorm:viewreport', $PAGE->cm->context)) {
$url = new moodle_url('/mod/scorm/report.php', ['id' => $PAGE->cm->id]);
$scormnode->add(get_string("reports", "scorm"), $url, navigation_node::TYPE_CUSTOM, null, 'scormreport');
}
}
+10 -12
View File
@@ -995,16 +995,16 @@ function scorm_print_launch ($user, $scorm, $action, $cm) {
'action' => $CFG->wwwroot.'/mod/scorm/player.php',
'class' => 'container'));
if ($scorm->hidebrowse == 0) {
print_string('mode', 'scorm');
echo ': '.html_writer::empty_tag('input', array('type' => 'radio', 'id' => 'b', 'name' => 'mode',
'value' => 'browse', 'class' => 'mr-1')).
html_writer::label(get_string('browse', 'scorm'), 'b');
echo html_writer::empty_tag('input', array('type' => 'radio',
'id' => 'n', 'name' => 'mode',
'value' => 'normal', 'checked' => 'checked',
'class' => 'mx-1')).
html_writer::label(get_string('normal', 'scorm'), 'n');
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');
} else {
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'mode', 'value' => 'normal'));
}
@@ -1026,8 +1026,6 @@ function scorm_print_launch ($user, $scorm, $action, $cm) {
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'scoid', 'value' => $launchsco));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'cm', 'value' => $cm->id));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'currentorg', 'value' => $orgidentifier));
echo html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('enter', 'scorm'),
'class' => 'btn btn-primary'));
echo html_writer::end_tag('form');
echo html_writer::end_div();
}
+8 -2
View File
@@ -83,6 +83,8 @@ if ($displaymode !== '') {
$url->param('display', $displaymode);
}
$PAGE->set_url($url);
$PAGE->set_secondary_active_tab("modulepage");
$forcejs = get_config('scorm', 'forcejavascript');
if (!empty($forcejs)) {
$PAGE->add_body_class('forcejavascript');
@@ -191,7 +193,7 @@ if (file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.js')) {
}
echo $OUTPUT->header();
if (!empty($scorm->displayactivityname)) {
if (!empty($scorm->displayactivityname) && !$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($scorm->name));
}
@@ -203,7 +205,11 @@ $PAGE->requires->string_for_js('popupsblocked', 'scorm');
$name = false;
echo html_writer::start_div('', array('id' => 'scormpage'));
$scrompagestyle = "margin-top: 1em";
if ($mode === 'normal') {
$scrompagestyle = "margin-top: 3em";
}
echo html_writer::start_div('', array('id' => 'scormpage', 'style' => $scrompagestyle));
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'));
+19
View File
@@ -76,6 +76,25 @@ class mod_scorm_renderer extends plugin_renderer_base {
return html_writer::tag('div', $output, array('class' => 'paging'));
}
/**
* Rendered HTML for the report action is provided.
*
* @param \mod_scorm\output\actionbar $actionbar actionbar object.
* @return bool|string rendered HTML for the report action.
*/
public function report_actionbar(\mod_scorm\output\actionbar $actionbar): string {
return $this->render_from_template('mod_scorm/report_actionbar', $actionbar->export_for_template($this));
}
/**
* Rendered HTML for the user report action is provided
*
* @param \mod_scorm\output\userreportsactionbar $userreportsactionbar userreportsactionbar object
* @return string rendered HTML for the user report action.
*/
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));
}
}
/**
+6 -3
View File
@@ -56,6 +56,9 @@ $PAGE->set_pagelayout('report');
require_capability('mod/scorm:viewreport', $contextmodule);
// Activate the secondary nav tab.
navigation_node::override_active_url(new moodle_url('/mod/scorm/report.php', ['id' => $id]));
if (count($reportlist) < 1) {
print_error('erroraccessingreport', 'scorm');
}
@@ -86,9 +89,9 @@ if (empty($noheader)) {
$PAGE->navbar->add($strreport, new moodle_url('/mod/scorm/report.php', array('id' => $cm->id)));
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($scorm->name));
$currenttab = 'reports';
require($CFG->dirroot . '/mod/scorm/tabs.php');
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($scorm->name));
}
}
// Open the selected Scorm report and display it.
+10 -24
View File
@@ -43,6 +43,13 @@ class report extends \mod_scorm\report {
$attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_ALL_STUDENTS, PARAM_INT);
$PAGE->set_url(new \moodle_url($PAGE->url, array('attemptsmode' => $attemptsmode)));
// Scorm action bar for report.
if ($download === '') {
$actionbar = new \mod_scorm\output\actionbar($cm->id, true, $attemptsmode);
$renderer = $PAGE->get_renderer('mod_scorm');
echo $renderer->report_actionbar($actionbar);
}
if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) {
if (scorm_delete_responses($attemptids, $scorm)) { // Delete responses.
echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
@@ -401,7 +408,7 @@ class report extends \mod_scorm\report {
} else {
if (!$download) {
$url = new \moodle_url('/mod/scorm/report/userreport.php', array('id' => $cm->id,
'user' => $scouser->userid, 'attempt' => $scouser->attempt));
'user' => $scouser->userid, 'attempt' => $scouser->attempt, 'mode' => 'basic'));
$row[] = \html_writer::link($url, $scouser->attempt);
} else {
$row[] = $scouser->attempt;
@@ -445,7 +452,8 @@ class report extends \mod_scorm\report {
}
if (!$download) {
$url = new \moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $cm->id,
'scoid' => $sco->id, 'user' => $scouser->userid, 'attempt' => $scouser->attempt));
'scoid' => $sco->id, 'user' => $scouser->userid, 'attempt' => $scouser->attempt,
'mode' => 'basic'));
$row[] = $OUTPUT->pix_icon($trackdata->status, $strstatus, 'scorm') . '<br>' .
\html_writer::link($url, $score, array('title' => get_string('details', 'scorm')));
} else {
@@ -488,28 +496,6 @@ class report extends \mod_scorm\report {
echo \html_writer::end_tag('div');
echo \html_writer::end_tag('form');
}
echo \html_writer::end_div();
if (!empty($attempts)) {
echo \html_writer::start_tag('table', array('class' => 'boxaligncenter')).\html_writer::start_tag('tr');
echo \html_writer::start_tag('td');
echo $OUTPUT->single_button(new \moodle_url($PAGE->url,
array('download' => 'ODS') + $displayoptions),
get_string('downloadods'));
echo \html_writer::end_tag('td');
echo \html_writer::start_tag('td');
echo $OUTPUT->single_button(new \moodle_url($PAGE->url,
array('download' => 'Excel') + $displayoptions),
get_string('downloadexcel'));
echo \html_writer::end_tag('td');
echo \html_writer::start_tag('td');
echo $OUTPUT->single_button(new \moodle_url($PAGE->url,
array('download' => 'CSV') + $displayoptions),
get_string('downloadtext'));
echo \html_writer::end_tag('td');
echo \html_writer::start_tag('td');
echo \html_writer::end_tag('td');
echo \html_writer::end_tag('tr').\html_writer::end_tag('table');
}
}
} else {
if ($candelete && !$download) {
@@ -135,6 +135,10 @@ class report extends \mod_scorm\report {
$contextmodule = context_module::instance($cm->id);
$actionbar = new \mod_scorm\output\actionbar($cm->id, false, 0);
$renderer = $PAGE->get_renderer('mod_scorm');
echo $renderer->report_actionbar($actionbar);
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used.
groups_print_activity_menu($cm, new moodle_url($PAGE->url));
}
@@ -44,6 +44,13 @@ class report extends \mod_scorm\report {
$attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_ALL_STUDENTS, PARAM_INT);
$PAGE->set_url(new \moodle_url($PAGE->url, array('attemptsmode' => $attemptsmode)));
// Scorm action bar for report.
if ($download === '') {
$actionbar = new \mod_scorm\output\actionbar($cm->id, true, $attemptsmode);
$renderer = $PAGE->get_renderer('mod_scorm');
echo $renderer->report_actionbar($actionbar);
}
if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) {
if (scorm_delete_responses($attemptids, $scorm)) { // Delete responses.
echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
@@ -446,9 +453,10 @@ class report extends \mod_scorm\report {
} else {
if (!$download) {
$url = new \moodle_url('/mod/scorm/report/userreport.php',
array('id' => $cm->id,
'user' => $scouser->userid,
'attempt' => $scouser->attempt));
array('id' => $cm->id,
'user' => $scouser->userid,
'attempt' => $scouser->attempt,
'mode' => 'interactions'));
$row[] = \html_writer::link($url, $scouser->attempt);
} else {
$row[] = $scouser->attempt;
@@ -486,7 +494,8 @@ class report extends \mod_scorm\report {
}
if (!$download) {
$url = new \moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $cm->id,
'scoid' => $sco->id, 'user' => $scouser->userid, 'attempt' => $scouser->attempt));
'scoid' => $sco->id, 'user' => $scouser->userid, 'attempt' => $scouser->attempt,
'mode' => 'interactions'));
$row[] = $OUTPUT->pix_icon($trackdata->status, $strstatus, 'scorm') . '<br>' .
\html_writer::link($url, $score, array('title' => get_string('details', 'scorm')));
} else {
@@ -578,34 +587,6 @@ class report extends \mod_scorm\report {
echo \html_writer::end_tag('div');
echo \html_writer::end_tag('form');
}
echo \html_writer::end_div();
if (!empty($attempts)) {
echo \html_writer::start_tag('table', array('class' => 'boxaligncenter')).\html_writer::start_tag('tr');
echo \html_writer::start_tag('td');
echo $OUTPUT->single_button(new \moodle_url($PAGE->url,
array('download' => 'ODS') + $displayoptions),
get_string('downloadods'),
'post',
['class' => 'mt-1']);
echo \html_writer::end_tag('td');
echo \html_writer::start_tag('td');
echo $OUTPUT->single_button(new \moodle_url($PAGE->url,
array('download' => 'Excel') + $displayoptions),
get_string('downloadexcel'),
'post',
['class' => 'mt-1']);
echo \html_writer::end_tag('td');
echo \html_writer::start_tag('td');
echo $OUTPUT->single_button(new \moodle_url($PAGE->url,
array('download' => 'CSV') + $displayoptions),
get_string('downloadtext'),
'post',
['class' => 'mt-1']);
echo \html_writer::end_tag('td');
echo \html_writer::start_tag('td');
echo \html_writer::end_tag('td');
echo \html_writer::end_tag('tr').\html_writer::end_tag('table');
}
}
} else {
if ($candelete && !$download) {
+10 -30
View File
@@ -50,6 +50,13 @@ class report extends \mod_scorm\report {
$attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_ALL_STUDENTS, PARAM_INT);
$PAGE->set_url(new \moodle_url($PAGE->url, array('attemptsmode' => $attemptsmode)));
// Scorm action bar for report.
if ($download === '') {
$actionbar = new \mod_scorm\output\actionbar($cm->id, true, $attemptsmode);
$renderer = $PAGE->get_renderer('mod_scorm');
echo $renderer->report_actionbar($actionbar);
}
if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) {
if (scorm_delete_responses($attemptids, $scorm)) { // Delete responses.
echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
@@ -436,7 +443,7 @@ class report extends \mod_scorm\report {
} else {
if (!$download) {
$url = new \moodle_url('/mod/scorm/report/userreport.php', array('id' => $cm->id,
'user' => $scouser->userid, 'attempt' => $scouser->attempt));
'user' => $scouser->userid, 'attempt' => $scouser->attempt, 'mode' => 'objectives'));
$row[] = \html_writer::link($url, $scouser->attempt);
} else {
$row[] = $scouser->attempt;
@@ -474,7 +481,8 @@ class report extends \mod_scorm\report {
}
if (!$download) {
$url = new \moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $cm->id,
'scoid' => $sco->id, 'user' => $scouser->userid, 'attempt' => $scouser->attempt));
'scoid' => $sco->id, 'user' => $scouser->userid, 'attempt' => $scouser->attempt,
'mode' => 'objectives'));
$row[] = $OUTPUT->pix_icon($trackdata->status, $strstatus, 'scorm') . '<br>' .
\html_writer::link($url, $score, array('title' => get_string('details', 'scorm')));
} else {
@@ -577,34 +585,6 @@ class report extends \mod_scorm\report {
echo \html_writer::end_tag('div');
echo \html_writer::end_tag('form');
}
echo \html_writer::end_div();
if (!empty($attempts)) {
echo \html_writer::start_tag('table', array('class' => 'boxaligncenter')).\html_writer::start_tag('tr');
echo \html_writer::start_tag('td');
echo $OUTPUT->single_button(new \moodle_url($PAGE->url,
array('download' => 'ODS') + $displayoptions),
get_string('downloadods'),
'post',
['class' => 'mt-1']);
echo \html_writer::end_tag('td');
echo \html_writer::start_tag('td');
echo $OUTPUT->single_button(new \moodle_url($PAGE->url,
array('download' => 'Excel') + $displayoptions),
get_string('downloadexcel'),
'post',
['class' => 'mt-1']);
echo \html_writer::end_tag('td');
echo \html_writer::start_tag('td');
echo $OUTPUT->single_button(new \moodle_url($PAGE->url,
array('download' => 'CSV') + $displayoptions),
get_string('downloadtext'),
'post',
['class' => 'mt-1']);
echo \html_writer::end_tag('td');
echo \html_writer::start_tag('td');
echo \html_writer::end_tag('td');
echo \html_writer::end_tag('tr').\html_writer::end_tag('table');
}
}
} else {
if ($candelete && !$download) {
+14 -6
View File
@@ -28,14 +28,16 @@ require_once($CFG->dirroot.'/mod/scorm/locallib.php');
$id = required_param('id', PARAM_INT); // Course Module ID.
$userid = required_param('user', PARAM_INT); // User ID.
$attempt = optional_param('attempt', 1, PARAM_INT); // attempt number.
$mode = optional_param('mode', '', PARAM_ALPHA); // Scorm mode from which reached here.
// Building the url to use for links.+ data details buildup.
$url = new moodle_url('/mod/scorm/report/userreport.php', array('id' => $id,
'user' => $userid,
'attempt' => $attempt));
'user' => $userid,
'attempt' => $attempt));
$tracksurl = new moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $id,
'user' => $userid,
'attempt' => $attempt));
'user' => $userid,
'attempt' => $attempt,
'mode' => $mode));
$cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST);
$course = get_course($cm->course);
$scorm = $DB->get_record('scorm', array('id' => $cm->instance), '*', MUST_EXIST);
@@ -44,6 +46,7 @@ $user = $DB->get_record('user', array('id' => $userid), implode(',', \core_user\
$attemptids = scorm_get_all_attempts($scorm->id, $userid);
$PAGE->set_url($url);
$PAGE->set_secondary_active_tab('scormreport');
// END of url setting + data buildup.
// Checking login +logging +getting context.
@@ -76,10 +79,15 @@ $PAGE->navbar->add($strreport, new moodle_url('/mod/scorm/report.php', array('id
$PAGE->navbar->add(fullname($user). " - $strattempt $attempt");
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($scorm->name));
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($scorm->name));
}
// End of Print the page header.
$currenttab = 'scoes';
require($CFG->dirroot . '/mod/scorm/report/userreporttabs.php');
$renderer = $PAGE->get_renderer('mod_scorm');
$useractionreport = new \mod_scorm\output\userreportsactionbar($id, $userid, $attempt, 'learning', $mode);
echo $renderer->user_report_actionbar($useractionreport);
// Printing user details.
$output = $PAGE->get_renderer('mod_scorm');
+6 -1
View File
@@ -31,6 +31,7 @@ $id = required_param('id', PARAM_INT); // Course Module ID.
$userid = required_param('user', PARAM_INT); // User ID.
$attempt = optional_param('attempt', 1, PARAM_INT); // attempt number.
$download = optional_param('download', '', PARAM_ALPHA);
$mode = optional_param('mode', '', PARAM_ALPHA); // Scorm mode from which reached here.
// Building the url to use for links.+ data details buildup.
$url = new moodle_url('/mod/scorm/report/userreportinteractions.php', array('id' => $id,
@@ -45,6 +46,7 @@ $user = $DB->get_record('user', array('id' => $userid), implode(',', \core_user\
$attemptids = scorm_get_all_attempts($scorm->id, $userid);
$PAGE->set_url($url);
$PAGE->set_secondary_active_tab('scormreport');
// END of url setting + data buildup.
// Checking login +logging +getting context.
@@ -96,7 +98,10 @@ if (!$table->is_downloading($download, $exportfilename)) {
echo $OUTPUT->heading(format_string($scorm->name));
// End of Print the page header.
$currenttab = 'interactions';
require($CFG->dirroot . '/mod/scorm/report/userreporttabs.php');
$renderer = $PAGE->get_renderer('mod_scorm');
$useractionreport = new \mod_scorm\output\userreportsactionbar($id, $userid, $attempt, 'interact', $mode);
echo $renderer->user_report_actionbar($useractionreport);
// Printing user details.
$output = $PAGE->get_renderer('mod_scorm');
-47
View File
@@ -1,47 +0,0 @@
<?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/>.
/**
* Sets up the tabs used by the scorm pages based on the users capabilities.
*
* @author Dan Marsden and others.
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package mod_scorm
*/
if (empty($scorm)) {
print_error('cannotaccess', 'mod_scorm');
}
if (!isset($currenttab)) {
$currenttab = '';
}
$tabs = array();
$row = array();
$inactive = array();
$activated = array();
$scoesurl = new moodle_url('/mod/scorm/report/userreport.php', array('id' => $id,
'user' => $userid,
'attempt' => $attempt));
$interactionssurl = new moodle_url('/mod/scorm/report/userreportinteractions.php', array('id' => $id,
'user' => $userid,
'attempt' => $attempt));
$row[] = new tabobject('scoes', $scoesurl, get_string('scoes', 'scorm'));
$row[] = new tabobject('interactions', $interactionssurl, get_string('interactions', 'scorm'));
$tabs[] = $row;
print_tabs($tabs, $currenttab, $inactive, $activated);
+11 -4
View File
@@ -29,6 +29,7 @@ require_once($CFG->libdir.'/tablelib.php');
$id = required_param('id', PARAM_INT); // Course Module ID.
$userid = required_param('user', PARAM_INT); // User ID.
$scoid = required_param('scoid', PARAM_INT); // SCO ID.
$mode = required_param('mode', PARAM_ALPHA); // Scorm mode.
$attempt = optional_param('attempt', 1, PARAM_INT); // attempt number.
$download = optional_param('download', '', PARAM_ALPHA);
@@ -36,7 +37,8 @@ $download = optional_param('download', '', PARAM_ALPHA);
$url = new moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $id,
'user' => $userid,
'attempt' => $attempt,
'scoid' => $scoid));
'scoid' => $scoid,
'mode' => $mode));
$cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST);
$course = get_course($cm->course);
$scorm = $DB->get_record('scorm', array('id' => $cm->instance), '*', MUST_EXIST);
@@ -60,7 +62,7 @@ if (!groups_user_groups_visible($course, $userid, $cm)) {
$event = \mod_scorm\event\tracks_viewed::create(array(
'context' => $contextmodule,
'relateduserid' => $userid,
'other' => array('attemptid' => $attempt, 'instanceid' => $scorm->id, 'scoid' => $scoid)
'other' => array('attemptid' => $attempt, 'instanceid' => $scorm->id, 'scoid' => $scoid, 'mode' => $mode)
));
$event->add_record_snapshot('course_modules', $cm);
$event->add_record_snapshot('scorm', $scorm);
@@ -76,6 +78,7 @@ $PAGE->navbar->add($strreport, new moodle_url('/mod/scorm/report.php', array('id
$PAGE->navbar->add("$strattempt $attempt - ".fullname($user),
new moodle_url('/mod/scorm/report/userreport.php', array('id' => $id, 'user' => $userid, 'attempt' => $attempt)));
$PAGE->navbar->add($selsco->title . ' - '. get_string('details', 'scorm'));
$PAGE->set_secondary_active_tab('scormreport');
if ($trackdata = scorm_get_tracks($selsco->id, $userid, $attempt)) {
if ($trackdata->status == '') {
@@ -95,9 +98,13 @@ $table = new flexible_table('mod_scorm-userreporttracks');
if (!$table->is_downloading($download, $exportfilename)) {
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($scorm->name));
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($scorm->name));
}
$currenttab = '';
require($CFG->dirroot . '/mod/scorm/report/userreporttabs.php');
$renderer = $PAGE->get_renderer('mod_scorm');
$useractionreport = new \mod_scorm\output\userreportsactionbar($id, $userid, $attempt, 'attempt', $mode, $scoid);
echo $renderer->user_report_actionbar($useractionreport);
echo $OUTPUT->box_start('generalbox boxaligncenter');
echo $OUTPUT->heading("$strattempt $attempt - ". fullname($user).': '.
format_string($selsco->title). ' - '. get_string('details', 'scorm'), 3);
-62
View File
@@ -1,62 +0,0 @@
<?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/>.
/**
* Sets up the tabs used by the scorm pages based on the users capabilities.
*
* @author Dan Marsden and others.
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package mod_scorm
*/
if (empty($scorm)) {
print_error('cannotaccess', 'mod_scorm');
}
if (!isset($currenttab)) {
$currenttab = '';
}
if (!isset($cm)) {
$cm = get_coursemodule_from_instance('scorm', $scorm->id);
}
$contextmodule = context_module::instance($cm->id);
$tabs = array();
$row = array();
$inactive = array();
$activated = array();
if (has_capability('mod/scorm:savetrack', $contextmodule)) {
$row[] = new tabobject('info', "$CFG->wwwroot/mod/scorm/view.php?id=$cm->id", get_string('info', 'scorm'));
}
if (has_capability('mod/scorm:viewreport', $contextmodule)) {
$row[] = new tabobject('reports', "$CFG->wwwroot/mod/scorm/report.php?id=$cm->id", get_string('reports', 'scorm'));
}
if (!($currenttab == 'info' && count($row) == 1)) {
$tabs[] = $row;
}
if ($currenttab == 'reports' && !empty($reportlist) && count($reportlist) > 1) {
$row2 = array();
foreach ($reportlist as $rep) {
$row2[] = new tabobject('scorm_'.$rep, $CFG->wwwroot."/mod/scorm/report.php?id=$cm->id&mode=$rep",
get_string('pluginname', 'scormreport_'.$rep));
}
$tabs[] = $row2;
}
print_tabs($tabs, $currenttab, $inactive, $activated);
@@ -0,0 +1,63 @@
{{!
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/report_actionbar
Actions bar for the reports page UI.
Classes required for JS:
* none
Data attributes required for JS:
* none
Context variables required for this template:
* see mod/scorm/classes/output/actionbar.php
Example context (json):
{
"scormreports": {
"id": "url_select_test",
"options": [
{"name": "Basic Report", "value": "/mod/scorm/report.php?id=69&mode=basic"},
{"name": "Graph Report", "value": "/mod/scorm/report.php?id=69&mode=graphs"},
{"name": "Interactions Report", "value": "/mod/scorm/report.php?id=69&mode=interactions"},
{"name": "Objectives Report", "value": "/mod/scorm/report.php?id=69&mode=objectives"}
]
},
"candownload": true,
"downloadods": "http://localhost/moodle/mod/scorm/report.php?id=143&mode=basic&attemptsmode=0&sesskey=AmfcC7riSb&download=ODS",
"downloadexcel": "http://localhost/moodle/mod/scorm/report.php?id=143&mode=basic&attemptsmode=0&sesskey=AmfcC7riSb&download=Excel",
"downloadtext": "http://localhost/moodle/mod/scorm/report.php?id=143&mode=basic&attemptsmode=0&sesskey=AmfcC7riSb&download=CSV"
}
}}
<div class="container-fluid mb-3">
<div class="row justify-content-between">
<div class="mr-5">
{{#scormreports}}
{{>core/url_select}}
{{/scormreports}}
</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>
<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>
</div>
@@ -0,0 +1,42 @@
{{!
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/report_actionbar
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:
* see mod/scorm/classes/output/userreportsactionbar.php
Example context (json):
{
"userreport": {
"id": "url_select_test",
"options": [
{"name": "Learning objects", "value": "/mod/scorm/report/userreport.php?id=70&user=13&attempt=1"},
{"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"
}
}}
<div class="container-fluid mb-3">
<div class="row">
<a class="btn btn-secondary mr-2" href="{{backurl}}">{{#str}}back, core {{/str}}</a>
{{#userreport}}
{{>core/url_select}}
{{/userreport}}
</div>
</div>
+3 -2
View File
@@ -271,7 +271,7 @@ class mod_scorm_event_testcase extends advanced_testcase {
'relateduserid' => 5,
'context' => context_module::instance($this->eventcm->id),
'courseid' => $this->eventcourse->id,
'other' => array('attemptid' => 2, 'instanceid' => $this->eventscorm->id, 'scoid' => 3)
'other' => array('attemptid' => 2, 'instanceid' => $this->eventscorm->id, 'scoid' => 3, 'mode' => 'interactions')
));
// Trigger and capture the event.
@@ -282,7 +282,8 @@ class mod_scorm_event_testcase extends advanced_testcase {
// Check that the legacy log data is valid.
$expected = array($this->eventcourse->id, 'scorm', 'userreporttracks', 'report/userreporttracks.php?id=' .
$this->eventcm->id . '&user=5&attempt=' . 2 . '&scoid=3', $this->eventscorm->id, $this->eventcm->id);
$this->eventcm->id . '&user=5&attempt=' . 2 . '&scoid=3' . '&mode=interactions',
$this->eventscorm->id, $this->eventcm->id);
$this->assertEventLegacyLogData($expected, $event);
$this->assertEventContextNotUsed($event);
}
+7 -5
View File
@@ -137,7 +137,9 @@ if (empty($preventskip) && empty($launch) && (has_capability('mod/scorm:skipview
$PAGE->set_title($pagetitle);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($scorm->name));
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($scorm->name));
}
// Display any activity information (eg completion requirements / dates).
$cminfo = cm_info::create($cm);
@@ -159,16 +161,13 @@ if (!empty($action) && confirm_sesskey() && has_capability('mod/scorm:deleteownr
}
}
$currenttab = 'info';
require($CFG->dirroot . '/mod/scorm/tabs.php');
// Print the main part of the page.
$attemptstatus = '';
if (empty($launch) && ($scorm->displayattemptstatus == SCORM_DISPLAY_ATTEMPTSTATUS_ALL ||
$scorm->displayattemptstatus == SCORM_DISPLAY_ATTEMPTSTATUS_ENTRY)) {
$attemptstatus = scorm_get_attempt_status($USER, $scorm, $cm);
}
echo $OUTPUT->box(format_module_intro('scorm', $scorm, $cm->id).$attemptstatus, 'container', 'intro');
echo $OUTPUT->box(format_module_intro('scorm', $scorm, $cm->id), 'container', '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);
@@ -176,6 +175,9 @@ list($available, $warnings) = scorm_get_availability_status($scorm);
if ($available && empty($launch)) {
scorm_print_launch($USER, $scorm, 'view.php?id='.$cm->id, $cm);
}
echo $OUTPUT->box($attemptstatus, 'container');
if (!empty($forcejs)) {
$message = $OUTPUT->box(get_string("forcejavascriptmessage", "scorm"), "container forcejavascriptmessage");
echo html_writer::tag('noscript', $message);