See Release Notes
Long Term Support Release
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 17 require_once($CFG->dirroot.'/mod/scorm/locallib.php'); 18 19 $userdata = new stdClass(); 20 $def = new stdClass(); 21 $cmiobj = new stdClass(); 22 23 if (!isset($currentorg)) { 24 $currentorg = ''; 25 } 26 27 if ($scoes = $DB->get_records('scorm_scoes', array('scorm' => $scorm->id), 'sortorder, id')) { 28 // Drop keys so that it is a simple array. 29 $scoes = array_values($scoes); 30 foreach ($scoes as $sco) { 31 $def->{($sco->id)} = new stdClass(); 32 $userdata->{($sco->id)} = new stdClass(); 33 $def->{($sco->id)} = get_scorm_default($userdata->{($sco->id)}, $scorm, $sco->id, $attempt, $mode); 34 35 // Reconstitute objectives, comments_from_learner and comments_from_lms. 36 $cmiobj->{($sco->id)} = ''; 37 $currentobj = ''; 38 $count = 0; 39 foreach ($userdata as $element => $value) { 40 if (substr($element, 0, 14) == 'cmi.objectives') { 41 $element = preg_replace('/\.(\d+)\./', "_\$1.", $element); 42 preg_match('/\_(\d+)\./', $element, $matches); 43 if (count($matches) > 0 && $currentobj != $matches[1]) { 44 $currentobj = $matches[1]; 45 $count++; 46 $end = strpos($element, $matches[1]) + strlen($matches[1]); 47 $subelement = substr($element, 0, $end); 48 $cmiobj->{($sco->id)} .= ' '.$subelement." = new Object();\n"; 49 $cmiobj->{($sco->id)} .= ' '.$subelement.".score = new Object();\n"; 50 $cmiobj->{($sco->id)} .= ' '.$subelement.".score._children = score_children;\n"; 51 $cmiobj->{($sco->id)} .= ' '.$subelement.".score.raw = '';\n"; 52 $cmiobj->{($sco->id)} .= ' '.$subelement.".score.min = '';\n"; 53 $cmiobj->{($sco->id)} .= ' '.$subelement.".score.max = '';\n"; 54 } 55 $cmiobj->{($sco->id)} .= ' '.$element.' = \''.$value."';\n"; 56 } 57 } 58 if ($count > 0) { 59 $cmiobj->{($sco->id)} .= ' cmi.objectives._count = '.$count.";\n"; 60 } 61 } 62 } 63 64 65 $PAGE->requires->js_init_call('M.scorm_api.init', array($def, $cmiobj, $scorm->auto, $CFG->wwwroot, $scorm->id, $scoid, 66 $attempt, $mode, $currentorg, sesskey(), $id, $scorm->autocommit));
title
Description
Body
title
Description
Body
title
Description
Body
title
Body