ソースを参照

Minor - format code.

Julio Montoya 10 年 前
コミット
6aa1d871ec

+ 163 - 143
main/gradebook/lib/be/evallink.class.php

@@ -1,160 +1,180 @@
 <?php
 /* For licensing terms, see /license.txt */
+
 /**
  * Class to be used as basis for links referring to Evaluation objects.
  * @author Bert Steppé
  * @package chamilo.gradebook
- */
-/**
- * Class
  * @package chamilo.gradebook
  */
 abstract class EvalLink extends AbstractLink
 {
-
     protected $evaluation = null;
 
-	/**
-	 * Constructor
-	 */
-    function __construct() {
-    	parent::__construct();
+    /**
+     * Constructor
+     */
+    function __construct()
+    {
+        parent::__construct();
     }
+
     // Functions implementing AbstractLink
 
-    public function has_results() {
-    	$eval = $this->get_evaluation();
-		return $eval->has_results();
-    }
-
-    public function calc_score($stud_id = null) {        
-    	$eval = $this->get_evaluation();
-		return $eval->calc_score($stud_id);
-    }
-
-	public function get_link() {
-    	$eval = $this->get_evaluation();
-		// course/platform admin can go to the view_results page
-		if (api_is_allowed_to_edit())
-			return 'gradebook_view_result.php?selecteval=' . $eval->get_id();
-		// students can go to the statistics page (if custom display enabled)
-		elseif (ScoreDisplay :: instance()->is_custom())
-			return 'gradebook_statistics.php?selecteval=' . $eval->get_id();
-		else
-			return null;
-	}
-
-    public function get_name() {
-    	$eval = $this->get_evaluation();
-    	return $eval->get_name();
-    }
-
-    public function get_description() {
-    	$eval = $this->get_evaluation();
-    	return $eval->get_description();
-    }
-
-    public function get_max() {
-    	$eval = $this->get_evaluation();
-    	return $eval->get_max();
-    }
-
-    public function is_valid_link() {
-    	$eval = $this->get_evaluation();
-    	return (isset($eval));
-    }
-	public function needs_name_and_description() {
-		return true;
-	}
-
-	public function needs_max() {
-		return true;
-	}
-
-	public function needs_results() {
-		return true;
-	}
-
-	public function add_linked_data() {
-		if ($this->is_valid_link()) {
-			$this->evaluation->add();
-			$this->set_ref_id($this->evaluation->get_id());
-		}
-	}
-
-	public function save_linked_data() {
-		if ($this->is_valid_link()) {
-			$this->evaluation->save();
-		}
-	}
-
-	public function delete_linked_data() {
-		if ($this->is_valid_link()) {
-			$this->evaluation->delete_with_results();
-		}
-	}
-
-	public function set_name ($name) {
-		if ($this->is_valid_link()) {
-			$this->evaluation->set_name($name);
-		}
-	}
-
-	public function set_description ($description) {
-		if ($this->is_valid_link()) {
-			$this->evaluation->set_description($description);
-		}
-	}
-
-	public function set_max ($max) {
-		if ($this->is_valid_link()) {
-			$this->evaluation->set_max($max);
-		}
-	}
-    
+    public function has_results()
+    {
+        $eval = $this->get_evaluation();
+        return $eval->has_results();
+    }
+
+    public function calc_score($stud_id = null)
+    {
+        $eval = $this->get_evaluation();
+        return $eval->calc_score($stud_id);
+    }
+
+    public function get_link()
+    {
+        $eval = $this->get_evaluation();
+        // course/platform admin can go to the view_results page
+        if (api_is_allowed_to_edit()) {
+            return 'gradebook_view_result.php?selecteval=' . $eval->get_id();
+        } // students can go to the statistics page (if custom display enabled)
+        elseif (ScoreDisplay :: instance()->is_custom()) {
+            return 'gradebook_statistics.php?selecteval=' . $eval->get_id();
+        } else {
+            return null;
+        }
+    }
+
+    public function get_name()
+    {
+        $eval = $this->get_evaluation();
+        return $eval->get_name();
+    }
+
+    public function get_description()
+    {
+        $eval = $this->get_evaluation();
+        return $eval->get_description();
+    }
+
+    public function get_max()
+    {
+        $eval = $this->get_evaluation();
+        return $eval->get_max();
+    }
+
+    public function is_valid_link()
+    {
+        $eval = $this->get_evaluation();
+        return (isset($eval));
+    }
+
+    public function needs_name_and_description()
+    {
+        return true;
+    }
+
+    public function needs_max()
+    {
+        return true;
+    }
+
+    public function needs_results()
+    {
+        return true;
+    }
+
+    public function add_linked_data()
+    {
+        if ($this->is_valid_link()) {
+            $this->evaluation->add();
+            $this->set_ref_id($this->evaluation->get_id());
+        }
+    }
+
+    public function save_linked_data()
+    {
+        if ($this->is_valid_link()) {
+            $this->evaluation->save();
+        }
+    }
+
+    public function delete_linked_data()
+    {
+        if ($this->is_valid_link()) {
+            $this->evaluation->delete_with_results();
+        }
+    }
+
+    public function set_name($name)
+    {
+        if ($this->is_valid_link()) {
+            $this->evaluation->set_name($name);
+        }
+    }
+
+    public function set_description($description)
+    {
+        if ($this->is_valid_link()) {
+            $this->evaluation->set_description($description);
+        }
+    }
+
+    public function set_max($max)
+    {
+        if ($this->is_valid_link()) {
+            $this->evaluation->set_max($max);
+        }
+    }
+
     // Functions overriding non-trivial implementations from AbstractLink
-	public function set_date ($date) {
-		$this->created_at = $date;
-		if ($this->is_valid_link()) {
-			$this->evaluation->set_date($date);
-		}
-	}
-
-	public function set_weight ($weight) {
-		$this->weight = $weight;
-		if ($this->is_valid_link()) {
-			$this->evaluation->set_weight($weight);
-		}
-	}
-
-	public function set_visible ($visible) {
-		$this->visible = $visible;
-		if ($this->is_valid_link()) {
-			$this->evaluation->set_visible($visible);
-		}
-	}
-
-	/**
-	 * Lazy load function to get the linked evaluation
-	 */
-	protected function get_evaluation () {
-		if (!isset($this->evaluation)) {
-			if (isset($this->ref_id)) {
-		    	$evalarray = Evaluation::load($this->get_ref_id());
-				$this->evaluation = $evalarray[0];
-			} else {
-				$eval = new Evaluation();
-				$eval->set_category_id(-1);
-				$eval->set_date(api_get_utc_datetime()); // these values will be changed
-				$eval->set_weight(0);    //   when the link setter
-				$eval->set_visible(0);   //     is called
-				$eval->set_id(-1); // a 'real' id will be set when eval is added to db
-				$eval->set_user_id($this->get_user_id());
-				$eval->set_course_code($this->get_course_code());
-				$this->evaluation = $eval;
-				$this->set_ref_id($eval->get_id());
-			}
-		}
-		return $this->evaluation;
-	}
+    public function set_date($date)
+    {
+        $this->created_at = $date;
+        if ($this->is_valid_link()) {
+            $this->evaluation->set_date($date);
+        }
+    }
+
+    public function set_weight($weight)
+    {
+        $this->weight = $weight;
+        if ($this->is_valid_link()) {
+            $this->evaluation->set_weight($weight);
+        }
+    }
+
+    public function set_visible($visible)
+    {
+        $this->visible = $visible;
+        if ($this->is_valid_link()) {
+            $this->evaluation->set_visible($visible);
+        }
+    }
+
+    /**
+     * Lazy load function to get the linked evaluation
+     */
+    protected function get_evaluation () {
+        if (!isset($this->evaluation)) {
+            if (isset($this->ref_id)) {
+                $evalarray = Evaluation::load($this->get_ref_id());
+                $this->evaluation = $evalarray[0];
+            } else {
+                $eval = new Evaluation();
+                $eval->set_category_id(-1);
+                $eval->set_date(api_get_utc_datetime()); // these values will be changed
+                $eval->set_weight(0);    //   when the link setter
+                $eval->set_visible(0);   //     is called
+                $eval->set_id(-1); // a 'real' id will be set when eval is added to db
+                $eval->set_user_id($this->get_user_id());
+                $eval->set_course_code($this->get_course_code());
+                $this->evaluation = $eval;
+                $this->set_ref_id($eval->get_id());
+            }
+        }
+        return $this->evaluation;
+    }
 }

+ 139 - 116
main/gradebook/lib/be/evaluation.class.php

@@ -1,18 +1,12 @@
 <?php
 /* For licensing terms, see /license.txt */
+
 /**
- * Defines a gradebook Evaluation object
- * @package chamilo.gradebook
- */
-/**
- * Class
+ * Class Evaluation
  * @package chamilo.gradebook
  */
 class Evaluation implements GradebookItem
 {
-
-// PROPERTIES
-
 	private $id;
 	private $name;
 	private $description;
@@ -24,112 +18,134 @@ class Evaluation implements GradebookItem
 	private $eval_max;
 	private $visible;
 
-    // CONSTRUCTORS
-
-    function __construct() {
+    public function __construct()
+    {
     }
 
-    // GETTERS AND SETTERS
-
-   	public function get_id() {
-		return $this->id;
-	}
+    public function get_id()
+    {
+        return $this->id;
+    }
 
-	public function get_name() {
-		return $this->name;
-	}
+    public function get_name()
+    {
+        return $this->name;
+    }
 
-	public function get_description() {
-		return $this->description;
-	}
+    public function get_description()
+    {
+        return $this->description;
+    }
 
-	public function get_user_id() {
-		return $this->user_id;
-	}
+    public function get_user_id()
+    {
+        return $this->user_id;
+    }
 
-	public function get_course_code() {
-		return $this->course_code;
-	}
+    public function get_course_code()
+    {
+        return $this->course_code;
+    }
 
-	public function get_category_id() {
-		return $this->category;
-	}
+    public function get_category_id()
+    {
+        return $this->category;
+    }
 
-	public function get_date() {
-		return $this->created_at;
-	}
+    public function get_date()
+    {
+        return $this->created_at;
+    }
 
-	public function get_weight() {
-		return $this->weight;
-	}
+    public function get_weight()
+    {
+        return $this->weight;
+    }
 
-	public function get_max() {
-		return $this->eval_max;
-	}
+    public function get_max()
+    {
+        return $this->eval_max;
+    }
 
-	public function get_type() {
-		return $this->type;
-	}
+    public function get_type()
+    {
+        return $this->type;
+    }
 
-	public function is_visible() {
-		return $this->visible;
-	}
+    public function is_visible()
+    {
+        return $this->visible;
+    }
 
-	public function get_locked() {
-		return $this->locked;
-	}
+    public function get_locked()
+    {
+        return $this->locked;
+    }
 
-    public function is_locked() {
-		return isset($this->locked) && $this->locked == 1 ? true : false ;
-	}
+    public function is_locked()
+    {
+        return isset($this->locked) && $this->locked == 1 ? true : false;
+    }
 
-	public function set_id ($id) {
-		$this->id = $id;
-	}
+    public function set_id($id)
+    {
+        $this->id = $id;
+    }
 
-	public function set_name ($name) {
-		$this->name = $name;
-	}
+    public function set_name($name)
+    {
+        $this->name = $name;
+    }
 
-	public function set_description ($description) {
-		$this->description = $description;
-	}
+    public function set_description($description)
+    {
+        $this->description = $description;
+    }
 
-	public function set_user_id ($user_id) {
-		$this->user_id = $user_id;
-	}
+    public function set_user_id($user_id)
+    {
+        $this->user_id = $user_id;
+    }
 
-	public function set_course_code ($course_code) {
-		$this->course_code = $course_code;
-	}
+    public function set_course_code($course_code)
+    {
+        $this->course_code = $course_code;
+    }
 
-	public function set_category_id ($category_id) {
-		$this->category = $category_id;
-	}
+    public function set_category_id($category_id)
+    {
+        $this->category = $category_id;
+    }
 
-	public function set_date ($date) {
-		$this->created_at = $date;
-	}
+    public function set_date($date)
+    {
+        $this->created_at = $date;
+    }
 
-	public function set_weight ($weight) {
-		$this->weight = $weight;
-	}
+    public function set_weight($weight)
+    {
+        $this->weight = $weight;
+    }
 
-	public function set_max ($max) {
-		$this->eval_max = $max;
-	}
+    public function set_max($max)
+    {
+        $this->eval_max = $max;
+    }
 
-	public function set_visible ($visible) {
-		$this->visible = $visible;
-	}
+    public function set_visible($visible)
+    {
+        $this->visible = $visible;
+    }
 
-    public function set_type ($type) {
-		$this->type = $type;
-	}
+    public function set_type($type)
+    {
+        $this->type = $type;
+    }
 
-	public function set_locked ($locked) {
-		$this->locked = $locked;
-	}
+    public function set_locked($locked)
+    {
+        $this->locked = $locked;
+    }
 
 	/**
 	 * Retrieve evaluations and return them as an array of Evaluation objects
@@ -218,7 +234,8 @@ class Evaluation implements GradebookItem
     /**
      * Insert this evaluation into the database
      */
-    public function add() {
+    public function add()
+    {
 		if (isset($this->name) && isset($this->user_id) && isset($this->weight) && isset ($this->eval_max) && isset($this->visible)) {
 			$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
 
@@ -265,7 +282,8 @@ class Evaluation implements GradebookItem
 		}
 	}
 
-	public function add_evaluation_log($idevaluation){
+	public function add_evaluation_log($idevaluation)
+    {
 		if (!empty($idevaluation)) {
 			$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
 			$tbl_grade_linkeval_log = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINKEVAL_LOG);
@@ -283,10 +301,12 @@ class Evaluation implements GradebookItem
 			}
 		}
 	}
+
 	/**
 	 * Update the properties of this evaluation in the database
 	 */
-	public function save() {
+	public function save()
+    {
 		$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
 		$sql = 'UPDATE '.$tbl_grade_evaluations
 			." SET name = '".Database::escape_string($this->get_name())."'"
@@ -323,20 +343,20 @@ class Evaluation implements GradebookItem
 	/**
 	 * Delete this evaluation from the database
 	 */
-	public function delete() {
+	public function delete()
+    {
 		$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
 		$sql = 'DELETE FROM '.$tbl_grade_evaluations.' WHERE id = '.intval($this->id);
 		Database::query($sql);
 	}
 
-// OTHER FUNCTIONS
-
 	/**
 	 * Check if an evaluation name (with the same parent category) already exists
 	 * @param $name name to check (if not given, the name property of this object will be checked)
 	 * @param $parent parent category
 	 */
-	public function does_name_exist($name, $parent) {
+	public function does_name_exist($name, $parent)
+    {
 		if (!isset ($name)) {
 			$name = $this->name;
 			$parent = $this->category;
@@ -414,16 +434,16 @@ class Evaluation implements GradebookItem
     	return (is_numeric($score) && $score >= 0 && $score <= $this->eval_max);
     }
 
-
 	/**
 	 * Calculate the score of this evaluation
-	 * @param $stud_id student id (default: all students who have results for this eval - then the average is returned)
+	 * @param int $stud_id (default: all students who have results for this eval - then the average is returned)
 	 * @return	array (score, max) if student is given
 	 * 			array (sum of scores, number of scores) otherwise
 	 * 			or null if no scores available
 	 */
-    public function calc_score ($stud_id = null) {
-		$results = Result::load(null,$stud_id,$this->id);
+    public function calc_score($stud_id = null)
+    {
+		$results = Result::load(null, $stud_id, $this->id);
 
 		$rescount = 0;
 		$sum = 0;
@@ -484,7 +504,8 @@ class Evaluation implements GradebookItem
 	/**
 	 * Internal function used by get_target_categories()
 	 */
-	private function add_target_subcategories($targets, $level, $catid) {
+	private function add_target_subcategories($targets, $level, $catid)
+    {
 		$subcats = Category::load(null,null,null,$catid);
 		foreach ($subcats as $cat) {
 			$targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
@@ -499,7 +520,8 @@ class Evaluation implements GradebookItem
 	 * If this evaluation moves from inside a course to outside,
 	 * its course code is also changed.
 	 */
-	public function move_to_cat ($cat) {
+	public function move_to_cat($cat)
+    {
 		$this->set_category_id($cat->get_id());
 		if ($this->get_course_code() != $cat->get_course_code()) {
 			$this->set_course_code($cat->get_course_code());
@@ -515,7 +537,8 @@ class Evaluation implements GradebookItem
 	 * @param $cat_id parent category (use 'null' to retrieve them in all categories)
 	 * @param $stud_id student id
 	 */
-    public function get_evaluations_with_result_for_student ($cat_id = null, $stud_id) {
+    public function get_evaluations_with_result_for_student ($cat_id = null, $stud_id)
+    {
 		$tbl_grade_evaluations = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
     	$tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
 
@@ -537,12 +560,11 @@ class Evaluation implements GradebookItem
 		return $alleval;
     }
 
-
-
     /**
      * Get a list of students that do not have a result record for this evaluation
      */
-    public function get_not_subscribed_students ($first_letter_user = '') {
+    public function get_not_subscribed_students ($first_letter_user = '')
+    {
 		$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
     	$tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
 
@@ -560,14 +582,14 @@ class Evaluation implements GradebookItem
 		return $db_users;
     }
 
-
     /**
      * Find evaluations by name
      * @param string $name_mask search string
      * @return array evaluation objects matching the search criterium
      * @todo can be written more efficiently using a new (but very complex) sql query
      */
-    public function find_evaluations ($name_mask,$selectcat) {
+    public function find_evaluations ($name_mask,$selectcat)
+    {
     	$rootcat = Category::load($selectcat);
 		$evals = $rootcat[0]->get_evaluations((api_is_allowed_to_create_course() ? null : api_get_user_id()), true);
 		$foundevals = array();
@@ -579,15 +601,13 @@ class Evaluation implements GradebookItem
 		return $foundevals;
     }
 
-
-
-// Other methods implementing GradebookItem
-
-    public function get_item_type() {
+    public function get_item_type()
+    {
 		return 'E';
 	}
 
-	public function get_icon_name() {
+	public function get_icon_name()
+    {
 		return $this->has_results() ? 'evalnotempty' : 'evalempty';
 	}
 
@@ -596,13 +616,15 @@ class Evaluation implements GradebookItem
   	 * @param int locked 1 or unlocked 0
   	 *
   	 **/
-  	function lock($locked) {
+  	function lock($locked)
+    {
   		$table_evaluation = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
   		$sql = "UPDATE $table_evaluation SET locked = '".intval($locked)."' WHERE id='".intval($this->id)."'";
   		Database::query($sql);
   	}
 
-    function check_lock_permissions() {
+    function check_lock_permissions()
+    {
         if (api_is_platform_admin()) {
             return true;
         } else {
@@ -612,7 +634,8 @@ class Evaluation implements GradebookItem
         }
     }
 
-    function delete_linked_data() {
+    function delete_linked_data()
+    {
 
     }
 }

+ 76 - 58
main/gradebook/lib/fe/gradebooktable.class.php

@@ -1,17 +1,11 @@
 <?php
 /* For licensing terms, see license.txt */
-/**
- * Script
- * @package chamilo.gradebook
- */
-/**
- * Init
- */
 
 require_once dirname(__FILE__).'/../../../inc/global.inc.php';
 require_once dirname(__FILE__).'/../be.inc.php';
 
 /**
+ * GradebookTable Class
  * Table to display categories, evaluations and links
  * @author Stijn Konings
  * @author Bert Steppé (refactored, optimised)
@@ -19,76 +13,76 @@ require_once dirname(__FILE__).'/../be.inc.php';
  */
 class GradebookTable extends SortableTable
 {
-	private $currentcat;
-	private $datagen;
-	private $evals_links;
+    private $currentcat;
+    private $datagen;
+    private $evals_links;
     public  $cats;
 
-	/**
-	 * Constructor
-	 */
-    function GradebookTable ($currentcat, $cats = array(), $evals = array(), $links = array(), $addparams = null)
+    /**
+     * Constructor
+     */
+    public function GradebookTable($currentcat, $cats = array(), $evals = array(), $links = array(), $addparams = null)
     {
-    	parent::__construct ('gradebooklist', null, null, (api_is_allowed_to_edit()?1:0));
-		$this->evals_links = array_merge($evals, $links);
-		$this->currentcat = $currentcat;
+        parent::__construct ('gradebooklist', null, null, (api_is_allowed_to_edit()?1:0));
+        $this->evals_links = array_merge($evals, $links);
+        $this->currentcat = $currentcat;
         $this->cats = $cats;
-		$this->datagen = new GradebookDataGenerator($cats, $evals, $links);
+        $this->datagen = new GradebookDataGenerator($cats, $evals, $links);
 
-		if (isset($addparams)) {
-			$this->set_additional_parameters($addparams);
-		}
+        if (isset($addparams)) {
+            $this->set_additional_parameters($addparams);
+        }
 
-		$column= 0;
-		if (api_is_allowed_to_edit(null, true)) {
-			$this->set_header($column++,'','','width="25px"');
-		}
+        $column= 0;
+        if (api_is_allowed_to_edit(null, true)) {
+            $this->set_header($column++, '', '', 'width="25px"');
+        }
 
-		$this->set_header($column++, get_lang('Type'),'','width="35px"');
-		$this->set_header($column++, get_lang('Name'), false);
+        $this->set_header($column++, get_lang('Type'), '', 'width="35px"');
+        $this->set_header($column++, get_lang('Name'), false);
 
         $this->set_header($column++, get_lang('Description'), false);
 
-		if (api_is_allowed_to_edit(null, true)) {
-			$this->set_header($column++, get_lang('Weight'),'','width="100px"');
-		} else {
-			$this->set_header($column++, get_lang('Weight'), false);
-			$this->set_header($column++, get_lang('Result'), false);
+        if (api_is_allowed_to_edit(null, true)) {
+            $this->set_header(
+                $column++,
+                get_lang('Weight'),
+                '',
+                'width="100px"'
+            );
+        } else {
+            $this->set_header($column++, get_lang('Weight'), false);
+            $this->set_header($column++, get_lang('Result'), false);
 
             if (!empty($cats)) {
                 $this->set_header($column++, get_lang('Actions'), false);
             }
-		}
+        }
 
         // Deactivates the odd/even alt rows in order that the +/- buttons work see #4047
 
         $this->odd_even_rows_enabled = false;
 
-		// Admins get an edit column.
-		if (api_is_allowed_to_edit(null, true)) {
-			$this->set_header($column++, get_lang('Modify'), false, 'width="195px"');
-			// Actions on multiple selected documents.
-			$this->set_form_actions(array (
-				'setvisible' => get_lang('SetVisible'),
-				'setinvisible' => get_lang('SetInvisible'),
+        // Admins get an edit column.
+        if (api_is_allowed_to_edit(null, true)) {
+            $this->set_header($column++, get_lang('Modify'), false, 'width="195px"');
+            // Actions on multiple selected documents.
+            $this->set_form_actions(array (
+                'setvisible' => get_lang('SetVisible'),
+                'setinvisible' => get_lang('SetInvisible'),
                 'deleted' => get_lang('DeleteSelected')
                 ));
-		} else {
-	 	    if (empty($_GET['selectcat']) &&  !api_is_allowed_to_edit()) {
-			    $this->set_header($column++, get_lang('Certificates'),false);
-	 	    } else {
-	 	    	//$evals_links = array_merge($evals, $links);
-	 	    	//if (count($evals_links)>0) {
-             	    //$this->set_header($column++, get_lang('Results'), false);
-             	//}
-	 	    }
-		}
+        } else {
+            if (empty($_GET['selectcat']) && !api_is_allowed_to_edit()) {
+                $this->set_header($column++, get_lang('Certificates'), false);
+            }
+        }
     }
 
     /**
      * @return GradebookDataGenerator
      */
-    function get_data()
+    public function get_data()
     {
         return $this->datagen;
     }
@@ -97,7 +91,7 @@ class GradebookTable extends SortableTable
 	 * Function used by SortableTable to get total number of items in the table
      * @return int
 	 */
-	function get_total_number_of_items()
+    public function get_total_number_of_items()
     {
 		return $this->datagen->get_total_items_count();
 	}
@@ -111,7 +105,7 @@ class GradebookTable extends SortableTable
      * @param int $sort
      * @return array|mixed
      */
-    function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null)
+    public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null)
     {
         //variables load in index.php
         global $certificate_min_score;
@@ -244,6 +238,7 @@ class GradebookTable extends SortableTable
                     }
                 } else {
                     $score = $item->calc_score(api_get_user_id());
+
                     if (!empty($score[1])) {
                         $complete_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT);
                         $score = $score[0]/$score[1]*$item->get_weight();
@@ -470,22 +465,37 @@ class GradebookTable extends SortableTable
         return $sortable_data;
     }
 
-    // Other functions
+    /**
+     * @param $item
+     * @return mixed
+     */
     private function build_certificate_min_score ($item)
     {
         return $item->get_certificate_min_score();
     }
 
-    private function build_weight ($item)
+    /**
+     * @param $item
+     * @return mixed
+     */
+    private function build_weight($item)
     {
         return $item->get_weight();
     }
 
+    /**
+     * @param $item
+     * @return mixed
+     */
     private function build_course_code ($item)
     {
     	return $item->get_course_code();
     }
 
+    /**
+     * @param $item
+     * @return string
+     */
     private function build_id_column ($item)
     {
 		switch ($item->get_item_type()) {
@@ -501,13 +511,17 @@ class GradebookTable extends SortableTable
 		}
 	}
 
-	private function build_type_column ($item, $attributes = array())
+    /**
+     * @param $item
+     * @param array $attributes
+     * @return string
+     */
+    private function build_type_column ($item, $attributes = array())
     {
 		return build_type_icon_tag($item->get_icon_name(), $attributes);
 	}
 
 	/**
-	 *
 	 * Generate name column
 	 * @param unknown_type $item
 	 * @return string
@@ -594,7 +608,11 @@ class GradebookTable extends SortableTable
 		}
 	}
 
-	private function build_edit_column($item)
+    /**
+     * @param $item
+     * @return null|string
+     */
+    private function build_edit_column($item)
     {
 		switch ($item->get_item_type()) {
 			// category