From 3cc7515843c63d75780819ff2adfb8cf5d23ba77 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Mon, 7 May 2012 20:51:43 +1200 Subject: [PATCH] MDL-30598 SCORM fix a few coding guideline issues, tidy up phpdocs --- mod/scorm/loaddatamodel.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/mod/scorm/loaddatamodel.php b/mod/scorm/loaddatamodel.php index f48611a693b97..d6e2ebccbe4ef 100644 --- a/mod/scorm/loaddatamodel.php +++ b/mod/scorm/loaddatamodel.php @@ -14,14 +14,22 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +/** + * This page loads the correct JS file based on package type + * + * @package mod_scorm + * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + require_once("../../config.php"); require_once('locallib.php'); $id = optional_param('id', 0, PARAM_INT); // Course Module ID, or -$a = optional_param('a', 0, PARAM_INT); // scorm ID -$scoid = required_param('scoid', PARAM_INT); // sco ID -$mode = optional_param('mode', '', PARAM_ALPHA); // navigation mode -$attempt = required_param('attempt', PARAM_INT); // new attempt +$a = optional_param('a', 0, PARAM_INT); // scorm ID. +$scoid = required_param('scoid', PARAM_INT); // sco ID. +$mode = optional_param('mode', '', PARAM_ALPHA); // navigation mode. +$attempt = required_param('attempt', PARAM_INT); // new attempt. if (!empty($id)) { $cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST); @@ -39,9 +47,11 @@ require_login($course, false, $cm); +$userdata = new stdClass(); if ($usertrack = scorm_get_tracks($scoid, $USER->id, $attempt)) { - // according to SCORM 2004 spec(RTE V1, 4.2.8), only cmi.exit==suspend should allow previous datamodel elements on re-launch - if (!scorm_version_check($scorm->version, SCORM_13) || (isset($usertrack->{'cmi.exit'}) && ($usertrack->{'cmi.exit'} == 'suspend'))) { + // According to SCORM 2004 spec(RTE V1, 4.2.8), only cmi.exit==suspend should allow previous datamodel elements on re-launch. + if (!scorm_version_check($scorm->version, SCORM_13) || + (isset($usertrack->{'cmi.exit'}) && ($usertrack->{'cmi.exit'} == 'suspend'))) { foreach ($usertrack as $key => $value) { $userdata->$key = addslashes_js($value); } @@ -80,13 +90,13 @@ header('Content-Type: text/javascript; charset=UTF-8'); -$scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe +$scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe. if (file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.js.php')) { include_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.js.php'); } else { include_once($CFG->dirroot.'/mod/scorm/datamodels/scorm_12.js.php'); } -// set the start time of this SCO +// Set the start time of this SCO. scorm_insert_track($USER->id, $scorm->id, $scoid, $attempt, 'x.start.time', time()); ?>