Completed
Push — 1.10.x ( f4311b...34fa34 )
by Yannick
413:19 queued 371:33
created
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.
main/inc/ajax/admin.ajax.php 2 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -189,6 +189,8 @@
 block discarded – undo
189 189
  * @param float  Timeout
190 190
  * @param bool   Include HTTP Request headers?
191 191
  * @param bool   Include HTTP Response headers?
192
+ * @param string $ip
193
+ * @return string
192 194
  */
193 195
 function _http_request($ip, $port = 80, $uri = '/', $getdata = array(), $timeout = 5, $req_hdr = false, $res_hdr = false)
194 196
 {
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
             $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $urlInfo['url']));
51 51
             $cleanUrl = str_replace('/', '-', $url);
52 52
 
53
-            $newUrlDir = api_get_path(SYS_APP_PATH) . "home/$cleanUrl/admin/";
53
+            $newUrlDir = api_get_path(SYS_APP_PATH)."home/$cleanUrl/admin/";
54 54
         } else {
55
-            $newUrlDir = api_get_path(SYS_APP_PATH) . "home/admin/";
55
+            $newUrlDir = api_get_path(SYS_APP_PATH)."home/admin/";
56 56
         }
57 57
 
58 58
         if (!file_exists($newUrlDir)) {
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
             }
167 167
 
168 168
             if ($system_version != $version_info) {
169
-                $output = '<br /><span style="color:red">' . get_lang('YourVersionNotUpToDate') . '. '.get_lang('LatestVersionIs').' <b>Chamilo '.$version_info.'</b>. '.get_lang('YourVersionIs').' <b>Chamilo '.$system_version. '</b>. '.str_replace('http://www.chamilo.org', '<a href="http://www.chamilo.org">http://www.chamilo.org</a>', get_lang('PleaseVisitOurWebsite')).'</span>';
169
+                $output = '<br /><span style="color:red">'.get_lang('YourVersionNotUpToDate').'. '.get_lang('LatestVersionIs').' <b>Chamilo '.$version_info.'</b>. '.get_lang('YourVersionIs').' <b>Chamilo '.$system_version.'</b>. '.str_replace('http://www.chamilo.org', '<a href="http://www.chamilo.org">http://www.chamilo.org</a>', get_lang('PleaseVisitOurWebsite')).'</span>';
170 170
             } else {
171 171
                 $output = '<br /><span style="color:green">'.get_lang('VersionUpToDate').': Chamilo '.$version_info.'</span>';
172 172
             }
173 173
         } else {
174
-            $output = '<span style="color:red">' . get_lang('ImpossibleToContactVersionServerPleaseTryAgain') . '</span>';
174
+            $output = '<span style="color:red">'.get_lang('ImpossibleToContactVersionServerPleaseTryAgain').'</span>';
175 175
         }
176 176
     } else {
177
-        $output = '<span style="color:red">' . get_lang('AllowurlfopenIsSetToOff') . '</span>';
177
+        $output = '<span style="color:red">'.get_lang('AllowurlfopenIsSetToOff').'</span>';
178 178
     }
179 179
     return $output;
180 180
 }
@@ -197,17 +197,17 @@  discard block
 block discarded – undo
197 197
     $getdata_str = count($getdata) ? '?' : '';
198 198
 
199 199
     foreach ($getdata as $k => $v) {
200
-                $getdata_str .= urlencode($k) .'='. urlencode($v) . '&';
200
+                $getdata_str .= urlencode($k).'='.urlencode($v).'&';
201 201
     }
202 202
 
203 203
     $crlf = "\r\n";
204
-    $req = $verb .' '. $uri . $getdata_str .' HTTP/1.1' . $crlf;
205
-    $req .= 'Host: '. $ip . $crlf;
206
-    $req .= 'User-Agent: Mozilla/5.0 Firefox/3.6.12' . $crlf;
207
-    $req .= 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' . $crlf;
208
-    $req .= 'Accept-Language: en-us,en;q=0.5' . $crlf;
209
-    $req .= 'Accept-Encoding: deflate' . $crlf;
210
-    $req .= 'Accept-Charset: utf-8;q=0.7,*;q=0.7' . $crlf;
204
+    $req = $verb.' '.$uri.$getdata_str.' HTTP/1.1'.$crlf;
205
+    $req .= 'Host: '.$ip.$crlf;
206
+    $req .= 'User-Agent: Mozilla/5.0 Firefox/3.6.12'.$crlf;
207
+    $req .= 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'.$crlf;
208
+    $req .= 'Accept-Language: en-us,en;q=0.5'.$crlf;
209
+    $req .= 'Accept-Encoding: deflate'.$crlf;
210
+    $req .= 'Accept-Charset: utf-8;q=0.7,*;q=0.7'.$crlf;
211 211
 
212 212
     $req .= $crlf;
213 213
 
Please login to merge, or discard this patch.
main/inc/lib/access_url_edit_courses_to_url_functions.lib.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
      * a given string
23 23
      * @param string String to search for
24 24
      * @param int Deprecated param
25
-     * @return string A formatted, xajax answer block
25
+     * @return xajaxResponse A formatted, xajax answer block
26 26
      * @assert () === false
27 27
      */
28 28
     function search_courses($needle, $id)
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,17 +44,17 @@
 block discarded – undo
44 44
                     ORDER BY name, id
45 45
                     LIMIT 11';
46 46
             $rs = Database::query($sql);
47
-            $i=0;
47
+            $i = 0;
48 48
             while ($session = Database :: fetch_array($rs)) {
49 49
                 $i++;
50
-                if ($i<=10) {
50
+                if ($i <= 10) {
51 51
                      $return .= '<a href="#" onclick="add_user_to_url(\''.addslashes($session['id']).'\',\''.addslashes($session['name']).' ('.addslashes($session['id']).')'.'\')">'.$session['name'].' </a><br />';
52 52
                 } else {
53 53
                     $return .= '...<br />';
54 54
                 }
55 55
             }
56 56
         }
57
-        $xajax_response -> addAssign('ajax_list_courses','innerHTML',api_utf8_encode($return));
57
+        $xajax_response -> addAssign('ajax_list_courses', 'innerHTML', api_utf8_encode($return));
58 58
         return $xajax_response;
59 59
     }
60 60
 }
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,17 +38,17 @@
 block discarded – undo
38 38
             $needle = Database::escape_string($needle);
39 39
             // search courses where username or firstname or lastname begins likes $needle
40 40
             $sql = 'SELECT code, title FROM '.$tbl_course.' u '.
41
-                   ' WHERE (title LIKE "'.$needle.'%" '.
42
-                   ' OR code LIKE "'.$needle.'%" '.
43
-                   ' ) '.
44
-                   ' ORDER BY title, code '.
45
-                   ' LIMIT 11';
41
+                    ' WHERE (title LIKE "'.$needle.'%" '.
42
+                    ' OR code LIKE "'.$needle.'%" '.
43
+                    ' ) '.
44
+                    ' ORDER BY title, code '.
45
+                    ' LIMIT 11';
46 46
             $rs = Database::query($sql);
