Эх сурвалжийг харах

Minor - format code, removing var_dumps

Julio Montoya 10 жил өмнө
parent
commit
36e541add2

+ 0 - 4
main/inc/lib/sessionmanager.lib.php

@@ -1754,11 +1754,7 @@ class SessionManager
     ) {
         $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
         $tableSessionCourse = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
-
         $sessionId = intval($sessionId);
-        if ($sessionId == 118 && $courseInfo['code'] == 'C1') {
-            var_dump($userList);
-        }
 
         if (empty($sessionId) || empty($userList) || empty($courseInfo)) {
             return false;

+ 4 - 4
main/inc/lib/skill.lib.php

@@ -28,7 +28,7 @@ class SkillProfile extends Model
         $profiles = Database::store_result($result, 'ASSOC');
         return $profiles;
     }
-    
+
     /**
     * This function is for editing profile info from profile_id.
     * @param int $profileId
@@ -113,7 +113,7 @@ class SkillRelProfile extends Model
     */
 
     public function getProfileInfo($profileId)
-    { 
+    {
         $sql = "SELECT * FROM $this->table p INNER JOIN $this->tableProfile pr ON(pr.id = p.profile_id) WHERE p.profile_id = ".intval($profileId);
         $result = Database::query($sql);
         $profileData = Database::fetch_array($result, 'ASSOC');
@@ -299,7 +299,7 @@ class SkillRelGradebook extends Model
                 }
             }
         }
-        //var_dump($gradebooks_to_add, $gradebooks_to_remove);
+
         if (!empty($gradebooks_to_remove)) {
             foreach ($gradebooks_to_remove as $id) {
                 $this->delete($id);
@@ -853,7 +853,7 @@ class Skill extends Model
                 );
             }
         }
-        //var_dump($simple_tree[0]['children']);
+
         return json_encode($simple_tree[0]['children']);
     }
 

+ 79 - 73
main/inc/lib/skill.visualizer.lib.php

@@ -5,179 +5,185 @@
  * @package chamilo.admin
  * @todo lib not use. Only the class variables not the functions
  */
