Merge branch 'MDL-46469-master' of git://github.com/ankitagarwal/moodle

This commit is contained in:
Marina Glancy 2014-08-19 14:01:48 +08:00
commit 04821cbbe7
13 changed files with 430 additions and 207 deletions

View File

@ -19,11 +19,13 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_scorm;
/*******************************************************************/
// Default class for Scorm plugins
//
// Doesn't do anything on it's own -- it needs to be extended.
// This class displays scorm reports. Because it is called from
// This class displays scorm reports. Because it is called from
// within /mod/scorm/report.php you can assume that the page header
// and footer are taken care of.
//
@ -33,7 +35,7 @@
defined('MOODLE_INTERNAL') || die();
class scorm_default_report {
class report {
/**
* displays the full report
* @param stdClass $scorm full SCORM object

View File

@ -0,0 +1,40 @@
<?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/>.
/**
* This file contains mappings for classes that have been renamed so that they meet the requirements of the autoloader.
*
* Renaming isn't always the recommended approach, but can provide benefit in situations where we've already got a
* close structure, OR where lots of classes get included and not necessarily used, or checked for often.
*
* When renaming a class delete the original class and add an entry to the db/renamedclasses.php directory for that
* component.
* This way we don't need to keep around old classes, instead creating aliases only when required.
* One big advantage to this method is that we provide consistent debugging for renamed classes when they are used.
*
* @package mod_scorm
* @copyright 2014 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
// Like other files in the db directory this file uses an array.
// The old class name is the key, the new class name is the value.
// The array must be called $renamedclasses.
$renamedclasses = array(
'scorm_default_report' => 'mod_scorm\report'
);

View File

@ -22,7 +22,7 @@ require_once($CFG->dirroot.'/mod/scorm/locallib.php');
require_once($CFG->dirroot.'/mod/scorm/reportsettings_form.php');
require_once($CFG->dirroot.'/mod/scorm/report/reportlib.php');
require_once($CFG->libdir.'/formslib.php');
require_once($CFG->dirroot.'/mod/scorm/report/default.php'); // Parent class.
define('SCORM_REPORT_DEFAULT_PAGE_SIZE', 20);
define('SCORM_REPORT_ATTEMPTS_ALL_STUDENTS', 0);
define('SCORM_REPORT_ATTEMPTS_STUDENTS_WITH', 1);
@ -91,8 +91,9 @@ if (empty($noheader)) {
}
// Open the selected Scorm report and display it.
$reportclassname = "scorm_{$mode}_report";
$report = new $reportclassname();
$classname = "scormreport_{$mode}\\report";
$legacyclassname = "scorm_{$mode}_report";
$report = class_exists($classname) ? new $classname() : new $legacyclassname();
$report->display($scorm, $cm, $course, $download); // Run the report!
// Print footer.

View File

@ -21,25 +21,27 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace scormreport_basic;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/csvlib.class.php');
class scorm_basic_report extends scorm_default_report {
class report extends \mod_scorm\report {
/**
* displays the full report
* @param stdClass $scorm full SCORM object
* @param stdClass $cm - full course_module object
* @param stdClass $course - full course object
* @param \stdClass $scorm full SCORM object
* @param \stdClass $cm - full course_module object
* @param \stdClass $course - full course object
* @param string $download - type of download being requested
*/
public function display($scorm, $cm, $course, $download) {
global $CFG, $DB, $OUTPUT, $PAGE;
$contextmodule = context_module::instance($cm->id);
$contextmodule = \context_module::instance($cm->id);
$action = optional_param('action', '', PARAM_ALPHA);
$attemptids = optional_param_array('attemptid', array(), PARAM_RAW);
$attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_ALL_STUDENTS, PARAM_INT);
$PAGE->set_url(new moodle_url($PAGE->url, array('attemptsmode' => $attemptsmode)));
$PAGE->set_url(new \moodle_url($PAGE->url, array('attemptsmode' => $attemptsmode)));
if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) {
if (scorm_delete_responses($attemptids, $scorm)) { // Delete responses.
@ -50,7 +52,7 @@ class scorm_basic_report extends scorm_default_report {
$currentgroup = groups_get_activity_group($cm, true);
// Detailed report.
$mform = new mod_scorm_report_settings($PAGE->url, compact('currentgroup'));
$mform = new \mod_scorm_report_settings($PAGE->url, compact('currentgroup'));
if ($fromform = $mform->get_data()) {
$detailedrep = $fromform->detailedrep;
$pagesize = $fromform->pagesize;
@ -69,7 +71,7 @@ class scorm_basic_report extends scorm_default_report {
$displayoptions['attemptsmode'] = $attemptsmode;
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used.
if (!$download) {
groups_print_activity_menu($cm, new moodle_url($PAGE->url, $displayoptions));
groups_print_activity_menu($cm, new \moodle_url($PAGE->url, $displayoptions));
}
}
@ -104,7 +106,7 @@ class scorm_basic_report extends scorm_default_report {
if ( !$nostudents ) {
// Now check if asked download of data.
$coursecontext = context_course::instance($course->id);
$coursecontext = \context_course::instance($course->id);
if ($download) {
$shortname = format_string($course->shortname, true, array('context' => $coursecontext));
$filename = clean_filename("$shortname ".format_string($scorm->name, true));
@ -149,7 +151,7 @@ class scorm_basic_report extends scorm_default_report {
}
if (!$download) {
$table = new flexible_table('mod-scorm-report');
$table = new \flexible_table('mod-scorm-report');
$table->define_columns($columns);
$table->define_headers($headers);
@ -194,7 +196,7 @@ class scorm_basic_report extends scorm_default_report {
$filename .= ".ods";
// Creating a workbook.
$workbook = new MoodleODSWorkbook("-");
$workbook = new \MoodleODSWorkbook("-");
// Sending HTTP headers.
$workbook->send($filename);
// Creating the first worksheet.
@ -233,7 +235,7 @@ class scorm_basic_report extends scorm_default_report {
$filename .= ".xls";
// Creating a workbook.
$workbook = new MoodleExcelWorkbook("-");
$workbook = new \MoodleExcelWorkbook("-");
// Sending HTTP headers.
$workbook->send($filename);
// Creating the first worksheet.
@ -267,7 +269,7 @@ class scorm_basic_report extends scorm_default_report {
}
$rownum = 1;
} else if ($download == 'CSV') {
$csvexport = new csv_export_writer("tab");
$csvexport = new \csv_export_writer("tab");
$csvexport->set_filename($filename, ".txt");
$csvexport->add_data($headers);
}
@ -276,7 +278,7 @@ class scorm_basic_report extends scorm_default_report {
// Construct the SQL.
$select = 'SELECT DISTINCT '.$DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)').' AS uniqueid, ';
$select .= 'st.scormid AS scormid, st.attempt AS attempt, ' .
user_picture::fields('u', array('idnumber'), 'userid') .
\user_picture::fields('u', array('idnumber'), 'userid') .
get_extra_user_fields_sql($coursecontext, 'u', '', array('email', 'idnumber')) . ' ';
// This part is the same for all cases - join users and scorm_scoes_track tables.
@ -334,7 +336,7 @@ class scorm_basic_report extends scorm_default_report {
$table->pagesize($pagesize, $total);
echo html_writer::start_div('scormattemptcounts');
echo \html_writer::start_div('scormattemptcounts');
if ( $count->nbresults == $count->nbattempts ) {
echo get_string('reportcountattempts', 'scorm', $count);
} else if ( $count->nbattempts > 0 ) {
@ -342,26 +344,26 @@ class scorm_basic_report extends scorm_default_report {
} else {
echo $count->nbusers.' '.get_string('users');
}
echo html_writer::end_div();
echo \html_writer::end_div();
}
// Fetch the attempts.
if (!$download) {
$attempts = $DB->get_records_sql($select.$from.$where.$sort, $params,
$table->get_page_start(), $table->get_page_size());
echo html_writer::start_div('', array('id' => 'scormtablecontainer'));
echo \html_writer::start_div('', array('id' => 'scormtablecontainer'));
if ($candelete) {
// Start form.
$strreallydel = addslashes_js(get_string('deleteattemptcheck', 'scorm'));
echo html_writer::start_tag('form', array('id' => 'attemptsform', 'method' => 'post',
echo \html_writer::start_tag('form', array('id' => 'attemptsform', 'method' => 'post',
'action' => $PAGE->url->out(false),
'onsubmit' => 'return confirm("'.$strreallydel.'");'));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'delete'));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
echo html_writer::start_div('', array('style' => 'display: none;'));
echo html_writer::input_hidden_params($PAGE->url);
echo html_writer::end_div();
echo html_writer::start_div();
echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'delete'));
echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
echo \html_writer::start_div('', array('style' => 'display: none;'));
echo \html_writer::input_hidden_params($PAGE->url);
echo \html_writer::end_div();
echo \html_writer::start_div();
}
$table->initialbars($totalinitials > 20); // Build table rows.
} else {
@ -378,21 +380,21 @@ class scorm_basic_report extends scorm_default_report {
}
if (in_array('checkbox', $columns)) {
if ($candelete && !empty($timetracks->start)) {
$row[] = html_writer::checkbox('attemptid[]', $scouser->userid . ':' . $scouser->attempt, false);
$row[] = \html_writer::checkbox('attemptid[]', $scouser->userid . ':' . $scouser->attempt, false);
} else if ($candelete) {
$row[] = '';
}
}
if (in_array('picture', $columns)) {
$user = new stdClass();
$additionalfields = explode(',', user_picture::fields());
$user = new \stdClass();
$additionalfields = explode(',', \user_picture::fields());
$user = username_load_fields_from_object($user, $scouser, null, $additionalfields);
$user->id = $scouser->userid;
$row[] = $OUTPUT->user_picture($user, array('courseid' => $course->id));
}
if (!$download) {
$url = new moodle_url('/user/view.php', array('id' => $scouser->userid, 'course' => $course->id));
$row[] = html_writer::link($url, fullname($scouser));
$url = new \moodle_url('/user/view.php', array('id' => $scouser->userid, 'course' => $course->id));
$row[] = \html_writer::link($url, fullname($scouser));
} else {
$row[] = fullname($scouser);
}
@ -406,11 +408,9 @@ class scorm_basic_report extends scorm_default_report {
$row[] = '-';
} else {
if (!$download) {
$url = new moodle_url('/mod/scorm/report/userreport.php',
array('id' => $cm->id,
'user' => $scouser->userid,
'attempt' => $scouser->attempt));
$row[] = html_writer::link($url, $scouser->attempt);
$url = new \moodle_url('/mod/scorm/report/userreport.php', array('id' => $cm->id,
'user' => $scouser->userid, 'attempt' => $scouser->attempt));
$row[] = \html_writer::link($url, $scouser->attempt);
} else {
$row[] = $scouser->attempt;
}
@ -452,11 +452,11 @@ class scorm_basic_report extends scorm_default_report {
$score = $strstatus;
}
if (!$download) {
$url = new moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $cm->id,
$url = new \moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $cm->id,
'scoid' => $sco->id, 'user' => $scouser->userid, 'attempt' => $scouser->attempt));
$row[] = html_writer::img($OUTPUT->pix_url($trackdata->status, 'scorm'), $strstatus,
array('title' => $strstatus)) . html_writer::empty_tag('br') .
html_writer::link($url, $score, array('title' => get_string('details', 'scorm')));
$row[] = \html_writer::img($OUTPUT->pix_url($trackdata->status, 'scorm'), $strstatus,
array('title' => $strstatus)) . \html_writer::empty_tag('br') .
\html_writer::link($url, $score, array('title' => get_string('details', 'scorm')));
} else {
$row[] = $score;
}
@ -464,8 +464,8 @@ class scorm_basic_report extends scorm_default_report {
// If we don't have track data, we haven't attempted yet.
$strstatus = get_string('notattempted', 'scorm');
if (!$download) {
$row[] = html_writer::img($OUTPUT->pix_url('notattempted', 'scorm'), $strstatus,
array('title' => $strstatus)).html_writer::empty_tag('br').$strstatus;
$row[] = \html_writer::img($OUTPUT->pix_url('notattempted', 'scorm'), $strstatus,
array('title' => $strstatus)).\html_writer::empty_tag('br').$strstatus;
} else {
$row[] = $strstatus;
}
@ -490,50 +490,50 @@ class scorm_basic_report extends scorm_default_report {
if (!$download) {
$table->finish_output();
if ($candelete) {
echo html_writer::start_tag('table', array('id' => 'commands'));
echo html_writer::start_tag('tr').html_writer::start_tag('td');
echo html_writer::link('javascript:select_all_in(\'DIV\', null, \'scormtablecontainer\');',
echo \html_writer::start_tag('table', array('id' => 'commands'));
echo \html_writer::start_tag('tr').\html_writer::start_tag('td');
echo \html_writer::link('javascript:select_all_in(\'DIV\', null, \'scormtablecontainer\');',
get_string('selectall', 'scorm')).' / ';
echo html_writer::link('javascript:deselect_all_in(\'DIV\', null, \'scormtablecontainer\');',
echo \html_writer::link('javascript:deselect_all_in(\'DIV\', null, \'scormtablecontainer\');',
get_string('selectnone', 'scorm'));
echo '&nbsp;&nbsp;';
echo html_writer::empty_tag('input', array('type' => 'submit',
echo \html_writer::empty_tag('input', array('type' => 'submit',
'value' => get_string('deleteselected', 'quiz_overview')));
echo html_writer::end_tag('td').html_writer::end_tag('tr').html_writer::end_tag('table');
echo \html_writer::end_tag('td').\html_writer::end_tag('tr').\html_writer::end_tag('table');
// Close form.
echo html_writer::end_tag('div');
echo html_writer::end_tag('form');
echo \html_writer::end_tag('div');
echo \html_writer::end_tag('form');
}
echo html_writer::end_div();
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,
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,
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,
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');
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) {
echo html_writer::end_div();
echo html_writer::end_tag('form');
echo \html_writer::end_div();
echo \html_writer::end_tag('form');
$table->finish_output();
}
echo html_writer::end_div();
echo \html_writer::end_div();
}
// Show preferences form irrespective of attempts are there to report or not.
if (!$download) {

View File

@ -0,0 +1,40 @@
<?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/>.
/**
* This file contains mappings for classes that have been renamed so that they meet the requirements of the autoloader.
*
* Renaming isn't always the recommended approach, but can provide benefit in situations where we've already got a
* close structure, OR where lots of classes get included and not necessarily used, or checked for often.
*
* When renaming a class delete the original class and add an entry to the db/renamedclasses.php directory for that
* component.
* This way we don't need to keep around old classes, instead creating aliases only when required.
* One big advantage to this method is that we provide consistent debugging for renamed classes when they are used.
*
* @package scormreport_basic
* @copyright 2014 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
// Like other files in the db directory this file uses an array.
// The old class name is the key, the new class name is the value.
// The array must be called $renamedclasses.
$renamedclasses = array(
'scorm_basic_report' => 'scormreport_basic\report'
);

View File

@ -21,6 +21,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace scormreport_graphs;
defined('MOODLE_INTERNAL') || die();
/**
* Main class to control the graphs reporting
@ -30,30 +32,30 @@ defined('MOODLE_INTERNAL') || die();
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class scorm_graphs_report extends scorm_default_report {
class report extends \mod_scorm\report {
/**
* Displays the full report
*
* @param stdClass $scorm full SCORM object
* @param stdClass $cm - full course_module object
* @param stdClass $course - full course object
* @param \stdClass $scorm full SCORM object
* @param \stdClass $cm - full course_module object
* @param \stdClass $course - full course object
* @param string $download - type of download being requested
*/
public function display($scorm, $cm, $course, $download) {
global $DB, $OUTPUT, $PAGE;
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used.
groups_print_activity_menu($cm, new moodle_url($PAGE->url));
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used.
groups_print_activity_menu($cm, new \moodle_url($PAGE->url));
}
if ($scoes = $DB->get_records('scorm_scoes', array("scorm" => $scorm->id), 'sortorder, id')) {
foreach ($scoes as $sco) {
if ($sco->launch != '') {
$imageurl = new moodle_url('/mod/scorm/report/graphs/graph.php',
$imageurl = new \moodle_url('/mod/scorm/report/graphs/graph.php',
array('scoid' => $sco->id));
$graphname = $sco->title;
echo $OUTPUT->heading($graphname, 3);
echo html_writer::tag('div', html_writer::empty_tag('img',
echo \html_writer::tag('div', \html_writer::empty_tag('img',
array('src' => $imageurl, 'alt' => $graphname)),
array('class' => 'graph'));
}

View File

@ -0,0 +1,40 @@
<?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/>.
/**
* This file contains mappings for classes that have been renamed so that they meet the requirements of the autoloader.
*
* Renaming isn't always the recommended approach, but can provide benefit in situations where we've already got a
* close structure, OR where lots of classes get included and not necessarily used, or checked for often.
*
* When renaming a class delete the original class and add an entry to the db/renamedclasses.php directory for that
* component.
* This way we don't need to keep around old classes, instead creating aliases only when required.
* One big advantage to this method is that we provide consistent debugging for renamed classes when they are used.
*
* @package scormreport_graph
* @copyright 2014 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
// Like other files in the db directory this file uses an array.
// The old class name is the key, the new class name is the value.
// The array must be called $renamedclasses.
$renamedclasses = array(
'scorm_graph_report' => 'scormreport_graph\report'
);

View File

@ -21,26 +21,28 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace scormreport_interactions;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot.'/mod/scorm/report/interactions/responsessettings_form.php');
class scorm_interactions_report extends scorm_default_report {
class report extends \mod_scorm\report {
/**
* displays the full report
* @param stdClass $scorm full SCORM object
* @param stdClass $cm - full course_module object
* @param stdClass $course - full course object
* @param \stdClass $scorm full SCORM object
* @param \stdClass $cm - full course_module object
* @param \stdClass $course - full course object
* @param string $download - type of download being requested
*/
public function display($scorm, $cm, $course, $download) {
global $CFG, $DB, $OUTPUT, $PAGE;
$contextmodule = context_module::instance($cm->id);
$contextmodule = \context_module::instance($cm->id);
$action = optional_param('action', '', PARAM_ALPHA);
$attemptids = optional_param_array('attemptid', array(), PARAM_RAW);
$attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_ALL_STUDENTS, PARAM_INT);
$PAGE->set_url(new moodle_url($PAGE->url, array('attemptsmode' => $attemptsmode)));
$PAGE->set_url(new \moodle_url($PAGE->url, array('attemptsmode' => $attemptsmode)));
if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) {
if (scorm_delete_responses($attemptids, $scorm)) { // Delete responses.
@ -51,7 +53,7 @@ class scorm_interactions_report extends scorm_default_report {
$currentgroup = groups_get_activity_group($cm, true);
// Detailed report.
$mform = new mod_scorm_report_interactions_settings($PAGE->url, compact('currentgroup'));
$mform = new \mod_scorm_report_interactions_settings($PAGE->url, compact('currentgroup'));
if ($fromform = $mform->get_data()) {
$pagesize = $fromform->pagesize;
$includeqtext = $fromform->qtext;
@ -81,10 +83,10 @@ class scorm_interactions_report extends scorm_default_report {
$mform->set_data($displayoptions + array('pagesize' => $pagesize));
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used.
if (!$download) {
groups_print_activity_menu($cm, new moodle_url($PAGE->url, $displayoptions));
groups_print_activity_menu($cm, new \moodle_url($PAGE->url, $displayoptions));
}
}
$formattextoptions = array('context' => context_course::instance($course->id));
$formattextoptions = array('context' => \context_course::instance($course->id));
// We only want to show the checkbox to delete attempts
// if the user has permissions and if the report mode is showing attempts.
@ -117,7 +119,7 @@ class scorm_interactions_report extends scorm_default_report {
}
if ( !$nostudents ) {
// Now check if asked download of data.
$coursecontext = context_course::instance($course->id);
$coursecontext = \context_course::instance($course->id);
if ($download) {
$filename = clean_filename("$course->shortname ".format_string($scorm->name, true, $formattextoptions));
}
@ -162,7 +164,7 @@ class scorm_interactions_report extends scorm_default_report {
// Construct the SQL.
$select = 'SELECT DISTINCT '.$DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)').' AS uniqueid, ';
$select .= 'st.scormid AS scormid, st.attempt AS attempt, ' .
user_picture::fields('u', array('idnumber'), 'userid') .
\user_picture::fields('u', array('idnumber'), 'userid') .
get_extra_user_fields_sql($coursecontext, 'u', '', array('email', 'idnumber')) . ' ';
// This part is the same for all cases - join users and scorm_scoes_track tables.
@ -205,7 +207,7 @@ class scorm_interactions_report extends scorm_default_report {
}
if (!$download) {
$table = new flexible_table('mod-scorm-report');
$table = new \flexible_table('mod-scorm-report');
$table->define_columns($columns);
$table->define_headers($headers);
@ -260,7 +262,7 @@ class scorm_interactions_report extends scorm_default_report {
$filename .= ".ods";
// Creating a workbook.
$workbook = new MoodleODSWorkbook("-");
$workbook = new \MoodleODSWorkbook("-");
// Sending HTTP headers.
$workbook->send($filename);
// Creating the first worksheet.
@ -299,7 +301,7 @@ class scorm_interactions_report extends scorm_default_report {
$filename .= ".xls";
// Creating a workbook.
$workbook = new MoodleExcelWorkbook("-");
$workbook = new \MoodleExcelWorkbook("-");
// Sending HTTP headers.
$workbook->send($filename);
// Creating the first worksheet.
@ -333,7 +335,7 @@ class scorm_interactions_report extends scorm_default_report {
}
$rownum = 1;
} else if ($download == 'CSV') {
$csvexport = new csv_export_writer("tab");
$csvexport = new \csv_export_writer("tab");
$csvexport->set_filename($filename, ".txt");
$csvexport->add_data($headers);
}
@ -370,7 +372,7 @@ class scorm_interactions_report extends scorm_default_report {
$table->pagesize($pagesize, $total);
echo html_writer::start_div('scormattemptcounts');
echo \html_writer::start_div('scormattemptcounts');
if ( $count->nbresults == $count->nbattempts ) {
echo get_string('reportcountattempts', 'scorm', $count);
} else if ( $count->nbattempts > 0 ) {
@ -378,26 +380,26 @@ class scorm_interactions_report extends scorm_default_report {
} else {
echo $count->nbusers.' '.get_string('users');
}
echo html_writer::end_div();
echo \html_writer::end_div();
}
// Fetch the attempts.
if (!$download) {
$attempts = $DB->get_records_sql($select.$from.$where.$sort, $params,
$table->get_page_start(), $table->get_page_size());
echo html_writer::start_div('', array('id' => 'scormtablecontainer'));
echo \html_writer::start_div('', array('id' => 'scormtablecontainer'));
if ($candelete) {
// Start form.
$strreallydel = addslashes_js(get_string('deleteattemptcheck', 'scorm'));
echo html_writer::start_tag('form', array('id' => 'attemptsform', 'method' => 'post',
echo \html_writer::start_tag('form', array('id' => 'attemptsform', 'method' => 'post',
'action' => $PAGE->url->out(false),
'onsubmit' => 'return confirm("'.$strreallydel.'");'));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'delete'));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
echo html_writer::start_div('', array('style' => 'display: none;'));
echo html_writer::input_hidden_params($PAGE->url);
echo html_writer::end_div();
echo html_writer::start_div();
echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'delete'));
echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
echo \html_writer::start_div('', array('style' => 'display: none;'));
echo \html_writer::input_hidden_params($PAGE->url);
echo \html_writer::end_div();
echo \html_writer::start_div();
}
$table->initialbars($totalinitials > 20); // Build table rows.
} else {
@ -413,21 +415,21 @@ class scorm_interactions_report extends scorm_default_report {
}
if (in_array('checkbox', $columns)) {
if ($candelete && !empty($timetracks->start)) {
$row[] = html_writer::checkbox('attemptid[]', $scouser->userid . ':' . $scouser->attempt, false);
$row[] = \html_writer::checkbox('attemptid[]', $scouser->userid . ':' . $scouser->attempt, false);
} else if ($candelete) {
$row[] = '';
}
}
if (in_array('picture', $columns)) {
$user = new stdClass();
$additionalfields = explode(',', user_picture::fields());
$user = new \stdClass();
$additionalfields = explode(',', \user_picture::fields());
$user = username_load_fields_from_object($user, $scouser, null, $additionalfields);
$user->id = $scouser->userid;
$row[] = $OUTPUT->user_picture($user, array('courseid' => $course->id));
}
if (!$download) {
$url = new moodle_url('/user/view.php', array('id' => $scouser->userid, 'course' => $course->id));
$row[] = html_writer::link($url, fullname($scouser));
$url = new \moodle_url('/user/view.php', array('id' => $scouser->userid, 'course' => $course->id));
$row[] = \html_writer::link($url, fullname($scouser));
} else {
$row[] = fullname($scouser);
}
@ -441,11 +443,11 @@ class scorm_interactions_report extends scorm_default_report {
$row[] = '-';
} else {
if (!$download) {
$url = new moodle_url('/mod/scorm/report/userreport.php',
$url = new \moodle_url('/mod/scorm/report/userreport.php',
array('id' => $cm->id,
'user' => $scouser->userid,
'attempt' => $scouser->attempt));
$row[] = html_writer::link($url, $scouser->attempt);
$row[] = \html_writer::link($url, $scouser->attempt);
} else {
$row[] = $scouser->attempt;
}
@ -480,11 +482,11 @@ class scorm_interactions_report extends scorm_default_report {
$score = $strstatus;
}
if (!$download) {
$url = new moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $cm->id,
$url = new \moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $cm->id,
'scoid' => $sco->id, 'user' => $scouser->userid, 'attempt' => $scouser->attempt));
$row[] = html_writer::img($OUTPUT->pix_url($trackdata->status, 'scorm'), $strstatus,
array('title' => $strstatus)) . html_writer::empty_tag('br') .
html_writer::link($url, $score, array('title' => get_string('details', 'scorm')));
$row[] = \html_writer::img($OUTPUT->pix_url($trackdata->status, 'scorm'), $strstatus,
array('title' => $strstatus)) . \html_writer::empty_tag('br') .
\html_writer::link($url, $score, array('title' => get_string('details', 'scorm')));
} else {
$row[] = $score;
}
@ -530,8 +532,8 @@ class scorm_interactions_report extends scorm_default_report {
// If we don't have track data, we haven't attempted yet.
$strstatus = get_string('notattempted', 'scorm');
if (!$download) {
$row[] = html_writer::img($OUTPUT->pix_url('notattempted', 'scorm'), $strstatus,
array('title' => $strstatus)).html_writer::empty_tag('br').$strstatus;
$row[] = \html_writer::img($OUTPUT->pix_url('notattempted', 'scorm'), $strstatus,
array('title' => $strstatus)).\html_writer::empty_tag('br').$strstatus;
} else {
$row[] = $strstatus;
}
@ -559,50 +561,50 @@ class scorm_interactions_report extends scorm_default_report {
if (!$download) {
$table->finish_output();
if ($candelete) {
echo html_writer::start_tag('table', array('id' => 'commands'));
echo html_writer::start_tag('tr').html_writer::start_tag('td');
echo html_writer::link('javascript:select_all_in(\'DIV\', null, \'scormtablecontainer\');',
echo \html_writer::start_tag('table', array('id' => 'commands'));
echo \html_writer::start_tag('tr').\html_writer::start_tag('td');
echo \html_writer::link('javascript:select_all_in(\'DIV\', null, \'scormtablecontainer\');',
get_string('selectall', 'scorm')).' / ';
echo html_writer::link('javascript:deselect_all_in(\'DIV\', null, \'scormtablecontainer\');',
echo \html_writer::link('javascript:deselect_all_in(\'DIV\', null, \'scormtablecontainer\');',
get_string('selectnone', 'scorm'));
echo '&nbsp;&nbsp;';
echo html_writer::empty_tag('input', array('type' => 'submit',
echo \html_writer::empty_tag('input', array('type' => 'submit',
'value' => get_string('deleteselected', 'quiz_overview')));
echo html_writer::end_tag('td').html_writer::end_tag('tr').html_writer::end_tag('table');
echo \html_writer::end_tag('td').\html_writer::end_tag('tr').\html_writer::end_tag('table');
// Close form.
echo html_writer::end_tag('div');
echo html_writer::end_tag('form');
echo \html_writer::end_tag('div');
echo \html_writer::end_tag('form');
}
echo html_writer::end_div();
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,
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,
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,
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');
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) {
echo html_writer::end_div();
echo html_writer::end_tag('form');
echo \html_writer::end_div();
echo \html_writer::end_tag('form');
$table->finish_output();
}
echo html_writer::end_div();
echo \html_writer::end_div();
}
// Show preferences form irrespective of attempts are there to report or not.
if (!$download) {

View File

@ -0,0 +1,40 @@
<?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/>.
/**
* This file contains mappings for classes that have been renamed so that they meet the requirements of the autoloader.
*
* Renaming isn't always the recommended approach, but can provide benefit in situations where we've already got a
* close structure, OR where lots of classes get included and not necessarily used, or checked for often.
*
* When renaming a class delete the original class and add an entry to the db/renamedclasses.php directory for that
* component.
* This way we don't need to keep around old classes, instead creating aliases only when required.
* One big advantage to this method is that we provide consistent debugging for renamed classes when they are used.
*
* @package scormreport_interactions
* @copyright 2014 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
// Like other files in the db directory this file uses an array.
// The old class name is the key, the new class name is the value.
// The array must be called $renamedclasses.
$renamedclasses = array(
'scorm_interactions_report' => 'scormreport_objectives\report'
);

View File

@ -21,6 +21,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace scormreport_objectives;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot.'/mod/scorm/report/objectives/responsessettings_form.php');
@ -31,22 +33,22 @@ require_once($CFG->dirroot.'/mod/scorm/report/objectives/responsessettings_form.
* @copyright 2013 Dan Marsden
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class scorm_objectives_report extends scorm_default_report {
class report extends \mod_scorm\report {
/**
* displays the full report
* @param stdClass $scorm full SCORM object
* @param stdClass $cm - full course_module object
* @param stdClass $course - full course object
* @param \stdClass $scorm full SCORM object
* @param \stdClass $cm - full course_module object
* @param \stdClass $course - full course object
* @param string $download - type of download being requested
*/
public function display($scorm, $cm, $course, $download) {
global $CFG, $DB, $OUTPUT, $PAGE;
$contextmodule = context_module::instance($cm->id);
$contextmodule = \context_module::instance($cm->id);
$action = optional_param('action', '', PARAM_ALPHA);
$attemptids = optional_param_array('attemptid', array(), PARAM_RAW);
$attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_ALL_STUDENTS, PARAM_INT);
$PAGE->set_url(new moodle_url($PAGE->url, array('attemptsmode' => $attemptsmode)));
$PAGE->set_url(new \moodle_url($PAGE->url, array('attemptsmode' => $attemptsmode)));
if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) {
if (scorm_delete_responses($attemptids, $scorm)) { // Delete responses.
@ -57,7 +59,7 @@ class scorm_objectives_report extends scorm_default_report {
$currentgroup = groups_get_activity_group($cm, true);
// Detailed report.
$mform = new mod_scorm_report_objectives_settings($PAGE->url, compact('currentgroup'));
$mform = new \mod_scorm_report_objectives_settings($PAGE->url, compact('currentgroup'));
if ($fromform = $mform->get_data()) {
$pagesize = $fromform->pagesize;
$showobjectivescore = $fromform->objectivescore;
@ -79,10 +81,10 @@ class scorm_objectives_report extends scorm_default_report {
$mform->set_data($displayoptions + array('pagesize' => $pagesize));
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used.
if (!$download) {
groups_print_activity_menu($cm, new moodle_url($PAGE->url, $displayoptions));
groups_print_activity_menu($cm, new \moodle_url($PAGE->url, $displayoptions));
}
}
$formattextoptions = array('context' => context_course::instance($course->id));
$formattextoptions = array('context' => \context_course::instance($course->id));
// We only want to show the checkbox to delete attempts
// if the user has permissions and if the report mode is showing attempts.
@ -115,7 +117,7 @@ class scorm_objectives_report extends scorm_default_report {
}
if ( !$nostudents ) {
// Now check if asked download of data.
$coursecontext = context_course::instance($course->id);
$coursecontext = \context_course::instance($course->id);
if ($download) {
$filename = clean_filename("$course->shortname ".format_string($scorm->name, true, $formattextoptions));
}
@ -160,7 +162,7 @@ class scorm_objectives_report extends scorm_default_report {
// Construct the SQL.
$select = 'SELECT DISTINCT '.$DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)').' AS uniqueid, ';
$select .= 'st.scormid AS scormid, st.attempt AS attempt, ' .
user_picture::fields('u', array('idnumber'), 'userid') .
\user_picture::fields('u', array('idnumber'), 'userid') .
get_extra_user_fields_sql($coursecontext, 'u', '', array('email', 'idnumber')) . ' ';
// This part is the same for all cases - join users and scorm_scoes_track tables.
@ -215,7 +217,7 @@ class scorm_objectives_report extends scorm_default_report {
$emptycell = ''; // Used when an empty cell is being printed - in html we add a space.
if (!$download) {
$emptycell = '&nbsp;';
$table = new flexible_table('mod-scorm-report');
$table = new \flexible_table('mod-scorm-report');
$table->define_columns($columns);
$table->define_headers($headers);
@ -261,7 +263,7 @@ class scorm_objectives_report extends scorm_default_report {
$filename .= ".ods";
// Creating a workbook.
$workbook = new MoodleODSWorkbook("-");
$workbook = new \MoodleODSWorkbook("-");
// Sending HTTP headers.
$workbook->send($filename);
// Creating the first worksheet.
@ -300,7 +302,7 @@ class scorm_objectives_report extends scorm_default_report {
$filename .= ".xls";
// Creating a workbook.
$workbook = new MoodleExcelWorkbook("-");
$workbook = new \MoodleExcelWorkbook("-");
// Sending HTTP headers.
$workbook->send($filename);
// Creating the first worksheet.
@ -334,7 +336,7 @@ class scorm_objectives_report extends scorm_default_report {
}
$rownum = 1;
} else if ($download == 'CSV') {
$csvexport = new csv_export_writer("tab");
$csvexport = new \csv_export_writer("tab");
$csvexport->set_filename($filename, ".txt");
$csvexport->add_data($headers);
}
@ -371,7 +373,7 @@ class scorm_objectives_report extends scorm_default_report {
$table->pagesize($pagesize, $total);
echo html_writer::start_div('scormattemptcounts');
echo \html_writer::start_div('scormattemptcounts');
if ( $count->nbresults == $count->nbattempts ) {
echo get_string('reportcountattempts', 'scorm', $count);
} else if ( $count->nbattempts > 0 ) {
@ -379,26 +381,26 @@ class scorm_objectives_report extends scorm_default_report {
} else {
echo $count->nbusers.' '.get_string('users');
}
echo html_writer::end_div();
echo \html_writer::end_div();
}
// Fetch the attempts.
if (!$download) {
$attempts = $DB->get_records_sql($select.$from.$where.$sort, $params,
$table->get_page_start(), $table->get_page_size());
echo html_writer::start_div('', array('id' => 'scormtablecontainer'));
echo \html_writer::start_div('', array('id' => 'scormtablecontainer'));
if ($candelete) {
// Start form.
$strreallydel = addslashes_js(get_string('deleteattemptcheck', 'scorm'));
echo html_writer::start_tag('form', array('id' => 'attemptsform', 'method' => 'post',
echo \html_writer::start_tag('form', array('id' => 'attemptsform', 'method' => 'post',
'action' => $PAGE->url->out(false),
'onsubmit' => 'return confirm("'.$strreallydel.'");'));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'delete'));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
echo html_writer::start_div('', array('style' => 'display: none;'));
echo html_writer::input_hidden_params($PAGE->url);
echo html_writer::end_div();
echo html_writer::start_div();
echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'delete'));
echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
echo \html_writer::start_div('', array('style' => 'display: none;'));
echo \html_writer::input_hidden_params($PAGE->url);
echo \html_writer::end_div();
echo \html_writer::start_div();
}
$table->initialbars($totalinitials > 20); // Build table rows.
} else {
@ -414,21 +416,21 @@ class scorm_objectives_report extends scorm_default_report {
}
if (in_array('checkbox', $columns)) {
if ($candelete && !empty($timetracks->start)) {
$row[] = html_writer::checkbox('attemptid[]', $scouser->userid . ':' . $scouser->attempt, false);
$row[] = \html_writer::checkbox('attemptid[]', $scouser->userid . ':' . $scouser->attempt, false);
} else if ($candelete) {
$row[] = '';
}
}
if (in_array('picture', $columns)) {
$user = new stdClass();
$additionalfields = explode(',', user_picture::fields());
$user = new \stdClass();
$additionalfields = explode(',', \user_picture::fields());
$user = username_load_fields_from_object($user, $scouser, null, $additionalfields);
$user->id = $scouser->userid;
$row[] = $OUTPUT->user_picture($user, array('courseid' => $course->id));
}
if (!$download) {
$url = new moodle_url('/user/view.php', array('id' => $scouser->userid, 'course' => $course->id));
$row[] = html_writer::link($url, fullname($scouser));
$url = new \moodle_url('/user/view.php', array('id' => $scouser->userid, 'course' => $course->id));
$row[] = \html_writer::link($url, fullname($scouser));
} else {
$row[] = fullname($scouser);
}
@ -442,11 +444,9 @@ class scorm_objectives_report extends scorm_default_report {
$row[] = '-';
} else {
if (!$download) {
$url = new moodle_url('/mod/scorm/report/userreport.php',
array('id' => $cm->id,
'user' => $scouser->userid,
'attempt' => $scouser->attempt));
$row[] = html_writer::link($url, $scouser->attempt);
$url = new \moodle_url('/mod/scorm/report/userreport.php', array('id' => $cm->id,
'user' => $scouser->userid, 'attempt' => $scouser->attempt));
$row[] = \html_writer::link($url, $scouser->attempt);
} else {
$row[] = $scouser->attempt;
}
@ -482,11 +482,11 @@ class scorm_objectives_report extends scorm_default_report {
$score = $strstatus;
}
if (!$download) {
$url = new moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $cm->id,
$url = new \moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $cm->id,
'scoid' => $sco->id, 'user' => $scouser->userid, 'attempt' => $scouser->attempt));
$row[] = html_writer::img($OUTPUT->pix_url($trackdata->status, 'scorm'), $strstatus,
array('title' => $strstatus)) . html_writer::empty_tag('br') .
html_writer::link($url, $score, array('title' => get_string('details', 'scorm')));
$row[] = \html_writer::img($OUTPUT->pix_url($trackdata->status, 'scorm'), $strstatus,
array('title' => $strstatus)) . \html_writer::empty_tag('br') .
\html_writer::link($url, $score, array('title' => get_string('details', 'scorm')));
} else {
$row[] = $score;
}
@ -543,8 +543,8 @@ class scorm_objectives_report extends scorm_default_report {
// If we don't have track data, we haven't attempted yet.
$strstatus = get_string('notattempted', 'scorm');
if (!$download) {
$row[] = html_writer::img($OUTPUT->pix_url('notattempted', 'scorm'), $strstatus,
array('title' => $strstatus)).html_writer::empty_tag('br').$strstatus;
$row[] = \html_writer::img($OUTPUT->pix_url('notattempted', 'scorm'), $strstatus,
array('title' => $strstatus)).\html_writer::empty_tag('br').$strstatus;
} else {
$row[] = $strstatus;
}
@ -572,50 +572,50 @@ class scorm_objectives_report extends scorm_default_report {
if (!$download) {
$table->finish_output();
if ($candelete) {
echo html_writer::start_tag('table', array('id' => 'commands'));
echo html_writer::start_tag('tr').html_writer::start_tag('td');
echo html_writer::link('javascript:select_all_in(\'DIV\', null, \'scormtablecontainer\');',
echo \html_writer::start_tag('table', array('id' => 'commands'));
echo \html_writer::start_tag('tr').\html_writer::start_tag('td');
echo \html_writer::link('javascript:select_all_in(\'DIV\', null, \'scormtablecontainer\');',
get_string('selectall', 'scorm')).' / ';
echo html_writer::link('javascript:deselect_all_in(\'DIV\', null, \'scormtablecontainer\');',
echo \html_writer::link('javascript:deselect_all_in(\'DIV\', null, \'scormtablecontainer\');',
get_string('selectnone', 'scorm'));
echo '&nbsp;&nbsp;';
echo html_writer::empty_tag('input', array('type' => 'submit',
echo \html_writer::empty_tag('input', array('type' => 'submit',
'value' => get_string('deleteselected', 'quiz_overview')));
echo html_writer::end_tag('td').html_writer::end_tag('tr').html_writer::end_tag('table');
echo \html_writer::end_tag('td').\html_writer::end_tag('tr').\html_writer::end_tag('table');
// Close form.
echo html_writer::end_tag('div');
echo html_writer::end_tag('form');
echo \html_writer::end_tag('div');
echo \html_writer::end_tag('form');
}
echo html_writer::end_div();
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,
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,
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,
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');
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) {
echo html_writer::end_div();
echo html_writer::end_tag('form');
echo \html_writer::end_div();
echo \html_writer::end_tag('form');
$table->finish_output();
}
echo html_writer::end_div();
echo \html_writer::end_div();
}
// Show preferences form irrespective of attempts are there to report or not.
if (!$download) {

View File

@ -0,0 +1,40 @@
<?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/>.
/**
* This file contains mappings for classes that have been renamed so that they meet the requirements of the autoloader.
*
* Renaming isn't always the recommended approach, but can provide benefit in situations where we've already got a
* close structure, OR where lots of classes get included and not necessarily used, or checked for often.
*
* When renaming a class delete the original class and add an entry to the db/renamedclasses.php directory for that
* component.
* This way we don't need to keep around old classes, instead creating aliases only when required.
* One big advantage to this method is that we provide consistent debugging for renamed classes when they are used.
*
* @package scormreport_objectives
* @copyright 2014 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
// Like other files in the db directory this file uses an array.
// The old class name is the key, the new class name is the value.
// The array must be called $renamedclasses.
$renamedclasses = array(
'scorm_objectives_report' => 'scormreport_objectives\report'
);

View File

@ -36,8 +36,22 @@ function scorm_report_list($context) {
}
$installed = core_component::get_plugin_list('scormreport');
foreach ($installed as $reportname => $notused) {
// Moodle 2.8+ style of autoloaded classes.
$classname = "scormreport_$reportname\\report";
if (class_exists($classname)) {
$report = new $classname();
if ($report->canview($context)) {
$reportlist[] = $reportname;
}
continue;
}
// Legacy style of naming classes.
$pluginfile = $CFG->dirroot.'/mod/scorm/report/'.$reportname.'/report.php';
if (is_readable($pluginfile)) {
debugging("Please use autoloaded classnames for your plugin. Refer MDL-46469 for details", DEBUG_DEVELOPER);
include_once($pluginfile);
$reportclassname = "scorm_{$reportname}_report";
if (class_exists($reportclassname)) {

View File

@ -4,3 +4,5 @@ This files describes API changes in the mod_scorm code.
* Coding style fixes. A large number of coding style issues were fixed in MDL-45887. This means any local modifications
to mod_scorm are likely to conflict.
* All scorm report plugins should use namespaced classnames now. Refer MDL-46469 for details.