From e1e6a51f41b966ea5d4eec37a2aa48145e2fe006 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Tue, 1 Dec 2009 21:46:16 -0500 Subject: [PATCH] General fixes and improvements --- main/newscorm/lp_ajax_initialize.php | 10 +-- main/newscorm/scorm_api.php | 101 +++++++++++++-------------- 2 files changed, 55 insertions(+), 56 deletions(-) diff --git a/main/newscorm/lp_ajax_initialize.php b/main/newscorm/lp_ajax_initialize.php index 4ce5891dee..d7b1bbb0dc 100644 --- a/main/newscorm/lp_ajax_initialize.php +++ b/main/newscorm/lp_ajax_initialize.php @@ -120,7 +120,7 @@ function initialize_item($lp_id,$user_id,$view_id,$next_item) "olms.G_lastError = 0;" . "olms.G_LastErrorMessage = 'No error';" ; /* - * and re-initialise the rest + * and re-initialise the rest (proper to the LMS) * -lms_lp_id * -lms_item_id * -lms_old_item_id @@ -146,12 +146,12 @@ function initialize_item($lp_id,$user_id,$view_id,$next_item) $return .= "olms.lms_lp_id=".$lp_id.";" . - "olms.lms_item_id=".$new_item_id.";" . + "olms.lms_item_id=".$next_item.";" . "olms.lms_old_item_id=0;" . "olms.lms_initialized=0;" . "olms.lms_view_id=".$view_id.";" . "olms.lms_user_id=".$user_id.";" . - "olms.next_item=".$new_item_id.";" . //this one is very important to replace possible literal strings + "olms.next_item=".$next_item.";" . //this one is very important to replace possible literal strings "olms.lms_next_item=".$mynext.";" . "olms.lms_previous_item=".$myprevious.";" . "olms.lms_item_type = '".$myitemtype."';" . @@ -166,8 +166,8 @@ function initialize_item($lp_id,$user_id,$view_id,$next_item) $mylp->set_error_msg(''); $mylp->prerequisites_match(); //check the prerequisites are all complete if($debug>1){error_log('Prereq_match() returned '.htmlentities($mylp->error),0);} - $_SESSION['scorm_item_id'] = $new_item_id;//Save the new item ID for the exercise tool to use - $_SESSION['lpobject'] = serialize($mylp); + //$_SESSION['scorm_item_id'] = $new_item_id;//Save the new item ID for the exercise tool to use + //$_SESSION['lpobject'] = serialize($mylp); return $return; } echo initialize_item($_POST['lid'],$_POST['uid'],$_POST['vid'],$_POST['iid']); \ No newline at end of file diff --git a/main/newscorm/scorm_api.php b/main/newscorm/scorm_api.php index c2884ad826..dcf2a26646 100755 --- a/main/newscorm/scorm_api.php +++ b/main/newscorm/scorm_api.php @@ -233,26 +233,9 @@ function LMSInitialize() { //this is the initialize function of all APIobjects */ olms.G_LastError = G_NoError ; olms.G_LastErrorMessage = 'No error'; - //reinit to list - reinit_updatable_vars_list(); - // Get LMS values for this item - params = { - 'lid': olms.lms_lp_id, - 'uid': olms.lms_user_id, - 'vid': olms.lms_view_id, - 'iid': olms.lms_item_id - }; - $.ajax({ - type: "POST", - url: "lp_ajax_initialize.php", - data: "", - success: function(tmp_data) { - $("#media").html(tmp_data); - } - }); + olms.lms_initialized=0; - dummy = olms.lesson_location; // if there are more parameters than "" if (arguments.length>1) { olms.G_LastError = G_InvalidArgumentError; @@ -260,6 +243,22 @@ function LMSInitialize() { //this is the initialize function of all APIobjects logit_scorm('Error '+ G_InvalidArgumentError + G_InvalidArgumentErrorMessage, 0); return('false'); } else { + //reinit the list of modified variables + reinit_updatable_vars_list(); + // Get LMS values for this item + params = { + 'lid': olms.lms_lp_id, + 'uid': olms.lms_user_id, + 'vid': olms.lms_view_id, + 'iid': olms.lms_item_id + }; + $.ajax({ + type: "POST", + url: "lp_ajax_initialize.php", + data: params, + dataType: 'script', + async: false + }); // log a more complete object dump when initializing, so we know what data hasn't been cleaned var log = '
item : '+ olms.lms_item_id + '
score : '+ olms.score @@ -346,7 +345,7 @@ function LMSGetValue(param) olms.G_LastError = G_ElementIsWriteOnly; }else if(param == 'cmi.core.lesson_status'){ // ---- cmi.core.lesson_status - if(lesson_status != '') { + if(olms.lesson_status != '') { result=olms.lesson_status; } else { //result='not attempted'; @@ -842,30 +841,30 @@ function Commit(val) { * @param string */ function LMSFinish(val) { - olms.G_LastError = G_NoError ; - olms.G_LastErrorMessage = 'No error'; - // if olms.commit == false, then the SCORM didn't ask for a commit, so we - // should at least report that - if (( olms.commit == false )) { - logit_scorm('LMSFinish() (no LMSCommit())',1); + olms.G_LastError = G_NoError ; + olms.G_LastErrorMessage = 'No error'; + // if olms.commit == false, then the SCORM didn't ask for a commit, so we + // should at least report that + if (( olms.commit == false )) { + logit_scorm('LMSFinish() (no LMSCommit())',1); - } + } - //if ( olms.commit == true ) { - logit_scorm('LMSFinish() called',1); - savedata('finish'); - olms.commit = false; - //} + //if ( olms.commit == true ) { + logit_scorm('LMSFinish() called',1); + savedata('finish'); + olms.commit = false; + //} - //reinit to list - reinit_updatable_vars_list() - return('true'); + //reinit the list of modified variables + reinit_updatable_vars_list() + return('true'); } /** * Twin sister of LMSFinish(). Only provided for backwards compatibility. */ function Finish(val) { - return LMSFinish(val); + return LMSFinish(val); } /** * Returns the last error code as a string @@ -1461,35 +1460,35 @@ function xajax_save_item_scorm(lms_lp_id, lms_user_id, lms_view_id, lms_item_id) var is_interactions='false'; var params=''; params += 'lid='+lms_lp_id+'&uid='+lms_user_id+'&vid='+lms_view_id+'&iid='+lms_item_id; - var my_get_value_scorm=new Array(); - my_get_value_scorm=process_scorm_values(); + var my_scorm_values=new Array(); + my_scorm_values=process_scorm_values(); - for (k=0;k