From fd509e1ed050f911e1acd753f570bccf96a61cf4 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Sun, 10 Dec 2006 20:50:34 +0100 Subject: [PATCH] [svn r10437] Added handling of the parameters attribute in imsmanifest element --- main/newscorm/learnpath.class.php | 9 ++++++++- main/newscorm/scorm.class.php | 6 ++++-- main/newscorm/scormItem.class.php | 14 +++++++------- main/newscorm/scorm_update_db.php | 3 ++- main/newscorm/scorm_update_db_alter.php | 11 +++++++++++ 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index 10c5c7b809..b4f89f5b06 100644 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -2769,7 +2769,7 @@ class learnpath { $lp_pref = Database::get_course_table_prefix(); $lp_table = $lp_db.'.'.$lp_pref.'lp'; $lp_item_table = $lp_db.'.'.$lp_pref.'lp_item'; - $sel = "SELECT l.lp_type as ltype, l.path as lpath, li.item_type as litype, li.path as lipath " . + $sel = "SELECT l.lp_type as ltype, l.path as lpath, li.item_type as litype, li.path as lipath, li.parameters as liparams " . "FROM $lp_table l, $lp_item_table li WHERE li.id = $item_id AND li.lp_id = l.id"; if($this->debug>2){error_log('New LP - In learnpath::get_link() - selecting item '.$sel,0);} $res = api_sql_query($sel); @@ -2781,6 +2781,11 @@ class learnpath { $lp_path = $row['lpath']; $lp_item_type = $row['litype']; $lp_item_path = $row['lipath']; + $lp_item_params = $row['liparams']; + //add ? if none - left commented to give freedom to scorm implementation + //if(substr($lp_item_params,0,1)!='?'){ + // $lp_item_params = '?'.$lp_item_params; + //} if($type == 'http'){ $course_path = api_get_path(WEB_COURSE_PATH).api_get_course_path(); //web path }else{ @@ -2826,6 +2831,8 @@ class learnpath { //prerequisites did not match //$file = 'blank.php'; //} + //We want to use parameters if they were defined in the imsmanifest + $file.= $lp_item_params; }else{ $file = 'lp_content.php?type=dir'; } diff --git a/main/newscorm/scorm.class.php b/main/newscorm/scorm.class.php index b629875e3d..d0743ca82b 100644 --- a/main/newscorm/scorm.class.php +++ b/main/newscorm/scorm.class.php @@ -438,12 +438,14 @@ class scorm extends learnpath { "(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) " . + "prerequisite,display_order,launch_data," . + "parameters) " . "VALUES " . "($lp_id, '$type','".$identifier."','".$title."'," . "'$path',0,100, $value_add" . "$parent, $previous, 0, " . - "'$prereq', ".$item['rel_order'] . + "'$prereq', ".$item['rel_order'] .", '".$item['datafromlms']."'," . + "'".$item['parameters']."'" . ")"; $res_item = api_sql_query($sql_item); if($this->debug>1){error_log('New LP - In import_manifest(), inserting item : '.$sql_item.' : '.mysql_error(),0);} diff --git a/main/newscorm/scormItem.class.php b/main/newscorm/scormItem.class.php index 96f4c632a3..344861aae0 100644 --- a/main/newscorm/scormItem.class.php +++ b/main/newscorm/scormItem.class.php @@ -19,7 +19,7 @@ class scormItem extends learnpathItem{ //var $prerequisites = ''; - defined in learnpathItem.class.php var $maxtimeallowed = '00:00:00'; var $timelimitaction = ''; - var $datafromims = ''; + var $datafromlms = ''; var $masteryscore = ''; var $scorm_contact; @@ -80,11 +80,11 @@ class scormItem extends learnpathItem{ $this->timelimitaction = $tmp_children[0]->content; } break; - case 'datafromims': + case 'datafromlms': $tmp_children = $child->children(); if(count($tmp_children)==1 and $tmp_children[0]->content!='' ) { - $this->datafromims = $tmp_children[0]->content; + $this->datafromlms = $tmp_children[0]->content; } break; case 'masteryscore': @@ -186,13 +186,13 @@ class scormItem extends learnpathItem{ $this->timelimitaction = $child->firstChild->nodeValue; } break; - case 'datafromims': - case 'adlcp:datafromims': + case 'datafromlms': + case 'adlcp:datafromlms': $tmp_children = $child->childNodes; //if(count($tmp_children)==1 and $tmp_children[0]->textContent!='' ) if($tmp_children->length==1 and $child->firstChild->nodeValue!='' ) { - $this->datafromims = $child->firstChild->nodeValue; + $this->datafromlms = $child->firstChild->nodeValue; } break; case 'masteryscore': @@ -262,7 +262,7 @@ class scormItem extends learnpathItem{ { $list[] = array( 'abs_order' => $abs_order, - 'datafromims' => $this->datafromims, + 'datafromlms' => $this->datafromlms, 'identifier' => $this->identifier, 'identifierref' => $this->identifierref, 'isvisible' => $this->isvisible, diff --git a/main/newscorm/scorm_update_db.php b/main/newscorm/scorm_update_db.php index db9aef9445..91e0aa209d 100644 --- a/main/newscorm/scorm_update_db.php +++ b/main/newscorm/scorm_update_db.php @@ -62,7 +62,8 @@ $create_lp_item = "CREATE TABLE IF NOT EXISTS XXX_$new_lp_item (" . "next_item_id int unsigned not null default 0," . //the item after this one in the sequential learning order (MySQL id) "display_order int unsigned not null default 0," . //this is needed for ordering items under the same parent (previous_item_id doesn't give correct order after reordering) "prerequisite char(64) null," . //prerequisites in AICC scripting language as defined in the SCORM norm (allow logical operators) - "launch_data text not null default ''" . //data from imsmanifest + "launch_data text not null default '', " . //data from imsmanifest + "parameters text not null default ''" . //data from imsmanifest ")"; //table replacing the learnpath_user table $new_lp_item_view = 'lp_item_view'; diff --git a/main/newscorm/scorm_update_db_alter.php b/main/newscorm/scorm_update_db_alter.php index 1008e0da99..b7a2d1c7fb 100644 --- a/main/newscorm/scorm_update_db_alter.php +++ b/main/newscorm/scorm_update_db_alter.php @@ -31,6 +31,11 @@ $alter_lp_view = "ALTER TABLE XXX_$new_lp_view ADD COLUMN " . "progress int unsigned default 0" . ""; //table replacing the learnpath_user table +$new_lp_item = 'lp_item'; +$alter_lp_item = "ALTER TABLE XXX_$new_lp_item ADD COLUMN " . + "parameters text null default ''" . + ""; +//table replacing the learnpath_user table $new_lp_item_view = 'lp_item_view'; $alter_lp_item_view = "ALTER TABLE XXX_$new_lp_item_view ADD COLUMN " . "lesson_location text null default ''" . @@ -98,6 +103,12 @@ while ($row = Database::fetch_array($res)) echo "$create_table
\n"; api_sql_query($create_table); } + if (mysql_query("SELECT parameters FROM $new_lp_item")==false) + { + $create_table = str_replace('XXX_',$dbname,$alter_lp_item); + echo "$create_table
\n"; + api_sql_query($create_table); + } if (mysql_query("SELECT lesson_location FROM $new_lp_item_view")==false) { $create_table = str_replace('XXX_',$dbname,$alter_lp_item_view);