1 |
efrain |
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 |
$cmiint = new stdClass();
|
|
|
23 |
$cmicommentsuser = new stdClass();
|
|
|
24 |
$cmicommentslms = new stdClass();
|
|
|
25 |
|
|
|
26 |
if (!isset($currentorg)) {
|
|
|
27 |
$currentorg = '';
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
if ($scoes = $DB->get_records('scorm_scoes', array('scorm' => $scorm->id), 'sortorder, id')) {
|
|
|
31 |
// Drop keys so that it is a simple array.
|
|
|
32 |
$scoes = array_values($scoes);
|
|
|
33 |
foreach ($scoes as $sco) {
|
|
|
34 |
$def->{($sco->id)} = new stdClass();
|
|
|
35 |
$userdata->{($sco->id)} = new stdClass();
|
|
|
36 |
$def->{($sco->id)} = get_scorm_default($userdata->{($sco->id)}, $scorm, $sco->id, $attempt, $mode);
|
|
|
37 |
|
|
|
38 |
// Reconstitute objectives, comments_from_learner and comments_from_lms.
|
|
|
39 |
$cmiobj->{($sco->id)} = scorm_reconstitute_array_element($scorm->version, $userdata->{($sco->id)},
|
|
|
40 |
'cmi.objectives', array('score'));
|
|
|
41 |
$cmiint->{($sco->id)} = scorm_reconstitute_array_element($scorm->version, $userdata->{($sco->id)},
|
|
|
42 |
'cmi.interactions', array('objectives', 'correct_responses'));
|
|
|
43 |
$cmicommentsuser->{($sco->id)} = scorm_reconstitute_array_element($scorm->version, $userdata->{($sco->id)},
|
|
|
44 |
'cmi.comments_from_learner', array());
|
|
|
45 |
$cmicommentslms->{($sco->id)} = scorm_reconstitute_array_element($scorm->version, $userdata->{($sco->id)},
|
|
|
46 |
'cmi.comments_from_lms', array());
|
|
|
47 |
}
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
$scorm->autocommit = ($scorm->autocommit === "1") ? true : false;
|
|
|
51 |
$PAGE->requires->js_init_call('M.scorm_api.init', array($def, $cmiobj, $cmiint, $cmicommentsuser, $cmicommentslms,
|
|
|
52 |
scorm_debugging($scorm), $scorm->auto, $scorm->id, $CFG->wwwroot,
|
|
|
53 |
sesskey(), $scoid, $attempt, $mode, $id, $currentorg, $scorm->autocommit));
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
// Pull in the debugging utilities.
|
|
|
57 |
if (scorm_debugging($scorm)) {
|
|
|
58 |
require_once($CFG->dirroot.'/mod/scorm/datamodels/debug.js.php');
|
|
|
59 |
echo html_writer::script('AppendToLog("Moodle SCORM 1.3 API Loaded, Activity: '.
|
|
|
60 |
$scorm->name.', SCO: '.$sco->identifier.'", 0);');
|
|
|
61 |
}
|