Completed
Push — 1.10.x ( 8104fe...432f77 )
by Angel Fernando Quiroz
125:00 queued 74:07
created
main/gradebook/lib/fe/gradebooktable.class.php 4 patches
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,6 +32,8 @@  discard block
 block discarded – undo
32 32
      * @param array $evals
33 33
      * @param array $links
34 34
      * @param null $addparams
35
+     * @param boolean $showTeacherView
36
+     * @param integer $userId
35 37
      */
36 38
     public function __construct(
37 39
         $currentcat,
@@ -895,7 +897,7 @@  discard block
 block discarded – undo
895 897
 
896 898
     /**
897 899
      * @param $item
898
-     * @return mixed
900
+     * @return string|null
899 901
      */
900 902
     private function build_course_code($item)
901 903
     {
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
             $this->set_additional_parameters($addparams);
72 72
         }
73 73
 
74
-        $column= 0;
74
+        $column = 0;
75 75
         if ($this->teacherView) {
76 76
             if ($this->exportToPdf == false) {
77 77
                 $this->set_header($column++, '', '', 'width="25px"');
@@ -283,13 +283,13 @@  discard block
 block discarded – undo
283 283
                 $main_categories[$item->get_id()]['name'] = $item->get_name();
284 284
             } else {
285 285
                 $name = $this->build_name_link($item, $type);
286
-                $row[] = $invisibility_span_open.$name. $invisibility_span_close;
286
+                $row[] = $invisibility_span_open.$name.$invisibility_span_close;
287 287
                 $main_categories[$item->get_id()]['name'] = $name;
288 288
             }
289 289
 
290 290
             $this->dataForGraph['categories'][] = $item->get_name();
291 291
 
292
-            $main_categories[$item->get_id()]['weight']= $item->get_weight();
292
+            $main_categories[$item->get_id()]['weight'] = $item->get_weight();
293 293
             $total_categories_weight += $item->get_weight();
294 294
 
295 295
             // Description.
@@ -309,9 +309,9 @@  discard block
 block discarded – undo
309 309
             );
310 310
 
311 311
             if ($this->teacherView) {
312
-                $row[] = $invisibility_span_open .Display::tag('p', $weight, array('class' => 'score')).$invisibility_span_close;
312
+                $row[] = $invisibility_span_open.Display::tag('p', $weight, array('class' => 'score')).$invisibility_span_close;
313 313
             } else {
314
-                $row[] = $invisibility_span_open .$weight.$invisibility_span_close;
314
+                $row[] = $invisibility_span_open.$weight.$invisibility_span_close;
315 315
             }
316 316
 
317 317
             $category_weight = $item->get_weight();
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 
338 338
                 if (!empty($score[1])) {
339 339
                     $completeScore = $scoredisplay->display_score($score, SCORE_DIV_PERCENT);
340
-                    $score = $score[0]/$score[1]*$item->get_weight();
340
+                    $score = $score[0] / $score[1] * $item->get_weight();
341 341
                     $score = $scoredisplay->display_score(array($score, null), SCORE_SIMPLE);
342 342
                     $scoreToDisplay = Display::tip($score, $completeScore);
343 343
                 } else {
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
                     $totalResultAverageValue = strip_tags($scoredisplay->display_score($totalResult, SCORE_AVERAGE));
374 374
                     $this->dataForGraph['my_result'][] = (float) str_replace('%', '', $totalResultAverageValue);
375 375
                     $totalAverageValue = strip_tags($scoredisplay->display_score($totalAverage, SCORE_AVERAGE));
376
-                    $this->dataForGraph['average'][] =  (float) str_replace('%', '', $totalAverageValue);
376
+                    $this->dataForGraph['average'][] = (float) str_replace('%', '', $totalAverageValue);
377 377
                     // Ranking
378 378
                     $row[] = $ranking;
379 379
                     // Best
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
                         $row[] = $this->build_type_column($item, array('style' => 'padding-left:5px'));
457 457
 
458 458
                         // Name.
459
-                        $row[] = $invisibility_span_open."     ".$this->build_name_link($item, $type) . $invisibility_span_close;
459
+                        $row[] = $invisibility_span_open."     ".$this->build_name_link($item, $type).$invisibility_span_close;
460 460
 
461 461
                         // Description.
462 462
                         if ($this->exportToPdf == false) {
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
                             // Students get the results and certificates columns
495 495
                             $eval_n_links = array_merge($alleval, $alllink);
496 496
 
497
-                            if (count($eval_n_links)> 0) {
497
+                            if (count($eval_n_links) > 0) {
498 498
                                 $value_data = isset($data[4]) ? $data[4] : null;
499 499
 
500 500
                                 if (!is_null($value_data)) {
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
                 $row = array(
594 594
                     null,
595 595
                     null,
596
-                    '<strong>' . get_lang('Total') . '</strong>',
596
+                    '<strong>'.get_lang('Total').'</strong>',
597 597
                     null,
598 598
                     $total
599 599
                 );
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
                 if ($this->exportToPdf) {
664 664
                     $row = array(
665 665
                         null,
666
-                        '<h3>' . get_lang('Total') . '</h3>',
666
+                        '<h3>'.get_lang('Total').'</h3>',
667 667
                         $main_weight,
668 668
                         $totalResult,
669 669
                         $totalRanking,
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
                 } else {
674 674
                     $row = array(
675 675
                         null,
676
-                        '<h3>' . get_lang('Total') . '</h3>',
676
+                        '<h3>'.get_lang('Total').'</h3>',
677 677
                         null,
678 678
                         $main_weight,
679 679
                         $totalResult,
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
         }
689 689
 
690 690
         // Warning messages
691
-        $view = isset($_GET['view']) ? $_GET['view']: null;
691
+        $view = isset($_GET['view']) ? $_GET['view'] : null;
692 692
 
693 693
         if ($this->teacherView) {
694 694
             if (isset($_GET['selectcat']) &&
@@ -701,14 +701,14 @@  discard block
 block discarded – undo
701 701
                 $weight_category = intval($this->build_weight($category[0]));
702 702
 
703 703
                 $course_code = $this->build_course_code($category[0]);
704
-                $weight_total_links  = round($weight_total_links);
704
+                $weight_total_links = round($weight_total_links);
705 705
 
706 706
                 if ($weight_total_links > $weight_category ||
707 707
                     $weight_total_links < $weight_category ||
708 708
                     $weight_total_links > $weight_category
709 709
                 ) {
710 710
                     $warning_message = sprintf(get_lang('TotalWeightMustBeX'), $weight_category);
711
-                    $modify_icons  = '<a href="gradebook_edit_cat.php?editcat='.$id_cat.'&cidReq='.$course_code.'&id_session='.api_get_session_id().'">'.
711
+                    $modify_icons = '<a href="gradebook_edit_cat.php?editcat='.$id_cat.'&cidReq='.$course_code.'&id_session='.api_get_session_id().'">'.
712 712
                         Display::return_icon('edit.png', $warning_message, array(), ICON_SIZE_SMALL).'</a>';
713 713
                     $warning_message .= $modify_icons;
714 714
                     Display::display_warning_message($warning_message, false);
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
                 );
722 722
 
723 723
                 if (!empty($content_html)) {
724
-                    $new_content = explode('</head>',$content_html['content']);
724
+                    $new_content = explode('</head>', $content_html['content']);
725 725
                 }
726 726
 
727 727
                 if (empty($new_content[0])) {
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
                     is_array($course_codes)
756 756
                 ) {
757 757
                     $warning_message = '';
758
-                    for ($x = 0; $x<count($weight_categories);$x++) {
758
+                    for ($x = 0; $x < count($weight_categories); $x++) {
759 759
                         $weight_category = intval($weight_categories[$x]);
760 760
                         $certificate_min_score = intval($certificate_min_scores[$x]);
761 761
                         $course_code = $course_codes[$x];
@@ -763,12 +763,12 @@  discard block
 block discarded – undo
763 763
                         if (empty($certificate_min_score) ||
764 764
                             ($certificate_min_score > $weight_category)
765 765
                         ) {
766
-                            $warning_message .= $course_code .'&nbsp;-&nbsp;'.get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan').'&nbsp;'.$weight_category.'<br />';
766
+                            $warning_message .= $course_code.'&nbsp;-&nbsp;'.get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan').'&nbsp;'.$weight_category.'<br />';
767 767
                         }
768 768
                     }
769 769
 
770 770
                     if (!empty($warning_message)) {
771
-                        Display::display_warning_message($warning_message,false);
771
+                        Display::display_warning_message($warning_message, false);
772 772
                     }
773 773
                 }
774 774
             }
@@ -812,15 +812,15 @@  discard block
 block discarded – undo
812 812
             $pChart->Antialias = FALSE;
813 813
 
814 814
             /* Add a border to the picture */
815
-            $pChart->drawRectangle(0,0,$xSize-10,$ySize-10,array("R"=>0,"G"=>0,"B"=>0));
815
+            $pChart->drawRectangle(0, 0, $xSize - 10, $ySize - 10, array("R"=>0, "G"=>0, "B"=>0));
816 816
 
817
-            $pChart->drawText(10,16,get_lang('Results'),array("FontSize"=>11,"Align"=>TEXT_ALIGN_BOTTOMLEFT));
817
+            $pChart->drawText(10, 16, get_lang('Results'), array("FontSize"=>11, "Align"=>TEXT_ALIGN_BOTTOMLEFT));
818 818
 
819
-            $pChart->setGraphArea(50, 30, $xSize-50, $ySize-50);
819
+            $pChart->setGraphArea(50, 30, $xSize - 50, $ySize - 50);
820 820
 
821 821
             $pChart->setFontProperties(
822 822
                 array(
823
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
823
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
824 824
                     'FontSize' => 10,
825 825
                 )
826 826
             );
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
 
841 841
             /* Draw the line chart */
842 842
             $pChart->drawLineChart();
843
-            $pChart->drawPlotChart(array("DisplayValues"=>TRUE,"PlotBorder"=>TRUE,"BorderSize"=>2,"Surrounding"=>-60,"BorderAlpha"=>80));
843
+            $pChart->drawPlotChart(array("DisplayValues"=>TRUE, "PlotBorder"=>TRUE, "BorderSize"=>2, "Surrounding"=>-60, "BorderAlpha"=>80));
844 844
 
845 845
             /* Write the chart legend */
846 846
             $pChart->drawLegend(
@@ -860,13 +860,13 @@  discard block
 block discarded – undo
860 860
             $chartHash = $myCache->getHash($dataSet);
861 861
 
862 862
             $myCache->writeToCache($chartHash, $pChart);
863
-            $imgSysPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
863
+            $imgSysPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
864 864
             $myCache->saveFromCache($chartHash, $imgSysPath);
865
-            $imgWebPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
865
+            $imgWebPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
866 866
 
867 867
             if (file_exists($imgSysPath)) {
868 868
                 $result = '<div id="contentArea" style="text-align: center;" >';
869
-                $result .= '<img src="' . $imgWebPath.'" >';
869
+                $result .= '<img src="'.$imgWebPath.'" >';
870 870
                 $result .= '</div>';
871 871
                 return $result;
872 872
             }
@@ -911,13 +911,13 @@  discard block
 block discarded – undo
911 911
         switch ($item->get_item_type()) {
912 912
             // category
913 913
             case 'C' :
914
-                return 'CATE' . $item->get_id();
914
+                return 'CATE'.$item->get_id();
915 915
             // evaluation
916 916
             case 'E' :
917
-                return 'EVAL' . $item->get_id();
917
+                return 'EVAL'.$item->get_id();
918 918
             // link
919 919
             case 'L' :
920
-                return 'LINK' . $item->get_id();
920
+                return 'LINK'.$item->get_id();
921 921
         }
922 922
     }
923 923
 
@@ -945,20 +945,20 @@  discard block
 block discarded – undo
945 945
         switch ($item->get_item_type()) {
946 946
             // category
947 947
             case 'C' :
948
-                $prms_uri='?selectcat=' . $item->get_id() . '&amp;view='.$view;
948
+                $prms_uri = '?selectcat='.$item->get_id().'&amp;view='.$view;
949 949
 
950 950
                 if (isset($_GET['isStudentView'])) {
951
-                    if ( isset($is_student) || ( isset($_SESSION['studentview']) && $_SESSION['studentview']=='studentview') ) {
952
-                        $prms_uri=$prms_uri.'&amp;isStudentView='.Security::remove_XSS($_GET['isStudentView']);
951
+                    if (isset($is_student) || (isset($_SESSION['studentview']) && $_SESSION['studentview'] == 'studentview')) {
952
+                        $prms_uri = $prms_uri.'&amp;isStudentView='.Security::remove_XSS($_GET['isStudentView']);
953 953
                     }
954 954
                 }
955 955
 
956 956
                 $cat = new Category();
957
-                $show_message=$cat->show_message_resource_delete($item->get_course_code());
957
+                $show_message = $cat->show_message_resource_delete($item->get_course_code());
958 958
                 return '&nbsp;<a href="'.Security::remove_XSS($_SESSION['gradebook_dest']).$prms_uri.'">'
959 959
                 . $item->get_name()
960 960
                 . '</a>'
961
-                . ($item->is_course() ? ' &nbsp;[' . $item->get_course_code() . ']'.$show_message : '');
961
+                . ($item->is_course() ? ' &nbsp;['.$item->get_course_code().']'.$show_message : '');
962 962
                 // evaluation
963 963
             case 'E' :
964 964
                 $cat = new Category();
@@ -966,10 +966,10 @@  discard block
 block discarded – undo
966 966
                 $show_message = $cat->show_message_resource_delete($course_id);
967 967
 
968 968
                 // course/platform admin can go to the view_results page
969
-                if (api_is_allowed_to_edit() && $show_message===false) {
969
+                if (api_is_allowed_to_edit() && $show_message === false) {
970 970
                     if ($item->get_type() == 'presence') {
971 971
                         return '&nbsp;'
972
-                        . '<a href="gradebook_view_result.php?cidReq='.$course_id.'&amp;selecteval=' . $item->get_id() . '">'
972
+                        . '<a href="gradebook_view_result.php?cidReq='.$course_id.'&amp;selecteval='.$item->get_id().'">'
973 973
                         . $item->get_name()
974 974
                         . '</a>';
975 975
                     } else {
@@ -978,20 +978,20 @@  discard block
 block discarded – undo
978 978
                             $extra = '';
979 979
                         }
980 980
                         return '&nbsp;'
981
-                        . '<a href="gradebook_view_result.php?' . api_get_cidreq() . '&selecteval=' . $item->get_id() . '">'
981
+                        . '<a href="gradebook_view_result.php?'.api_get_cidreq().'&selecteval='.$item->get_id().'">'
982 982
                         . $item->get_name()
983 983
                         . '</a>&nbsp;'.$extra;
984 984
                     }
985
-                } elseif (ScoreDisplay :: instance()->is_custom() && $show_message===false) {
985
+                } elseif (ScoreDisplay :: instance()->is_custom() && $show_message === false) {
986 986
                     // students can go to the statistics page (if custom display enabled)
987 987
                     return '&nbsp;'
988
-                    . '<a href="gradebook_statistics.php?' . api_get_cidreq() . '&selecteval=' . $item->get_id() . '">'
988
+                    . '<a href="gradebook_statistics.php?'.api_get_cidreq().'&selecteval='.$item->get_id().'">'
989 989
                     . $item->get_name()
990 990
                     . '</a>';
991 991
 
992 992
                 } elseif ($show_message === false && !api_is_allowed_to_edit() && !ScoreDisplay :: instance()->is_custom()) {
993 993
                     return '&nbsp;'
994
-                    . '<a href="gradebook_statistics.php?' . api_get_cidreq() . '&selecteval=' . $item->get_id() . '">'
994
+                    . '<a href="gradebook_statistics.php?'.api_get_cidreq().'&selecteval='.$item->get_id().'">'
995 995
                     . $item->get_name()
996 996
                     . '</a>';
997 997
                 } else {
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
                 $url = $item->get_link();
1007 1007
 
1008 1008
                 if (isset($url) && $show_message === false) {
1009
-                    $text = '&nbsp;<a href="' . $item->get_link() . '">'
1009
+                    $text = '&nbsp;<a href="'.$item->get_link().'">'
1010 1010
                         . $item->get_name()
1011 1011
                         . '</a>';
1012 1012
                 } else {
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -256,10 +256,11 @@
 block discarded – undo
256 256
         }
257 257
 
258 258
         // Categories.
259
-        if (!empty($data_array))
260
-        foreach ($data_array as $data) {
259
+        if (!empty($data_array)) {
260
+                foreach ($data_array as $data) {
261 261
             // list of items inside the gradebook (exercises, lps, forums, etc)
262 262
             $row  = array();
263
+        }
263 264
             /** @var AbstractLink $item */
264 265
             $item = $mainCategory = $data[0];
265 266
 
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 
4
-use ChamiloSession as Session;
5 4
 use Symfony\Component\Finder\Finder;
6 5
 
7 6
 require_once '../inc/global.inc.php';
Please login to merge, or discard this patch.
main/gradebook/lib/fe/linkform.class.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -124,8 +124,8 @@
 block discarded – undo
124 124
 	}
125 125
 
126 126
 	/**
127
-	 * @param $link
128
-	 * @param $courseCode
127
+	 * @param integer $link
128
+	 * @param null|string $courseCode
129 129
 	 * @return AttendanceLink|DropboxLink|ExerciseLink|ForumThreadLink|LearnpathLink|null|StudentPublicationLink|SurveyLink
130 130
 	 */
131 131
 	private function createLink($link, $courseCode)
Please login to merge, or discard this patch.
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -10,133 +10,133 @@
 block discarded – undo
10 10
  */
11 11
 class LinkForm extends FormValidator
12 12
 {
13
-	const TYPE_CREATE = 1;
14
-	const TYPE_MOVE = 2;
15
-	/** @var Category */
16
-	private $category_object;
17
-	private $link_object;
18
-	private $extra;
13
+    const TYPE_CREATE = 1;
14
+    const TYPE_MOVE = 2;
15
+    /** @var Category */
16
+    private $category_object;
17
+    private $link_object;
18
+    private $extra;
19 19
 
20
-	/**
21
-	 * Builds a form containing form items based on a given parameter
22
-	 * @param int form_type 1=choose link
23
-	 * @param obj cat_obj the category object
24
-	 * @param string form name
25
-	 * @param method
26
-	 * @param action
27
-	 */
28
-	public function LinkForm(
29
-		$form_type,
30
-		$category_object,
31
-		$link_object,
32
-		$form_name,
33
-		$method = 'post',
34
-		$action = null,
35
-		$extra = null
36
-	) {
37
-		parent :: __construct($form_name, $method, $action);
20
+    /**
21
+     * Builds a form containing form items based on a given parameter
22
+     * @param int form_type 1=choose link
23
+     * @param obj cat_obj the category object
24
+     * @param string form name
25
+     * @param method
26
+     * @param action
27
+     */
28
+    public function LinkForm(
29
+        $form_type,
30
+        $category_object,
31
+        $link_object,
32
+        $form_name,
33
+        $method = 'post',
34
+        $action = null,
35
+        $extra = null
36
+    ) {
37
+        parent :: __construct($form_name, $method, $action);
38 38
 
39
-		if (isset ($category_object)) {
40
-			$this->category_object = $category_object;
41
-		} else {
42
-			if (isset($link_object)) {
43
-				$this->link_object = $link_object;
44
-			}
45
-		}
39
+        if (isset ($category_object)) {
40
+            $this->category_object = $category_object;
41
+        } else {
42
+            if (isset($link_object)) {
43
+                $this->link_object = $link_object;
44
+            }
45
+        }
46 46
 
47
-		if (isset ($extra)) {
48
-			$this->extra = $extra;
49
-		}
50
-		if ($form_type == self :: TYPE_CREATE) {
51
-			$this->build_create();
52
-		} elseif ($form_type == self :: TYPE_MOVE) {
53
-			$this->build_move();
54
-		}
55
-	}
47
+        if (isset ($extra)) {
48
+            $this->extra = $extra;
49
+        }
50
+        if ($form_type == self :: TYPE_CREATE) {
51
+            $this->build_create();
52
+        } elseif ($form_type == self :: TYPE_MOVE) {
53
+            $this->build_move();
54
+        }
55
+    }
56 56
 
57
-	protected function build_move()
58
-	{
59
-		$renderer =& $this->defaultRenderer();
60
-		$renderer->setCustomElementTemplate('<span>{element}</span> ');
61
-		$this->addElement('static',null,null,'"'.$this->link_object->get_name().'" ');
62
-		$this->addElement('static',null,null,get_lang('MoveTo').' : ');
63
-		$select = $this->addElement('select','move_cat',null,null);
64
-		$line = '';
65
-		foreach ($this->link_object->get_target_categories() as $cat) {
66
-			for ($i=0;$i<$cat[2];$i++) {
67
-				$line .= '&mdash;';
68
-			}
69
-			$select->addoption($line.' '.$cat[1],$cat[0]);
70
-			$line = '';
71
-		}
72
-		$this->addElement('submit', null, get_lang('Ok'));
73
-	}
57
+    protected function build_move()
58
+    {
59
+        $renderer =& $this->defaultRenderer();
60
+        $renderer->setCustomElementTemplate('<span>{element}</span> ');
61
+        $this->addElement('static',null,null,'"'.$this->link_object->get_name().'" ');
62
+        $this->addElement('static',null,null,get_lang('MoveTo').' : ');
63
+        $select = $this->addElement('select','move_cat',null,null);
64
+        $line = '';
65
+        foreach ($this->link_object->get_target_categories() as $cat) {
66
+            for ($i=0;$i<$cat[2];$i++) {
67
+                $line .= '&mdash;';
68
+            }
69
+            $select->addoption($line.' '.$cat[1],$cat[0]);
70
+            $line = '';
71
+        }
72
+        $this->addElement('submit', null, get_lang('Ok'));
73
+    }
74 74
 
75
-	/**
76
-	 * Builds the form
77
-	 */
78
-	protected function build_create()
79
-	{
80
-		$this->addElement('header', get_lang('MakeLink'));
81
-		$select = $this->addElement(
82
-			'select',
83
-			'select_link',
84
-			get_lang('ChooseLink'),
85
-			null,
86
-			array('onchange' => 'document.create_link.submit()')
87
-		);
75
+    /**
76
+     * Builds the form
77
+     */
78
+    protected function build_create()
79
+    {
80
+        $this->addElement('header', get_lang('MakeLink'));
81
+        $select = $this->addElement(
82
+            'select',
83
+            'select_link',
84
+            get_lang('ChooseLink'),
85
+            null,
86
+            array('onchange' => 'document.create_link.submit()')
87
+        );
88 88
 
89
-		$linkTypes = LinkFactory::get_all_types();
89
+        $linkTypes = LinkFactory::get_all_types();
90 90
 
91
-		$select->addoption('['.get_lang('ChooseLink').']', 0);
91
+        $select->addoption('['.get_lang('ChooseLink').']', 0);
92 92
 
93
-		$courseCode = $this->category_object->get_course_code();
93
+        $courseCode = $this->category_object->get_course_code();
94 94
 
95
-		foreach ($linkTypes as $linkType) {
96
-			// The hot potatoe link will be added "inside" the exercise option.
97
-			if ($linkType == LINK_HOTPOTATOES) {
98
-				continue;
99
-			}
100
-			$link = $this->createLink($linkType, $courseCode);
101
-			// disable this element if the link works with a dropdownlist
102
-			// and if there are no links left
103
-			if (!$link->needs_name_and_description() && count($link->get_all_links()) == '0') {
104
-				$select->addoption($link->get_type_name(), $linkType, 'disabled');
105
-			} else {
106
-				if ($link->get_type() == LINK_EXERCISE) {
107
-					// Adding exercise
108
-					$select->addoption($link->get_type_name(), $linkType);
109
-					// Adding hot potatoes
110
-					$linkHot = $this->createLink(LINK_HOTPOTATOES, $courseCode);
111
-					$select->addoption(
112
-						'&nbsp;&nbsp;&nbsp;'.$linkHot->get_type_name(),
113
-						LINK_HOTPOTATOES
114
-					);
115
-				} else {
116
-					$select->addoption($link->get_type_name(), $linkType);
117
-				}
118
-			}
119
-		}
95
+        foreach ($linkTypes as $linkType) {
96
+            // The hot potatoe link will be added "inside" the exercise option.
97
+            if ($linkType == LINK_HOTPOTATOES) {
98
+                continue;
99
+            }
100
+            $link = $this->createLink($linkType, $courseCode);
101
+            // disable this element if the link works with a dropdownlist
102
+            // and if there are no links left
103
+            if (!$link->needs_name_and_description() && count($link->get_all_links()) == '0') {
104
+                $select->addoption($link->get_type_name(), $linkType, 'disabled');
105
+            } else {
106
+                if ($link->get_type() == LINK_EXERCISE) {
107
+                    // Adding exercise
108
+                    $select->addoption($link->get_type_name(), $linkType);
109
+                    // Adding hot potatoes
110
+                    $linkHot = $this->createLink(LINK_HOTPOTATOES, $courseCode);
111
+                    $select->addoption(
112
+                        '&nbsp;&nbsp;&nbsp;'.$linkHot->get_type_name(),
113
+                        LINK_HOTPOTATOES
114
+                    );
115
+                } else {
116
+                    $select->addoption($link->get_type_name(), $linkType);
117
+                }
118
+            }
119
+        }
120 120
 
121
-		if (isset($this->extra)) {
122
-			$this->setDefaults(array('select_link' => $this->extra));
123
-		}
124
-	}
121
+        if (isset($this->extra)) {
122
+            $this->setDefaults(array('select_link' => $this->extra));
123
+        }
124
+    }
125 125
 
126
-	/**
127
-	 * @param $link
128
-	 * @param $courseCode
129
-	 * @return AttendanceLink|DropboxLink|ExerciseLink|ForumThreadLink|LearnpathLink|null|StudentPublicationLink|SurveyLink
130
-	 */
131
-	private function createLink($link, $courseCode)
132
-	{
133
-		$link = LinkFactory::create($link);
134
-		if (!empty($courseCode)) {
135
-			$link->set_course_code($courseCode);
136
-		} elseif(!empty($_GET['course_code'])) {
137
-			$link->set_course_code(Database::escape_string($_GET['course_code'], null, false));
138
-		}
126
+    /**
127
+     * @param $link
128
+     * @param $courseCode
129
+     * @return AttendanceLink|DropboxLink|ExerciseLink|ForumThreadLink|LearnpathLink|null|StudentPublicationLink|SurveyLink
130
+     */
131
+    private function createLink($link, $courseCode)
132
+    {
133
+        $link = LinkFactory::create($link);
134
+        if (!empty($courseCode)) {
135
+            $link->set_course_code($courseCode);
136
+        } elseif(!empty($_GET['course_code'])) {
137
+            $link->set_course_code(Database::escape_string($_GET['course_code'], null, false));
138
+        }
139 139
 
140
-		return $link;
141
-	}
140
+        return $link;
141
+    }
142 142
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -56,17 +56,17 @@  discard block
 block discarded – undo
56 56
 
57 57
 	protected function build_move()
58 58
 	{
59
-		$renderer =& $this->defaultRenderer();
59
+		$renderer = & $this->defaultRenderer();
60 60
 		$renderer->setCustomElementTemplate('<span>{element}</span> ');
61
-		$this->addElement('static',null,null,'"'.$this->link_object->get_name().'" ');
62
-		$this->addElement('static',null,null,get_lang('MoveTo').' : ');
63
-		$select = $this->addElement('select','move_cat',null,null);
61
+		$this->addElement('static', null, null, '"'.$this->link_object->get_name().'" ');
62
+		$this->addElement('static', null, null, get_lang('MoveTo').' : ');
63
+		$select = $this->addElement('select', 'move_cat', null, null);
64 64
 		$line = '';
65 65
 		foreach ($this->link_object->get_target_categories() as $cat) {
66
-			for ($i=0;$i<$cat[2];$i++) {
66
+			for ($i = 0; $i < $cat[2]; $i++) {
67 67
 				$line .= '&mdash;';
68 68
 			}
69
-			$select->addoption($line.' '.$cat[1],$cat[0]);
69
+			$select->addoption($line.' '.$cat[1], $cat[0]);
70 70
 			$line = '';
71 71
 		}
72 72
 		$this->addElement('submit', null, get_lang('Ok'));
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 		$link = LinkFactory::create($link);
134 134
 		if (!empty($courseCode)) {
135 135
 			$link->set_course_code($courseCode);
136
-		} elseif(!empty($_GET['course_code'])) {
136
+		} elseif (!empty($_GET['course_code'])) {
137 137
 			$link->set_course_code(Database::escape_string($_GET['course_code'], null, false));
138 138
 		}
139 139
 
Please login to merge, or discard this patch.
main/gradebook/lib/flatview_data_generator.class.php 2 patches
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      * @param array $evals
31 31
      * @param array $links
32 32
      * @param array $params
33
-     * @param null $mainCourseCategory
33
+     * @param Category|null $mainCourseCategory
34 34
      */
35 35
     public function FlatViewDataGenerator(
36 36
         $users = array(),
@@ -276,6 +276,8 @@  discard block
 block discarded – undo
276 276
 
277 277
     /**
278 278
      * Get actual array data
279
+     * @param integer $users_count
280
+     * @param integer $items_count
279 281
      * @return array 2-dimensional array - each array contains the elements:
280 282
      * 0: user id
281 283
      * 1: user lastname
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
             isset($this->params['only_subcat']) &&
115 115
             $this->params['only_subcat'] == $this->category->get_id()
116 116
         ) {
117
-            $main_weight  = $this->category->get_weight();
117
+            $main_weight = $this->category->get_weight();
118 118
             $grade_model_id = $this->category->get_grade_model_id();
119 119
         } else {
120
-            $main_cat  = Category::load($parent_id, null, null);
120
+            $main_cat = Category::load($parent_id, null, null);
121 121
             $main_weight = $main_cat[0]->get_weight();
122 122
             $grade_model_id = $main_cat[0]->get_grade_model_id();
123 123
         }
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
                     $list = [];
200 200
                     $list['items'] = $finalList;
201 201
                     $list['header'] = '<center>'.$mainHeader.'</center>';
202
-                    $headers[]= $list;
202
+                    $headers[] = $list;
203 203
                 } else {
204 204
                     $headers[] = '<center>'.$mainHeader.'</center>';
205 205
                 }
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
                 (isset($this->params['only_total_category']) &&
210 210
                     $this->params['only_total_category'] == false)
211 211
             ) {
212
-                for ($count=0; ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); $count++) {
212
+                for ($count = 0; ($count < $items_count) && ($items_start + $count < count($this->evals_links)); $count++) {
213 213
                     /** @var AbstractLink $item */
214 214
                     $item = $this->evals_links[$count + $items_start];
215 215
                     $weight = round(100 * $item->get_weight() / $main_weight, 1);
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
                     !in_array($item->get_id(), $evaluationsAdded)
228 228
                 ) {
229 229
                     $weight = round(100 * $item->get_weight() / $main_weight, 1);
230
-                    $headers[] = $item->get_name() . ' ' . $weight . ' % ';
230
+                    $headers[] = $item->get_name().' '.$weight.' % ';
231 231
                 }
232 232
             }
233 233
         }
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
         if (!isset($items_count)) {
267 267
             $items_count = count($this->evals_links) - $items_start;
268 268
         }
269
-        for ($count=0; ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); $count++) {
269
+        for ($count = 0; ($count < $items_count) && ($items_start + $count < count($this->evals_links)); $count++) {
270 270
             $item = $this->evals_links [$count + $items_start];
271 271
             $headers[] = $item->get_name();
272 272
         }
@@ -293,13 +293,13 @@  discard block
 block discarded – undo
293 293
     ) {
294 294
         // Do some checks on users/items counts, redefine if invalid values
295 295
         if (!isset($users_count)) {
296
-            $users_count = count ($this->users) - $users_start;
296
+            $users_count = count($this->users) - $users_start;
297 297
         }
298 298
         if ($users_count < 0) {
299 299
             $users_count = 0;
300 300
         }
301 301
         if (!isset($items_count)) {
302
-            $items_count = count ($this->evals) + count ($this->links) - $items_start;
302
+            $items_count = count($this->evals) + count($this->links) - $items_start;
303 303
         }
304 304
         if ($items_count < 0) {
305 305
             $items_count = 0;
@@ -312,10 +312,10 @@  discard block
 block discarded – undo
312 312
 
313 313
         // sort users array
314 314
         if ($users_sorting & self :: FVDG_SORT_LASTNAME) {
315
-            usort($userTable, array('FlatViewDataGenerator','sort_by_last_name'));
315
+            usort($userTable, array('FlatViewDataGenerator', 'sort_by_last_name'));
316 316
 
317 317
         } elseif ($users_sorting & self :: FVDG_SORT_FIRSTNAME) {
318
-            usort($userTable, array('FlatViewDataGenerator','sort_by_first_name'));
318
+            usort($userTable, array('FlatViewDataGenerator', 'sort_by_first_name'));
319 319
         }
320 320
 
321 321
         if ($users_sorting & self :: FVDG_SORT_DESC) {
@@ -356,10 +356,10 @@  discard block
 block discarded – undo
356 356
         $parent_id = $this->category->get_parent_id();
357 357
 
358 358
         if ($parent_id == 0 or $this->params['only_subcat'] == $this->category->get_id()) {
359
-            $main_weight  = $this->category->get_weight();
359
+            $main_weight = $this->category->get_weight();
360 360
             $grade_model_id = $this->category->get_grade_model_id();
361 361
         } else {
362
-            $main_cat  = Category::load($parent_id, null, null);
362
+            $main_cat = Category::load($parent_id, null, null);
363 363
             $main_weight = $main_cat[0]->get_weight();
364 364
             $grade_model_id = $main_cat[0]->get_grade_model_id();
365 365
         }
@@ -471,11 +471,11 @@  discard block
 block discarded – undo
471 471
                     $divide = $score[1] == 0 ? 1 : $score[1];
472 472
 
473 473
                     $sub_cat_percentage = $sum_categories_weight_array[$sub_cat->get_id()];
474
-                    $item_value  = $score[0]/$divide*$main_weight;
474
+                    $item_value = $score[0] / $divide * $main_weight;
475 475
 
476 476
                     // Fixing total when using one or multiple gradebooks
477
-                    $percentage = $sub_cat->get_weight()/($sub_cat_percentage) * $sub_cat_percentage/$this->category->get_weight();
478
-                    $item_value = $percentage*$item_value;
477
+                    $percentage = $sub_cat->get_weight() / ($sub_cat_percentage) * $sub_cat_percentage / $this->category->get_weight();
478
+                    $item_value = $percentage * $item_value;
479 479
                     $item_total += $sub_cat->get_weight();
480 480
                     /*
481 481
                         if ($convert_using_the_global_weight) {
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
                 if ($convert_using_the_global_weight) {
522 522
                     //$item_total = $main_weight;
523 523
                 }
524
-            } else  {
524
+            } else {
525 525
                 // All evaluations
526 526
                 $result = $this->parseEvaluations(
527 527
                     $user_id,
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
             // Sub cat weight
629 629
             //$sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
630 630
 
631
-            $item_value = isset($score[0]) ? $score[0]/$divide : 0;
631
+            $item_value = isset($score[0]) ? $score[0] / $divide : 0;
632 632
 
633 633
             // Fixing total when using one or multiple gradebooks.
634 634
             if (empty($parentCategoryIdFilter)) {
@@ -710,11 +710,11 @@  discard block
 block discarded – undo
710 710
         $data = array();
711 711
 
712 712
         foreach ($selected_users as $user) {
713
-            $row = array ();
714
-            for ($count=0;$count < count($this->evals_links); $count++) {
713
+            $row = array();
714
+            for ($count = 0; $count < count($this->evals_links); $count++) {
715 715
                 $item = $this->evals_links [$count];
716 716
                 $score = $item->calc_score($user[0]);
717
-                $porcent_score = isset($score[1]) &&  $score[1] > 0 ? ($score[0]*100)/$score[1] :0;
717
+                $porcent_score = isset($score[1]) && $score[1] > 0 ? ($score[0] * 100) / $score[1] : 0;
718 718
                 $row[$item->get_name()] = $porcent_score;
719 719
             }
720 720
             $data[$user[0]] = $row;
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
             $tmp = array();
727 727
             foreach ($items as $item => $value) {
728 728
                 $tmp[] = $item;
729
-                if (in_array($item,$tmp)) {
729
+                if (in_array($item, $tmp)) {
730 730
                     $data_by_item[$item][$uid] = $value;
731 731
                 }
732 732
             }
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
         */
738 738
         $result = array();
739 739
         foreach ($data_by_item as $k => $v) {
740
-            $average = round(array_sum($v)/count($v));
740
+            $average = round(array_sum($v) / count($v));
741 741
             arsort($v);
742 742
             $maximum = array_shift($v);
743 743
             $minimum = array_pop($v);
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
                 $minimum = 0;
747 747
             }
748 748
 
749
-            $summary= array(
749
+            $summary = array(
750 750
                 'max' => $maximum,
751 751
                 'min' => $minimum,
752 752
                 'avg' => $average
@@ -763,32 +763,32 @@  discard block
 block discarded – undo
763 763
     public function get_data_to_graph()
764 764
     {
765 765
         // do some checks on users/items counts, redefine if invalid values
766
-        $usertable = array ();
766
+        $usertable = array();
767 767
         foreach ($this->users as $user) {
768 768
             $usertable[] = $user;
769 769
         }
770 770
         // sort users array
771
-        usort($usertable, array ('FlatViewDataGenerator','sort_by_first_name'));
771
+        usort($usertable, array('FlatViewDataGenerator', 'sort_by_first_name'));
772 772
 
773
-        $data = array ();
773
+        $data = array();
774 774
 
775 775
         $selected_users = $usertable;
776 776
         foreach ($selected_users as $user) {
777
-            $row = array ();
778
-            $row[] = $user[0];    // user id
777
+            $row = array();
778
+            $row[] = $user[0]; // user id
779 779
             $item_value = 0;
780 780
             $item_total = 0;
781 781
 
782
-            for ($count=0;$count < count($this->evals_links); $count++) {
782
+            for ($count = 0; $count < count($this->evals_links); $count++) {
783 783
                 $item = $this->evals_links[$count];
784 784
                 $score = $item->calc_score($user[0]);
785 785
 
786
-                $divide =( ($score[1])==0 ) ? 1 : $score[1];
787
-                $item_value += $score[0]/$divide*$item->get_weight();
786
+                $divide = (($score[1]) == 0) ? 1 : $score[1];
787
+                $item_value += $score[0] / $divide * $item->get_weight();
788 788
                 $item_total += $item->get_weight();
789 789
 
790 790
 
791
-                $score_denom = ($score[1]==0) ? 1 : $score[1];
791
+                $score_denom = ($score[1] == 0) ? 1 : $score[1];
792 792
                 $score_final = ($score[0] / $score_denom) * 100;
793 793
                 $row[] = $score_final;
794 794
             }
@@ -814,15 +814,15 @@  discard block
 block discarded – undo
814 814
             $usertable[] = $user;
815 815
         }
816 816
         // sort users array
817
-        usort($usertable, array ('FlatViewDataGenerator','sort_by_first_name'));
817
+        usort($usertable, array('FlatViewDataGenerator', 'sort_by_first_name'));
818 818
 
819 819
         // generate actual data array
820 820
         $scoredisplay = ScoreDisplay :: instance();
821 821
         $data = array();
822 822
         $selected_users = $usertable;
823 823
         foreach ($selected_users as $user) {
824
-            $row = array ();
825
-            $row[] = $user[0];    // user id
824
+            $row = array();
825
+            $row[] = $user[0]; // user id
826 826
             $item_value = 0;
827 827
             $item_total = 0;
828 828
             $final_score = 0;
@@ -843,8 +843,8 @@  discard block
 block discarded – undo
843 843
                     $divide = $score[1] == 0 ? 1 : $score[1];
844 844
 
845 845
                     //$sub_cat_percentage = $sum_categories_weight_array[$sub_cat->get_id()];
846
-                    $item_value     = $score[0]/$divide*$main_weight;
847
-                    $item_total        += $sub_cat->get_weight();
846
+                    $item_value = $score[0] / $divide * $main_weight;
847
+                    $item_total += $sub_cat->get_weight();
848 848
 
849 849
                     $row[] = array(
850 850
                         $item_value,
@@ -861,23 +861,23 @@  discard block
 block discarded – undo
861 861
                     trim($scoredisplay->display_score($total_score, SCORE_CUSTOM, null, true))
862 862
                 );
863 863
             } else {
864
-                for ($count=0;$count < count($this->evals_links); $count++) {
864
+                for ($count = 0; $count < count($this->evals_links); $count++) {
865 865
                     $item = $this->evals_links [$count];
866 866
                     $score = $item->calc_score($user[0]);
867 867
                     $divide = ($score[1]) == 0 ? 1 : $score[1];
868 868
                     $item_value += $score[0] / $divide * $item->get_weight();
869
-                    $item_total+=$item->get_weight();
870
-                    $score_denom=($score[1]==0) ? 1 : $score[1];
869
+                    $item_total += $item->get_weight();
870
+                    $score_denom = ($score[1] == 0) ? 1 : $score[1];
871 871
                     $score_final = ($score[0] / $score_denom) * 100;
872
-                    $row[] = array ($score_final, trim($scoredisplay->display_score($score, SCORE_CUSTOM,null, true)));
872
+                    $row[] = array($score_final, trim($scoredisplay->display_score($score, SCORE_CUSTOM, null, true)));
873 873
 
874 874
                 }
875
-                $total_score=array($item_value,$item_total);
875
+                $total_score = array($item_value, $item_total);
876 876
                 $score_final = ($item_value / $item_total) * 100;
877 877
                 if ($displayWarning) {
878
-                    Display::display_warning_message( Display::display_warning_message($total_score[1]));
878
+                    Display::display_warning_message(Display::display_warning_message($total_score[1]));
879 879
                 }
880
-                $row[] =array ($score_final, trim($scoredisplay->display_score($total_score, SCORE_CUSTOM, null, true)));
880
+                $row[] = array($score_final, trim($scoredisplay->display_score($total_score, SCORE_CUSTOM, null, true)));
881 881
             }
882 882
 
883 883
             $data[] = $row;
Please login to merge, or discard this patch.
main/gradebook/lib/gradebook_data_generator.class.php 2 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,6 +71,7 @@  discard block
 block discarded – undo
71 71
 
72 72
     /**
73 73
      * Get actual array data
74
+     * @param integer $count
74 75
      * @return array 2-dimensional array - each array contains the elements:
75 76
      * 0: cat/eval/link object
76 77
      * 1: item name
@@ -304,7 +305,7 @@  discard block
 block discarded – undo
304 305
     /**
305 306
      * @param int $userId
306 307
      * @param GradebookItem $item
307
-     * @param $ignore_score_color
308
+     * @param boolean $ignore_score_color
308 309
      * @return null|string
309 310
      */
310 311
     private function build_result_column(
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
         if (count($allcats) > 0) {
43 43
             // get sub categories id
44 44
             $tabCategories = array();
45
-            for ($i=0; $i < count($allcats); $i++) {
45
+            for ($i = 0; $i < count($allcats); $i++) {
46 46
                 $tabCategories[] = $allcats[$i]->get_id();
47 47
             }
48 48
             // dont display links that belongs to a sub category
49 49
             $tabLinkToDisplay = array();
50
-            for ($i=0; $i < count($alllinks); $i++) {
50
+            for ($i = 0; $i < count($alllinks); $i++) {
51 51
                 if (!in_array($alllinks[$i]->get_category_id(), $tabCategories)) {
52 52
                     $tabLinkToDisplay[] = $alllinks[$i];
53 53
                 }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         //$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
90 90
         // do some checks on count, redefine if invalid value
91 91
         if (!isset($count)) {
92
-            $count = count ($this->items) - $start;
92
+            $count = count($this->items) - $start;
93 93
         }
94 94
         if ($count < 0) {
95 95
             $count = 0;
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
         $display = $scoreDisplay->display_score($score, SCORE_DIV, SCORE_BOTH, true);
247 247
         $type = $item->get_item_type();
248 248
         if ($type == 'L' && get_class($item) == 'ExerciseLink') {
249
-            $display  = ExerciseLib::show_score($score[0], $score[1], false);
249
+            $display = ExerciseLib::show_score($score[0], $score[1], false);
250 250
         }
251 251
 
252 252
         return array(
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
         $type = $item->get_item_type();
269 269
 
270 270
         if ($type == 'L' && get_class($item) == 'ExerciseLink') {
271
-            $display  = ExerciseLib::show_score($score[0], $score[1], false);
271
+            $display = ExerciseLib::show_score($score[0], $score[1], false);
272 272
         }
273 273
 
274 274
         return array(
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 
362 362
                 $type = $item->get_item_type();
363 363
                 if ($type == 'L' && get_class($item) == 'ExerciseLink') {
364
-                    $display  = ExerciseLib::show_score($score[0], $score[1], false);
364
+                    $display = ExerciseLib::show_score($score[0], $score[1], false);
365 365
                 }
366 366
 
367 367
                 return array(
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
     public function sort_by_type($item1, $item2)
443 443
     {
444 444
         if ($item1->get_item_type() == $item2->get_item_type()) {
445
-            return $this->sort_by_name($item1,$item2);
445
+            return $this->sort_by_name($item1, $item2);
446 446
         } else {
447 447
             return ($item1->get_item_type() < $item2->get_item_type() ? -1 : 1);
448 448
         }
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
     {
458 458
         $result = api_strcmp($item1->get_description(), $item2->get_description());
459 459
         if ($result == 0) {
460
-            return $this->sort_by_name($item1,$item2);
460
+            return $this->sort_by_name($item1, $item2);
461 461
         }
462 462
         return $result;
463 463
     }
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
     public function sort_by_weight($item1, $item2)
471 471
     {
472 472
         if ($item1->get_weight() == $item2->get_weight()) {
473
-            return $this->sort_by_name($item1,$item2);
473
+            return $this->sort_by_name($item1, $item2);
474 474
         } else {
475 475
             return ($item1->get_weight() < $item2->get_weight() ? -1 : 1);
476 476
         }
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
         }
502 502
 
503 503
         if ($timestamp1 == $timestamp2) {
504
-            return $this->sort_by_name($item1,$item2);
504
+            return $this->sort_by_name($item1, $item2);
505 505
         } else {
506 506
             return ($timestamp1 < $timestamp2 ? -1 : 1);
507 507
         }
Please login to merge, or discard this patch.
main/gradebook/lib/gradebook_result.class.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
 
77 77
     /**
78 78
      * Exports the complete report as an XLS file
79
-     * @return	boolean		False on error
79
+     * @return	boolean|null		False on error
80 80
      */
81 81
     public function exportCompleteReportXLS($data)
82 82
     {
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     /**
15 15
      * constructor of the class
16 16
      */
17
-    public function __construct($get_questions=false,$get_answers=false)
17
+    public function __construct($get_questions = false, $get_answers = false)
18 18
     {
19 19
     }
20 20
 
@@ -36,21 +36,21 @@  discard block
 block discarded – undo
36 36
         //titles
37 37
 
38 38
         foreach ($dato[0] as $header_col) {
39
-            if(!empty($header_col)) {
40
-                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($header_col))).';';
39
+            if (!empty($header_col)) {
40
+                $data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($header_col))).';';
41 41
             }
42 42
         }
43 43
 
44
-        $data .="\r\n";
44
+        $data .= "\r\n";
45 45
         $cant_students = count($dato[1]);
46 46
         //print_r($data);		exit();
47 47
 
48
-        for($i=0;$i<$cant_students;$i++) {
48
+        for ($i = 0; $i < $cant_students; $i++) {
49 49
             $column = 0;
50
-            foreach($dato[1][$i] as $col_name) {
51
-                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($col_name))).';';
50
+            foreach ($dato[1][$i] as $col_name) {
51
+                $data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($col_name))).';';
52 52
             }
53
-            $data .="\r\n";
53
+            $data .= "\r\n";
54 54
         }
55 55
 
56 56
         //output the results
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         for ($i = 0; $i < $cant_students; $i++) {
102 102
             $column = 0;
103 103
             foreach ($data[1][$i] as $col_name) {
104
-                $worksheet->SetCellValueByColumnAndRow($line,$column, html_entity_decode(strip_tags($col_name)));
104
+                $worksheet->SetCellValueByColumnAndRow($line, $column, html_entity_decode(strip_tags($col_name)));
105 105
                 $column++;
106 106
             }
107 107
             $line++;
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      */
122 122
     public function exportCompleteReportDOC($data)
123 123
     {
124
-        $filename = 'gradebook_results_'.api_get_local_time() . '.docx';
124
+        $filename = 'gradebook_results_'.api_get_local_time().'.docx';
125 125
 
126 126
         $doc = new \PhpOffice\PhpWord\PhpWord();
127 127
         $section = $doc->addSection(['orientation' => 'landscape']);
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
             }
141 141
         }
142 142
 
143
-        $file = api_get_path(SYS_ARCHIVE_PATH) . api_replace_dangerous_char($filename);
143
+        $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
144 144
         $doc->save($file, 'Word2007');
145 145
 
146 146
         DocumentManager::file_send_for_download($file, true, $filename);
Please login to merge, or discard this patch.
main/gradebook/lib/results_data_generator.class.php 2 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -45,6 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
     /**
47 47
      * Get actual array data
48
+     * @param integer $count
48 49
      * @return array 2-dimensional array - each array contains the elements:
49 50
      * 0 ['id']        : user id
50 51
      * 1 ['result_id'] : result id
@@ -130,6 +131,7 @@  discard block
 block discarded – undo
130 131
      * @param float Current absolute score (max score is taken from $this->evaluation->get_max()
131 132
      * @param bool  Whether we want the real score (2/4 (50 %)) or the transformation (A, B, C, etc)
132 133
      * @param bool  Whether we want to ignore the score color
134
+     * @param boolean $realscore
133 135
      * @result string The score as we want to show it
134 136
      */
135 137
     private function get_score_display ($score, $realscore, $ignore_score_color = false)
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     /**
39 39
      * Get total number of results (rows)
40 40
      */
41
-    public function get_total_results_count ()
41
+    public function get_total_results_count()
42 42
     {
43 43
         return count($this->results);
44 44
     }
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
      * 4 ['score']     : student's score
54 54
      * 5 ['display']   : custom score display (only if custom scoring enabled)
55 55
      */
56
-    public function get_data ($sorting = 0, $start = 0, $count = null, $ignore_score_color = false, $pdf=false)
56
+    public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false, $pdf = false)
57 57
     {
58 58
         // do some checks on count, redefine if invalid value
59 59
         $number_decimals = api_get_setting('gradebook_number_decimals');
60 60
         if (!isset($count)) {
61
-            $count = count ($this->results) - $start;
61
+            $count = count($this->results) - $start;
62 62
         }
63 63
         if ($count < 0) {
64 64
             $count = 0;
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
         $scoredisplay = ScoreDisplay :: instance();
67 67
         // generate actual data array
68 68
         $table = array();
69
-        foreach($this->results as $result) {
69
+        foreach ($this->results as $result) {
70 70
             $user = array();
71 71
             $info = api_get_user_info($result->get_user_id());
72 72
             $user['id'] = $result->get_user_id();
73
-            if ($pdf){
73
+            if ($pdf) {
74 74
                 $user['username'] = $info['username'];
75 75
             }
76 76
             $user['result_id'] = $result->get_id();
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
                 true
93 93
             )
94 94
             );
95
-            if ($pdf && $number_decimals == null){
95
+            if ($pdf && $number_decimals == null) {
96 96
                 $user['scoreletter'] = $result->get_score();
97 97
             }
98 98
             if ($scoredisplay->is_custom()) {
@@ -132,13 +132,13 @@  discard block
 block discarded – undo
132 132
      * @param bool  Whether we want to ignore the score color
133 133
      * @result string The score as we want to show it
134 134
      */
135
-    private function get_score_display ($score, $realscore, $ignore_score_color = false)
135
+    private function get_score_display($score, $realscore, $ignore_score_color = false)
136 136
     {
137 137
         if ($score != null) {
138 138
             $scoredisplay = ScoreDisplay :: instance();
139 139
             $type = SCORE_CUSTOM;
140 140
             if ($realscore === true) {
141
-                $type = SCORE_DIV_PERCENT ;
141
+                $type = SCORE_DIV_PERCENT;
142 142
             }
143 143
 
144 144
             return $scoredisplay->display_score(
@@ -172,10 +172,10 @@  discard block
 block discarded – undo
172 172
         }
173 173
     }
174 174
 
175
-    function sort_by_mask ($item1, $item2)
175
+    function sort_by_mask($item1, $item2)
176 176
     {
177
-        $score1 = (isset($item1['score']) ? array($item1['score'],$this->evaluation->get_max()) : null);
178
-        $score2 = (isset($item2['score']) ? array($item2['score'],$this->evaluation->get_max()) : null);
177
+        $score1 = (isset($item1['score']) ? array($item1['score'], $this->evaluation->get_max()) : null);
178
+        $score2 = (isset($item2['score']) ? array($item2['score'], $this->evaluation->get_max()) : null);
179 179
         return ScoreDisplay :: compare_scores_by_custom_display($score1, $score2);
180 180
     }
181 181
 }
Please login to merge, or discard this patch.
main/gradebook/lib/scoredisplay.class.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 
233 233
     /**
234 234
      * @param int $category_id
235
-     * @return bool
235
+     * @return false|null
236 236
      */
237 237
     public function insert_defaults($category_id)
238 238
     {
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
     }
264 264
 
265 265
     /**
266
-     * @return int|null|string
266
+     * @return integer
267 267
      */
268 268
     public function get_number_decimals()
269 269
     {
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
 
338 338
     /**
339 339
      * @param $score
340
-     * @param $type
341
-     * @return float|string
340
+     * @param integer $type
341
+     * @return string
342 342
      */
343 343
     private function display_default($score, $type)
344 344
     {
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         //Setting custom enabled
45 45
         $value = api_get_setting('gradebook_score_display_custom');
46 46
         $value = $value['my_display_custom'];
47
-        $this->custom_enabled  = $value == 'true' ? true : false;
47
+        $this->custom_enabled = $value == 'true' ? true : false;
48 48
 
49 49
         if ($this->custom_enabled) {
50 50
             $params = array('category = ?' =>  array('Gradebook'));
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
                 sort($portal_displays);
62 62
             }
63 63
             $this->custom_display = $portal_displays;
64
-            if (count($this->custom_display)>0) {
64
+            if (count($this->custom_display) > 0) {
65 65
                 $value = api_get_setting('gradebook_score_display_upperlimit');
66 66
                 $value = $value['my_display_upperlimit'];
67
-                $this->upperlimit_included  = $value == 'true' ? true : false;
67
+                $this->upperlimit_included = $value == 'true' ? true : false;
68 68
                 $this->custom_display_conv = $this->convert_displays($this->custom_display);
69 69
             }
70 70
         }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             //Load course settings
76 76
             if ($this->custom_enabled) {
77 77
                 $this->custom_display = $this->get_custom_displays();
78
-                if (count($this->custom_display)> 0) {
78
+                if (count($this->custom_display) > 0) {
79 79
                     $this->custom_display_conv = $this->convert_displays($this->custom_display);
80 80
                 }
81 81
             }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
     /**
104 104
      * Compare the custom display of 2 scores, can be useful in sorting
105 105
      */
106
-    public static function compare_scores_by_custom_display ($score1, $score2)
106
+    public static function compare_scores_by_custom_display($score1, $score2)
107 107
     {
108 108
         if (!isset($score1)) {
109 109
             return (isset($score2) ? 1 : 0);
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
             if ($custom1 == $custom2) {
117 117
                 return 0;
118 118
             } else {
119
-                return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1);
119
+                return (($score1[0] / $score1[1]) < ($score2[0] / $score2[1]) ? -1 : 1);
120 120
             }
121 121
         }
122 122
     }
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         }
185 185
 
186 186
         $sql = 'SELECT id FROM '.$tbl_gradebook_category.'
187
-                WHERE course_code = "'.$curr_course_code.'" '. $session_condition;
187
+                WHERE course_code = "'.$curr_course_code.'" '.$session_condition;
188 188
         $rs  = Database::query($sql);
189 189
         $category_id = 0;
190 190
         if (Database::num_rows($rs) > 0) {
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
         );
254 254
 
255 255
         $tbl_display = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_SCORE_DISPLAY);
256
-        foreach($display as $value => $text) {
256
+        foreach ($display as $value => $text) {
257 257
             $params = array(
258 258
                 'score' => $value,
259 259
                 'display' => $text,
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
         $my_score = $score == 0 ? 1 : $score;
310 310
 
311 311
         if ($type == SCORE_BAR) {
312
-            $percentage = $my_score[0]/$my_score[1]*100;
312
+            $percentage = $my_score[0] / $my_score[1] * 100;
313 313
 
314 314
             return Display::bar_progress($percentage);
315 315
         }
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
             case SCORE_PERCENT :                        // XX %
351 351
                 return $this->display_as_percent($score);
352 352
             case SCORE_DIV_PERCENT :                    // X / Y (XX %)
353
-                return $this->display_as_div($score).' (' . $this->display_as_percent($score) . ')';
353
+                return $this->display_as_div($score).' ('.$this->display_as_percent($score).')';
354 354
             case SCORE_AVERAGE :                        // XX %
355 355
                 return $this->display_as_percent($score);
356 356
             case SCORE_DECIMAL :                        // 0.50  (X/Y)
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
                 if (!empty($custom)) {
361 361
                     $custom = ' - '.$custom;
362 362
                 }
363
-                return $this->display_as_div($score).' (' . $this->display_as_percent($score) . ')'.$custom;
363
+                return $this->display_as_div($score).' ('.$this->display_as_percent($score).')'.$custom;
364 364
             case SCORE_DIV_SIMPLE_WITH_CUSTOM :         // X - Good!
365 365
                 $custom = $this->display_custom($score);
366 366
 
@@ -412,9 +412,9 @@  discard block
 block discarded – undo
412 412
      */
413 413
     private function display_as_decimal($score)
414 414
     {
415
-        $score_denom = ($score[1]==0) ? 1 : $score[1];
415
+        $score_denom = ($score[1] == 0) ? 1 : $score[1];
416 416
 
417
-        return $this->format_score($score[0]/$score_denom);
417
+        return $this->format_score($score[0] / $score_denom);
418 418
     }
419 419
 
420 420
     /**
@@ -422,9 +422,9 @@  discard block
 block discarded – undo
422 422
      */
423 423
     private function display_as_percent($score)
424 424
     {
425
-        $score_denom = ($score[1]==0) ? 1 : $score[1];
425
+        $score_denom = ($score[1] == 0) ? 1 : $score[1];
426 426
 
427
-        return $this->format_score($score[0]/$score_denom*100) . ' %';
427
+        return $this->format_score($score[0] / $score_denom * 100).' %';
428 428
     }
429 429
 
430 430
     /**
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
         } else {
441 441
             $score[0] = isset($score[0]) ? $this->format_score($score[0]) : 0;
442 442
             $score[1] = isset($score[1]) ? $this->format_score($score[1]) : 0;
443
-            return  $score[0] . ' / ' . $score[1];
443
+            return  $score[0].' / '.$score[1];
444 444
         }
445 445
     }
446 446
 
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
      */
451 451
     private function display_custom($score)
452 452
     {
453
-        $my_score_denom= ($score[1]==0) ? 1 : $score[1];
453
+        $my_score_denom = ($score[1] == 0) ? 1 : $score[1];
454 454
         $scaledscore = $score[0] / $my_score_denom;
455 455
         if ($this->upperlimit_included) {
456 456
             foreach ($this->custom_display_conv as $displayitem) {
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
                 ORDER BY score';
515 515
         $result = Database::query($sql);
516 516
 
517
-        return Database::store_result($result,'ASSOC');
517
+        return Database::store_result($result, 'ASSOC');
518 518
     }
519 519
 
520 520
     /**
Please login to merge, or discard this patch.
main/gradebook/lib/user_data_generator.class.php 4 patches
Doc Comments   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,6 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 	/**
74 74
 	 * Get actual array data
75
+	 * @param integer $count
75 76
 	 * @return array 2-dimensional array - each array contains the elements:
76 77
 	 * 0: eval/link object
77 78
 	 * 1: item name
@@ -285,7 +286,7 @@  discard block
 block discarded – undo
285 286
 
286 287
 	/**
287 288
 	 * @param $item
288
-	 * @param $ignore_score_color
289
+	 * @param boolean $ignore_score_color
289 290
 	 * @return string
290 291
 	 */
291 292
 	private function build_average_column($item, $ignore_score_color)
@@ -306,7 +307,7 @@  discard block
 block discarded – undo
306 307
 
307 308
 	/**
308 309
 	 * @param $item
309
-	 * @param $ignore_score_color
310
+	 * @param boolean $ignore_score_color
310 311
 	 * @return string
311 312
 	 */
312 313
 	private function build_result_column($item, $ignore_score_color)
@@ -323,7 +324,7 @@  discard block
 block discarded – undo
323 324
 
324 325
 	/**
325 326
 	 * @param $item
326
-	 * @param $ignore_score_color
327
+	 * @param boolean $ignore_score_color
327 328
 	 * @return string
328 329
 	 */
329 330
 	private function build_mask_column($item, $ignore_score_color)
@@ -339,7 +340,7 @@  discard block
 block discarded – undo
339 340
 
340 341
 	/**
341 342
 	 * @param $coursecode
342
-	 * @return mixed
343
+	 * @return string
343 344
 	 */
344 345
 	private function get_course_name_from_code_cached($coursecode)
345 346
 	{
Please login to merge, or discard this patch.
Indentation   +346 added lines, -346 removed lines patch added patch discarded remove patch
@@ -10,28 +10,28 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class UserDataGenerator
12 12
 {
13
-	// Sorting types constants
14
-	const UDG_SORT_TYPE = 1;
15
-	const UDG_SORT_NAME = 2;
16
-	const UDG_SORT_COURSE = 4;
17
-	const UDG_SORT_CATEGORY = 8;
18
-	const UDG_SORT_AVERAGE = 16;
19
-	const UDG_SORT_SCORE = 32;
20
-	const UDG_SORT_MASK = 64;
21
-
22
-	const UDG_SORT_ASC = 128;
23
-	const UDG_SORT_DESC = 256;
24
-
25
-	private $items;
26
-	private $userid;
27
-
28
-	private $coursecodecache;
29
-	private $categorycache;
30
-	private $scorecache;
31
-	private $avgcache;
32
-
33
-	public function UserDataGenerator($userid, $evals = array(), $links = array())
34
-	{
13
+    // Sorting types constants
14
+    const UDG_SORT_TYPE = 1;
15
+    const UDG_SORT_NAME = 2;
16
+    const UDG_SORT_COURSE = 4;
17
+    const UDG_SORT_CATEGORY = 8;
18
+    const UDG_SORT_AVERAGE = 16;
19
+    const UDG_SORT_SCORE = 32;
20
+    const UDG_SORT_MASK = 64;
21
+
22
+    const UDG_SORT_ASC = 128;
23
+    const UDG_SORT_DESC = 256;
24
+
25
+    private $items;
26
+    private $userid;
27
+
28
+    private $coursecodecache;
29
+    private $categorycache;
30
+    private $scorecache;
31
+    private $avgcache;
32
+
33
+    public function UserDataGenerator($userid, $evals = array(), $links = array())
34
+    {
35 35
         $this->userid = $userid;
36 36
         $evals_filtered = array();
37 37
         $result = array();
@@ -62,330 +62,330 @@  discard block
 block discarded – undo
62 62
         $this->avgcache = null;
63 63
     }
64 64
 
65
-	/**
66
-	 * Get total number of items (rows)
67
-	 */
68
-	public function get_total_items_count()
69
-	{
70
-		return count($this->items);
71
-	}
72
-
73
-	/**
74
-	 * Get actual array data
75
-	 * @return array 2-dimensional array - each array contains the elements:
76
-	 * 0: eval/link object
77
-	 * 1: item name
78
-	 * 2: course name
79
-	 * 3: category name
80
-	 * 4: average score
81
-	 * 5: student's score
82
-	 * 6: student's score as custom display (only if custom scoring enabled)
83
-	 */
84
-	public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false)
85
-	{
86
-		// do some checks on count, redefine if invalid value
87
-		if (!isset($count)) {
88
-			$count = count ($this->items) - $start;
89
-		}
90
-		if ($count < 0) {
91
-			$count = 0;
92
-		}
93
-		$allitems = $this->items;
94
-
95
-		// sort users array
96
-		if ($sorting & self :: UDG_SORT_TYPE) {
97
-			usort($allitems, array('UserDataGenerator', 'sort_by_type'));
98
-		}elseif ($sorting & self :: UDG_SORT_NAME) {
99
-			usort($allitems, array('UserDataGenerator', 'sort_by_name'));
100
-		} elseif ($sorting & self :: UDG_SORT_COURSE) {
101
-			usort($allitems, array('UserDataGenerator', 'sort_by_course'));
102
-		} elseif ($sorting & self :: UDG_SORT_CATEGORY) {
103
-			usort($allitems, array('UserDataGenerator', 'sort_by_category'));
104
-		} elseif ($sorting & self :: UDG_SORT_AVERAGE) {
105
-			// if user sorts on average scores, first calculate them and cache them
106
-			foreach ($allitems as $item) {
107
-				$this->avgcache[$item->get_item_type() . $item->get_id()]= $item->calc_score();
108
-			}
109
-			usort($allitems, array('UserDataGenerator', 'sort_by_average'));
110
-		} elseif ($sorting & self :: UDG_SORT_SCORE) {
111
-			// if user sorts on student's scores, first calculate them and cache them
112
-			foreach ($allitems as $item) {
113
-				$this->scorecache[$item->get_item_type() . $item->get_id()]
114
-					= $item->calc_score($this->userid);
115
-			}
116
-			usort($allitems, array('UserDataGenerator', 'sort_by_score'));
117
-		} elseif ($sorting & self :: UDG_SORT_MASK) {
118
-			// if user sorts on student's masks, first calculate scores and cache them
119
-			foreach ($allitems as $item) {
120
-				$this->scorecache[$item->get_item_type() . $item->get_id()]
121
-					= $item->calc_score($this->userid);
122
-			}
123
-			usort($allitems, array('UserDataGenerator', 'sort_by_mask'));
124
-		}
125
-
126
-		if ($sorting & self :: UDG_SORT_DESC) {
127
-			$allitems = array_reverse($allitems);
128
-		}
129
-		// select the items we have to display
130
-		$visibleitems = array_slice($allitems, $start, $count);
131
-
132
-		// fill score cache if not done yet
133
-		if (!isset ($this->scorecache)) {
134
-			foreach ($visibleitems as $item) {
135
-				$this->scorecache[$item->get_item_type() . $item->get_id()]
136
-					= $item->calc_score($this->userid);
137
-			}
138
-
139
-		}
140
-		// generate the data to display
141
-		$scoredisplay = ScoreDisplay :: instance();
142
-		$data = array();
143
-		foreach ($visibleitems as $item) {
144
-			$row = array ();
145
-			$row[] = $item;
146
-			$row[] = $item->get_name();
147
-			$row[] = $this->build_course_name($item);
148
-			$row[] = $this->build_category_name($item);
149
-			$row[] = $this->build_average_column($item, $ignore_score_color);
150
-			$row[] = $this->build_result_column($item, $ignore_score_color);
151
-			if ($scoredisplay->is_custom())
152
-				$row[] = $this->build_mask_column($item, $ignore_score_color);
153
-			$data[] = $row;
154
-		}
155
-		return $data;
156
-	}
157
-
158
-	/**
159
-	 * @param $item1
160
-	 * @param $item2
161
-	 * @return int
162
-	 */
163
-	function sort_by_type($item1, $item2)
164
-	{
165
-		if ($item1->get_item_type() == $item2->get_item_type()) {
166
-			return $this->sort_by_name($item1,$item2);
167
-		} else {
168
-			return ($item1->get_item_type() < $item2->get_item_type() ? -1 : 1);
169
-		}
170
-	}
171
-
172
-	/**
173
-	 * @param $item1
174
-	 * @param $item2
175
-	 * @return int
176
-	 */
177
-	function sort_by_course($item1, $item2)
178
-	{
179
-		$name1 = api_strtolower($this->get_course_name_from_code_cached($item1->get_course_code()));
180
-		$name2 = api_strtolower($this->get_course_name_from_code_cached($item2->get_course_code()));
181
-		return api_strnatcmp($name1, $name2);
182
-	}
183
-
184
-	/**
185
-	 * @param $item1
186
-	 * @param $item2
187
-	 * @return int
188
-	 */
189
-	function sort_by_category($item1, $item2)
190
-	{
191
-		$cat1 = $this->get_category_cached($item1->get_category_id());
192
-		$cat2 = $this->get_category_cached($item2->get_category_id());
193
-		$name1 = api_strtolower($this->get_category_name_to_display($cat1));
194
-		$name2 = api_strtolower($this->get_category_name_to_display($cat2));
195
-
196
-		return api_strnatcmp($name1, $name2);
197
-	}
198
-
199
-	/**
200
-	 * @param $item1
201
-	 * @param $item2
202
-	 * @return int
203
-	 */
204
-	function sort_by_name($item1, $item2)
205
-	{
206
-		return api_strnatcmp($item1->get_name(),$item2->get_name());
207
-	}
208
-
209
-	/**
210
-	 * @param $item1
211
-	 * @param $item2
212
-	 * @return int
213
-	 */
214
-	function sort_by_average($item1, $item2)
215
-	{
216
-		$score1 = $this->avgcache[$item1->get_item_type() . $item1->get_id()];
217
-		$score2 = $this->avgcache[$item2->get_item_type() . $item2->get_id()];
218
-
219
-		return $this->compare_scores($score1, $score2);
220
-	}
221
-
222
-	/**
223
-	 * @param $item1
224
-	 * @param $item2
225
-	 * @return int
226
-	 */
227
-	function sort_by_score($item1, $item2)
228
-	{
229
-		$score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()];
230
-		$score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()];
231
-
232
-		return $this->compare_scores($score1, $score2);
233
-	}
234
-
235
-	/**
236
-	 * @param $item1
237
-	 * @param $item2
238
-	 * @return int
239
-	 */
240
-	function sort_by_mask($item1, $item2)
241
-	{
242
-		$score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()];
243
-		$score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()];
244
-
245
-		return ScoreDisplay :: compare_scores_by_custom_display($score1, $score2);
246
-	}
247
-
248
-	/**
249
-	 * @param $score1
250
-	 * @param $score2
251
-	 * @return int
252
-	 */
253
-	function compare_scores($score1, $score2)
254
-	{
255
-		if (!isset($score1)) {
256
-			return (isset($score2) ? 1 : 0);
257
-		} elseif (!isset($score2)) {
258
-			return -1;
259
-		} elseif (($score1[0]/$score1[1]) == ($score2[0]/$score2[1])) {
260
-			return 0;
261
-		} else {
262
-			return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1);
263
-		}
264
-	}
265
-
266
-	/**
267
-	 * @param $item
268
-	 * @return mixed
269
-	 */
270
-	private function build_course_name($item)
271
-	{
272
-		return $this->get_course_name_from_code_cached($item->get_course_code());
273
-	}
274
-
275
-	/**
276
-	 * @param $item
277
-	 * @return string
278
-	 */
279
-	private function build_category_name($item)
280
-	{
281
-		$cat = $this->get_category_cached($item->get_category_id());
282
-
283
-		return $this->get_category_name_to_display($cat);
284
-	}
285
-
286
-	/**
287
-	 * @param $item
288
-	 * @param $ignore_score_color
289
-	 * @return string
290
-	 */
291
-	private function build_average_column($item, $ignore_score_color)
292
-	{
293
-		if (isset($this->avgcache)) {
294
-			$avgscore = $this->avgcache[$item->get_item_type() . $item->get_id()];
295
-		} else {
296
-			$avgscore = $item->calc_score();
297
-		}
298
-
299
-		$scoredisplay = ScoreDisplay :: instance();
300
-		$displaytype = SCORE_AVERAGE;
301
-		/*if ($ignore_score_color)
65
+    /**
66
+     * Get total number of items (rows)
67
+     */
68
+    public function get_total_items_count()
69
+    {
70
+        return count($this->items);
71
+    }
72
+
73
+    /**
74
+     * Get actual array data
75
+     * @return array 2-dimensional array - each array contains the elements:
76
+     * 0: eval/link object
77
+     * 1: item name
78
+     * 2: course name
79
+     * 3: category name
80
+     * 4: average score
81
+     * 5: student's score
82
+     * 6: student's score as custom display (only if custom scoring enabled)
83
+     */
84
+    public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false)
85
+    {
86
+        // do some checks on count, redefine if invalid value
87
+        if (!isset($count)) {
88
+            $count = count ($this->items) - $start;
89
+        }
90
+        if ($count < 0) {
91
+            $count = 0;
92
+        }
93
+        $allitems = $this->items;
94
+
95
+        // sort users array
96
+        if ($sorting & self :: UDG_SORT_TYPE) {
97
+            usort($allitems, array('UserDataGenerator', 'sort_by_type'));
98
+        }elseif ($sorting & self :: UDG_SORT_NAME) {
99
+            usort($allitems, array('UserDataGenerator', 'sort_by_name'));
100
+        } elseif ($sorting & self :: UDG_SORT_COURSE) {
101
+            usort($allitems, array('UserDataGenerator', 'sort_by_course'));
102
+        } elseif ($sorting & self :: UDG_SORT_CATEGORY) {
103
+            usort($allitems, array('UserDataGenerator', 'sort_by_category'));
104
+        } elseif ($sorting & self :: UDG_SORT_AVERAGE) {
105
+            // if user sorts on average scores, first calculate them and cache them
106
+            foreach ($allitems as $item) {
107
+                $this->avgcache[$item->get_item_type() . $item->get_id()]= $item->calc_score();
108
+            }
109
+            usort($allitems, array('UserDataGenerator', 'sort_by_average'));
110
+        } elseif ($sorting & self :: UDG_SORT_SCORE) {
111
+            // if user sorts on student's scores, first calculate them and cache them
112
+            foreach ($allitems as $item) {
113
+                $this->scorecache[$item->get_item_type() . $item->get_id()]
114
+                    = $item->calc_score($this->userid);
115
+            }
116
+            usort($allitems, array('UserDataGenerator', 'sort_by_score'));
117
+        } elseif ($sorting & self :: UDG_SORT_MASK) {
118
+            // if user sorts on student's masks, first calculate scores and cache them
119
+            foreach ($allitems as $item) {
120
+                $this->scorecache[$item->get_item_type() . $item->get_id()]
121
+                    = $item->calc_score($this->userid);
122
+            }
123
+            usort($allitems, array('UserDataGenerator', 'sort_by_mask'));
124
+        }
125
+
126
+        if ($sorting & self :: UDG_SORT_DESC) {
127
+            $allitems = array_reverse($allitems);
128
+        }
129
+        // select the items we have to display
130
+        $visibleitems = array_slice($allitems, $start, $count);
131
+
132
+        // fill score cache if not done yet
133
+        if (!isset ($this->scorecache)) {
134
+            foreach ($visibleitems as $item) {
135
+                $this->scorecache[$item->get_item_type() . $item->get_id()]
136
+                    = $item->calc_score($this->userid);
137
+            }
138
+
139
+        }
140
+        // generate the data to display
141
+        $scoredisplay = ScoreDisplay :: instance();
142
+        $data = array();
143
+        foreach ($visibleitems as $item) {
144
+            $row = array ();
145
+            $row[] = $item;
146
+            $row[] = $item->get_name();
147
+            $row[] = $this->build_course_name($item);
148
+            $row[] = $this->build_category_name($item);
149
+            $row[] = $this->build_average_column($item, $ignore_score_color);
150
+            $row[] = $this->build_result_column($item, $ignore_score_color);
151
+            if ($scoredisplay->is_custom())
152
+                $row[] = $this->build_mask_column($item, $ignore_score_color);
153
+            $data[] = $row;
154
+        }
155
+        return $data;
156
+    }
157
+
158
+    /**
159
+     * @param $item1
160
+     * @param $item2
161
+     * @return int
162
+     */
163
+    function sort_by_type($item1, $item2)
164
+    {
165
+        if ($item1->get_item_type() == $item2->get_item_type()) {
166
+            return $this->sort_by_name($item1,$item2);
167
+        } else {
168
+            return ($item1->get_item_type() < $item2->get_item_type() ? -1 : 1);
169
+        }
170
+    }
171
+
172
+    /**
173
+     * @param $item1
174
+     * @param $item2
175
+     * @return int
176
+     */
177
+    function sort_by_course($item1, $item2)
178
+    {
179
+        $name1 = api_strtolower($this->get_course_name_from_code_cached($item1->get_course_code()));
180
+        $name2 = api_strtolower($this->get_course_name_from_code_cached($item2->get_course_code()));
181
+        return api_strnatcmp($name1, $name2);
182
+    }
183
+
184
+    /**
185
+     * @param $item1
186
+     * @param $item2
187
+     * @return int
188
+     */
189
+    function sort_by_category($item1, $item2)
190
+    {
191
+        $cat1 = $this->get_category_cached($item1->get_category_id());
192
+        $cat2 = $this->get_category_cached($item2->get_category_id());
193
+        $name1 = api_strtolower($this->get_category_name_to_display($cat1));
194
+        $name2 = api_strtolower($this->get_category_name_to_display($cat2));
195
+
196
+        return api_strnatcmp($name1, $name2);
197
+    }
198
+
199
+    /**
200
+     * @param $item1
201
+     * @param $item2
202
+     * @return int
203
+     */
204
+    function sort_by_name($item1, $item2)
205
+    {
206
+        return api_strnatcmp($item1->get_name(),$item2->get_name());
207
+    }
208
+
209
+    /**
210
+     * @param $item1
211
+     * @param $item2
212
+     * @return int
213
+     */
214
+    function sort_by_average($item1, $item2)
215
+    {
216
+        $score1 = $this->avgcache[$item1->get_item_type() . $item1->get_id()];
217
+        $score2 = $this->avgcache[$item2->get_item_type() . $item2->get_id()];
218
+
219
+        return $this->compare_scores($score1, $score2);
220
+    }
221
+
222
+    /**
223
+     * @param $item1
224
+     * @param $item2
225
+     * @return int
226
+     */
227
+    function sort_by_score($item1, $item2)
228
+    {
229
+        $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()];
230
+        $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()];
231
+
232
+        return $this->compare_scores($score1, $score2);
233
+    }
234
+
235
+    /**
236
+     * @param $item1
237
+     * @param $item2
238
+     * @return int
239
+     */
240
+    function sort_by_mask($item1, $item2)
241
+    {
242
+        $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()];
243
+        $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()];
244
+
245
+        return ScoreDisplay :: compare_scores_by_custom_display($score1, $score2);
246
+    }
247
+
248
+    /**
249
+     * @param $score1
250
+     * @param $score2
251
+     * @return int
252
+     */
253
+    function compare_scores($score1, $score2)
254
+    {
255
+        if (!isset($score1)) {
256
+            return (isset($score2) ? 1 : 0);
257
+        } elseif (!isset($score2)) {
258
+            return -1;
259
+        } elseif (($score1[0]/$score1[1]) == ($score2[0]/$score2[1])) {
260
+            return 0;
261
+        } else {
262
+            return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1);
263
+        }
264
+    }
265
+
266
+    /**
267
+     * @param $item
268
+     * @return mixed
269
+     */
270
+    private function build_course_name($item)
271
+    {
272
+        return $this->get_course_name_from_code_cached($item->get_course_code());
273
+    }
274
+
275
+    /**
276
+     * @param $item
277
+     * @return string
278
+     */
279
+    private function build_category_name($item)
280
+    {
281
+        $cat = $this->get_category_cached($item->get_category_id());
282
+
283
+        return $this->get_category_name_to_display($cat);
284
+    }
285
+
286
+    /**
287
+     * @param $item
288
+     * @param $ignore_score_color
289
+     * @return string
290
+     */
291
+    private function build_average_column($item, $ignore_score_color)
292
+    {
293
+        if (isset($this->avgcache)) {
294
+            $avgscore = $this->avgcache[$item->get_item_type() . $item->get_id()];
295
+        } else {
296
+            $avgscore = $item->calc_score();
297
+        }
298
+
299
+        $scoredisplay = ScoreDisplay :: instance();
300
+        $displaytype = SCORE_AVERAGE;
301
+        /*if ($ignore_score_color)
302 302
 			$displaytype |= SCORE_IGNORE_SPLIT;
303 303
         */
304
-		return $scoredisplay->display_score($avgscore, $displaytype);
305
-	}
306
-
307
-	/**
308
-	 * @param $item
309
-	 * @param $ignore_score_color
310
-	 * @return string
311
-	 */
312
-	private function build_result_column($item, $ignore_score_color)
313
-	{
314
-		$studscore = $this->scorecache[$item->get_item_type() . $item->get_id()];
315
-		$scoredisplay = ScoreDisplay :: instance();
316
-		$displaytype = SCORE_DIV_PERCENT;
317
-		if ($ignore_score_color) {
318
-			$displaytype |= SCORE_IGNORE_SPLIT;
319
-		}
320
-
321
-		return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_DEFAULT);
322
-	}
323
-
324
-	/**
325
-	 * @param $item
326
-	 * @param $ignore_score_color
327
-	 * @return string
328
-	 */
329
-	private function build_mask_column($item, $ignore_score_color)
330
-	{
331
-		$studscore = $this->scorecache[$item->get_item_type() . $item->get_id()];
332
-		$scoredisplay = ScoreDisplay :: instance();
333
-		$displaytype = SCORE_DIV_PERCENT;
334
-		if ($ignore_score_color) {
335
-			$displaytype |= SCORE_IGNORE_SPLIT;
336
-		}
337
-		return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_CUSTOM);
338
-	}
339
-
340
-	/**
341
-	 * @param $coursecode
342
-	 * @return mixed
343
-	 */
344
-	private function get_course_name_from_code_cached($coursecode)
345
-	{
346
-		if (isset ($this->coursecodecache)
347
-			&& isset ($this->coursecodecache[$coursecode])) {
348
-			return $this->coursecodecache[$coursecode];
349
-		} else {
350
-			$name = CourseManager::getCourseNameFromCode($coursecode);
351
-			$this->coursecodecache[$coursecode] = $name;
352
-			return $name;
353
-		}
354
-	}
355
-
356
-	/**
357
-	 * @param $category_id
358
-	 * @return null
359
-	 */
360
-	private function get_category_cached($category_id)
361
-	{
362
-		if (isset ($this->categorycache)
363
-			&& isset ($this->categorycache[$category_id])) {
364
-			return $this->categorycache[$category_id];
365
-		}else {
366
-			$cat = Category::load($category_id);
367
-			if (isset($cat)){
368
-				$this->categorycache[$category_id] = $cat[0];
369
-				return $cat[0];
370
-			}else
371
-				return null;
372
-		}
373
-	}
374
-
375
-	/**
376
-	 * @param $cat
377
-	 * @return string
378
-	 */
379
-	private function get_category_name_to_display($cat)
380
-	{
381
-		if (isset($cat)) {
382
-			if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null){
383
-				return '';
384
-			} else {
385
-				return $cat->get_name();
386
-			}
387
-		} else {
388
-			return '';
389
-		}
390
-	}
304
+        return $scoredisplay->display_score($avgscore, $displaytype);
305
+    }
306
+
307
+    /**
308
+     * @param $item
309
+     * @param $ignore_score_color
310
+     * @return string
311
+     */
312
+    private function build_result_column($item, $ignore_score_color)
313
+    {
314
+        $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()];
315
+        $scoredisplay = ScoreDisplay :: instance();
316
+        $displaytype = SCORE_DIV_PERCENT;
317
+        if ($ignore_score_color) {
318
+            $displaytype |= SCORE_IGNORE_SPLIT;
319
+        }
320
+
321
+        return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_DEFAULT);
322
+    }
323
+
324
+    /**
325
+     * @param $item
326
+     * @param $ignore_score_color
327
+     * @return string
328
+     */
329
+    private function build_mask_column($item, $ignore_score_color)
330
+    {
331
+        $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()];
332
+        $scoredisplay = ScoreDisplay :: instance();
333
+        $displaytype = SCORE_DIV_PERCENT;
334
+        if ($ignore_score_color) {
335
+            $displaytype |= SCORE_IGNORE_SPLIT;
336
+        }
337
+        return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_CUSTOM);
338
+    }
339
+
340
+    /**
341
+     * @param $coursecode
342
+     * @return mixed
343
+     */
344
+    private function get_course_name_from_code_cached($coursecode)
345
+    {
346
+        if (isset ($this->coursecodecache)
347
+            && isset ($this->coursecodecache[$coursecode])) {
348
+            return $this->coursecodecache[$coursecode];
349
+        } else {
350
+            $name = CourseManager::getCourseNameFromCode($coursecode);
351
+            $this->coursecodecache[$coursecode] = $name;
352
+            return $name;
353
+        }
354
+    }
355
+
356
+    /**
357
+     * @param $category_id
358
+     * @return null
359
+     */
360
+    private function get_category_cached($category_id)
361
+    {
362
+        if (isset ($this->categorycache)
363
+            && isset ($this->categorycache[$category_id])) {
364
+            return $this->categorycache[$category_id];
365
+        }else {
366
+            $cat = Category::load($category_id);
367
+            if (isset($cat)){
368
+                $this->categorycache[$category_id] = $cat[0];
369
+                return $cat[0];
370
+            }else
371
+                return null;
372
+        }
373
+    }
374
+
375
+    /**
376
+     * @param $cat
377
+     * @return string
378
+     */
379
+    private function get_category_name_to_display($cat)
380
+    {
381
+        if (isset($cat)) {
382
+            if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null){
383
+                return '';
384
+            } else {
385
+                return $cat->get_name();
386
+            }
387
+        } else {
388
+            return '';
389
+        }
390
+    }
391 391
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 
51 51
         }
52 52
         if (count($result) == 0) {
53
-            $evals_filtered=$evals;
53
+            $evals_filtered = $evals;
54 54
         } else {
55
-            $evals_filtered=$evals_filtered_copy;
55
+            $evals_filtered = $evals_filtered_copy;
56 56
         }
57 57
         $this->items = array_merge($evals_filtered, $links);
58 58
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	{
86 86
 		// do some checks on count, redefine if invalid value
87 87
 		if (!isset($count)) {
88
-			$count = count ($this->items) - $start;
88
+			$count = count($this->items) - $start;
89 89
 		}
90 90
 		if ($count < 0) {
91 91
 			$count = 0;
@@ -104,20 +104,20 @@  discard block
 block discarded – undo
104 104
 		} elseif ($sorting & self :: UDG_SORT_AVERAGE) {
105 105
 			// if user sorts on average scores, first calculate them and cache them
106 106
 			foreach ($allitems as $item) {
107
-				$this->avgcache[$item->get_item_type() . $item->get_id()]= $item->calc_score();
107
+				$this->avgcache[$item->get_item_type().$item->get_id()] = $item->calc_score();
108 108
 			}
109 109
 			usort($allitems, array('UserDataGenerator', 'sort_by_average'));
110 110
 		} elseif ($sorting & self :: UDG_SORT_SCORE) {
111 111
 			// if user sorts on student's scores, first calculate them and cache them
112 112
 			foreach ($allitems as $item) {
113
-				$this->scorecache[$item->get_item_type() . $item->get_id()]
113
+				$this->scorecache[$item->get_item_type().$item->get_id()]
114 114
 					= $item->calc_score($this->userid);
115 115
 			}
116 116
 			usort($allitems, array('UserDataGenerator', 'sort_by_score'));
117 117
 		} elseif ($sorting & self :: UDG_SORT_MASK) {
118 118
 			// if user sorts on student's masks, first calculate scores and cache them
119 119
 			foreach ($allitems as $item) {
120
-				$this->scorecache[$item->get_item_type() . $item->get_id()]
120
+				$this->scorecache[$item->get_item_type().$item->get_id()]
121 121
 					= $item->calc_score($this->userid);
122 122
 			}
123 123
 			usort($allitems, array('UserDataGenerator', 'sort_by_mask'));
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 		// fill score cache if not done yet
133 133
 		if (!isset ($this->scorecache)) {
134 134
 			foreach ($visibleitems as $item) {
135
-				$this->scorecache[$item->get_item_type() . $item->get_id()]
135
+				$this->scorecache[$item->get_item_type().$item->get_id()]
136 136
 					= $item->calc_score($this->userid);
137 137
 			}
138 138
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		$scoredisplay = ScoreDisplay :: instance();
142 142
 		$data = array();
143 143
 		foreach ($visibleitems as $item) {
144
-			$row = array ();
144
+			$row = array();
145 145
 			$row[] = $item;
146 146
 			$row[] = $item->get_name();
147 147
 			$row[] = $this->build_course_name($item);
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	function sort_by_type($item1, $item2)
164 164
 	{
165 165
 		if ($item1->get_item_type() == $item2->get_item_type()) {
166
-			return $this->sort_by_name($item1,$item2);
166
+			return $this->sort_by_name($item1, $item2);
167 167
 		} else {
168 168
 			return ($item1->get_item_type() < $item2->get_item_type() ? -1 : 1);
169 169
 		}
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 */
204 204
 	function sort_by_name($item1, $item2)
205 205
 	{
206
-		return api_strnatcmp($item1->get_name(),$item2->get_name());
206
+		return api_strnatcmp($item1->get_name(), $item2->get_name());
207 207
 	}
208 208
 
209 209
 	/**
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
 	 */
214 214
 	function sort_by_average($item1, $item2)
215 215
 	{
216
-		$score1 = $this->avgcache[$item1->get_item_type() . $item1->get_id()];
217
-		$score2 = $this->avgcache[$item2->get_item_type() . $item2->get_id()];
216
+		$score1 = $this->avgcache[$item1->get_item_type().$item1->get_id()];
217
+		$score2 = $this->avgcache[$item2->get_item_type().$item2->get_id()];
218 218
 
219 219
 		return $this->compare_scores($score1, $score2);
220 220
 	}
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 	 */
227 227
 	function sort_by_score($item1, $item2)
228 228
 	{
229
-		$score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()];
230
-		$score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()];
229
+		$score1 = $this->scorecache[$item1->get_item_type().$item1->get_id()];
230
+		$score2 = $this->scorecache[$item2->get_item_type().$item2->get_id()];
231 231
 
232 232
 		return $this->compare_scores($score1, $score2);
233 233
 	}
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
 	 */
240 240
 	function sort_by_mask($item1, $item2)
241 241
 	{
242
-		$score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()];
243
-		$score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()];
242
+		$score1 = $this->scorecache[$item1->get_item_type().$item1->get_id()];
243
+		$score2 = $this->scorecache[$item2->get_item_type().$item2->get_id()];
244 244
 
245 245
 		return ScoreDisplay :: compare_scores_by_custom_display($score1, $score2);
246 246
 	}
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
 			return (isset($score2) ? 1 : 0);
257 257
 		} elseif (!isset($score2)) {
258 258
 			return -1;
259
-		} elseif (($score1[0]/$score1[1]) == ($score2[0]/$score2[1])) {
259
+		} elseif (($score1[0] / $score1[1]) == ($score2[0] / $score2[1])) {
260 260
 			return 0;
261 261
 		} else {
262
-			return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1);
262
+			return (($score1[0] / $score1[1]) < ($score2[0] / $score2[1]) ? -1 : 1);
263 263
 		}
264 264
 	}
265 265
 
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	private function build_average_column($item, $ignore_score_color)
292 292
 	{
293 293
 		if (isset($this->avgcache)) {
294
-			$avgscore = $this->avgcache[$item->get_item_type() . $item->get_id()];
294
+			$avgscore = $this->avgcache[$item->get_item_type().$item->get_id()];
295 295
 		} else {
296 296
 			$avgscore = $item->calc_score();
297 297
 		}
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 	 */
312 312
 	private function build_result_column($item, $ignore_score_color)
313 313
 	{
314
-		$studscore = $this->scorecache[$item->get_item_type() . $item->get_id()];
314
+		$studscore = $this->scorecache[$item->get_item_type().$item->get_id()];
315 315
 		$scoredisplay = ScoreDisplay :: instance();
316 316
 		$displaytype = SCORE_DIV_PERCENT;
317 317
 		if ($ignore_score_color) {
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	 */
329 329
 	private function build_mask_column($item, $ignore_score_color)
330 330
 	{
331
-		$studscore = $this->scorecache[$item->get_item_type() . $item->get_id()];
331
+		$studscore = $this->scorecache[$item->get_item_type().$item->get_id()];
332 332
 		$scoredisplay = ScoreDisplay :: instance();
333 333
 		$displaytype = SCORE_DIV_PERCENT;
334 334
 		if ($ignore_score_color) {
@@ -362,12 +362,12 @@  discard block
 block discarded – undo
362 362
 		if (isset ($this->categorycache)
363 363
 			&& isset ($this->categorycache[$category_id])) {
364 364
 			return $this->categorycache[$category_id];
365
-		}else {
365
+		} else {
366 366
 			$cat = Category::load($category_id);
367
-			if (isset($cat)){
367
+			if (isset($cat)) {
368 368
 				$this->categorycache[$category_id] = $cat[0];
369 369
 				return $cat[0];
370
-			}else
370
+			} else
371 371
 				return null;
372 372
 		}
373 373
 	}
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 	private function get_category_name_to_display($cat)
380 380
 	{
381 381
 		if (isset($cat)) {
382
-			if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null){
382
+			if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null) {
383 383
 				return '';
384 384
 			} else {
385 385
 				return $cat->get_name();
Please login to merge, or discard this patch.
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		// sort users array
96 96
 		if ($sorting & self :: UDG_SORT_TYPE) {
97 97
 			usort($allitems, array('UserDataGenerator', 'sort_by_type'));
98
-		}elseif ($sorting & self :: UDG_SORT_NAME) {
98
+		} elseif ($sorting & self :: UDG_SORT_NAME) {
99 99
 			usort($allitems, array('UserDataGenerator', 'sort_by_name'));
100 100
 		} elseif ($sorting & self :: UDG_SORT_COURSE) {
101 101
 			usort($allitems, array('UserDataGenerator', 'sort_by_course'));
@@ -148,8 +148,9 @@  discard block
 block discarded – undo
148 148
 			$row[] = $this->build_category_name($item);
149 149
 			$row[] = $this->build_average_column($item, $ignore_score_color);
150 150
 			$row[] = $this->build_result_column($item, $ignore_score_color);
151
-			if ($scoredisplay->is_custom())
152
-				$row[] = $this->build_mask_column($item, $ignore_score_color);
151
+			if ($scoredisplay->is_custom()) {
152
+							$row[] = $this->build_mask_column($item, $ignore_score_color);
153
+			}
153 154
 			$data[] = $row;
154 155
 		}
155 156
 		return $data;
@@ -362,13 +363,14 @@  discard block
 block discarded – undo
362 363
 		if (isset ($this->categorycache)
363 364
 			&& isset ($this->categorycache[$category_id])) {
364 365
 			return $this->categorycache[$category_id];
365
-		}else {
366
+		} else {
366 367
 			$cat = Category::load($category_id);
367 368
 			if (isset($cat)){
368 369
 				$this->categorycache[$category_id] = $cat[0];
369 370
 				return $cat[0];
370
-			}else
371
-				return null;
371
+			} else {
372
+							return null;
373
+			}
372 374
 		}
373 375
 	}
374 376
 
Please login to merge, or discard this patch.
main/group/group_space.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -471,7 +471,7 @@
 block discarded – undo
471 471
  * Display a user icon that links to the user page
472 472
  *
473 473
  * @param integer $user_id the id of the user
474
- * @return html code
474
+ * @return string code
475 475
  *
476 476
  * @author Patrick Cool <[email protected]>, Ghent University, Belgium
477 477
  * @version April 2008
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 require_once '../inc/global.inc.php';
13
-$current_course_tool  = TOOL_GROUP;
13
+$current_course_tool = TOOL_GROUP;
14 14
 
15 15
 // Notice for unauthorized people.
16 16
 api_protect_course_script(true);
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
 echo '<div class="actions">';
71 71
 echo '<a href="group.php">'.
72
-    Display::return_icon('back.png',get_lang('BackToGroupList'),'',ICON_SIZE_MEDIUM).
72
+    Display::return_icon('back.png', get_lang('BackToGroupList'), '', ICON_SIZE_MEDIUM).
73 73
     '</a>';
74 74
 
75 75
 /*
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
  */
87 87
 $unsubscribe_group = '';
88 88
 if (GroupManager :: is_self_unregistration_allowed($user_id, $current_group['id'])) {
89
-    $unsubscribe_group = '<a class="btn btn-default" href="'.api_get_self().'?selfUnReg=1" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."'".')) return false;">'.
89
+    $unsubscribe_group = '<a class="btn btn-default" href="'.api_get_self().'?selfUnReg=1" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."'".')) return false;">'.
90 90
         get_lang("StudentUnsubscribe").'</a>';
91 91
 }
92 92
 echo '&nbsp;</div>';
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
     GroupManager::is_tutor_of_group(api_get_user_id(), api_get_group_id())
99 99
 ) {
100 100
     $my_origin = isset($origin) ? $origin : '';
101
-    $edit_url =  '<a href="'.api_get_path(WEB_CODE_PATH).'group/settings.php?'.api_get_cidreq().'&origin='.$my_origin.'">'.
102
-        Display::return_icon('edit.png', get_lang('EditGroup'),'',ICON_SIZE_SMALL).'</a>';
101
+    $edit_url = '<a href="'.api_get_path(WEB_CODE_PATH).'group/settings.php?'.api_get_cidreq().'&origin='.$my_origin.'">'.
102
+        Display::return_icon('edit.png', get_lang('EditGroup'), '', ICON_SIZE_SMALL).'</a>';
103 103
 }
104 104
 
105 105
 echo Display::page_header(
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
     $forums_of_groups = get_forums_of_group($current_group['id']);
217 217
 
218 218
     if (is_array($forums_of_groups)) {
219
-        if ( $current_group['forum_state'] == GroupManager::TOOL_PUBLIC) {
219
+        if ($current_group['forum_state'] == GroupManager::TOOL_PUBLIC) {
220 220
             foreach ($forums_of_groups as $key => $value) {
221 221
                 if ($value['forum_group_public_private'] == 'public') {
222 222
                     $actions_array[] = array(
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 if (count($tutors) == 0) {
299 299
     $tutor_info = get_lang('GroupNoneMasc');
300 300
 } else {
301
-    isset($origin) ? $my_origin = $origin:$my_origin='';
301
+    isset($origin) ? $my_origin = $origin : $my_origin = '';
302 302
     $tutor_info .= '<ul class="thumbnails">';
303 303
     foreach ($tutors as $index => $tutor) {
304 304
         $userInfo = api_get_user_info($tutor['user_id']);
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
     global $current_group;
405 405
 
406 406
     // Database table definition
407
-    $table_group_user 	= Database :: get_course_table(TABLE_GROUP_USER);
408
-    $table_user 		= Database :: get_main_table(TABLE_MAIN_USER);
407
+    $table_group_user = Database :: get_course_table(TABLE_GROUP_USER);
408
+    $table_user = Database :: get_main_table(TABLE_MAIN_USER);
409 409
 
410 410
     $course_id = api_get_course_int_id();
411 411
 
Please login to merge, or discard this patch.