1<?php 2// This file is part of Moodle - http://moodle.org/ 3// 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. 8// 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. 13// 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/>. 16 17require_once($CFG->dirroot.'/mod/scorm/locallib.php'); 18 19// Set some vars to use as default values. 20$userdata = new stdClass(); 21$def = new stdClass(); 22$cmiobj = new stdClass(); 23$cmiint = new stdClass(); 24 25if (!isset($currentorg)) { 26 $currentorg = ''; 27} 28 29if ($scoes = $DB->get_records('scorm_scoes', array('scorm' => $scorm->id), 'sortorder, id')) { 30 // Drop keys so that it is a simple array. 31 $scoes = array_values($scoes); 32 foreach ($scoes as $sco) { 33 $def->{($sco->id)} = new stdClass(); 34 $userdata->{($sco->id)} = new stdClass(); 35 $def->{($sco->id)} = get_scorm_default($userdata->{($sco->id)}, $scorm, $sco->id, $attempt, $mode); 36 37 // Reconstitute objectives. 38 $cmiobj->{($sco->id)} = scorm_reconstitute_array_element($scorm->version, $userdata->{($sco->id)}, 39 'cmi.objectives', array('score')); 40 $cmiint->{($sco->id)} = scorm_reconstitute_array_element($scorm->version, $userdata->{($sco->id)}, 41 'cmi.interactions', array('objectives', 'correct_responses')); 42 } 43} 44 45// If SCORM 1.2 standard mode is disabled allow higher datamodel limits. 46if (intval(get_config("scorm", "scormstandard"))) { 47 $cmistring256 = '^[\\u0000-\\uFFFF]{0,255}$'; 48 $cmistring4096 = '^[\\u0000-\\uFFFF]{0,4096}$'; 49} else { 50 $cmistring256 = '^[\\u0000-\\uFFFF]{0,64000}$'; 51 $cmistring4096 = $cmistring256; 52} 53 54$scorm->autocommit = ($scorm->autocommit === "1") ? true : false; 55$scorm->masteryoverride = ($scorm->masteryoverride === "1") ? true : false; 56$PAGE->requires->js_init_call('M.scorm_api.init', array($def, $cmiobj, $cmiint, $cmistring256, $cmistring4096, 57 scorm_debugging($scorm), $scorm->auto, $scorm->id, $CFG->wwwroot, 58 sesskey(), $scoid, $attempt, $mode, $id, $currentorg, $scorm->autocommit, 59 $scorm->masteryoverride, $scorm->hidetoc)); 60 61// Pull in the debugging utilities. 62if (scorm_debugging($scorm)) { 63 require_once($CFG->dirroot.'/mod/scorm/datamodels/debug.js.php'); 64 echo html_writer::script('AppendToLog("Moodle SCORM 1.2 API Loaded, Activity: '. 65 $scorm->name.', SCO: '.$sco->identifier.'", 0);'); 66} 67