47 47
             $i=0;
48 48
             while ($course = Database :: fetch_array($rs)) {
49 49
                 $i++;
50 50
                 if ($i<=10) {
51
-                     $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\''.addslashes($course['code']).'\',\''.addslashes($course['title']).' ('.addslashes($course['code']).')'.'\')">'.$course['title'].' ('.$course['code'].')</a><br />';
51
+                        $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\''.addslashes($course['code']).'\',\''.addslashes($course['title']).' ('.addslashes($course['code']).')'.'\')">'.$course['title'].' ('.$course['code'].')</a><br />';
52 52
                 } else {
53 53
                     $return .= '...<br />';
54 54
                 }
Please login to merge, or discard this patch.
main/inc/lib/access_url_edit_users_to_url_functions.lib.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
      * search string
24 24
      * @param string Search string
25 25
      * @param int Deprecated param
26
-     * @return string Xajax response block
26
+     * @return xajaxResponse Xajax response block
27 27
      * @assert () === false
28 28
      */
29 29
     function search_users($needle, $id)
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -43,22 +43,22 @@
 block discarded – undo
43 43
                    ' WHERE (username LIKE "'.$needle.'%" '.
44 44
                    ' OR firstname LIKE "'.$needle.'%" '.
45 45
                    ' OR lastname LIKE "'.$needle.'%") '.
46
-                    $order_clause .
46
+                    $order_clause.
47 47
                    ' LIMIT 11';
48 48
 
49 49
             $rs = Database::query($sql);
50
-            $i=0;
50
+            $i = 0;
51 51
 
52 52
             while ($user = Database :: fetch_array($rs)) {
53 53
                 $i++;
54
-                if ($i<=10) {
54
+                if ($i <= 10) {
55 55
                     $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\''.addslashes($user['user_id']).'\',\''.api_get_person_name(addslashes($user['firstname']), addslashes($user['lastname'])).' ('.addslashes($user['username']).')'.'\')">'.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')</a><br />';
56 56
                 } else {
57 57
                     $return .= '...<br />';
58 58
                 }
59 59
             }
60 60
         }
61
-        $xajax_response -> addAssign('ajax_list_users','innerHTML',api_utf8_encode($return));
61
+        $xajax_response -> addAssign('ajax_list_users', 'innerHTML', api_utf8_encode($return));
62 62
         return $xajax_response;
63 63
     }
64 64
 }
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@
 block discarded – undo
40 40
             // search users where username or firstname or lastname begins likes $needle
41 41
             $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
42 42
             $sql = 'SELECT u.user_id, username, lastname, firstname FROM '.$tbl_user.' u '.
43
-                   ' WHERE (username LIKE "'.$needle.'%" '.
44
-                   ' OR firstname LIKE "'.$needle.'%" '.
45
-                   ' OR lastname LIKE "'.$needle.'%") '.
43
+                    ' WHERE (username LIKE "'.$needle.'%" '.
44
+                    ' OR firstname LIKE "'.$needle.'%" '.
45
+                    ' OR lastname LIKE "'.$needle.'%") '.
46 46
                     $order_clause .
47
-                   ' LIMIT 11';
47
+                    ' LIMIT 11';
48 48
 
49 49
             $rs = Database::query($sql);
50 50
             $i=0;
Please login to merge, or discard this patch.
main/inc/lib/add_course.lib.inc.php 2 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 
190 190
     /**
191 191
      * Gets an array with all the course tables (deprecated?)
192
-     * @return array
192
+     * @return string[]
193 193
      * @assert (null) !== null
194 194
      */
195 195
     public static function get_course_tables()
@@ -310,6 +310,8 @@  discard block
 block discarded – undo
310 310
      * @param string Complete path to directory we want to list
311 311
      * @param array A list of files to which we want to add the files found
312 312
      * @param string Type of base directory from which we want to recover the files
313
+     * @param string $path
314
+     * @param string $media
313 315
      * @return array
314 316
      * @assert (null,null,null) === false
315 317
      * @assert ('abc',array(),'') === array()
@@ -371,6 +373,7 @@  discard block
 block discarded – undo
371 373
      * Sorts pictures by type (used?)
372 374
      * @param array List of files (sthg like array(0=>array('png'=>1)))
373 375
      * @param string File type
376
+     * @param string $type
374 377
      * @return array The received array without files not matching type
375 378
      * @assert (array(),null) === array()
376 379
      */
