2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * Returns an array of reports to which are currently readable.
20 * @author Ankit Kumar Agarwal
21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 defined('MOODLE_INTERNAL') ||
die();
26 /* Generates and returns list of available Scorm report sub-plugins
28 * @param context context level to check caps against
29 * @return array list of valid reports present
31 function scorm_report_list($context) {
34 if (!empty($reportlist)) {
37 $installed = core_component
::get_plugin_list('scormreport');
38 foreach ($installed as $reportname => $notused) {
40 // Moodle 2.8+ style of autoloaded classes.
41 $classname = "scormreport_$reportname\\report";
42 if (class_exists($classname)) {
43 $report = new $classname();
45 if ($report->canview($context)) {
46 $reportlist[] = $reportname;
51 // Legacy style of naming classes.
52 $pluginfile = $CFG->dirroot
.'/mod/scorm/report/'.$reportname.'/report.php';
53 if (is_readable($pluginfile)) {
54 debugging("Please use autoloaded classnames for your plugin. Refer MDL-46469 for details", DEBUG_DEVELOPER
);
55 include_once($pluginfile);
56 $reportclassname = "scorm_{$reportname}_report";
57 if (class_exists($reportclassname)) {
58 $report = new $reportclassname();
60 if ($report->canview($context)) {
61 $reportlist[] = $reportname;
69 * Returns The maximum numbers of Questions associated with an Scorm Pack
72 * @return int an integer representing the question count
74 function get_scorm_question_count($scormid) {
78 $select = "scormid = ? AND ";
79 $select .= $DB->sql_like("element", "?", false);
81 $params[] = "cmi.interactions_%.id";
82 $rs = $DB->get_recordset_select("scorm_scoes_track", $select, $params, 'element');
83 $keywords = array("cmi.interactions_", ".id");
85 foreach ($rs as $record) {
86 $num = trim(str_ireplace($keywords, '', $record->element
));
87 if (is_numeric($num) && $num > $count) {
91 // Done as interactions start at 0 (do only if we have something to report).
94 $rs->close(); // Closing recordset.