-
- class SkillVisualizer {
-    
+class SkillVisualizer
+{
     public $block_size = 120; //see CSS window class
     public $canvas_x   = 1024;
     public $canvas_y   = 800;
-    
+
     public $offset_x   = 0;
     public $offset_y   = 50;
-    
+
     public $space_between_blocks_x = 100;
     public $space_between_blocks_y = 150;
-    
+
     public $center_x = null;
-   
+
     private $html    = '';
     private $type    = 'read';
     private $js      = '';
-       
-    function __construct($skills, $type = 'read') {
-        $this->skills   = $skills;       
-        $this->type     = $type; 
-        $this->center_x = intval($offset_x + $this->canvas_x/2 - $this->block_size/2); 
+
+    function __construct($skills, $type = 'read')
+    {
+        $this->skills   = $skills;
+        $this->type     = $type;
+        $this->center_x = intval($offset_x + $this->canvas_x/2 - $this->block_size/2);
     }
-    
-    function prepare_skill_box($skill, $position, $class) {
+
+    function prepare_skill_box($skill, $position, $class)
+    {
         $block_id = $skill['id'];
-        
+
         $extra_class = 'third_window';
         if ($skill['parent_id'] == 0) {
             $extra_class = 'second_window';
         }
-        
+
         $this->html .= '<div id="block_'.$block_id.'" class = "open_block window '.$extra_class.'  '.$class.'" style = "top:' . $position['y'] . 'px; left:' . $position['x'] . 'px;">';
         /*$gradebook_string = '';
         if (!empty($skill['gradebooks'])) {
             foreach ($skill['gradebooks'] as $gradebook) {
                 //uncomment this to show the gradebook tags
-                $gradebook_string .= Display::span($gradebook['name'], array('class'=>'label_tag gradebook','style'=>'width:50px')).'<br />';    
+                $gradebook_string .= Display::span($gradebook['name'], array('class'=>'label_tag gradebook','style'=>'width:50px')).'<br />';
             }
-        } */       
+        } */
         $content =  $skill['name'];
         $content .= '<div class="btn-group">';
         $content .= Display::url(get_lang('Edit'), '#', array('id'=>'edit_block_'.$block_id, 'class'=>'edit_block btn'));
-        $content .= Display::url('+', '#', array('id'=>'edit_block_'.$block_id, 'class'=>'edit_block btn'));        
+        $content .= Display::url('+', '#', array('id'=>'edit_block_'.$block_id, 'class'=>'edit_block btn'));
         $content .= '</div>';
-        
+
         $this->html .= $content.' '.$gradebook_string;
-        
+
         if ($this->type == 'edit' && $skill['parent_id'] != 0) {
             //$this->html .= Display::url(Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL), '#', array('id'=>'edit_block_'.$block_id,'class'=>'edit_block'));
             //$this->html .= Display::url(Display::return_icon('add.png', get_lang('Add'), array(), ICON_SIZE_SMALL), '#', array('id'=>'edit_block_'.$block_id,'class'=>'edit_block'));
-            //$this->html .= Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), '#', array('id=>"edit_block_'.$block_id,'class'=>'edit_block'));            
+            //$this->html .= Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), '#', array('id=>"edit_block_'.$block_id,'class'=>'edit_block'));
             //$this->html .= Display::url(Display::return_icon('up.png', get_lang('Close'), array(), ICON_SIZE_SMALL), '#', array('id'=>'close_block_'.$block_id,'class'=>'close_block'));
-            
+
             //$this->html .= Display::url(Display::return_icon('down.png', get_lang('Open'), array(), ICON_SIZE_SMALL), '#', array('id'=>'open_block_'.$block_id,'class'=>'open_block'));
         }
-        $this->html .= '</div>';   
+        $this->html .= '</div>';
     }
-    
+
     /**
      * Adds a node using jplumb
      */
     private function add_item($skill, $position) {
         $block_id = $skill['id'];
-        $end_point = 'readEndpoint';        
-        $class = 'default_window';        
+        $end_point = 'readEndpoint';
+        $class = 'default_window';
         if ($this->type == 'edit') {
             $class = 'edit_window';
-            $end_point = 'editEndpoint';            
+            $end_point = 'editEndpoint';
         } else {
-            
-            if ($skill['done_by_user'] == 1) {                
+
+            if ($skill['done_by_user'] == 1) {
                 $class = 'done_window';
-                $end_point = 'doneEndpoint';                
+                $end_point = 'doneEndpoint';
             } else {
                 $end_point = 'defaultEndpoint';
             }
-        } 
+        }
         $this->prepare_skill_box($skill, $position, $class);
-        
+
         if ($skill['parent_id'] == 0) {
             return;
         }
         //default_arrow_color
-            
+
         $this->js .= 'var e'.$block_id.' = prepare("block_' . $block_id.'",  '.$end_point.');'."\n";
-        $this->js .= 'var e'.$skill['parent_id'].' = prepare("block_' . $skill['parent_id'].'",  '.$end_point.');'."\n";                        
+        $this->js .= 'var e'.$skill['parent_id'].' = prepare("block_' . $skill['parent_id'].'",  '.$end_point.');'."\n";
         $this->js .= 'jsPlumb.connect({source: e'.$block_id.', target:e'.$skill['parent_id'].'});'."\n";;
     }
-    
+
     /**
      * Displays the HTMl part of jplumb
      */
-    public function display_html() {                     
-        echo $this->return_html();        
+    public function display_html()
+    {
+        echo $this->return_html();
     }
-    
+
     /**
      * Displays the Javascript part of jplumb
      */
-    public function display_js() {
+    public function display_js()
+    {
         echo $this->return_js();
     }
-    
-    public function return_js() {
+
+    public function return_js()
+    {
         return $this->get_js();
     }
-    
-    public function return_html() {
-         if (empty($this->skills)) {
+
+    public function return_html()
+    {
+        if (empty($this->skills)) {
             return '';
         }
         $skill_count = sizeof($this->skills);
-        //$corner = 360 / $skill_count;   
+        //$corner = 360 / $skill_count;
         $count = 0;
-        
+
         $brothers = array();
-        
+
         foreach ($this->skills as &$skill) {
             if (!in_array($skill['parent_id'], array(0,1))) {
                 continue;
             }
-            $childs = isset($skill['children']) ? count($skill['children']) : 0 ;               
-              
+            $childs = isset($skill['children']) ? count($skill['children']) : 0 ;
+
             //$x = round($this->offsetX * sin(deg2rad($corner * $count)));
             //$y = round($this->offsetY * cos(deg2rad($corner * $count)));
-            
+
             /*if (isset($brothers[$skill['parent_id']])) {
                 $brothers[$skill['parent_id']] +=2;
             } else {
                 $brothers[$skill['parent_id']] = 1;
-            }*/            
-            $brother_count = $brothers[$skill['id']];            
+            }*/
+            $brother_count = $brothers[$skill['id']];
             $my_count = 0;
-            $parent_x = 0; 
-            if ($skill['parent_id'] == 0) {                
-                //$x = 130*$childs/2;     
+            $parent_x = 0;
+            if ($skill['parent_id'] == 0) {
+                //$x = 130*$childs/2;
                 //$x = $this->space_between_blocks_x*$childs/2;
                 $x = $this->canvas_x/2  - $this->block_size/2;
-            } else {                
+            } else {
                 $max = isset($this->skills[$skill['parent_id']]['children']) ? count($this->skills[$skill['parent_id']]['children']) : 0;
-                foreach($this->skills[$skill['parent_id']]['children'] as  $id => $sk) {                    
-                    if ($skill['id'] == $sk['id']) {                                                
+                foreach($this->skills[$skill['parent_id']]['children'] as  $id => $sk) {
+                    if ($skill['id'] == $sk['id']) {
                         break;
                     }
-                    $my_count++;                        
+                    $my_count++;
                 }
                 $parent_x = isset($this->skills[$skill['parent_id']]['x']) ? $this->skills[$skill['parent_id']]['x'] : 0;
                 //$x = $my_count*$this->space_between_blocks_x + $parent_x  + $this->block_size - ($this->space_between_blocks_x*$max/2) ;
                 $x = $my_count*$this->space_between_blocks_x + $parent_x  + $this->block_size - ($this->canvas_x/2 ) ;
             }
-                    
-            $y = $skill['level']*$this->space_between_blocks_y;   
-              
+
+            $y = $skill['level']*$this->space_between_blocks_y;
+
             $skill['x'] = $x;
             $skill['y'] = $y;
-            
-                 
-        //    var_dump($skill);                   
+
+
+            //    var_dump($skill);
             //$skill['description']  = "{$brothers[$skill['parent_id']]} $x - $y";
             //$skill['name']  =  $skill['name']."  |  $x = $my_count * 150  +  $parent_x - (150* $max/2) - 10*$childs ";
-            $this->add_item($skill, array('x' => $this->offset_x + $x, 'y' => $this->offset_y +$y));            
+            $this->add_item($skill, array('x' => $this->offset_x + $x, 'y' => $this->offset_y +$y));
         }
-        return $this->get_html();        
+        return $this->get_html();
     }
-    
 
-    private function get_html() {
+    private function get_html()
+    {
         return $this->html;
     }
-   
-    private function get_js() {
+
+    private function get_js()
+    {
         return $this->js;
     }
-}
+}

+ 0 - 1
main/inc/lib/usermanager.lib.php

@@ -4157,7 +4157,6 @@ class UserManager
         if ($getCount) {
             $result = Database::query($sql);
             $row = Database::fetch_array($result);
-            //var_dump($sql);
             return $row['count'];
         }
 

+ 3 - 0
main/inc/lib/userportal.lib.php

@@ -3,6 +3,9 @@
 
 use \ChamiloSession as Session;
 
+/**
+ * Class IndexManager
+ */
 class IndexManager
 {
     //An instance of the template engine

+ 0 - 1
main/mySpace/myStudents.php

@@ -383,7 +383,6 @@ if (!empty($student_id)) {
             array(),
             $session_id
         );
-        //var_dump($avg_student_score);
     }
 
     $avg_student_progress = round($avg_student_progress, 2);

+ 41 - 36
main/newscorm/learnpathItem.class.php

@@ -5,8 +5,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
- * @package    chamilo.learnpath
- * @author    Yannick Warnier <ywarnier@beeznest.org>
+ * @package chamilo.learnpath
+ * @author  Yannick Warnier <ywarnier@beeznest.org>
  */
 class learnpathItem
 {
@@ -2823,8 +2823,9 @@ class learnpathItem
 
     /**
      * Saves data in the database
-     * @param    boolean    Save from URL params (1) or from object attributes (0)
-     * @param    boolean    The results of a check on prerequisites for this item. True if prerequisites are completed, false otherwise. Defaults to false. Only used if not sco or au
+     * @param boolean $from_outside Save from URL params (1) or from object attributes (0)
+     * @param boolean $prereqs_complete The results of a check on prerequisites for this item.
+     * True if prerequisites are completed, false otherwise. Defaults to false. Only used if not sco or au
      * @return    boolean    True on success, false on failure
      */
     public function save($from_outside = true, $prereqs_complete = false)
@@ -2992,19 +2993,20 @@ class learnpathItem
                     break;
             }
         }
-        //$time = $this->time
+
         if (self::debug > 1) {
             error_log(
                 'New LP - End of learnpathItem::save() - Calling write_to_db()',
                 0
             );
         }
+
         return $this->write_to_db();
     }
 
     /**
      * Sets the number of attempt_id to a given value
-     * @param    integer    The given value to set attempt_id to
+     * @param    integer  $num  The given value to set attempt_id to
      * @return    boolean    TRUE on success, FALSE otherwise
      */
     public function set_attempt_id($num)
@@ -3021,7 +3023,7 @@ class learnpathItem
 
     /**
      * Sets the core_exit value to the one given
-     * @return  bool    True (always)
+     * @return  bool  $value  True (always)
      */
     public function set_core_exit($value)
     {
@@ -3041,7 +3043,8 @@ class learnpathItem
 
     /**
      * Sets the item's description
-     * @param    string    Description
+     * @param    string  $string  Description
+     *
      * @return  void
      */
     public function set_description($string = '')
@@ -3056,7 +3059,7 @@ class learnpathItem
 
     /**
      * Sets the lesson_location value
-     * @param    string    lesson_location as provided by the SCO
+     * @param    string  $location  lesson_location as provided by the SCO
      * @return    boolean    True on success, false otherwise
      */
     public function set_lesson_location($location)
@@ -3073,7 +3076,7 @@ class learnpathItem
 
     /**
      * Sets the item's depth level in the LP tree (0 is at root)
-     * @param    integer    Level
+     * @param    integer $int   Level
      * @return  void
      */
     public function set_level($int = 0)
@@ -3088,7 +3091,7 @@ class learnpathItem
 
     /**
      * Sets the lp_view id this item view is registered to
-     * @param    integer    lp_view DB ID
+     * @param int $lp_view_id   lp_view DB ID
      * @param int $course_id
      * @return  void
      * @todo //todo insert into lp_item_view if lp_view not exists
@@ -3174,7 +3177,7 @@ class learnpathItem
                     WHERE
                         c_id = $course_id AND
                         lp_iv_id = '" . $this->db_item_view_id . "'";
-            //error_log('sql10->'.$sql);
+
             $res = Database::query($sql);
             if ($res !== false) {
                 $this->interactions_count = Database::num_rows($res);
@@ -3189,7 +3192,7 @@ class learnpathItem
                     WHERE
                         c_id = $course_id AND
                         lp_iv_id = '" . $this->db_item_view_id . "'";
-            //error_log('sql11->'.$sql);
+
             $res = Database::query($sql);
             if ($res !== false) {
                 $this->objectives_count = Database::num_rows($res);
@@ -3222,7 +3225,7 @@ class learnpathItem
     /**
      * Sets the prevent_reinit attribute. This is based on the LP value and is set at creation time for
      * each learnpathItem. It is a (bad?) way of avoiding a reference to the LP when saving an item.
-     * @param    integer    1 for "prevent", 0 for "don't prevent" saving freshened values (new "not attempted" status etc)
+     * @param   integer 1 for "prevent", 0 for "don't prevent" saving freshened values (new "not attempted" status etc)
      * @return  void
      */
     public function set_prevent_reinit($prevent)
@@ -3240,7 +3243,7 @@ class learnpathItem
     /**
      * Sets the score value. If the mastery_score is set and the score reaches
      * it, then set the status to 'passed'.
-     * @param   float       Score
+     * @param   float    $score   Score
      * @return    boolean   True on success, false otherwise
      */
     public function set_score($score)
@@ -3283,8 +3286,9 @@ class learnpathItem
 
     /**
      * Sets the maximum score for this item
-     * @param    int        Maximum score - must be a decimal or an empty string
-     * @return    boolean    True on success, false on error
+     * @param  int $score Maximum score - must be a decimal or an empty string
+     *
+     * @return boolean    True on success, false on error
      */
     public function set_max_score($score)
     {
@@ -3308,7 +3312,7 @@ class learnpathItem
 
     /**
      * Sets the status for this item
-     * @param    string      $status Status - must be one of the values defined in $this->possible_status
+     * @param    string $status Status - must be one of the values defined in $this->possible_status
      * (this affects the status setting)
      * @return    boolean    True on success, false on error
      */
@@ -3345,7 +3349,7 @@ class learnpathItem
 
     /**
      * Set the (indexing) terms for this learnpath item
-     * @param   string  Terms, as a comma-split list
+     * @param   string  $terms Terms, as a comma-split list
      * @return  boolean Always return true
      */
     public function set_terms($terms)
@@ -3475,8 +3479,10 @@ class learnpathItem
 
     /**
      * Checks if the current status is part of the list of status given
-     * @param    strings_array  $list  An array of status to check for. If the current status is one of the strings, return true
-     * @return    boolean            True if the status was one of the given strings, false otherwise
+     * @param  array  $list  An array of status to check for.
+     * If the current status is one of the strings, return true
+     *
+     * @return    boolean True if the status was one of the given strings, false otherwise
      */
     public function status_is($list = array())
     {
@@ -3519,7 +3525,7 @@ class learnpathItem
 
     /**
      * Updates the time info according to the given session_time
-     * @param    integer    Time in seconds
+     * @param    integer  $total_sec  Time in seconds
      * @return  void
      * TODO: Make this method better by allowing better/multiple time slices.
      */
@@ -3658,10 +3664,13 @@ class learnpathItem
         if (is_array($this->objectives) && count($this->objectives) > 0) {
             // Save objectives.
             $tbl = Database::get_course_table(TABLE_LP_ITEM_VIEW);
-            $sql = "SELECT id FROM $tbl " .
-                "WHERE c_id = $course_id AND lp_item_id = " . $this->db_id . " " .
-                "AND   lp_view_id = " . $this->view_id . " " .
-                "AND   view_count = " . $this->attempt_id;
+            $sql = "SELECT id
+                    FROM $tbl
+                    WHERE
+                        c_id = $course_id AND
+                        lp_item_id = " . $this->db_id . " AND
+                        lp_view_id = " . $this->view_id . " AND
+                        view_count = " . $this->attempt_id;
             $res = Database::query($sql);
             if (Database::num_rows($res) > 0) {
                 $row = Database::fetch_array($res);
@@ -3677,13 +3686,11 @@ class learnpathItem
                     $iva_table = Database::get_course_table(
                         TABLE_LP_IV_OBJECTIVE
                     );
-                    $iva_sql = "SELECT id FROM $iva_table " .
-                        "WHERE c_id = $course_id AND lp_iv_id = $lp_iv_id " .
-                        //"AND order_id = $index";
-                        //also check for the objective ID as it must be unique for this SCO view
-                        "AND objective_id = '" . Database::escape_string(
-                            $objective[0]
-                        ) . "'";
+                    $iva_sql = "SELECT id FROM $iva_table
+                                WHERE
+                                    c_id = $course_id AND
+                                    lp_iv_id = $lp_iv_id AND
+                                    objective_id = '" . Database::escape_string($objective[0]) . "'";
                     $iva_res = Database::query($iva_sql);
                     // id(0), type(1), time(2), weighting(3),
                     // correct_responses(4), student_response(5),
@@ -3710,7 +3717,6 @@ class learnpathItem
                             ) . "' " .
                             "WHERE c_id = $course_id AND id = $iva_id";
                         Database::query($ivau_sql);
-                        //error_log($ivau_sql, 0);
                     } else {
                         // Insert new one.
                         $ivai_sql = "INSERT INTO $iva_table " .
@@ -3762,7 +3768,7 @@ class learnpathItem
                     c_id = ' . $course_id . ' AND
                     lp_item_id="' . $this->db_id . '" AND
                     lp_view_id="' . $this->view_id . '" AND
-                    view_count="' . $this->get_attempt_id() . '" ;';
+                    view_count="' . $this->get_attempt_id() . '" ';
         $rs_verified = Database::query($sql);
         $row_verified = Database::fetch_array($rs_verified);
 
@@ -3855,7 +3861,6 @@ class learnpathItem
             $check_res = Database::query($check);
             // Depending on what we want (really), we'll update or insert a new row
             // now save into DB.
-            $res = 0;
             if (!$inserted && Database::num_rows($check_res) < 1) {
                 $sql = "INSERT INTO $item_view_table " .
                     "(c_id, total_time, " .

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

@@ -30,12 +30,8 @@ class scormResource {
      * @param	string	Type of construction needed ('db' or 'manifest', default = 'manifest')
      * @param	mixed	Depending on the type given, DB id for the lp_item or reference to the DOM element
      */
-    public function __construct($type = 'manifest', &$element) {
-        /*
-        echo "<pre>Analysing resource:<br />\n";
-        var_dump($element);
-        echo "</pre><br />\n";
-        */
+    public function __construct($type = 'manifest', &$element)
+    {
         if (isset($element)) {
 
             // Parsing using PHP5 DOMXML methods.
@@ -73,7 +69,7 @@ class scormResource {
                     }
                     //$keep_href = '';
                     if ($element->hasAttributes()){ //in some cases we get here with an empty attributes array
-                    // TODO: Find when and why we get such a case (empty array).
+                        // TODO: Find when and why we get such a case (empty array).
                         $attributes = $element->attributes;
                         foreach ($attributes as $attrib) {
                             switch ($attrib->name) {
@@ -113,7 +109,7 @@ class scormResource {
      * @return	string	Path for this resource
      */
     public function get_path() {
-        if (!empty($this->href)) {            
+        if (!empty($this->href)) {
             return Database::escape_string($this->href);
         } else {
             return '';
@@ -125,7 +121,7 @@ class scormResource {
      * @return	string	generally 'asset' or 'sco' as these are the only two values defined in SCORM 1.2
      */
     public function get_scorm_type() {
-        if (!empty($this->scormtype)) {            
+        if (!empty($this->scormtype)) {
             return Database::escape_string($this->scormtype);
         } else {
             return '';