|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00025 defined('MOODLE_INTERNAL') || die(); 00026 00027 /* Generates and returns list of available Scorm report sub-plugins 00028 * 00029 * @param context context level to check caps against 00030 * @return array list of valid reports present 00031 */ 00032 function scorm_report_list($context) { 00033 global $CFG; 00034 static $reportlist; 00035 if (!empty($reportlist)) { 00036 return $reportlist; 00037 } 00038 $installed = get_plugin_list('scormreport'); 00039 foreach ($installed as $reportname => $notused) { 00040 $pluginfile = $CFG->dirroot.'/mod/scorm/report/'.$reportname.'/report.php'; 00041 if (is_readable($pluginfile)) { 00042 include_once($pluginfile); 00043 $reportclassname = "scorm_{$reportname}_report"; 00044 if (class_exists($reportclassname)) { 00045 $report = new $reportclassname(); 00046 00047 if ($report->canview($context)) { 00048 $reportlist[] = $reportname; 00049 } 00050 } 00051 } 00052 } 00053 return $reportlist; 00054 } 00061 function get_scorm_question_count($scormid) { 00062 global $DB; 00063 $count = 0; 00064 $params = array(); 00065 $select = "scormid = ? AND "; 00066 $select .= $DB->sql_like("element", "?", false); 00067 $params[] = $scormid; 00068 $params[] = "cmi.interactions_%.id"; 00069 $rs = $DB->get_recordset_select("scorm_scoes_track", $select, $params, 'element'); 00070 $keywords = array("cmi.interactions_", ".id"); 00071 foreach ($rs as $record) { 00072 $num = trim(str_ireplace($keywords, '', $record->element)); 00073 if (is_numeric($num) && $num > $count) { 00074 $count = $num; 00075 } 00076 } 00077 //done as interactions start at 0 00078 $count++; 00079 $rs->close(); // closing recordset 00080 return $count; 00081 } 00082