Browse Source

Minor - format code.

jmontoyaa 7 years ago
parent
commit
9df170dbc2

+ 12 - 4
main/gradebook/lib/GradebookUtils.php

@@ -482,8 +482,14 @@ class GradebookUtils
      * @param null $mainCourseCategory
      * @return array
      */
-    public static function get_printable_data($cat, $users, $alleval, $alllinks, $params, $mainCourseCategory = null)
-    {
+    public static function get_printable_data(
+        $cat,
+        $users,
+        $alleval,
+        $alllinks,
+        $params,
+        $mainCourseCategory = null
+    ) {
         $datagen = new FlatViewDataGenerator(
             $users,
             $alleval,
@@ -684,8 +690,10 @@ class GradebookUtils
      * @param int $cat_id The category id
      * @return array
      */
-    public static function get_list_gradebook_certificates_by_user_id($user_id, $cat_id = null)
-    {
+    public static function get_list_gradebook_certificates_by_user_id(
+        $user_id,
+        $cat_id = null
+    ) {
         $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
         $sql = 'SELECT 
                     gc.score_certificate, 

+ 38 - 4
main/gradebook/lib/flatview_data_generator.class.php

@@ -863,7 +863,14 @@ class FlatViewDataGenerator
 
                     $row[] = array(
                         $item_value,
-                        trim($scoredisplay->display_score($real_score, SCORE_CUSTOM, null, true))
+                        trim(
+                            $scoredisplay->display_score(
+                                $real_score,
+                                SCORE_CUSTOM,
+                                null,
+                                true
+                            )
+                        )
                     );
                     $item_value_total += $item_value;
                     $final_score += $score[0];
@@ -873,7 +880,14 @@ class FlatViewDataGenerator
                 $total_score = array($final_score, $item_total);
                 $row[] = array(
                     $final_score,
-                    trim($scoredisplay->display_score($total_score, SCORE_CUSTOM, null, true))
+                    trim(
+                        $scoredisplay->display_score(
+                            $total_score,
+                            SCORE_CUSTOM,
+                            null,
+                            true
+                        )
+                    )
                 );
             } else {
                 for ($count = 0; $count < count($this->evals_links); $count++) {
@@ -884,7 +898,17 @@ class FlatViewDataGenerator
                     $item_total += $item->get_weight();
                     $score_denom = ($score[1] == 0) ? 1 : $score[1];
                     $score_final = ($score[0] / $score_denom) * 100;
-                    $row[] = array($score_final, trim($scoredisplay->display_score($score, SCORE_CUSTOM, null, true)));
+                    $row[] = array(
+                        $score_final,
+                        trim(
+                            $scoredisplay->display_score(
+                                $score,
+                                SCORE_CUSTOM,
+                                null,
+                                true
+                            )
+                        )
+                    );
 
                 }
                 $total_score = array($item_value, $item_total);
@@ -892,7 +916,17 @@ class FlatViewDataGenerator
                 if ($displayWarning) {
                     echo Display::return_message($total_score[1], 'warning');
                 }
-                $row[] = array($score_final, trim($scoredisplay->display_score($total_score, SCORE_CUSTOM, null, true)));
+                $row[] = array(
+                    $score_final,
+                    trim(
+                        $scoredisplay->display_score(
+                            $total_score,
+                            SCORE_CUSTOM,
+                            null,
+                            true
+                        )
+                    )
+                );
             }
 
             $data[] = $row;

+ 19 - 14
main/gradebook/lib/gradebook_data_generator.class.php

@@ -327,21 +327,25 @@ class GradebookDataGenerator
                         ];
                     //}
 
-                $display = $scoredisplay->display_score(
-                    $score,
-                    SCORE_DIV_PERCENT_WITH_CUSTOM
-                );
-
-                $type = $item->get_item_type();
-                if ($type == 'L' && get_class($item) == 'ExerciseLink') {
-                    $display = ExerciseLib::show_score($score[0], $score[1], false);
-                }
+                    $display = $scoredisplay->display_score(
+                        $score,
+                        SCORE_DIV_PERCENT_WITH_CUSTOM
+                    );
 
-                return array(
-                    'display' => $display,
-                    'score' => $score,
-                    'score_weight' => $scoreWeight,
-                );
+                    $type = $item->get_item_type();
+                    if ($type == 'L' && get_class($item) == 'ExerciseLink') {
+                        $display = ExerciseLib::show_score(
+                            $score[0],
+                            $score[1],
+                            false
+                        );
+                    }
+
+                    return array(
+                        'display' => $display,
+                        'score' => $score,
+                        'score_weight' => $scoreWeight,
+                    );
             }
         }
 
@@ -374,6 +378,7 @@ class GradebookDataGenerator
      * Returns the link to the certificate generation, if the score is enough, otherwise
      * returns an empty string. This only works with categories.
      * @param    object Item
+     * @return string
      */
     public function get_certificate_link($item)
     {

+ 15 - 9
main/gradebook/lib/results_data_generator.class.php

@@ -54,8 +54,13 @@ class ResultsDataGenerator
      * 4 ['score']     : student's score
      * 5 ['display']   : custom score display (only if custom scoring enabled)
      */
-    public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false, $pdf = false)
-    {
+    public function get_data(
+        $sorting = 0,
+        $start = 0,
+        $count = null,
+        $ignore_score_color = false,
+        $pdf = false
+    ) {
         // do some checks on count, redefine if invalid value
         $number_decimals = api_get_setting('gradebook_number_decimals');
         if (!isset($count)) {
@@ -86,12 +91,13 @@ class ResultsDataGenerator
                     $ignore_score_color
                 );
             }
-            $user['percentage_score'] = intval($scoredisplay->display_score(
-                array($result->get_score(), $this->evaluation->get_max()),
-                SCORE_PERCENT,
-                SCORE_BOTH,
-                true
-            )
+            $user['percentage_score'] = intval(
+                $scoredisplay->display_score(
+                    array($result->get_score(), $this->evaluation->get_max()),
+                    SCORE_PERCENT,
+                    SCORE_BOTH,
+                    true
+                )
             );
             if ($pdf && $number_decimals == null) {
                 $user['scoreletter'] = $result->get_score();
@@ -132,7 +138,7 @@ class ResultsDataGenerator
      * @param bool  Whether we want the real score (2/4 (50 %)) or the transformation (A, B, C, etc)
      * @param bool  Whether we want to ignore the score color
      * @param boolean $realscore
-     * @result string The score as we want to show it
+     * @return string The score as we want to show it
      */
     private function get_score_display($score, $realscore, $ignore_score_color = false)
     {

+ 7 - 4
main/gradebook/lib/scoredisplay.class.php

@@ -24,7 +24,7 @@ class ScoreDisplay
     public static function instance($category_id = 0)
     {
         static $instance;
-        if (!isset ($instance)) {
+        if (!isset($instance)) {
             $instance = new ScoreDisplay($category_id);
         }
 
@@ -197,8 +197,11 @@ class ScoreDisplay
      * @param int   score color percent (optional)
      * @param int   gradebook category id (optional)
      */
-    public function update_custom_score_display_settings($displays, $scorecolpercent = 0, $category_id = null)
-    {
+    public function update_custom_score_display_settings(
+        $displays,
+        $scorecolpercent = 0,
+        $category_id = null
+    ) {
         $this->custom_display = $displays;
         $this->custom_display_conv = $this->convert_displays($this->custom_display);
 
@@ -448,6 +451,7 @@ class ScoreDisplay
     /**
      * Depends on the teacher's configuration of thresholds. i.e. [0 50] "Bad", [50:100] "Good"
      * @param array $score
+     * @return string
      */
     private function display_custom($score)
     {
@@ -564,7 +568,6 @@ class ScoreDisplay
     private function sort_display($item1, $item2)
     {
         if ($item1['score'] === $item2['score']) {
-
             return 0;
         } else {
             return ($item1['score'] < $item2['score'] ? -1 : 1);

+ 37 - 17
main/gradebook/lib/user_data_generator.class.php

@@ -39,7 +39,6 @@ class UserDataGenerator
     public function __construct($userid, $evals = array(), $links = array())
     {
         $this->userid = $userid;
-        $evals_filtered = array();
         $result = array();
         foreach ($evals as $eval) {
             $toadd = true;
@@ -87,8 +86,12 @@ class UserDataGenerator
      * 5: student's score
      * 6: student's score as custom display (only if custom scoring enabled)
      */
-    public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false)
-    {
+    public function get_data(
+        $sorting = 0,
+        $start = 0,
+        $count = null,
+        $ignore_score_color = false
+    ) {
         // do some checks on count, redefine if invalid value
         if (!isset($count)) {
             $count = count($this->items) - $start;
@@ -167,7 +170,7 @@ class UserDataGenerator
      * @param $item2
      * @return int
      */
-    function sort_by_type($item1, $item2)
+    public function sort_by_type($item1, $item2)
     {
         if ($item1->get_item_type() == $item2->get_item_type()) {
             return $this->sort_by_name($item1, $item2);
@@ -181,10 +184,14 @@ class UserDataGenerator
      * @param $item2
      * @return int
      */
-    function sort_by_course($item1, $item2)
+    public function sort_by_course($item1, $item2)
     {
-        $name1 = api_strtolower($this->get_course_name_from_code_cached($item1->get_course_code()));
-        $name2 = api_strtolower($this->get_course_name_from_code_cached($item2->get_course_code()));
+        $name1 = api_strtolower(
+            $this->get_course_name_from_code_cached($item1->get_course_code())
+        );
+        $name2 = api_strtolower(
+            $this->get_course_name_from_code_cached($item2->get_course_code())
+        );
         return api_strnatcmp($name1, $name2);
     }
 
@@ -193,7 +200,7 @@ class UserDataGenerator
      * @param $item2
      * @return int
      */
-    function sort_by_category($item1, $item2)
+    public function sort_by_category($item1, $item2)
     {
         $cat1 = $this->get_category_cached($item1->get_category_id());
         $cat2 = $this->get_category_cached($item2->get_category_id());
@@ -208,7 +215,7 @@ class UserDataGenerator
      * @param $item2
      * @return int
      */
-    function sort_by_name($item1, $item2)
+    public function sort_by_name($item1, $item2)
     {
         return api_strnatcmp($item1->get_name(), $item2->get_name());
     }
@@ -218,7 +225,7 @@ class UserDataGenerator
      * @param $item2
      * @return int
      */
-    function sort_by_average($item1, $item2)
+    public function sort_by_average($item1, $item2)
     {
         $score1 = $this->avgcache[$item1->get_item_type().$item1->get_id()];
         $score2 = $this->avgcache[$item2->get_item_type().$item2->get_id()];
@@ -231,7 +238,7 @@ class UserDataGenerator
      * @param $item2
      * @return int
      */
-    function sort_by_score($item1, $item2)
+    public function sort_by_score($item1, $item2)
     {
         $score1 = $this->scorecache[$item1->get_item_type().$item1->get_id()];
         $score2 = $this->scorecache[$item2->get_item_type().$item2->get_id()];
@@ -244,7 +251,7 @@ class UserDataGenerator
      * @param $item2
      * @return int
      */
-    function sort_by_mask($item1, $item2)
+    public function sort_by_mask($item1, $item2)
     {
         $score1 = $this->scorecache[$item1->get_item_type().$item1->get_id()];
         $score2 = $this->scorecache[$item2->get_item_type().$item2->get_id()];
@@ -257,7 +264,7 @@ class UserDataGenerator
      * @param $score2
      * @return int
      */
-    function compare_scores($score1, $score2)
+    public function compare_scores($score1, $score2)
     {
         if (!isset($score1)) {
             return (isset($score2) ? 1 : 0);
@@ -325,7 +332,11 @@ class UserDataGenerator
             $displaytype |= SCORE_IGNORE_SPLIT;
         }
 
-        return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_DEFAULT);
+        return $scoredisplay->display_score(
+            $studscore,
+            $displaytype,
+            SCORE_ONLY_DEFAULT
+        );
     }
 
     /**
@@ -341,7 +352,12 @@ class UserDataGenerator
         if ($ignore_score_color) {
             $displaytype |= SCORE_IGNORE_SPLIT;
         }
-        return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_CUSTOM);
+
+        return $scoredisplay->display_score(
+            $studscore,
+            $displaytype,
+            SCORE_ONLY_CUSTOM
+        );
     }
 
     /**
@@ -350,7 +366,9 @@ class UserDataGenerator
      */
     private function get_course_name_from_code_cached($coursecode)
     {
-        if (isset($this->coursecodecache) && isset($this->coursecodecache[$coursecode])) {
+        if (isset($this->coursecodecache) &&
+            isset($this->coursecodecache[$coursecode])
+        ) {
             return $this->coursecodecache[$coursecode];
         } else {
             $name = CourseManager::getCourseNameFromCode($coursecode);
@@ -365,7 +383,9 @@ class UserDataGenerator
      */
     private function get_category_cached($category_id)
     {
-        if (isset($this->categorycache) && isset ($this->categorycache[$category_id])) {
+        if (isset($this->categorycache) &&
+            isset($this->categorycache[$category_id])
+        ) {
             return $this->categorycache[$category_id];
         } else {
             $cat = Category::load($category_id);