Browse Source

Fix for SCORM API initialisation, to fix objectives logging issues.

Jean-Karim Bockstael 14 years ago
parent
commit
3b0d5ad8b3
1 changed files with 17 additions and 3 deletions
  1. 17 3
      main/newscorm/lp_ajax_initialize.php

+ 17 - 3
main/newscorm/lp_ajax_initialize.php

@@ -104,6 +104,19 @@ function initialize_item($lp_id,$user_id,$view_id,$next_item)
     if (!empty($myistring)) {
         $myistring = substr($myistring,1);
     }
+	// Obtention des donnees d'objectifs
+	$phpobjectives = array();
+	$mycoursedb = Database::get_course_table(TABLE_LP_IV_OBJECTIVE);
+	$mylp_iv_id = $mylpi->db_item_view_id;
+	$sql = "SELECT objective_id, status, score_raw, score_max, score_min
+		FROM ".$mycoursedb."
+		WHERE lp_iv_id = ".$mylp_iv_id."
+		ORDER BY id ASC;";
+	$res = mysql_query($sql);
+	while ($row = mysql_fetch_row($res)) {
+		$phpobjectives[] = $row;	
+	}
+	$myobjectives = json_encode($phpobjectives);
     $return .=
             "olms.score=".$myscore.";" .
             "olms.max=".$mymax.";" .
@@ -117,8 +130,9 @@ function initialize_item($lp_id,$user_id,$view_id,$next_item)
             "olms.max_time_allowed = '".$mymax_time_allowed."';" .
             "olms.launch_data = '".$mylaunch_data."';" .
             "olms.interactions = new Array(".$myistring.");" .
-            "olms.item_objectives = new Array();" .
-            "olms.G_lastError = 0;" .
+            //"olms.item_objectives = new Array();" .
+            "olms.item_objectives = ".$myobjectives.";" .
+	    "olms.G_lastError = 0;" .
             "olms.G_LastErrorMessage = 'No error';" ;
     /*
      * and re-initialise the rest (proper to the LMS)
@@ -171,4 +185,4 @@ function initialize_item($lp_id,$user_id,$view_id,$next_item)
     //$_SESSION['lpobject'] = serialize($mylp);
     return $return;
 }
-echo initialize_item($_POST['lid'],$_POST['uid'],$_POST['vid'],$_POST['iid']);
+echo initialize_item($_POST['lid'],$_POST['uid'],$_POST['vid'],$_POST['iid']);