Please login to merge, or discard this patch.
Spacing   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 
42 42
         while (!$keys_are_unique) {
43 43
 
44
-            $keys_course_id = $prefix_for_all . $unique_prefix . $wanted_code . $final_suffix['CourseId'];
44
+            $keys_course_id = $prefix_for_all.$unique_prefix.$wanted_code.$final_suffix['CourseId'];
45 45
             //$keys_course_db_name = $prefix_for_base_name . $unique_prefix . strtoupper($keys_course_id) . $final_suffix['CourseDb'];
46
-            $keys_course_repository = $prefix_for_path . $unique_prefix . $wanted_code . $final_suffix['CourseDir'];
46
+            $keys_course_repository = $prefix_for_path.$unique_prefix.$wanted_code.$final_suffix['CourseDir'];
47 47
             $keys_are_unique = true;
48 48
 
49 49
             // Check whether they are unique.
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 
53 53
             if (Database::num_rows($result)) {
54 54
                 $keys_are_unique = false;
55
-                $try_new_fsc_id ++;
55
+                $try_new_fsc_id++;
56 56
                 $final_suffix['CourseId'] = substr(md5(uniqid(rand())), 0, 4);
57 57
             }
58 58
             if (file_exists(api_get_path(SYS_COURSE_PATH).$keys_course_repository)) {
59 59
                 $keys_are_unique = false;
60
-                $try_new_fsc_dir ++;
60
+                $try_new_fsc_dir++;
61 61
                 $final_suffix['CourseDir'] = substr(md5(uniqid(rand())), 0, 4);
62 62
             }
63 63
 
@@ -85,12 +85,12 @@  discard block
 block discarded – undo
85 85
         $perm = api_get_permissions_for_new_directories();
86 86
         $perm_file = api_get_permissions_for_new_files();
87 87
         $htmlpage = "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\">\n    <title>Not authorized</title>\n  </head>\n  <body>\n  </body>\n</html>";
88
-        $cp = api_get_path(SYS_COURSE_PATH) . $course_repository;
88
+        $cp = api_get_path(SYS_COURSE_PATH).$course_repository;
89 89
 
90 90
         //Creating document folder
91 91
         mkdir($cp, $perm);
92
-        mkdir($cp . '/document', $perm);
93
-        $cpt = $cp . '/document/index.html';
92
+        mkdir($cp.'/document', $perm);
93
+        $cpt = $cp.'/document/index.html';
94 94
         $fd = fopen($cpt, 'w');
95 95
         fwrite($fd, $htmlpage);
96 96
         fclose($fd);
@@ -112,49 +112,49 @@  discard block
 block discarded – undo
112 112
         @copy($cpt, $cp . '/document/video/index.html');    */
113 113
 
114 114
         //Creatind dropbox folder
115
-        mkdir($cp . '/dropbox', $perm);
116
-        $cpt = $cp . '/dropbox/index.html';
115
+        mkdir($cp.'/dropbox', $perm);
116
+        $cpt = $cp.'/dropbox/index.html';
117 117
         $fd = fopen($cpt, 'w');
118 118
         fwrite($fd, $htmlpage);
119 119
         fclose($fd);
120 120
         @chmod($cpt, $perm_file);
121
-        mkdir($cp . '/group', $perm);
122
-        @copy($cpt, $cp . '/group/index.html');
123
-        mkdir($cp . '/page', $perm);
124
-        @copy($cpt, $cp . '/page/index.html');
125
-        mkdir($cp . '/scorm', $perm);
126
-        @copy($cpt, $cp . '/scorm/index.html');
127
-        mkdir($cp . '/upload', $perm);
128
-        @copy($cpt, $cp . '/upload/index.html');
129
-        mkdir($cp . '/upload/forum', $perm);
130
-        @copy($cpt, $cp . '/upload/forum/index.html');
131
-        mkdir($cp . '/upload/forum/images', $perm);
132
-        @copy($cpt, $cp . '/upload/forum/images/index.html');
133
-        mkdir($cp . '/upload/test', $perm);
134
-        @copy($cpt, $cp . '/upload/test/index.html');
135
-        mkdir($cp . '/upload/blog', $perm);
136
-        @copy($cpt, $cp . '/upload/blog/index.html');
137
-        mkdir($cp . '/upload/learning_path', $perm);
138
-        @copy($cpt, $cp . '/upload/learning_path/index.html');
139
-        mkdir($cp . '/upload/learning_path/images', $perm);
140
-        @copy($cpt, $cp . '/upload/learning_path/images/index.html');
141
-        mkdir($cp . '/upload/calendar', $perm);
142
-        @copy($cpt, $cp . '/upload/calendar/index.html');
143
-        mkdir($cp . '/upload/calendar/images', $perm);
144
-        @copy($cpt, $cp . '/upload/calendar/images/index.html');
145
-        mkdir($cp . '/work', $perm);
146
-        @copy($cpt, $cp . '/work/index.html');
147
-        mkdir($cp . '/upload/announcements', $perm);
148
-        @copy($cpt, $cp . '/upload/announcements/index.html');
149
-        mkdir($cp . '/upload/announcements/images', $perm);
150
-        @copy($cpt, $cp . '/upload/announcements/images/index.html');
121
+        mkdir($cp.'/group', $perm);
122
+        @copy($cpt, $cp.'/group/index.html');
123
+        mkdir($cp.'/page', $perm);
124
+        @copy($cpt, $cp.'/page/index.html');
125
+        mkdir($cp.'/scorm', $perm);
126
+        @copy($cpt, $cp.'/scorm/index.html');
127
+        mkdir($cp.'/upload', $perm);
128
+        @copy($cpt, $cp.'/upload/index.html');
129
+        mkdir($cp.'/upload/forum', $perm);
130
+        @copy($cpt, $cp.'/upload/forum/index.html');
131
+        mkdir($cp.'/upload/forum/images', $perm);
132
+        @copy($cpt, $cp.'/upload/forum/images/index.html');
133
+        mkdir($cp.'/upload/test', $perm);
134
+        @copy($cpt, $cp.'/upload/test/index.html');
135
+        mkdir($cp.'/upload/blog', $perm);
136
+        @copy($cpt, $cp.'/upload/blog/index.html');
137
+        mkdir($cp.'/upload/learning_path', $perm);
138
+        @copy($cpt, $cp.'/upload/learning_path/index.html');
139
+        mkdir($cp.'/upload/learning_path/images', $perm);
140
+        @copy($cpt, $cp.'/upload/learning_path/images/index.html');
141
+        mkdir($cp.'/upload/calendar', $perm);
142
+        @copy($cpt, $cp.'/upload/calendar/index.html');
143
+        mkdir($cp.'/upload/calendar/images', $perm);
144
+        @copy($cpt, $cp.'/upload/calendar/images/index.html');
145
+        mkdir($cp.'/work', $perm);
146
+        @copy($cpt, $cp.'/work/index.html');
147
+        mkdir($cp.'/upload/announcements', $perm);
148
+        @copy($cpt, $cp.'/upload/announcements/index.html');
149
+        mkdir($cp.'/upload/announcements/images', $perm);
150
+        @copy($cpt, $cp.'/upload/announcements/images/index.html');
151 151
 
152 152
         //Oral expression question type
153
-        mkdir($cp . '/exercises', $perm);
154
-        @copy($cpt, $cp . '/exercises/index.html');
153
+        mkdir($cp.'/exercises', $perm);
154
+        @copy($cpt, $cp.'/exercises/index.html');
155 155
 
156 156
         // Create .htaccess in the dropbox directory.
157
-        $fp = fopen($cp . '/dropbox/.htaccess', 'w');
157
+        $fp = fopen($cp.'/dropbox/.htaccess', 'w');
158 158
         fwrite(
159 159
             $fp,
160 160
             "AuthName AllowLocalAccess
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
     {
298 298
         $list = self::get_course_tables();
299 299
         foreach ($list as $table) {
300
-            $sql = "DROP TABLE IF EXISTS " . DB_COURSE_PREFIX . $table;
300
+            $sql = "DROP TABLE IF EXISTS ".DB_COURSE_PREFIX.$table;
301 301
             Database::query($sql);
302 302
         }
303 303
     }
@@ -319,47 +319,47 @@  discard block
 block discarded – undo
319 319
         if ($media == 'images') {
320 320
             $code_path = api_get_path(
321 321
                     SYS_CODE_PATH
322
-                ) . 'default_course_document/images/';
322
+                ).'default_course_document/images/';
323 323
         }
324 324
         if ($media == 'audio') {
325 325
             $code_path = api_get_path(
326 326
                     SYS_CODE_PATH
327
-                ) . 'default_course_document/audio/';
327
+                ).'default_course_document/audio/';
328 328
         }
329 329
         if ($media == 'flash') {
330 330
             $code_path = api_get_path(
331 331
                     SYS_CODE_PATH
332
-                ) . 'default_course_document/flash/';
332
+                ).'default_course_document/flash/';
333 333
         }
334 334
         if ($media == 'video') {
335 335
             $code_path = api_get_path(
336 336
                     SYS_CODE_PATH
337
-                ) . 'default_course_document/video/';
337
+                ).'default_course_document/video/';
338 338
         }
339 339
         if ($media == 'certificates') {
340 340
             $code_path = api_get_path(
341 341
                     SYS_CODE_PATH
342
-                ) . 'default_course_document/certificates/';
342
+                ).'default_course_document/certificates/';
343 343
         }
