Browse Source

Minor - format code

Julio Montoya 11 years ago
parent
commit
45c6d9e537
2 changed files with 33 additions and 24 deletions
  1. 9 5
      main/newscorm/learnpathItem.class.php
  2. 24 19
      main/newscorm/lp_ajax_save_item.php

+ 9 - 5
main/newscorm/learnpathItem.class.php

@@ -11,7 +11,8 @@
  * lp_item defines items belonging to a learnpath. Each item has a name, a score, a use time and additional
  * information that enables tracking a user's progress in a learning path
  */
-class learnpathItem {
+class learnpathItem
+{
 	public $attempt_id; // Also called "objectives" SCORM-wise.
 	public $audio; // The path to an audio file (stored in document/audio/).
 	public $children = array(); // Contains the ids of children items.
@@ -1844,7 +1845,8 @@ class learnpathItem {
 	 * @return  void
 	 * @todo //todo insert into lp_item_view if lp_view not exists
 	 */
-	public function set_lp_view($lp_view_id, $course_id = null) {
+	public function set_lp_view($lp_view_id, $course_id = null)
+    {
 	    if (empty($course_id)) {
 	        $course_id = api_get_course_int_id();
 	    } else {
@@ -1935,7 +1937,8 @@ class learnpathItem {
 	 * @param	float	Score
 	 * @return	boolean	True on success, false otherwise
 	 */
-	public function set_score($score) {
+	public function set_score($score)
+    {
         //$possible_status = array('not attempted','incomplete','completed','passed','failed','browsed');
         $debug = self::debug;
    		if ($debug > 0) { error_log('learnpathItem::set_score('.$score.')', 0); }
@@ -1944,7 +1947,7 @@ class learnpathItem {
    			$master = $this->get_mastery_score();
    			$current_status = $this->get_status(false);
 
-            //Fixes bug when SCORM doesn't send a mastery score even if they sent a score!
+            // Fixes bug when SCORM doesn't send a mastery score even if they sent a score!
             if ($master == -1) {
                 $master = $this->max_score;
             }
@@ -1989,7 +1992,8 @@ class learnpathItem {
 	 * @param	string	Status - must be one of the values defined in $this->possible_status
 	 * @return	boolean	True on success, false on error
 	 */
-	public function set_status($status) {
+	public function set_status($status)
+    {
    		if (self::debug > 0) { error_log('learnpathItem::set_status('.$status.')', 0); }
 	 	$found = false;
 	 	foreach ($this->possible_status  as $possible) {

+ 24 - 19
main/newscorm/lp_ajax_save_item.php

@@ -44,7 +44,8 @@ require_once 'aiccItem.class.php';
  * @param   array   Interactions array
  * @param   string  Core exit SCORM string
  */
-function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1, $min = -1, $status = '', $time = 0, $suspend = '', $location = '', $interactions = array(), $core_exit = 'none') {
+function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1, $min = -1, $status = '', $time = 0, $suspend = '', $location = '', $interactions = array(), $core_exit = 'none')
+{
     $return = null;
 
     if ($debug > 0) {
@@ -82,6 +83,8 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
     }
 
     $prereq_check = $mylp->prerequisites_match($item_id);
+
+    /** @var learnpathItem $mylpi */
     $mylpi = $mylp->items[$item_id];
 
     if (empty($mylpi)) {
@@ -91,14 +94,14 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
         return false;
     }
 
-    //This functions sets the $this->db_item_view_id variable needed in get_status() see BT#5069
+    // This functions sets the $this->db_item_view_id variable needed in get_status() see BT#5069
     $mylpi->set_lp_view($view_id);
 
     if ($prereq_check === true) {
         if ($debug > 1) { error_log('Prereq are check'); }
 
         // Launch the prerequisites check and set error if needed
-        if (isset($max) && $max != -1)  {
+        if (isset($max) && $max != -1) {
             $mylpi->max_score = $max;
             $mylpi->set_max_score($max);
             if ($debug > 1) { error_log("Setting max_score: $max"); }
@@ -109,7 +112,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
             if ($debug > 1) { error_log("Setting min_score: $min"); }
         }
 
-        //set_score function already saves the status
+        // set_score function already saves the status
         if (isset($score) && $score != -1) {
             if ($debug > 1) { error_log('Calling set_score('.$score.')', 0); }
             if ($debug > 1) { error_log('set_score changes the status to failed/passed if mastery score is provided', 0); }
@@ -118,7 +121,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
         } else {
             if ($debug > 1) { error_log("Score not updated"); }
 
-            //Default behaviour
+            // Default behaviour
             if (isset($status) && $status != '' && $status != 'undefined') {
                 if ($debug > 1) { error_log('Calling set_status('.$status.')', 0); }
                 $mylpi->set_status($status);
@@ -266,6 +269,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
 
     Session::write('lpobject', serialize($mylp));
     if ($debug > 0) { error_log('---------------- lp_ajax_save_item.php : save_item end ----- '); }
+
     return $return;
 }
 
@@ -274,7 +278,7 @@ if (isset($_REQUEST['interact'])) {
     if (is_array($_REQUEST['interact'])) {
         foreach ($_REQUEST['interact'] as $idx => $interac) {
             $interactions[$idx] = split(',', substr($interac, 1, -1));
-            if(!isset($interactions[$idx][7])){ // Make sure there are 7 elements.
+            if (!isset($interactions[$idx][7])) { // Make sure there are 7 elements.
                 $interactions[$idx][7] = '';
             }
         }
@@ -282,16 +286,17 @@ if (isset($_REQUEST['interact'])) {
 }
 
 echo save_item(
-            (!empty($_REQUEST['lid'])?$_REQUEST['lid']:null),
-            (!empty($_REQUEST['uid'])?$_REQUEST['uid']:null),
-            (!empty($_REQUEST['vid'])?$_REQUEST['vid']:null),
-            (!empty($_REQUEST['iid'])?$_REQUEST['iid']:null),
-            (!empty($_REQUEST['s'])?$_REQUEST['s']:null),
-            (!empty($_REQUEST['max'])?$_REQUEST['max']:null),
-            (!empty($_REQUEST['min'])?$_REQUEST['min']:null),
-            (!empty($_REQUEST['status'])?$_REQUEST['status']:null),
-            (!empty($_REQUEST['t'])?$_REQUEST['t']:null),
-            (!empty($_REQUEST['suspend'])?$_REQUEST['suspend']:null),
-            (!empty($_REQUEST['loc'])?$_REQUEST['loc']:null),
-            $interactions,
-            (!empty($_REQUEST['core_exit'])?$_REQUEST['core_exit']:''));
+    (!empty($_REQUEST['lid'])?$_REQUEST['lid']:null),
+    (!empty($_REQUEST['uid'])?$_REQUEST['uid']:null),
+    (!empty($_REQUEST['vid'])?$_REQUEST['vid']:null),
+    (!empty($_REQUEST['iid'])?$_REQUEST['iid']:null),
+    (!empty($_REQUEST['s'])?$_REQUEST['s']:null),
+    (!empty($_REQUEST['max'])?$_REQUEST['max']:null),
+    (!empty($_REQUEST['min'])?$_REQUEST['min']:null),
+    (!empty($_REQUEST['status'])?$_REQUEST['status']:null),
+    (!empty($_REQUEST['t'])?$_REQUEST['t']:null),
+    (!empty($_REQUEST['suspend'])?$_REQUEST['suspend']:null),
+    (!empty($_REQUEST['loc'])?$_REQUEST['loc']:null),
+    $interactions,
+    (!empty($_REQUEST['core_exit'])?$_REQUEST['core_exit']:'')
+);