|
@@ -27,12 +27,19 @@ class scorm extends learnpath
|
|
|
public $organizations = array();
|
|
|
public $organizations_att = array();
|
|
|
public $metadata = array();
|
|
|
- public $idrefs = array();
|
|
|
- public $refurls = array();
|
|
|
- public $subdir = '';
|
|
|
+
|
|
|
+ public $idrefs = array();
|
|
|
+
|
|
|
+ public $refurls = array();
|
|
|
+
|
|
|
+ maritime_nav/maritime_nav. This is the path that will be used in the
|
|
|
+ lp_path when importing a package. */
|
|
|
+ public $subdir = '';
|
|
|
public $items = array();
|
|
|
- public $zipname = '';
|
|
|
- public $lastzipnameindex = 0;
|
|
|
+
|
|
|
+ public $zipname = '';
|
|
|
+
|
|
|
+ public $lastzipnameindex = 0;
|
|
|
public $manifest_encoding = 'UTF-8';
|
|
|
public $debug = false;
|
|
|
|
|
@@ -42,13 +49,13 @@ class scorm extends learnpath
|
|
|
* @param integer Learnpath ID in DB
|
|
|
* @param integer User ID
|
|
|
*/
|
|
|
- function __construct($course_code = null, $resource_id = null, $user_id = null)
|
|
|
+ public function __construct($course_code = null, $resource_id = null, $user_id = null)
|
|
|
{
|
|
|
- if ($this->debug > 0) { error_log('New LP - scorm::scorm('.$course_code.','.$resource_id.','.$user_id.') - In scorm constructor', 0); }
|
|
|
+ if ($this->debug > 0) {
|
|
|
+ error_log('New LP - scorm::scorm('.$course_code.','.$resource_id.','.$user_id.') - In scorm constructor', 0);
|
|
|
+ }
|
|
|
if (!empty($course_code) && !empty($resource_id) && !empty($user_id)) {
|
|
|
parent::__construct($course_code, $resource_id, $user_id);
|
|
|
- } else {
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -56,7 +63,7 @@ class scorm extends learnpath
|
|
|
* Opens a resource
|
|
|
* @param integer Database ID of the resource
|
|
|
*/
|
|
|
- function open($id)
|
|
|
+ public function open($id)
|
|
|
{
|
|
|
if ($this->debug > 0) { error_log('New LP - scorm::open() - In scorm::open method', 0); }
|
|
|
|
|
@@ -75,9 +82,11 @@ class scorm extends learnpath
|
|
|
* @param string Path to the imsmanifest.xml file on the system. If not defined, uses the base path of the course's scorm dir
|
|
|
* @return array Structured array representing the imsmanifest's contents
|
|
|
*/
|
|
|
- function parse_manifest($file = '')
|
|
|
+ public function parse_manifest($file = '')
|
|
|
{
|
|
|
- if ($this->debug > 0) { error_log('In scorm::parse_manifest('.$file.')', 0); }
|
|
|
+ if ($this->debug > 0) {
|
|
|
+ error_log('In scorm::parse_manifest('.$file.')', 0);
|
|
|
+ }
|
|
|
if (empty($file)) {
|
|
|
|
|
|
}
|
|
@@ -89,19 +98,25 @@ class scorm extends learnpath
|
|
|
if ($this->debug > 0) { error_log('In scorm::parse_manifest() - Parsing using PHP5 method', 0); }
|
|
|
|
|
|
|
|
|
- $this->manifest_encoding = self::detect_manifest_encoding($xml);
|
|
|
+
|
|
|
+ $this->manifest_encoding = self::detect_manifest_encoding($xml);
|
|
|
|
|
|
- $xml = api_utf8_encode_xml($xml, $this->manifest_encoding);
|
|
|
+
|
|
|
+ $xml = api_utf8_encode_xml($xml, $this->manifest_encoding);
|
|
|
|
|
|
$doc = new DOMDocument();
|
|
|
$res = @$doc->loadXML($xml);
|
|
|
if ($res === false) {
|
|
|
- if ($this->debug > 0) { error_log('New LP - In scorm::parse_manifest() - Exception thrown when loading '.$file.' in DOMDocument', 0); }
|
|
|
+ if ($this->debug > 0) {
|
|
|
+ error_log('New LP - In scorm::parse_manifest() - Exception thrown when loading '.$file.' in DOMDocument', 0);
|
|
|
+ }
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- if ($this->debug > 1) { error_log('New LP - Called (encoding:'.$doc->xmlEncoding.' - saved: '.$this->manifest_encoding.')', 0); }
|
|
|
+ if ($this->debug > 1) {
|
|
|
+ error_log('New LP - Called (encoding:'.$doc->xmlEncoding.' - saved: '.$this->manifest_encoding.')', 0);
|
|
|
+ }
|
|
|
|
|
|
$root = $doc->documentElement;
|
|
|
if ($root->hasAttributes()) {
|
|
@@ -219,6 +234,7 @@ class scorm extends learnpath
|
|
|
$this->set_error_msg("File $file could not be read");
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
|
|
|
return $this->manifest;
|
|
|
}
|
|
@@ -230,8 +246,8 @@ class scorm extends learnpath
|
|
|
* @param string $xml The input xml-text.
|
|
|
* @return string The detected value of the input xml.
|
|
|
*/
|
|
|
- private function detect_manifest_encoding(& $xml) {
|
|
|
-
|
|
|
+ private function detect_manifest_encoding(& $xml)
|
|
|
+ {
|
|
|
if (api_is_valid_utf8($xml)) {
|
|
|
return 'UTF-8';
|
|
|
}
|
|
@@ -258,18 +274,21 @@ class scorm extends learnpath
|
|
|
if (empty($test_string)) {
|
|
|
$test_string = $xml;
|
|
|
}
|
|
|
- return api_detect_encoding($test_string);
|
|
|
|
|
|
+ return api_detect_encoding($test_string);
|
|
|
}
|
|
|
|
|
|
|
|
|
* Import the scorm object (as a result from the parse_manifest function) into the database structure
|
|
|
- * @param string Unique course code
|
|
|
- * @return bool Returns -1 on error
|
|
|
+ * @param string $course_code
|
|
|
+ * @param int $use_max_score
|
|
|
+ * @return bool Returns -1 on error
|
|
|
*/
|
|
|
- function import_manifest($course_code, $use_max_score = 1)
|
|
|
+ public function import_manifest($course_code, $use_max_score = 1)
|
|
|
{
|
|
|
- if ($this->debug > 0) { error_log('New LP - Entered import_manifest('.$course_code.')', 0); }
|
|
|
+ if ($this->debug > 0) {
|
|
|
+ error_log('New LP - Entered import_manifest('.$course_code.')', 0);
|
|
|
+ }
|
|
|
$course_info = api_get_course_info($course_code);
|
|
|
$course_id = $course_info['real_id'];
|
|
|
|
|
@@ -282,7 +301,7 @@ class scorm extends learnpath
|
|
|
$is_session = api_get_session_id();
|
|
|
$is_session != 0 ? $session_id = $is_session : $session_id = 0;
|
|
|
|
|
|
- $oOrganization =& $this->organizations[$id];
|
|
|
+ $oOrganization = & $this->organizations[$id];
|
|
|
|
|
|
|
|
|
|
|
@@ -382,17 +401,14 @@ class scorm extends learnpath
|
|
|
$prereq = Database::escape_string($item['prerequisites']);
|
|
|
|
|
|
$sql_item = "INSERT INTO $new_lp_item (c_id, lp_id,item_type,ref,title, path,min_score,max_score, $field_add parent_item_id,previous_item_id,next_item_id, prerequisite,display_order,launch_data, parameters)
|
|
|
- VALUES ($course_id, $lp_id, '$type','$identifier', '$title', '$path' , 0, $max_score, $value_add $parent, $previous, 0, " .
|
|
|
- "'$prereq', ".$item['rel_order'] .", '".$item['datafromlms']."'," .
|
|
|
- "'".$item['parameters']."'" .
|
|
|
- ")";
|
|
|
+ VALUES ($course_id, $lp_id, '$type', '$identifier', '$title', '$path' , 0, $max_score, $value_add $parent, $previous, 0, '$prereq', ".$item['rel_order'] .", '".$item['datafromlms']."', '".$item['parameters']."' )";
|
|
|
|
|
|
- $res_item = Database::query($sql_item);
|
|
|
+ Database::query($sql_item);
|
|
|
if ($this->debug > 1) { error_log('New LP - In import_manifest(), inserting item : '.$sql_item.' : '.Database::error(), 0); }
|
|
|
$item_id = Database::insert_id();
|
|
|
|
|
|
$upd = "UPDATE $new_lp_item SET next_item_id = $item_id WHERE c_id = $course_id AND id = $previous";
|
|
|
- $upd_res = Database::query($upd);
|
|
|
+ Database::query($upd);
|
|
|
|
|
|
$previous = $item_id;
|
|
|
|
|
@@ -456,7 +472,7 @@ class scorm extends learnpath
|
|
|
* @param string Current path (optional)
|
|
|
* @return string Absolute path to the imsmanifest.xml file or empty string on error
|
|
|
*/
|
|
|
- function import_local_package($file_path, $current_dir = '')
|
|
|
+ public function import_local_package($file_path, $current_dir = '')
|
|
|
{
|
|
|
|
|
|
$file_info = array();
|
|
@@ -468,10 +484,10 @@ class scorm extends learnpath
|
|
|
|
|
|
|
|
|
* Imports a zip file into the Chamilo structure
|
|
|
- * @param string Zip file info as given by $_FILES['userFile']
|
|
|
- * @return string Absolute path to the imsmanifest.xml file or empty string on error
|
|
|
+ * @param string $zip_file_info Zip file info as given by $_FILES['userFile']
|
|
|
+ * @return string $current_dir Absolute path to the imsmanifest.xml file or empty string on error
|
|
|
*/
|
|
|
- function import_package($zip_file_info, $current_dir = '')
|
|
|
+ public function import_package($zip_file_info, $current_dir = '')
|
|
|
{
|
|
|
if ($this->debug > 0) { error_log('In scorm::import_package('.print_r($zip_file_info,true).',"'.$current_dir.'") method', 0); }
|
|
|
|
|
@@ -659,7 +675,8 @@ class scorm extends learnpath
|
|
|
* Sets the proximity setting in the database
|
|
|
* @param string Proximity setting
|
|
|
*/
|
|
|
- function set_proximity($proxy = '') {
|
|
|
+ public function set_proximity($proxy = '')
|
|
|
+ {
|
|
|
$course_id = api_get_course_int_id();
|
|
|
if ($this->debug > 0) { error_log('In scorm::set_proximity('.$proxy.') method', 0); }
|
|
|
$lp = $this->get_id();
|
|
@@ -677,7 +694,8 @@ class scorm extends learnpath
|
|
|
* Sets the theme setting in the database
|
|
|
* @param string theme setting
|
|
|
*/
|
|
|
- function set_theme($theme = '') {
|
|
|
+ public function set_theme($theme = '')
|
|
|
+ {
|
|
|
$course_id = api_get_course_int_id();
|
|
|
if ($this->debug > 0) { error_log('In scorm::set_theme('.$theme.') method', 0); }
|
|
|
$lp = $this->get_id();
|
|
@@ -695,7 +713,8 @@ class scorm extends learnpath
|
|
|
* Sets the image setting in the database
|
|
|
* @param string preview_image setting
|
|
|
*/
|
|
|
- function set_preview_image($preview_image = '') {
|
|
|
+ public function set_preview_image($preview_image = '')
|
|
|
+ {
|
|
|
$course_id = api_get_course_int_id();
|
|
|
if ($this->debug > 0) { error_log('In scorm::set_theme('.$preview_image.') method', 0); }
|
|
|
$lp = $this->get_id();
|
|
@@ -713,7 +732,8 @@ class scorm extends learnpath
|
|
|
* Sets the author setting in the database
|
|
|
* @param string preview_image setting
|
|
|
*/
|
|
|
- function set_author($author = '') {
|
|
|
+ public function set_author($author = '')
|
|
|
+ {
|
|
|
$course_id = api_get_course_int_id();
|
|
|
if ($this->debug > 0) { error_log('In scorm::set_author('.$author.') method', 0); }
|
|
|
$lp = $this->get_id();
|
|
@@ -731,7 +751,8 @@ class scorm extends learnpath
|
|
|
* Sets the content maker setting in the database
|
|
|
* @param string Proximity setting
|
|
|
*/
|
|
|
- function set_maker($maker = '') {
|
|
|
+ public function set_maker($maker = '')
|
|
|
+ {
|
|
|
$course_id = api_get_course_int_id();
|
|
|
if ($this->debug > 0) { error_log('In scorm::set_maker method('.$maker.')', 0); }
|
|
|
$lp = $this->get_id();
|
|
@@ -749,7 +770,8 @@ class scorm extends learnpath
|
|
|
* Exports the current SCORM object's files as a zip. Excerpts taken from learnpath_functions.inc.php::exportpath()
|
|
|
* @param integer Learnpath ID (optional, taken from object context if not defined)
|
|
|
*/
|
|
|
- function export_zip($lp_id = null) {
|
|
|
+ public function export_zip($lp_id = null)
|
|
|
+ {
|
|
|
if ($this->debug > 0) { error_log('In scorm::export_zip method('.$lp_id.')', 0); }
|
|
|
if (empty($lp_id)) {
|
|
|
if (!is_object($this)) {
|
|
@@ -815,7 +837,8 @@ class scorm extends learnpath
|
|
|
* @param string Resource ID as used in resource array
|
|
|
* @return string The resource's path as declared in imsmanifest.xml
|
|
|
*/
|
|
|
- function get_res_path($id) {
|
|
|
+ public function get_res_path($id)
|
|
|
+ {
|
|
|
if ($this->debug > 0) { error_log('In scorm::get_res_path('.$id.') method', 0); }
|
|
|
$path = '';
|
|
|
if (isset($this->resources[$id])) {
|
|
@@ -830,7 +853,8 @@ class scorm extends learnpath
|
|
|
* @param string Resource ID as used in resource array
|
|
|
* @return string The resource's type as declared in imsmanifest.xml
|
|
|
*/
|
|
|
- function get_res_type($id) {
|
|
|
+ public function get_res_type($id)
|
|
|
+ {
|
|
|
if ($this->debug > 0) { error_log('In scorm::get_res_type('.$id.') method', 0); }
|
|
|
$type = '';
|
|
|
if (isset($this->resources[$id])) {
|
|
@@ -847,7 +871,8 @@ class scorm extends learnpath
|
|
|
* Gets the default organisation's title
|
|
|
* @return string The organization's title
|
|
|
*/
|
|
|
- function get_title() {
|
|
|
+ public function get_title()
|
|
|
+ {
|
|
|
if ($this->debug > 0) { error_log('In scorm::get_title() method', 0); }
|
|
|
$title = '';
|
|
|
if (isset($this->manifest['organizations']['default'])) {
|
|
@@ -872,7 +897,8 @@ class scorm extends learnpath
|
|
|
* @return integer New LP ID or false on failure
|
|
|
* TODO @TODO Implement imsmanifest_path parameter
|
|
|
*/
|
|
|
- function reimport_manifest($course, $lp_id = null, $imsmanifest_path = '') {
|
|
|
+ public function reimport_manifest($course, $lp_id = null, $imsmanifest_path = '')
|
|
|
+ {
|
|
|
if ($this->debug > 0) { error_log('In scorm::reimport_manifest() method', 0); }
|
|
|
global $_course;
|
|
|
|