344 344
         if (is_dir($path)) {
345 345
             $handle = opendir($path);
346 346
             while (false !== ($file = readdir($handle))) {
347
-                if (is_dir($path . $file) && strpos($file, '.') !== 0) {
347
+                if (is_dir($path.$file) && strpos($file, '.') !== 0) {
348 348
                     $files[]['dir'] = str_replace(
349 349
                         $code_path,
350 350
                         '',
351
-                        $path . $file . '/'
351
+                        $path.$file.'/'
352 352
                     );
353 353
                     $files = self::browse_folders(
354
-                        $path . $file . '/',
354
+                        $path.$file.'/',
355 355
                         $files,
356 356
                         $media
357 357
                     );
358
-                } elseif (is_file($path . $file) && strpos($file, '.') !== 0) {
358
+                } elseif (is_file($path.$file) && strpos($file, '.') !== 0) {
359 359
                     $files[]['file'] = str_replace(
360 360
                         $code_path,
361 361
                         '',
362
-                        $path . $file
362
+                        $path.$file
363 363
                     );
364 364
                 }
365 365
             }
@@ -471,8 +471,8 @@  discard block
 block discarded – undo
471 471
             TABLE_MAIN_GRADEBOOK_CERTIFICATE
472 472
         );
473 473
 
474
-        include_once api_get_path(SYS_CODE_PATH) . 'lang/english/trad4all.inc.php';
475
-        $file_to_include = api_get_path(SYS_CODE_PATH) . 'lang/' . $language . '/trad4all.inc.php';
474
+        include_once api_get_path(SYS_CODE_PATH).'lang/english/trad4all.inc.php';
475
+        $file_to_include = api_get_path(SYS_CODE_PATH).'lang/'.$language.'/trad4all.inc.php';
476 476
 
477 477
         if (file_exists($file_to_include)) {
478 478
             include_once $file_to_include;
@@ -486,117 +486,117 @@  discard block
 block discarded – undo
486 486
 
487 487
         Database::query(
488 488
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
489
-            VALUES ($course_id, 1, '" . TOOL_COURSE_DESCRIPTION . "','course_description/','info.gif','" . self::string2binary(
489
+            VALUES ($course_id, 1, '".TOOL_COURSE_DESCRIPTION."','course_description/','info.gif','".self::string2binary(
490 490
                 api_get_setting(
491 491
                     'course_create_active_tools',
492 492
                     'course_description'
493 493
                 )
494
-            ) . "','0','squaregrey.gif', 0,'_self','authoring','0')"
494
+            )."','0','squaregrey.gif', 0,'_self','authoring','0')"
495 495
         );
496 496
         Database::query(
497 497
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
498
-            VALUES ($course_id, 2, '" . TOOL_CALENDAR_EVENT . "','calendar/agenda.php','agenda.gif','" . self::string2binary(
498
+            VALUES ($course_id, 2, '".TOOL_CALENDAR_EVENT."','calendar/agenda.php','agenda.gif','".self::string2binary(
499 499
                 api_get_setting('course_create_active_tools', 'agenda')
500
-            ) . "','0','squaregrey.gif',0,'_self','interaction','0')"
500
+            )."','0','squaregrey.gif',0,'_self','interaction','0')"
501 501
         );
502 502
         Database::query(
503 503
             "INSERT INTO $tbl_course_homepage  (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
504
-            VALUES ($course_id, 3, '" . TOOL_DOCUMENT . "','document/document.php','folder_document.gif','" . self::string2binary(
504
+            VALUES ($course_id, 3, '".TOOL_DOCUMENT."','document/document.php','folder_document.gif','".self::string2binary(
505 505
                 api_get_setting('course_create_active_tools', 'documents')
506
-            ) . "','0','squaregrey.gif',0,'_self','authoring','0')"
506
+            )."','0','squaregrey.gif',0,'_self','authoring','0')"
507 507
         );
508 508
         Database::query(
509 509
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
510
-            VALUES ($course_id, 4, '" . TOOL_LEARNPATH . "','newscorm/lp_controller.php','scorms.gif','" . self::string2binary(
510
+            VALUES ($course_id, 4, '".TOOL_LEARNPATH."','newscorm/lp_controller.php','scorms.gif','".self::string2binary(
511 511
                 api_get_setting('course_create_active_tools', 'learning_path')
512
-            ) . "','0','squaregrey.gif',0,'_self','authoring','0')"
512
+            )."','0','squaregrey.gif',0,'_self','authoring','0')"
513 513
         );
514 514
         Database::query(
515 515
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
516
-             VALUES ($course_id, 5, '" . TOOL_LINK . "','link/link.php','links.gif','" . self::string2binary(
516
+             VALUES ($course_id, 5, '".TOOL_LINK."','link/link.php','links.gif','".self::string2binary(
517 517
                 api_get_setting('course_create_active_tools', 'links')
518
-            ) . "','0','squaregrey.gif',0,'_self','authoring','0')"
518
+            )."','0','squaregrey.gif',0,'_self','authoring','0')"
519 519
         );
520 520
         Database::query(
521 521
             "INSERT INTO $tbl_course_homepage  (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
522
-            VALUES  ($course_id, 6, '" . TOOL_QUIZ . "','exercice/exercice.php','quiz.gif','" . self::string2binary(
522
+            VALUES  ($course_id, 6, '".TOOL_QUIZ."','exercice/exercice.php','quiz.gif','".self::string2binary(
523 523
                 api_get_setting('course_create_active_tools', 'quiz')
524
-            ) . "','0','squaregrey.gif',0,'_self','authoring','0')"
524
+            )."','0','squaregrey.gif',0,'_self','authoring','0')"
525 525
         );
526 526
         Database::query(
527 527
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
528
-            VALUES ($course_id, 7, '" . TOOL_ANNOUNCEMENT . "','announcements/announcements.php','valves.gif','" . self::string2binary(
528
+            VALUES ($course_id, 7, '".TOOL_ANNOUNCEMENT."','announcements/announcements.php','valves.gif','".self::string2binary(
529 529
                 api_get_setting('course_create_active_tools', 'announcements')
530
-            ) . "','0','squaregrey.gif', 0,'_self','authoring','0')"
530
+            )."','0','squaregrey.gif', 0,'_self','authoring','0')"
531 531
         );
532 532
         Database::query(
533 533
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
534
-            VALUES ($course_id, 8, '" . TOOL_FORUM . "','forum/index.php','forum.gif','" . self::string2binary(
534
+            VALUES ($course_id, 8, '".TOOL_FORUM."','forum/index.php','forum.gif','".self::string2binary(
535 535
                 api_get_setting('course_create_active_tools', 'forums')
536
-            ) . "','0','squaregrey.gif',0,'_self','interaction','0')"
536
+            )."','0','squaregrey.gif',0,'_self','interaction','0')"
537 537
         );
538 538
         Database::query(
539 539
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
540
-            VALUES ($course_id, 9, '" . TOOL_DROPBOX . "','dropbox/index.php','dropbox.gif','" . self::string2binary(
540
+            VALUES ($course_id, 9, '".TOOL_DROPBOX."','dropbox/index.php','dropbox.gif','".self::string2binary(
541 541
                 api_get_setting('course_create_active_tools', 'dropbox')
542
-            ) . "','0','squaregrey.gif',0,'_self','interaction','0')"
542
+            )."','0','squaregrey.gif',0,'_self','interaction','0')"
543 543
         );
544 544
         Database::query(
545 545
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
546
-            VALUES ($course_id, 10, '" . TOOL_USER . "','user/user.php','members.gif','" . self::string2binary(
546
+            VALUES ($course_id, 10, '".TOOL_USER."','user/user.php','members.gif','".self::string2binary(
547 547
                 api_get_setting('course_create_active_tools', 'users')
548
-            ) . "','0','squaregrey.gif',0,'_self','interaction','0')"
548
+            )."','0','squaregrey.gif',0,'_self','interaction','0')"
549 549
         );
550 550
         Database::query(
551 551
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
552
-            VALUES ($course_id, 11, '" . TOOL_GROUP . "','group/group.php','group.gif','" . self::string2binary(
552
+            VALUES ($course_id, 11, '".TOOL_GROUP."','group/group.php','group.gif','".self::string2binary(
553 553
                 api_get_setting('course_create_active_tools', 'groups')
554
-            ) . "','0','squaregrey.gif',0,'_self','interaction','0')"
554
+            )."','0','squaregrey.gif',0,'_self','interaction','0')"
555 555
         );
556 556
         Database::query(
557 557
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
558
-            VALUES ($course_id, 12, '" . TOOL_CHAT . "','chat/chat.php','chat.gif','" . self::string2binary(
558
+            VALUES ($course_id, 12, '".TOOL_CHAT."','chat/chat.php','chat.gif','".self::string2binary(
559 559
                 api_get_setting('course_create_active_tools', 'chat')
560
-            ) . "','0','squaregrey.gif',0,'_self','interaction','0')"
560
+            )."','0','squaregrey.gif',0,'_self','interaction','0')"
561 561
         );
562 562
         Database::query(
563 563
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
564
-            VALUES ($course_id, 13, '" . TOOL_STUDENTPUBLICATION . "','work/work.php','works.gif','" . self::string2binary(
564
+            VALUES ($course_id, 13, '".TOOL_STUDENTPUBLICATION."','work/work.php','works.gif','".self::string2binary(
565 565
                 api_get_setting(
566 566
                     'course_create_active_tools',
567 567
                     'student_publications'
568 568
                 )
569
-            ) . "','0','squaregrey.gif',0,'_self','interaction','0')"
569
+            )."','0','squaregrey.gif',0,'_self','interaction','0')"
570 570
         );
571 571
         Database::query(
572 572
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
573
-            VALUES ($course_id, 14, '" . TOOL_SURVEY . "','survey/survey_list.php','survey.gif','" . self::string2binary(
573
+            VALUES ($course_id, 14, '".TOOL_SURVEY."','survey/survey_list.php','survey.gif','".self::string2binary(
574 574
                 api_get_setting('course_create_active_tools', 'survey')
575
-            ) . "','0','squaregrey.gif',0,'_self','interaction','0')"
575
+            )."','0','squaregrey.gif',0,'_self','interaction','0')"
576 576
         );
577 577
         Database::query(
578 578
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
579
-            VALUES ($course_id, 15, '" . TOOL_WIKI . "','wiki/index.php','wiki.gif','" . self::string2binary(
579
+            VALUES ($course_id, 15, '".TOOL_WIKI."','wiki/index.php','wiki.gif','".self::string2binary(
580 580
                 api_get_setting('course_create_active_tools', 'wiki')
581
-            ) . "','0','squaregrey.gif',0,'_self','interaction','0')"
581
+            )."','0','squaregrey.gif',0,'_self','interaction','0')"
582 582
         );
583 583
         Database::query(
584 584
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
585
-            VALUES ($course_id, 16, '" . TOOL_GRADEBOOK . "','gradebook/index.php','gradebook.gif','" . self::string2binary(
585
+            VALUES ($course_id, 16, '".TOOL_GRADEBOOK."','gradebook/index.php','gradebook.gif','".self::string2binary(
586 586
                 api_get_setting('course_create_active_tools', 'gradebook')
587
-            ) . "','0','squaregrey.gif',0,'_self','authoring','0')"
587
+            )."','0','squaregrey.gif',0,'_self','authoring','0')"
588 588
         );
589 589
         Database::query(
590 590
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
591
-            VALUES ($course_id, 17, '" . TOOL_GLOSSARY . "','glossary/index.php','glossary.gif','" . self::string2binary(
591
+            VALUES ($course_id, 17, '".TOOL_GLOSSARY."','glossary/index.php','glossary.gif','".self::string2binary(
592 592
                 api_get_setting('course_create_active_tools', 'glossary')
593
-            ) . "','0','squaregrey.gif',0,'_self','authoring','0')"
593
+            )."','0','squaregrey.gif',0,'_self','authoring','0')"
594 594
         );
595 595
         Database::query(
596 596
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
597
-            VALUES ($course_id, 18, '" . TOOL_NOTEBOOK . "','notebook/index.php','notebook.gif','" . self::string2binary(
597
+            VALUES ($course_id, 18, '".TOOL_NOTEBOOK."','notebook/index.php','notebook.gif','".self::string2binary(
598 598
                 api_get_setting('course_create_active_tools', 'notebook')
599
-            ) . "','0','squaregrey.gif',0,'_self','interaction','0')"
599
+            )."','0','squaregrey.gif',0,'_self','interaction','0')"
600 600
         );
601 601
 
602 602
         $setting = intval(self::string2binary(
@@ -605,13 +605,13 @@  discard block
 block discarded – undo
605 605
 
606 606
         Database::query(
607 607
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
608
-            VALUES ($course_id, 19, '" . TOOL_ATTENDANCE . "','attendance/index.php','attendance.gif','" . $setting. "','0','squaregrey.gif',0,'_self','authoring','0')"
608
+            VALUES ($course_id, 19, '".TOOL_ATTENDANCE."','attendance/index.php','attendance.gif','".$setting."','0','squaregrey.gif',0,'_self','authoring','0')"
609 609
         );
610 610
         Database::query(
611 611
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
612
-            VALUES ($course_id, 20, '" . TOOL_COURSE_PROGRESS . "','course_progress/index.php','course_progress.gif','" . self::string2binary(
612
+            VALUES ($course_id, 20, '".TOOL_COURSE_PROGRESS."','course_progress/index.php','course_progress.gif','".self::string2binary(
613 613
                 intval(api_get_setting('course_create_active_tools', 'course_progress'))
614
-            ) . "','0','squaregrey.gif',0,'_self','authoring','0')"
614
+            )."','0','squaregrey.gif',0,'_self','authoring','0')"
615 615
         );
616 616
 
617 617
         if (api_get_setting('service_visio', 'active') == 'true') {
@@ -619,11 +619,11 @@  discard block
 block discarded – undo
619 619
             if (!empty($mycheck)) {
620 620
                 Database::query(
621 621
                     "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
622
-                     VALUES ($course_id, 21, '" . TOOL_VISIO_CONFERENCE . "','conference/index.php?type=conference','visio_meeting.gif','1','0','squaregrey.gif','NO','_self','interaction','0')"
622
+                     VALUES ($course_id, 21, '".TOOL_VISIO_CONFERENCE."','conference/index.php?type=conference','visio_meeting.gif','1','0','squaregrey.gif','NO','_self','interaction','0')"
623 623
                 );
624 624
                 Database::query(
625 625
                     "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
626
-                     VALUES ($course_id, 22, '" . TOOL_VISIO_CLASSROOM . "','conference/index.php?type=classroom','visio.gif','1','0','squaregrey.gif','NO','_self','authoring','0')"
626
+                     VALUES ($course_id, 22, '".TOOL_VISIO_CLASSROOM."','conference/index.php?type=classroom','visio.gif','1','0','squaregrey.gif','NO','_self','authoring','0')"
627 627
                 );
628 628
             }
629 629
         }
@@ -631,33 +631,33 @@  discard block
 block discarded – undo
631 631
         if (api_get_setting('search_enabled') == 'true') {
632 632
             Database::query(
633 633
                 "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
634
-                VALUES ($course_id, 23, '" . TOOL_SEARCH . "','search/','info.gif','" . self::string2binary(
634
+                VALUES ($course_id, 23, '".TOOL_SEARCH."','search/','info.gif','".self::string2binary(
635 635
                     api_get_setting(
636 636
                         'course_create_active_tools',
637 637
                         'enable_search'
638 638
                     )
639
-                ) . "','0','search.gif',0,'_self','authoring','0')"
639
+                )."','0','search.gif',0,'_self','authoring','0')"
640 640
             );
641 641
         }
642 642
 
643 643
         $sql = "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
644
-                VALUES ($course_id, 24,'" . TOOL_BLOGS . "','blog/blog_admin.php','blog_admin.gif','" . intval(self::string2binary(
644
+                VALUES ($course_id, 24,'".TOOL_BLOGS."','blog/blog_admin.php','blog_admin.gif','".intval(self::string2binary(
645 645
                 api_get_setting('course_create_active_tools', 'blogs'))
646
-            ) . "','1','squaregrey.gif',0,'_self','admin','0')";
646
+            )."','1','squaregrey.gif',0,'_self','admin','0')";
647 647
         Database::query($sql);
648 648
 
649 649
         /*  Course homepage tools for course admin only  */
650 650
         Database::query(
651 651
             "INSERT INTO $tbl_course_homepage  (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
652
-            VALUES ($course_id, 25, '" . TOOL_TRACKING . "','tracking/courseLog.php','statistics.gif','$visible_for_course_admin','1','', 0,'_self','admin','0')"
652
+            VALUES ($course_id, 25, '".TOOL_TRACKING."','tracking/courseLog.php','statistics.gif','$visible_for_course_admin','1','', 0,'_self','admin','0')"
653 653
         );
654 654
         Database::query(
655 655
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
656
-            VALUES ($course_id, 26, '" . TOOL_COURSE_SETTING . "','course_info/infocours.php','reference.gif','$visible_for_course_admin','1','', 0,'_self','admin','0')"
656
+            VALUES ($course_id, 26, '".TOOL_COURSE_SETTING."','course_info/infocours.php','reference.gif','$visible_for_course_admin','1','', 0,'_self','admin','0')"
657 657
         );
658 658
         Database::query(
659 659
             "INSERT INTO $tbl_course_homepage (c_id, id, name, link, image, visibility, admin, address, added_tool, target, category, session_id)
660
-            VALUES ($course_id, 27, '" . TOOL_COURSE_MAINTENANCE . "','course_info/maintenance.php','backup.gif','$visible_for_course_admin','1','',0,'_self', 'admin','0')"
660
+            VALUES ($course_id, 27, '".TOOL_COURSE_MAINTENANCE."','course_info/maintenance.php','backup.gif','$visible_for_course_admin','1','',0,'_self', 'admin','0')"
661 661
         );
662 662
 
663 663
         $defaultEmailExerciseAlert = 1;
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
 
709 709
         Database::query(
710 710
             "INSERT INTO $TABLEGROUPCATEGORIES (c_id, id, title , description, max_student, self_reg_allowed, self_unreg_allowed, groups_per_user, display_order, doc_state,calendar_state, work_state ,announcements_state, forum_state, wiki_state, chat_state)
711
-             VALUES ($course_id, '2', '" . self::lang2db(get_lang('DefaultGroupCategory')) . "', '', '8', '0', '0', '0', '0', 1, 1 ,1 ,1 ,1, 1, 1);"
711
+             VALUES ($course_id, '2', '".self::lang2db(get_lang('DefaultGroupCategory'))."', '', '8', '0', '0', '0', '0', 1, 1 ,1 ,1 ,1, 1, 1);"
712 712
         );
713 713
 
714 714
         /*    Example Material  */
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
         $perm = api_get_permissions_for_new_directories();
739 739
         $perm_file = api_get_permissions_for_new_files();
740 740
 
741
-        $chat_path = $sys_course_path . $course_repository . '/document/chat_files';
741
+        $chat_path = $sys_course_path.$course_repository.'/document/chat_files';
742 742
 
743 743
         if (!is_dir($chat_path)) {
744 744
             @mkdir($chat_path, api_get_permissions_for_new_directories());
@@ -770,11 +770,11 @@  discard block
 block discarded – undo
770 770
                 'certificates',
771 771
             );
772 772
 
773
-            $default_course_path = api_get_path(SYS_CODE_PATH) . 'default_course_document/';
773
+            $default_course_path = api_get_path(SYS_CODE_PATH).'default_course_document/';
774 774
 
775 775
             $default_document_array = array();
776 776
             foreach ($folders_to_copy_from_default_course as $folder) {
777
-                $default_course_folder_path = $default_course_path . $folder . '/';
777
+                $default_course_folder_path = $default_course_path.$folder.'/';
778 778
                 $files = self::browse_folders(
779 779
                     $default_course_folder_path,
780 780
                     array(),
@@ -805,30 +805,30 @@  discard block
 block discarded – undo
805 805
                     //hack until feature #5242 is implemented
806 806
                     if ($media_type == 'images') {
807 807
                         $media_type = 'images/gallery';
808
-                        $images_folder = $sys_course_path . $course_repository . "/document/images/";
808
+                        $images_folder = $sys_course_path.$course_repository."/document/images/";
809 809
 
810 810
                         if (!is_dir($images_folder)) {
811 811
                             //Creating index.html
812 812
                             mkdir($images_folder, $perm);
813
-                            $fd = fopen($images_folder . 'index.html', 'w');
813
+                            $fd = fopen($images_folder.'index.html', 'w');
814 814
                             fwrite($fd, $htmlpage);
815
-                            @chmod($images_folder . 'index.html', $perm_file);
815
+                            @chmod($images_folder.'index.html', $perm_file);
816 816
                         }
817 817
                     }
818 818
 
819
-                    $course_documents_folder = $sys_course_path . $course_repository . "/document/$media_type/";
820
-                    $default_course_path = api_get_path(SYS_CODE_PATH) . 'default_course_document' . $path_documents;
819
+                    $course_documents_folder = $sys_course_path.$course_repository."/document/$media_type/";
820
+                    $default_course_path = api_get_path(SYS_CODE_PATH).'default_course_document'.$path_documents;
821 821
 
822 822
                     if (!is_dir($course_documents_folder)) {
823 823
                         // Creating index.html
824 824
                         mkdir($course_documents_folder, $perm);
825 825
                         $fd = fopen(
826
-                            $course_documents_folder . 'index.html',
826
+                            $course_documents_folder.'index.html',
827 827
                             'w'
828 828
                         );
829 829
                         fwrite($fd, $htmlpage);
830 830
                         @chmod(
831
-                            $course_documents_folder . 'index.html',
831
+                            $course_documents_folder.'index.html',
832 832
                             $perm_file
833 833
                         );
834 834
                     }
@@ -836,15 +836,15 @@  discard block
 block discarded – undo
836 836
                     if (is_array($array_media) && count($array_media) > 0) {
837 837
                         foreach ($array_media as $key => $value) {
838 838
                             if (isset($value['dir']) && !empty($value['dir'])) {
839
-                                if (!is_dir($course_documents_folder . $value['dir'])) {
839
+                                if (!is_dir($course_documents_folder.$value['dir'])) {
840 840
                                     //Creating folder
841 841
                                     mkdir(
842
-                                        $course_documents_folder . $value['dir'],
842
+                                        $course_documents_folder.$value['dir'],
843 843
                                         $perm
844 844
                                     );
845 845
 
846 846
                                     //Creating index.html (for light protection)
847
-                                    $index_html = $course_documents_folder . $value['dir'] . '/index.html';
847
+                                    $index_html = $course_documents_folder.$value['dir'].'/index.html';
848 848
                                     $fd = fopen($index_html, 'w');
849 849
                                     fwrite($fd, $htmlpage);
850 850
                                     @chmod($index_html, $perm_file);
@@ -866,12 +866,12 @@  discard block
 block discarded – undo
866 866
                                     }
867 867
 
868 868
                                     if ($media_type == 'images/gallery') {
869
-                                        $folder_path = 'gallery/' . $folder_path;
869
+                                        $folder_path = 'gallery/'.$folder_path;
870 870
                                     }
871 871
 
872 872
                                     Database::query(
873 873
                                         "INSERT INTO $TABLETOOLDOCUMENT (c_id, path,title,filetype,size)
874
-                                        VALUES ($course_id,'$path_documents" . $folder_path . "','" . $title . "','folder','0')"
874
+                                        VALUES ($course_id,'$path_documents".$folder_path."','".$title."','folder','0')"
875 875
                                     );
876 876
                                     $image_id = Database:: insert_id();
877 877
 
@@ -884,33 +884,33 @@  discard block
 block discarded – undo
884 884
 
885 885
                             if (isset($value['file']) && !empty($value['file'])) {
886 886
                                 if (!file_exists(
887
-                                    $course_documents_folder . $value['file']
887
+                                    $course_documents_folder.$value['file']
888 888
                                 )
889 889
                                 ) {
890 890
                                     //Copying file
891 891
                                     copy(
892
-                                        $default_course_path . $value['file'],
893
-                                        $course_documents_folder . $value['file']
892
+                                        $default_course_path.$value['file'],
893
+                                        $course_documents_folder.$value['file']
894 894
                                     );
895 895
                                     chmod(
896
-                                        $course_documents_folder . $value['file'],
896
+                                        $course_documents_folder.$value['file'],
897 897
                                         $perm_file
898 898
                                     );
899 899
                                     //echo $default_course_path.$value['file']; echo ' - '; echo $course_documents_folder.$value['file']; echo '<br />';
900 900
                                     $temp = explode('/', $value['file']);
901 901
                                     $file_size = filesize(
902
-                                        $course_documents_folder . $value['file']
902
+                                        $course_documents_folder.$value['file']
903 903
                                     );
904 904
 
905 905
                                     //hack until feature #5242 is implemented
906 906
                                     if ($media_type == 'images/gallery') {
907
-                                        $value["file"] = 'gallery/' . $value["file"];
907
+                                        $value["file"] = 'gallery/'.$value["file"];
908 908
                                     }
909 909
 
910 910
                                     //Inserting file in the DB
911 911
                                     Database::query(
912 912
                                         "INSERT INTO $TABLETOOLDOCUMENT (c_id, path,title,filetype,size)
913
-                                        VALUES ($course_id,'$path_documents" . $value["file"] . "','" . $temp[count($temp) - 1] . "','file','$file_size')"
913
+                                        VALUES ($course_id,'$path_documents".$value["file"]."','".$temp[count($temp) - 1]."','file','$file_size')"
914 914
                                     );
915 915
                                     $image_id = Database:: insert_id();
916 916
                                     if ($image_id) {
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
                                         $sql = "UPDATE $TABLETOOLDOCUMENT SET id = iid WHERE iid = $image_id";
919 919
                                         Database::query($sql);
920 920
 
921
-                                        if ($path_documents . $value['file'] == '/certificates/default.html') {
921
+                                        if ($path_documents.$value['file'] == '/certificates/default.html') {
922 922
                                             $example_cert_id = $image_id;
923 923
                                         }
924 924
                                         Database::query(
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
                     'c_id' => $course_id,
959 959
                     'url' => 'http://www.google.com',
960 960
                     'title' => 'Google',
961
-                    'description' => get_lang('Google') ,
961
+                    'description' => get_lang('Google'),
962 962
                     'category_id' => 0,
963 963
                     'on_homepage' => 0,
964 964
                     'target' => '_self',
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
                     'c_id' => $course_id,
969 969
                     'url' => 'http://www.wikipedia.org',
970 970
                     'title' => 'Wikipedia',
971
-                    'description' => get_lang('Wikipedia') ,
971
+                    'description' => get_lang('Wikipedia'),
972 972
                     'category_id' => 0,
973 973
                     'on_homepage' => 0,
974 974
                     'target' => '_self',
@@ -976,7 +976,7 @@  discard block
 block discarded – undo
976 976
                 ]
977 977
             ];
978 978
 
979
-            foreach($links as $params) {
979
+            foreach ($links as $params) {
980 980
                 $link->save($params);
981 981
             }
982 982
 
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
             /* Introduction text */
996 996
 
997 997
             $intro_text = '<p style="text-align: center;">
998
-                            <img src="' . api_get_path(REL_CODE_PATH) . 'img/mascot.png" alt="Mr. Chamilo" title="Mr. Chamilo" />
999
-                            <h2>' . self::lang2db(get_lang('IntroductionText')) . '</h2>
998
+                            <img src="' . api_get_path(REL_CODE_PATH).'img/mascot.png" alt="Mr. Chamilo" title="Mr. Chamilo" />
999
+                            <h2>' . self::lang2db(get_lang('IntroductionText')).'</h2>
1000 1000
                          </p>';
1001 1001
 
1002 1002
             $toolIntro = new Chamilo\CourseBundle\Entity\CToolIntro();
@@ -1032,9 +1032,9 @@  discard block
 block discarded – undo
1032 1032
             $html = '<table width="100%" border="0" cellpadding="0" cellspacing="0">
1033 1033
                         <tr>
1034 1034
                         <td width="220" valign="top" align="left">
1035
-                            <img src="' . api_get_path(WEB_CODE_PATH) . 'default_course_document/images/mr_chamilo/doubts.png">
1035
+                            <img src="' . api_get_path(WEB_CODE_PATH).'default_course_document/images/mr_chamilo/doubts.png">
1036 1036
                         </td>
1037
-                        <td valign="top" align="left">' . get_lang('Antique') . '</td></tr>
1037
+                        <td valign="top" align="left">' . get_lang('Antique').'</td></tr>
1038 1038
                     </table>';
1039 1039
             $exercise->type = 1;
1040 1040
             $exercise->setRandom(0);
@@ -1279,7 +1279,7 @@  discard block
 block discarded – undo
1279 1279
                 'https://'
1280 1280
             ) === false
1281 1281
         ) {
1282
-            $department_url = 'http://' . $department_url;
1282
+            $department_url = 'http://'.$department_url;
1283 1283
         }
1284 1284
         //just in case
1285 1285
         if ($department_url == 'http://') {
@@ -1290,26 +1290,26 @@  discard block
 block discarded – undo
1290 1290
         if ($ok_to_register_course) {
1291 1291
 
1292 1292
             // Here we must add 2 fields.
1293
-            $sql = "INSERT INTO " . $TABLECOURSE . " SET
1293
+            $sql = "INSERT INTO ".$TABLECOURSE." SET
1294 1294
                         code = '".Database:: escape_string($code)."',
1295 1295
                         directory = '".Database:: escape_string($directory)."',
1296 1296
                         course_language = '".Database:: escape_string($course_language)."',
1297 1297
                         title = '".Database:: escape_string($title)."',
1298 1298
                         description = '".self::lang2db(get_lang('CourseDescription'))."',
1299 1299
                         category_code = '".Database:: escape_string($category_code)."',
1300
-                        visibility      = '" . $visibility . "',
1300
+                        visibility      = '" . $visibility."',
1301 1301
                         show_score      = '1',
1302
-                        disk_quota      = '" . intval($disk_quota) . "',
1302
+                        disk_quota      = '" . intval($disk_quota)."',
1303 1303
                         creation_date   = '$time',
1304
-                        expiration_date = '" . $expiration_date . "',
1304
+                        expiration_date = '".$expiration_date."',
1305 1305
                         last_edit       = '$time',
1306 1306
                         last_visit      = NULL,
1307
-                        tutor_name = '" . Database:: escape_string($tutor_name) . "',
1308
-                        department_name = '" . Database:: escape_string($department_name) . "',
1309
-                        department_url = '" . Database:: escape_string($department_url) . "',
1310
-                        subscribe = '" . intval($subscribe) . "',
1311
-                        unsubscribe = '" . intval($unsubscribe) . "',
1312
-                        visual_code = '" . Database:: escape_string($visual_code) . "'";
1307
+                        tutor_name = '".Database:: escape_string($tutor_name)."',
1308
+                        department_name = '" . Database:: escape_string($department_name)."',
1309
+                        department_url = '" . Database:: escape_string($department_url)."',
1310
+                        subscribe = '" . intval($subscribe)."',
1311
+                        unsubscribe = '" . intval($unsubscribe)."',
1312
+                        visual_code = '" . Database:: escape_string($visual_code)."'";
1313 1313
             Database::query($sql);
1314 1314
             $course_id = Database::insert_id();
1315 1315
 
@@ -1324,12 +1324,12 @@  discard block
 block discarded – undo
1324 1324
                         $code
1325 1325
                     );
1326 1326
                     if (!empty($user_id)) {
1327
-                        $sql = "INSERT INTO " . $TABLECOURSUSER . " SET
1328
-                                c_id     = '" . $course_id . "',
1329
-                                user_id         = '" . intval($user_id) . "',
1327
+                        $sql = "INSERT INTO ".$TABLECOURSUSER." SET
1328
+                                c_id     = '" . $course_id."',
1329
+                                user_id         = '" . intval($user_id)."',
1330 1330
                                 status          = '1',
1331 1331
                                 is_tutor        = '0',
1332
-                                sort            = '" . ($i_course_sort) . "',
1332
+                                sort            = '" . ($i_course_sort)."',
1333 1333
                                 relation_type = 0,
1334 1334
                                 user_course_cat = '0'";
1335 1335
                         Database::query($sql);
@@ -1348,12 +1348,12 @@  discard block
 block discarded – undo
1348 1348
                         if (empty($key)) {
1349 1349
                             continue;
1350 1350
                         }
1351
-                        $sql = "INSERT INTO " . $TABLECOURSUSER . " SET
1352
-                            c_id     = '" . Database::escape_string($course_id) . "',
1353
-                            user_id         = '" . Database::escape_string($key) . "',
1351
+                        $sql = "INSERT INTO ".$TABLECOURSUSER." SET
1352
+                            c_id     = '" . Database::escape_string($course_id)."',
1353
+                            user_id         = '" . Database::escape_string($key)."',
1354 1354
                             status          = '1',
1355 1355
                             is_tutor        = '0',
1356
-                            sort            = '" . ($sort + 1) . "',
1356
+                            sort            = '" . ($sort + 1)."',
1357 1357
                             relation_type = 0,
1358 1358
                             user_course_cat = '0'";
1359 1359
                         Database::query($sql);
@@ -1397,18 +1397,18 @@  discard block
 block discarded – undo
1397 1397
                     $iname = api_get_setting('Institution');
1398 1398
                     $subject = get_lang(
1399 1399
                             'NewCourseCreatedIn'
1400
-                        ) . ' ' . $siteName . ' - ' . $iname;
1400
+                        ).' '.$siteName.' - '.$iname;
1401 1401
                     $message = get_lang(
1402 1402
                             'Dear'
1403
-                        ) . ' ' . $recipient_name . ",\n\n" . get_lang(
1403
+                        ).' '.$recipient_name.",\n\n".get_lang(
1404 1404
                             'MessageOfNewCourseToAdmin'
1405
-                        ) . ' ' . $siteName . ' - ' . $iname . "\n";
1406
-                    $message .= get_lang('CourseName') . ' ' . $title . "\n";
1405
+                        ).' '.$siteName.' - '.$iname."\n";
1406
+                    $message .= get_lang('CourseName').' '.$title."\n";
1407 1407
                     $message .= get_lang(
1408 1408
                             'Category'
1409
-                        ) . ' ' . $category_code . "\n";
1410
-                    $message .= get_lang('Tutor') . ' ' . $tutor_name . "\n";
1411
-                    $message .= get_lang('Language') . ' ' . $course_language;
1409
+                        ).' '.$category_code."\n";
1410
+                    $message .= get_lang('Tutor').' '.$tutor_name."\n";
1411
+                    $message .= get_lang('Language').' '.$course_language;
1412 1412
 
1413 1413
                     $userInfo = api_get_user_info($user_id);
1414 1414
 
Please login to merge, or discard this patch.