Passed
Push — 1.10.x ( 4b2d9f...3e6bac )
by Yannick
182:52 queued 136:22
created
main/exercice/hotpotatoes_exercise_result.class.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -18,6 +18,7 @@
 block discarded – undo
18 18
 	 * Gets the results of all students (or just one student if access is limited)
19 19
 	 * @param	string		The document path (for HotPotatoes retrieval)
20 20
 	 * @param	integer		User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
21
+	 * @param string $document_path
21 22
 	 */
22 23
 	public function getExercisesReporting($document_path, $hotpotato_name)
23 24
     {
Please login to merge, or discard this patch.
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@  discard block
 block discarded – undo
14 14
     //stores the results
15 15
     private $results = array();
16 16
 
17
-	/**
18
-	 * Gets the results of all students (or just one student if access is limited)
19
-	 * @param	string		The document path (for HotPotatoes retrieval)
20
-	 * @param	integer		User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
21
-	 */
22
-	public function getExercisesReporting($document_path, $hotpotato_name)
17
+    /**
18
+     * Gets the results of all students (or just one student if access is limited)
19
+     * @param	string		The document path (for HotPotatoes retrieval)
20
+     * @param	integer		User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
21
+     */
22
+    public function getExercisesReporting($document_path, $hotpotato_name)
23 23
     {
24
-		$return = array();
24
+        $return = array();
25 25
         $TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
26 26
         $TBL_TRACK_HOTPOTATOES	= Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
27 27
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         $hotpotato_name  = Database::escape_string($hotpotato_name);
34 34
 
35 35
         if (!empty($exercise_id)) {
36
-          $session_id_and .= " AND exe_exo_id = $exercise_id ";
36
+            $session_id_and .= " AND exe_exo_id = $exercise_id ";
37 37
         }
38 38
 
39 39
         if (empty($user_id)) {
@@ -110,25 +110,25 @@  discard block
 block discarded – undo
110 110
         $this->results = $return;
111 111
 
112 112
         return true;
113
-	}
113
+    }
114 114
 
115 115
 
116
-	/**
117
-	 * Exports the complete report as a CSV file
118
-	 * @param	string		Document path inside the document tool
119
-	 * @param	integer		Optional user ID
120
-	 * @param	boolean		Whether to include user fields or not
121
-	 * @return	boolean		False on error
122
-	 */
123
-	public function exportCompleteReportCSV($document_path='', $hotpotato_name)
116
+    /**
117
+     * Exports the complete report as a CSV file
118
+     * @param	string		Document path inside the document tool
119
+     * @param	integer		Optional user ID
120
+     * @param	boolean		Whether to include user fields or not
121
+     * @return	boolean		False on error
122
+     */
123
+    public function exportCompleteReportCSV($document_path='', $hotpotato_name)
124 124
     {
125
-		global $charset;
126
-		$this->getExercisesReporting($document_path, $hotpotato_name);
127
-		$filename = 'exercise_results_'.date('YmdGis').'.csv';
128
-		if (!empty($user_id)) {
129
-			$filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
130
-		}
131
-		$data = '';
125
+        global $charset;
126
+        $this->getExercisesReporting($document_path, $hotpotato_name);
127
+        $filename = 'exercise_results_'.date('YmdGis').'.csv';
128
+        if (!empty($user_id)) {
129
+            $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
130
+        }
131
+        $data = '';
132 132
 
133 133
         if (api_is_western_name_order()) {
134 134
             if(!empty($this->results[0]['first_name'])) {
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         }
148 148
         $data .= get_lang('Email').';';
149 149
 
150
-		/*if ($export_user_fields) {
150
+        /*if ($export_user_fields) {
151 151
 			//show user fields section with a big th colspan that spans over all fields
152 152
 			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
153 153
 			$num = count($extra_user_fields);
@@ -156,25 +156,25 @@  discard block
 block discarded – undo
156 156
 			}
157 157
 		}*/
158 158
 
159
-		$data .= get_lang('Title').';';
160
-		$data .= get_lang('StartDate').';';
161
-		$data .= get_lang('Score').';';
162
-		$data .= get_lang('Total').';';
163
-		$data .= "\n";
159
+        $data .= get_lang('Title').';';
160
+        $data .= get_lang('StartDate').';';
161
+        $data .= get_lang('Score').';';
162
+        $data .= get_lang('Total').';';
163
+        $data .= "\n";
164 164
 
165
-		//results
166
-		foreach($this->results as $row) {
165
+        //results
166
+        foreach($this->results as $row) {
167 167
             if (api_is_western_name_order()) {
168
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
169
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
168
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
169
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
170 170
             } else {
171
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
172
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
171
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
172
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
173 173
             }
174 174
 
175 175
             $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
176 176
 
177
-			/*if ($export_user_fields) {
177
+            /*if ($export_user_fields) {
178 178
 				//show user fields data, if any, for this user
179 179
 				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
180 180
 				foreach($user_fields_values as $value) {
@@ -182,40 +182,40 @@  discard block
 block discarded – undo
182 182
 				}
183 183
 			}*/
184 184
 
185
-			$data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
186
-			$data .= str_replace("\r\n",'  ',$row['exe_date']).';';
187
-			$data .= str_replace("\r\n",'  ',$row['result']).';';
188
-			$data .= str_replace("\r\n",'  ',$row['max']).';';
189
-			$data .= "\n";
190
-		}
191
-
192
-		//output the results
193
-		$len = strlen($data);
194
-		header('Content-type: application/octet-stream');
195
-		header('Content-Type: application/force-download');
196
-		header('Content-length: '.$len);
197
-		if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
198
-			header('Content-Disposition: filename= '.$filename);
199
-		} else {
200
-			header('Content-Disposition: attachment; filename= '.$filename);
201
-		}
202
-		if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
203
-			header('Pragma: ');
204
-			header('Cache-Control: ');
205
-			header('Cache-Control: public'); // IE cannot download from sessions without a cache
206
-		}
207
-		header('Content-Description: '.$filename);
208
-		header('Content-transfer-encoding: binary');
209
-		// @todo add this utf-8 header for all csv files
210
-		echo "\xEF\xBB\xBF";  // force utf-8 header of csv file
211
-		echo $data;
212
-		return true;
213
-	}
214
-
215
-	/**
216
-	 * Exports the complete report as an XLS file
217
-	 * @return	boolean		False on error
218
-	 */
185
+            $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
186
+            $data .= str_replace("\r\n",'  ',$row['exe_date']).';';
187
+            $data .= str_replace("\r\n",'  ',$row['result']).';';
188
+            $data .= str_replace("\r\n",'  ',$row['max']).';';
189
+            $data .= "\n";
190
+        }
191
+
192
+        //output the results
193
+        $len = strlen($data);
194
+        header('Content-type: application/octet-stream');
195
+        header('Content-Type: application/force-download');
196
+        header('Content-length: '.$len);
197
+        if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
198
+            header('Content-Disposition: filename= '.$filename);
199
+        } else {
200
+            header('Content-Disposition: attachment; filename= '.$filename);
201
+        }
202
+        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
203
+            header('Pragma: ');
204
+            header('Cache-Control: ');
205
+            header('Cache-Control: public'); // IE cannot download from sessions without a cache
206
+        }
207
+        header('Content-Description: '.$filename);
208
+        header('Content-transfer-encoding: binary');
209
+        // @todo add this utf-8 header for all csv files
210
+        echo "\xEF\xBB\xBF";  // force utf-8 header of csv file
211
+        echo $data;
212
+        return true;
213
+    }
214
+
215
+    /**
216
+     * Exports the complete report as an XLS file
217
+     * @return	boolean		False on error
218
+     */
219 219
     public function exportCompleteReportXLS(
220 220
         $document_path = '',
221 221
         $user_id = null,
@@ -224,37 +224,37 @@  discard block
 block discarded – undo
224 224
         $exercise_id = 0,
225 225
         $hotpotato_name = null
226 226
     ) {
227
-		global $charset;
228
-		$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
229
-		$filename = 'exercise_results_'.api_get_local_time().'.xls';
230
-		if (!empty($user_id)) {
231
-			$filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
232
-		}
227
+        global $charset;
228
+        $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
229
+        $filename = 'exercise_results_'.api_get_local_time().'.xls';
230
+        if (!empty($user_id)) {
231
+            $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
232
+        }
233 233
 
234 234
         $spreadsheet = new PHPExcel();
235 235
         $spreadsheet->setActiveSheetIndex(0);
236 236
         $worksheet = $spreadsheet->getActiveSheet();
237 237
 
238 238
 
239
-		$line = 0;
240
-		$column = 0; //skip the first column (row titles)
239
+        $line = 0;
240
+        $column = 0; //skip the first column (row titles)
241 241
 
242
-		// check if exists column 'user'
243
-		$with_column_user = false;
244
-		foreach ($this->results as $result) {
245
-			if (!empty($result['last_name']) && !empty($result['first_name'])) {
246
-				$with_column_user = true;
247
-				break;
248
-			}
249
-		}
242
+        // check if exists column 'user'
243
+        $with_column_user = false;
244
+        foreach ($this->results as $result) {
245
+            if (!empty($result['last_name']) && !empty($result['first_name'])) {
246
+                $with_column_user = true;
247
+                break;
248
+            }
249
+        }
250 250
 
251
-		if ($with_column_user) {
252
-		    $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Email'));
253
-		    $column++;
251
+        if ($with_column_user) {
252
+            $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Email'));
253
+            $column++;
254 254
 
255 255
             if (api_is_western_name_order()) {
256
-    			$worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName'));
257
-    			$column++;
256
+                $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName'));
257
+                $column++;
258 258
                 $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('LastName'));
259 259
                 $column++;
260 260
             } else {
@@ -263,36 +263,36 @@  discard block
 block discarded – undo
263 263
                 $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName'));
264 264
                 $column++;
265 265
             }
266
-		}
266
+        }
267 267
 
268
-		if ($export_user_fields) {
269
-			//show user fields section with a big th colspan that spans over all fields
270
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
268
+        if ($export_user_fields) {
269
+            //show user fields section with a big th colspan that spans over all fields
270
+            $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
271 271
 
272
-			//show the fields names for user fields
273
-			foreach ($extra_user_fields as $field) {
274
-				$worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
275
-				$column++;
276
-			}
277
-		}
272
+            //show the fields names for user fields
273
+            foreach ($extra_user_fields as $field) {
274
+                $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
275
+                $column++;
276
+            }
277
+        }
278 278
 
279
-		$worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title'));
280
-		$column++;
281
-		$worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate'));
279
+        $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title'));
280
+        $column++;
281
+        $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate'));
282 282
         $column++;
283 283
         $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('EndDate'));
284 284
         $column++;
285 285
         $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Duration').' ('.get_lang('MinMinutes').')');
286
-		$column++;
287
-		$worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score'));
288
-		$column++;
289
-		$worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total'));
290
-		$column++;
286
+        $column++;
287
+        $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score'));
288
+        $column++;
289
+        $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total'));
290
+        $column++;
291 291
         $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Status'));
292
-		$line++;
292
+        $line++;
293 293
 
294
-		foreach ($this->results as $row) {
295
-			$column = 0;
294
+        foreach ($this->results as $row) {
295
+            $column = 0;
296 296
 
297 297
             if ($with_column_user) {
298 298
                 $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset));
@@ -309,38 +309,38 @@  discard block
 block discarded – undo
309 309
                     $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
310 310
                     $column++;
311 311
                 }
312
-			}
312
+            }
313 313
 
314
-			if ($export_user_fields) {
315
-				//show user fields data, if any, for this user
316
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
317
-				foreach($user_fields_values as $value) {
318
-					$worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
319
-					$column++;
320
-				}
321
-			}
314
+            if ($export_user_fields) {
315
+                //show user fields data, if any, for this user
316
+                $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
317
+                foreach($user_fields_values as $value) {
318
+                    $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
319
+                    $column++;
320
+                }
321
+            }
322 322
 
323
-			$worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
324
-			$column++;
325
-			$worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']);
323
+            $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
324
+            $column++;
325
+            $worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']);
326 326
             $column++;
327
-			$worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']);
327
+            $worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']);
328
+            $column++;
329
+            $worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']);
330
+            $column++;
331
+            $worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']);
332
+            $column++;
333
+            $worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']);
328 334
             $column++;
329
-			$worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']);
330
-			$column++;
331
-			$worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']);
332
-			$column++;
333
-			$worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']);
334
-			$column++;
335 335
             $worksheet->SetCellValueByColumnAndRow($line,$column,$row['status']);
336
-			$line++;
337
-		}
336
+            $line++;
337
+        }
338 338
 
339 339
         $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
340 340
         $writer = new PHPExcel_Writer_Excel2007($spreadsheet);
341 341
         $writer->save($file);
342 342
         DocumentManager::file_send_for_download($file, true, $filename);
343 343
 
344
-		return true;
345
-	}
344
+        return true;
345
+    }
346 346
 }
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
     {
24 24
 		$return = array();
25 25
         $TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
26
-        $TBL_TRACK_HOTPOTATOES	= Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
26
+        $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
27 27
 
28 28
         $cid             = api_get_course_id();
29 29
         $course_id       = api_get_course_int_id();
30 30
         //$user_id         = intval($user_id);
31 31
         $user_id = null;
32
-        $session_id_and  = ' AND te.session_id = ' . api_get_session_id() . ' ';
32
+        $session_id_and  = ' AND te.session_id = '.api_get_session_id().' ';
33 33
         $hotpotato_name  = Database::escape_string($hotpotato_name);
34 34
 
35 35
         if (!empty($exercise_id)) {
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         }
38 38
 
39 39
         if (empty($user_id)) {
40
-            $sql="SELECT firstname as userpart1, lastname as userpart2 ,
40
+            $sql = "SELECT firstname as userpart1, lastname as userpart2 ,
41 41
                     email,
42 42
                     tth.exe_name,
43 43
                     tth.exe_result,
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
                             tth.exe_name = '$hotpotato_name'
50 50
                     ORDER BY tth.c_id ASC, tth.exe_date ASC";
51 51
         } else {
52
-            $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' ';
52
+            $user_id_and = ' AND te.exe_user_id = '.api_get_user_id().' ';
53 53
             // get only this user's results
54 54
 
55 55
             $sql = "SELECT '', exe_name, exe_result , exe_weighting, exe_date
56 56
                     FROM $TBL_TRACK_HOTPOTATOES
57 57
                     WHERE
58
-                        exe_user_id = '" . $user_id . "' AND
58
+                        exe_user_id = '".$user_id."' AND
59 59
                         c_id = $course_id AND
60 60
                         tth.exe_name = '$hotpotato_name'
61 61
                     ORDER BY c_id ASC, exe_date ASC";
@@ -64,13 +64,13 @@  discard block
 block discarded – undo
64 64
         $results = array();
65 65
 
66 66
         $resx = Database::query($sql);
67
-        while ($rowx = Database::fetch_array($resx,'ASSOC')) {
67
+        while ($rowx = Database::fetch_array($resx, 'ASSOC')) {
68 68
             $results[] = $rowx;
69 69
         }
70 70
 
71 71
         $hpresults = array();
72 72
         $resx = Database::query($sql);
73
-        while ($rowx = Database::fetch_array($resx,'ASSOC')) {
73
+        while ($rowx = Database::fetch_array($resx, 'ASSOC')) {
74 74
             $hpresults[] = $rowx;
75 75
         }
76 76
 
@@ -89,19 +89,19 @@  discard block
 block discarded – undo
89 89
 
90 90
         // Print the Result of Hotpotatoes Tests
91 91
         if (is_array($hpresults)) {
92
-            for($i = 0; $i < sizeof($hpresults); $i++) {
92
+            for ($i = 0; $i < sizeof($hpresults); $i++) {
93 93
                 $return[$i] = array();
94 94
                 $title = GetQuizName($hpresults[$i]['exe_name'], $document_path);
95
-                if ($title =='') {
95
+                if ($title == '') {
96 96
                     $title = basename($hpresults[$i]['exe_name']);
97 97
                 }
98
-                if(empty($user_id)) {
98
+                if (empty($user_id)) {
99 99
                 $return[$i]['email'] = $hpresults[$i]['email'];
100 100
                     $return[$i]['first_name'] = $hpresults[$i]['userpart1'];
101 101
                     $return[$i]['last_name'] = $hpresults[$i]['userpart2'];
102 102
                 }
103 103
                 $return[$i]['title'] = $title;
104
-                $return[$i]['exe_date']  = $hpresults[$i]['exe_date'];
104
+                $return[$i]['exe_date'] = $hpresults[$i]['exe_date'];
105 105
 
106 106
                 $return[$i]['result'] = $hpresults[$i]['exe_result'];
107 107
                 $return[$i]['max'] = $hpresults[$i]['exe_weighting'];
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 * @param	boolean		Whether to include user fields or not
121 121
 	 * @return	boolean		False on error
122 122
 	 */
123
-	public function exportCompleteReportCSV($document_path='', $hotpotato_name)
123
+	public function exportCompleteReportCSV($document_path = '', $hotpotato_name)
124 124
     {
125 125
 		global $charset;
126 126
 		$this->getExercisesReporting($document_path, $hotpotato_name);
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
 		$data = '';
132 132
 
133 133
         if (api_is_western_name_order()) {
134
-            if(!empty($this->results[0]['first_name'])) {
134
+            if (!empty($this->results[0]['first_name'])) {
135 135
                 $data .= get_lang('FirstName').';';
136 136
             }
137
-            if(!empty($this->results[0]['last_name'])) {
137
+            if (!empty($this->results[0]['last_name'])) {
138 138
                 $data .= get_lang('LastName').';';
139 139
             }
140 140
         } else {
141
-            if(!empty($this->results[0]['last_name'])) {
141
+            if (!empty($this->results[0]['last_name'])) {
142 142
                 $data .= get_lang('LastName').';';
143 143
             }
144
-            if(!empty($this->results[0]['first_name'])) {
144
+            if (!empty($this->results[0]['first_name'])) {
145 145
                 $data .= get_lang('FirstName').';';
146 146
             }
147 147
         }
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
 		$data .= "\n";
164 164
 
165 165
 		//results
166
-		foreach($this->results as $row) {
166
+		foreach ($this->results as $row) {
167 167
             if (api_is_western_name_order()) {
168
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
169
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
168
+              $data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
169
+              $data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
170 170
             } else {
171
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
172
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
171
+              $data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
172
+              $data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
173 173
             }
174 174
 
175
-            $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
175
+            $data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
176 176
 
177 177
 			/*if ($export_user_fields) {
178 178
 				//show user fields data, if any, for this user
@@ -182,10 +182,10 @@  discard block
 block discarded – undo
182 182
 				}
183 183
 			}*/
184 184
 
185
-			$data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
186
-			$data .= str_replace("\r\n",'  ',$row['exe_date']).';';
187
-			$data .= str_replace("\r\n",'  ',$row['result']).';';
188
-			$data .= str_replace("\r\n",'  ',$row['max']).';';
185
+			$data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
186
+			$data .= str_replace("\r\n", '  ', $row['exe_date']).';';
187
+			$data .= str_replace("\r\n", '  ', $row['result']).';';
188
+			$data .= str_replace("\r\n", '  ', $row['max']).';';
189 189
 			$data .= "\n";
190 190
 		}
191 191
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		header('Content-Description: '.$filename);
208 208
 		header('Content-transfer-encoding: binary');
209 209
 		// @todo add this utf-8 header for all csv files
210
-		echo "\xEF\xBB\xBF";  // force utf-8 header of csv file
210
+		echo "\xEF\xBB\xBF"; // force utf-8 header of csv file
211 211
 		echo $data;
212 212
 		return true;
213 213
 	}
@@ -249,25 +249,25 @@  discard block
 block discarded – undo
249 249
 		}
250 250
 
251 251
 		if ($with_column_user) {
252
-		    $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Email'));
252
+		    $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Email'));
253 253
 		    $column++;
254 254
 
255 255
             if (api_is_western_name_order()) {
256
-    			$worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName'));
256
+    			$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('FirstName'));
257 257
     			$column++;
258
-                $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('LastName'));
258
+                $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('LastName'));
259 259
                 $column++;
260 260
             } else {
261
-                $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('LastName'));
261
+                $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('LastName'));
262 262
                 $column++;
263
-                $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName'));
263
+                $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('FirstName'));
264 264
                 $column++;
265 265
             }
266 266
 		}
267 267
 
268 268
 		if ($export_user_fields) {
269 269
 			//show user fields section with a big th colspan that spans over all fields
270
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
270
+			$extra_user_fields = UserManager::get_extra_fields(0, 1000, 5, 'ASC', false, 1);
271 271
 
272 272
 			//show the fields names for user fields
273 273
 			foreach ($extra_user_fields as $field) {
@@ -276,63 +276,63 @@  discard block
 block discarded – undo
276 276
 			}
277 277
 		}
278 278
 
279
-		$worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title'));
279
+		$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Title'));
280 280
 		$column++;
281
-		$worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate'));
281
+		$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('StartDate'));
282 282
         $column++;
283
-        $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('EndDate'));
283
+        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('EndDate'));
284 284
         $column++;
285
-        $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Duration').' ('.get_lang('MinMinutes').')');
285
+        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Duration').' ('.get_lang('MinMinutes').')');
286 286
 		$column++;
287
-		$worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score'));
287
+		$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Score'));
288 288
 		$column++;
289
-		$worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total'));
289
+		$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Total'));
290 290
 		$column++;
291
-        $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Status'));
291
+        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Status'));
292 292
 		$line++;
293 293
 
294 294
 		foreach ($this->results as $row) {
295 295
 			$column = 0;
296 296
 
297 297
             if ($with_column_user) {
298
-                $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset));
298
+                $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset));
299 299
                 $column++;
300 300
 
301 301
                 if (api_is_western_name_order()) {
302
-                    $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
302
+                    $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
303 303
                     $column++;
304
-                    $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset));
304
+                    $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset));
305 305
                     $column++;
306 306
                 } else {
307
-                    $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset));
307
+                    $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset));
308 308
                     $column++;
309
-                    $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
309
+                    $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
310 310
                     $column++;
311 311
                 }
312 312
 			}
313 313
 
314 314
 			if ($export_user_fields) {
315 315
 				//show user fields data, if any, for this user
316
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
317
-				foreach($user_fields_values as $value) {
318
-					$worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
316
+				$user_fields_values = UserManager::get_extra_user_data($row['user_id'], false, false, false, true);
317
+				foreach ($user_fields_values as $value) {
318
+					$worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
319 319
 					$column++;
320 320
 				}
321 321
 			}
322 322
 
323
-			$worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
323
+			$worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
324 324
 			$column++;
325
-			$worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']);
325
+			$worksheet->SetCellValueByColumnAndRow($line, $column, $row['start_date']);
326 326
             $column++;
327
-			$worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']);
327
+			$worksheet->SetCellValueByColumnAndRow($line, $column, $row['end_date']);
328 328
             $column++;
329
-			$worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']);
329
+			$worksheet->SetCellValueByColumnAndRow($line, $column, $row['duration']);
330 330
 			$column++;
331
-			$worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']);
331
+			$worksheet->SetCellValueByColumnAndRow($line, $column, $row['result']);
332 332
 			$column++;
333
-			$worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']);
333
+			$worksheet->SetCellValueByColumnAndRow($line, $column, $row['max']);
334 334
 			$column++;
335
-            $worksheet->SetCellValueByColumnAndRow($line,$column,$row['status']);
335
+            $worksheet->SetCellValueByColumnAndRow($line, $column, $row['status']);
336 336
 			$line++;
337 337
 		}
338 338
 
Please login to merge, or discard this patch.
main/exercice/hotspot.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
 	/**
53 53
 	 * @param FormValidator $form
54 54
 	 * @param null $objExercise
55
-	 * @return bool
55
+	 * @return null|false
56 56
 	 */
57 57
 	public function processCreation($form, $objExercise = null)
58 58
 	{
Please login to merge, or discard this patch.
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -12,78 +12,78 @@  discard block
 block discarded – undo
12 12
  **/
13 13
 class HotSpot extends Question
14 14
 {
15
-	static $typePicture = 'hotspot.png';
16
-	static $explanationLangVar = 'HotSpot';
17
-
18
-	public function __construct()
19
-	{
20
-		parent::__construct();
21
-		$this -> type = HOT_SPOT;
22
-	}
23
-
24
-	public function display()
25
-	{
26
-	}
27
-
28
-	/**
29
-	 * @param FormValidator $form
30
-	 * @param int $fck_config
31
-	 */
32
-	public function createForm (&$form, $fck_config=0)
33
-	{
34
-		parent::createForm($form, $fck_config);
35
-
36
-		if (!isset($_GET['editQuestion'])) {
37
-			$form->addElement('file','imageUpload',array('<img src="'.Display::return_icon('hotspot.png', null, null, ICON_SIZE_BIG, false, true).'" />', get_lang('UploadJpgPicture')) );
38
-
39
-			// setting the save button here and not in the question class.php
40
-			// Saving a question
41
-			$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
42
-			//$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
43
-			$form->addRule('imageUpload', get_lang('OnlyImagesAllowed'), 'filetype', array ('jpg', 'jpeg', 'png', 'gif'));
44
-			$form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile');
45
-		} else {
46
-			// setting the save button here and not in the question class.php
47
-			// Editing a question
48
-			$form->addButtonUpdate(get_lang('ModifyExercise'), 'submitQuestion');
49
-		}
50
-	}
51
-
52
-	/**
53
-	 * @param FormValidator $form
54
-	 * @param null $objExercise
55
-	 * @return bool
56
-	 */
57
-	public function processCreation($form, $objExercise = null)
58
-	{
59
-		$file_info = $form->getSubmitValue('imageUpload');
60
-		$_course = api_get_course_info();
61
-		parent::processCreation($form, $objExercise);
62
-
63
-		if(!empty($file_info['tmp_name'])) {
64
-			$this->uploadPicture($file_info['tmp_name'], $file_info['name']);
65
-			$documentPath  = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
66
-			$picturePath   = $documentPath.'/images';
67
-
68
-			// fixed width ang height
69
-			if (file_exists($picturePath.'/'.$this->picture)) {
70
-				$this->resizePicture('width', 800);
71
-				$this->save();
72
-			} else {
73
-				return false;
74
-			}
75
-		}
76
-	}
77
-
78
-	function createAnswersForm ($form)
79
-	{
80
-		// nothing
81
-	}
82
-
83
-	function processAnswersCreation ($form)
84
-	{
85
-		// nothing
86
-	}
15
+    static $typePicture = 'hotspot.png';
16
+    static $explanationLangVar = 'HotSpot';
17
+
18
+    public function __construct()
19
+    {
20
+        parent::__construct();
21
+        $this -> type = HOT_SPOT;
22
+    }
23
+
24
+    public function display()
25
+    {
26
+    }
27
+
28
+    /**
29
+     * @param FormValidator $form
30
+     * @param int $fck_config
31
+     */
32
+    public function createForm (&$form, $fck_config=0)
33
+    {
34
+        parent::createForm($form, $fck_config);
35
+
36
+        if (!isset($_GET['editQuestion'])) {
37
+            $form->addElement('file','imageUpload',array('<img src="'.Display::return_icon('hotspot.png', null, null, ICON_SIZE_BIG, false, true).'" />', get_lang('UploadJpgPicture')) );
38
+
39
+            // setting the save button here and not in the question class.php
40
+            // Saving a question
41
+            $form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
42
+            //$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
43
+            $form->addRule('imageUpload', get_lang('OnlyImagesAllowed'), 'filetype', array ('jpg', 'jpeg', 'png', 'gif'));
44
+            $form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile');
45
+        } else {
46
+            // setting the save button here and not in the question class.php
47
+            // Editing a question
48
+            $form->addButtonUpdate(get_lang('ModifyExercise'), 'submitQuestion');
49
+        }
50
+    }
51
+
52
+    /**
53
+     * @param FormValidator $form
54
+     * @param null $objExercise
55
+     * @return bool
56
+     */
57
+    public function processCreation($form, $objExercise = null)
58
+    {
59
+        $file_info = $form->getSubmitValue('imageUpload');
60
+        $_course = api_get_course_info();
61
+        parent::processCreation($form, $objExercise);
62
+
63
+        if(!empty($file_info['tmp_name'])) {
64
+            $this->uploadPicture($file_info['tmp_name'], $file_info['name']);
65
+            $documentPath  = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
66
+            $picturePath   = $documentPath.'/images';
67
+
68
+            // fixed width ang height
69
+            if (file_exists($picturePath.'/'.$this->picture)) {
70
+                $this->resizePicture('width', 800);
71
+                $this->save();
72
+            } else {
73
+                return false;
74
+            }
75
+        }
76
+    }
77
+
78
+    function createAnswersForm ($form)
79
+    {
80
+        // nothing
81
+    }
82
+
83
+    function processAnswersCreation ($form)
84
+    {
85
+        // nothing
86
+    }
87 87
 }
88 88
 
89 89
 /**
@@ -91,35 +91,35 @@  discard block
 block discarded – undo
91 91
  */
92 92
 class HotSpotDelineation extends HotSpot
93 93
 {
94
-	static $typePicture = 'hotspot-delineation.png';
95
-	static $explanationLangVar = 'HotspotDelineation';
96
-
97
-	function __construct()
98
-	{
99
-		parent::__construct();
100
-		$this -> type = HOT_SPOT_DELINEATION;
101
-
102
-	}
103
-
104
-	function createForm (&$form, $fck_config=0)
105
-	{
106
-		parent::createForm ($form, $fck_config);
107
-	}
108
-
109
-	function processCreation ($form, $objExercise = null)
110
-	{
111
-		$file_info = $form -> getSubmitValue('imageUpload');
112
-		parent::processCreation ($form, $objExercise);
113
-	}
114
-
115
-	function createAnswersForm ($form)
116
-	{
117
-		parent::createAnswersForm ($form);
118
-	}
119
-
120
-	function processAnswersCreation ($form)
121
-	{
122
-		parent::processAnswersCreation ($form);
123
-	}
94
+    static $typePicture = 'hotspot-delineation.png';
95
+    static $explanationLangVar = 'HotspotDelineation';
96
+
97
+    function __construct()
98
+    {
99
+        parent::__construct();
100
+        $this -> type = HOT_SPOT_DELINEATION;
101
+
102
+    }
103
+
104
+    function createForm (&$form, $fck_config=0)
105
+    {
106
+        parent::createForm ($form, $fck_config);
107
+    }
108
+
109
+    function processCreation ($form, $objExercise = null)
110
+    {
111
+        $file_info = $form -> getSubmitValue('imageUpload');
112
+        parent::processCreation ($form, $objExercise);
113
+    }
114
+
115
+    function createAnswersForm ($form)
116
+    {
117
+        parent::createAnswersForm ($form);
118
+    }
119
+
120
+    function processAnswersCreation ($form)
121
+    {
122
+        parent::processAnswersCreation ($form);
123
+    }
124 124
 }
125 125
 
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
 	 * @param FormValidator $form
30 30
 	 * @param int $fck_config
31 31
 	 */
32
-	public function createForm (&$form, $fck_config=0)
32
+	public function createForm(&$form, $fck_config = 0)
33 33
 	{
34 34
 		parent::createForm($form, $fck_config);
35 35
 
36 36
 		if (!isset($_GET['editQuestion'])) {
37
-			$form->addElement('file','imageUpload',array('<img src="'.Display::return_icon('hotspot.png', null, null, ICON_SIZE_BIG, false, true).'" />', get_lang('UploadJpgPicture')) );
37
+			$form->addElement('file', 'imageUpload', array('<img src="'.Display::return_icon('hotspot.png', null, null, ICON_SIZE_BIG, false, true).'" />', get_lang('UploadJpgPicture')));
38 38
 
39 39
 			// setting the save button here and not in the question class.php
40 40
 			// Saving a question
41 41
 			$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
42 42
 			//$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
43
-			$form->addRule('imageUpload', get_lang('OnlyImagesAllowed'), 'filetype', array ('jpg', 'jpeg', 'png', 'gif'));
43
+			$form->addRule('imageUpload', get_lang('OnlyImagesAllowed'), 'filetype', array('jpg', 'jpeg', 'png', 'gif'));
44 44
 			$form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile');
45 45
 		} else {
46 46
 			// setting the save button here and not in the question class.php
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 		$_course = api_get_course_info();
61 61
 		parent::processCreation($form, $objExercise);
62 62
 
63
-		if(!empty($file_info['tmp_name'])) {
63
+		if (!empty($file_info['tmp_name'])) {
64 64
 			$this->uploadPicture($file_info['tmp_name'], $file_info['name']);
65 65
 			$documentPath  = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
66 66
 			$picturePath   = $documentPath.'/images';
@@ -75,12 +75,12 @@  discard block
 block discarded – undo
75 75
 		}
76 76
 	}
77 77
 
78
-	function createAnswersForm ($form)
78
+	function createAnswersForm($form)
79 79
 	{
80 80
 		// nothing
81 81
 	}
82 82
 
83
-	function processAnswersCreation ($form)
83
+	function processAnswersCreation($form)
84 84
 	{
85 85
 		// nothing
86 86
 	}
@@ -101,25 +101,25 @@  discard block
 block discarded – undo
101 101
 
102 102
 	}
103 103
 
104
-	function createForm (&$form, $fck_config=0)
104
+	function createForm(&$form, $fck_config = 0)
105 105
 	{
106
-		parent::createForm ($form, $fck_config);
106
+		parent::createForm($form, $fck_config);
107 107
 	}
108 108
 
109
-	function processCreation ($form, $objExercise = null)
109
+	function processCreation($form, $objExercise = null)
110 110
 	{
111 111
 		$file_info = $form -> getSubmitValue('imageUpload');
112
-		parent::processCreation ($form, $objExercise);
112
+		parent::processCreation($form, $objExercise);
113 113
 	}
114 114
 
115
-	function createAnswersForm ($form)
115
+	function createAnswersForm($form)
116 116
 	{
117
-		parent::createAnswersForm ($form);
117
+		parent::createAnswersForm($form);
118 118
 	}
119 119
 
120
-	function processAnswersCreation ($form)
120
+	function processAnswersCreation($form)
121 121
 	{
122
-		parent::processAnswersCreation ($form);
122
+		parent::processAnswersCreation($form);
123 123
 	}
124 124
 }
125 125
 
Please login to merge, or discard this patch.
main/exercice/oral_expression.class.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
      * @param null $feedback_type
59 59
      * @param null $counter
60 60
      * @param null $score
61
-     * @return null|string
61
+     * @return string
62 62
      */
63 63
     function return_header($feedback_type = null, $counter = null, $score = null)
64 64
     {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
     function createAnswersForm($form)
32 32
     {
33 33
 
34
-        $form -> addElement('text','weighting', get_lang('Weighting'), array('class' => 'span1'));
34
+        $form -> addElement('text', 'weighting', get_lang('Weighting'), array('class' => 'span1'));
35 35
         global $text, $class;
36 36
         // setting the save button here and not in the question class.php
37 37
         $form->addButtonSave($text, 'submitQuestion');
Please login to merge, or discard this patch.
main/exercice/question.class.php 3 patches
Doc Comments   +8 added lines, -5 removed lines patch added patch discarded remove patch
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
     }
266 266
 
267 267
     /**
268
-     * @return bool|string
268
+     * @return string|false
269 269
      */
270 270
     public function selectPicturePath()
271 271
     {
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
      * @param string $Dimension - Resizing happens proportional according to given dimension: height|width|any
591 591
      * @param integer $Max - Maximum size
592 592
      *
593
-     * @return boolean - true if success, false if failed
593
+     * @return boolean|null - true if success, false if failed
594 594
      *
595 595
      * @author Toon Keppens
596 596
      */
@@ -751,6 +751,7 @@  discard block
 block discarded – undo
751 751
 
752 752
     /**
753 753
      * Sets extra info
754
+     * @param string $extra
754 755
      */
755 756
     public function setExtra($extra)
756 757
     {
@@ -1261,7 +1262,7 @@  discard block
 block discarded – undo
1261 1262
      *
1262 1263
      * @author Olivier Brouckaert
1263 1264
      * @param  array   Course info of the destination course
1264
-     * @return int     ID of the new question
1265
+     * @return false|string     ID of the new question
1265 1266
      */
1266 1267
     public function duplicate($course_info = null)
1267 1268
     {
@@ -1636,7 +1637,7 @@  discard block
 block discarded – undo
1636 1637
      * @param string $name
1637 1638
      * @param int $course_id
1638 1639
      * @param int $position
1639
-     * @return bool|int
1640
+     * @return false|string
1640 1641
      */
1641 1642
     static function saveQuestionOption($question_id, $name, $course_id, $position = 0)
1642 1643
     {
@@ -1775,6 +1776,7 @@  discard block
 block discarded – undo
1775 1776
      * @param   int     Maximum result for the question
1776 1777
      * @param   int     Type of question (see constants at beginning of question.class.php)
1777 1778
      * @param   int     Question level/category
1779
+     * @param string $quiz_id
1778 1780
      */
1779 1781
     public function create_question(
1780 1782
         $quiz_id,
@@ -1857,6 +1859,7 @@  discard block
 block discarded – undo
1857 1859
     /**
1858 1860
      * Get course medias
1859 1861
      * @param int course id
1862
+     * @param integer $course_id
1860 1863
      */
1861 1864
     static function get_course_medias(
1862 1865
         $course_id,
@@ -1922,7 +1925,7 @@  discard block
 block discarded – undo
1922 1925
     }
1923 1926
 
1924 1927
     /**
1925
-     * @return array
1928
+     * @return integer[]
1926 1929
      */
1927 1930
     public static function get_default_levels()
1928 1931
     {
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     public $type;
23 23
     public $level;
24 24
     public $picture;
25
-    public $exerciseList;  // array with the list of exercises which this question is in
25
+    public $exerciseList; // array with the list of exercises which this question is in
26 26
     public $category_list;
27 27
     public $parent_id;
28 28
     public $category;
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
             'multiple_answer_combination_true_false.class.php',
48 48
             'MultipleAnswerCombinationTrueFalse'
49 49
         ),
50
-        GLOBAL_MULTIPLE_ANSWER => array('global_multiple_answer.class.php' , 'GlobalMultipleAnswer'),
51
-        CALCULATED_ANSWER => array('calculated_answer.class.php' , 'CalculatedAnswer'),
50
+        GLOBAL_MULTIPLE_ANSWER => array('global_multiple_answer.class.php', 'GlobalMultipleAnswer'),
51
+        CALCULATED_ANSWER => array('calculated_answer.class.php', 'CalculatedAnswer'),
52 52
         UNIQUE_ANSWER_IMAGE => ['UniqueAnswerImage.php', 'UniqueAnswerImage'],
53 53
         DRAGGABLE => ['Draggable.php', 'Draggable'],
54 54
         MATCHING_DRAGGABLE => ['MatchingDraggable.php', 'MatchingDraggable']
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
         $id = intval($id);
108 108
 
109 109
         if (!empty($course_id)) {
110
-            $course_info =  api_get_course_info_by_id($course_id);
110
+            $course_info = api_get_course_info_by_id($course_id);
111 111
         } else {
112 112
             $course_info = api_get_course_info();
113 113
         }
114 114
 
115 115
         $course_id = $course_info['real_id'];
116 116
 
117
-        if (empty($course_id) || $course_id == -1 ) {
117
+        if (empty($course_id) || $course_id == -1) {
118 118
             return false;
119 119
         }
120 120
 
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
     public function selectPicturePath()
271 271
     {
272 272
         if (!empty($this->picture)) {
273
-            return api_get_path(WEB_COURSE_PATH) . $this->course['path'] . '/document/images/' . $this->picture;
273
+            return api_get_path(WEB_COURSE_PATH).$this->course['path'].'/document/images/'.$this->picture;
274 274
         }
275 275
 
276 276
         return false;
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
      */
308 308
     public function updateTitle($title)
309 309
     {
310
-        $this->question=$title;
310
+        $this->question = $title;
311 311
     }
312 312
 
313 313
     /**
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
                     // DO nothing
407 407
                 } else {
408 408
                     $sql = "INSERT INTO $TBL_QUESTION_REL_CATEGORY (c_id, question_id, category_id)
409
-                            VALUES (" . api_get_course_int_id() . ", $question_id, $category_id)";
409
+                            VALUES (".api_get_course_int_id().", $question_id, $category_id)";
410 410
                     Database::query($sql);
411 411
                 }
412 412
             }
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
             $sql = "SELECT count(*) AS nb FROM $table
434 434
                     WHERE
435 435
                         question_id = $question_id AND
436
-                        c_id=" . api_get_course_int_id();
436
+                        c_id=".api_get_course_int_id();
437 437
             $res = Database::query($sql);
438 438
             $row = Database::fetch_array($res);
439 439
             if ($row['nb'] > 0) {
@@ -441,11 +441,11 @@  discard block
 block discarded – undo
441 441
                         SET category_id = $category_id
442 442
                         WHERE
443 443
                             question_id = $question_id AND
444
-                            c_id = " . api_get_course_int_id();
444
+                            c_id = ".api_get_course_int_id();
445 445
                 Database::query($sql);
446 446
             } else {
447 447
                 $sql = "INSERT INTO $table (c_id, question_id, category_id)
448
-                        VALUES (" . api_get_course_int_id().", $question_id, $category_id)";
448
+                        VALUES (".api_get_course_int_id().", $question_id, $category_id)";
449 449
                 Database::query($sql);
450 450
             }
451 451
         }
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
         $sql = "DELETE FROM $table
464 464
                 WHERE
465 465
                     question_id = $question_id AND
466
-                    c_id = " . api_get_course_int_id();
466
+                    c_id = ".api_get_course_int_id();
467 467
         Database::query($sql);
468 468
     }
469 469
 
@@ -516,11 +516,11 @@  discard block
 block discarded – undo
516 516
             ) {
517 517
                 // removes old answers
518 518
                 $sql = "DELETE FROM $TBL_REPONSES
519
-                        WHERE c_id = $course_id AND question_id = " . intval($this->id);
519
+                        WHERE c_id = $course_id AND question_id = ".intval($this->id);
520 520
                 Database::query($sql);
521 521
             }
522 522
 
523
-            $this->type=$type;
523
+            $this->type = $type;
524 524
         }
525 525
     }
526 526
 
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
         if (!file_exists($picturePath)) {
545 545
             if (mkdir($picturePath, api_get_permissions_for_new_directories())) {
546 546
                 // document path
547
-                $documentPath = api_get_path(SYS_COURSE_PATH) . $this->course['path'] . "/document";
547
+                $documentPath = api_get_path(SYS_COURSE_PATH).$this->course['path']."/document";
548 548
                 $path = str_replace($documentPath, '', $picturePath);
549 549
                 $title_path = basename($picturePath);
550 550
                 $doc_id = add_document($this->course, $path, 'folder', 0, $title_path);
@@ -560,14 +560,14 @@  discard block
 block discarded – undo
560 560
 
561 561
         // if the question has got an ID
562 562
         if ($this->id) {
563
-            $this->picture = 'quiz-' . $this->id . '.jpg';
563
+            $this->picture = 'quiz-'.$this->id.'.jpg';
564 564
             $o_img = new Image($Picture);
565
-            $o_img->send_image($picturePath . '/' . $this->picture, -1, 'jpg');
565
+            $o_img->send_image($picturePath.'/'.$this->picture, -1, 'jpg');
566 566
             $document_id = add_document(
567 567
                 $this->course,
568
-                '/images/' . $this->picture,
568
+                '/images/'.$this->picture,
569 569
                 'file',
570
-                filesize($picturePath . '/' . $this->picture),
570
+                filesize($picturePath.'/'.$this->picture),
571 571
                 $this->picture
572 572
             );
573 573
             if ($document_id) {
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
         // if the question has an ID
602 602
         if ($this->id) {
603 603
             // Get dimensions from current image.
604
-            $my_image = new Image($picturePath . '/' . $this->picture);
604
+            $my_image = new Image($picturePath.'/'.$this->picture);
605 605
 
606 606
             $current_image_size = $my_image->get_image_size();
607 607
             $current_width = $current_image_size['width'];
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
             }
642 642
 
643 643
             $my_image->resize($new_width, $new_height);
644
-            $result = $my_image->send_image($picturePath . '/' . $this->picture);
644
+            $result = $my_image->send_image($picturePath.'/'.$this->picture);
645 645
 
646 646
             if ($result) {
647 647
                 return true;
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
             $picture = $this->picture;
667 667
             $this->picture = '';
668 668
 
669
-            return @unlink($picturePath . '/' . $picture) ? true : false;
669
+            return @unlink($picturePath.'/'.$picture) ? true : false;
670 670
         }
671 671
 
672 672
         return false;
@@ -683,27 +683,27 @@  discard block
 block discarded – undo
683 683
     {
684 684
         $course_id = $course_info['real_id'];
685 685
         $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
686
-        $destination_path = api_get_path(SYS_COURSE_PATH) . $course_info['path'] . '/document/images';
687
-        $source_path = api_get_path(SYS_COURSE_PATH) . $this->course['path'] . '/document/images';
686
+        $destination_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document/images';
687
+        $source_path = api_get_path(SYS_COURSE_PATH).$this->course['path'].'/document/images';
688 688
 
689 689
         // if the question has got an ID and if the picture exists
690 690
         if ($this->id && !empty($this->picture)) {
691 691
             $picture = explode('.', $this->picture);
692 692
             $extension = $picture[sizeof($picture) - 1];
693
-            $picture = 'quiz-' . $questionId . '.' . $extension;
694
-            $result = @copy($source_path . '/' . $this->picture, $destination_path . '/' . $picture) ? true : false;
693
+            $picture = 'quiz-'.$questionId.'.'.$extension;
694
+            $result = @copy($source_path.'/'.$this->picture, $destination_path.'/'.$picture) ? true : false;
695 695
             // If copy was correct then add to the database
696 696
             if ($result) {
697 697
                 $sql = "UPDATE $TBL_QUESTIONS SET
698
-                        picture = '" . Database::escape_string($picture) . "'
699
-                        WHERE c_id = $course_id AND id='" . intval($questionId) . "'";
698
+                        picture = '".Database::escape_string($picture)."'
699
+                        WHERE c_id = $course_id AND id='".intval($questionId)."'";
700 700
                 Database::query($sql);
701 701
 
702 702
                 $document_id = add_document(
703 703
                     $course_info,
704
-                    '/images/' . $picture,
704
+                    '/images/'.$picture,
705 705
                     'file',
706
-                    filesize($destination_path . '/' . $picture),
706
+                    filesize($destination_path.'/'.$picture),
707 707
                     $picture
708 708
                 );
709 709
                 if ($document_id) {
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
         $Extension = $PictureName[sizeof($PictureName) - 1];
739 739
 
740 740
         // saves the picture into a temporary file
741
-        @move_uploaded_file($Picture, $picturePath . '/tmp.' . $Extension);
741
+        @move_uploaded_file($Picture, $picturePath.'/tmp.'.$Extension);
742 742
     }
743 743
 
744 744
     /**
@@ -771,15 +771,15 @@  discard block
 block discarded – undo
771 771
 
772 772
         // if the question has got an ID and if the picture exists
773 773
         if ($this->id) {
774
-            if (file_exists($picturePath . '/tmp.jpg')) {
774
+            if (file_exists($picturePath.'/tmp.jpg')) {
775 775
                 $Extension = 'jpg';
776
-            } elseif (file_exists($picturePath . '/tmp.gif')) {
776
+            } elseif (file_exists($picturePath.'/tmp.gif')) {
777 777
                 $Extension = 'gif';
778
-            } elseif (file_exists($picturePath . '/tmp.png')) {
778
+            } elseif (file_exists($picturePath.'/tmp.png')) {
779 779
                 $Extension = 'png';
780 780
             }
781
-            $this->picture = 'quiz-' . $this->id . '.' . $Extension;
782
-            return @rename($picturePath . '/tmp.' . $Extension, $picturePath . '/' . $this->picture) ? true : false;
781
+            $this->picture = 'quiz-'.$this->id.'.'.$Extension;
782
+            return @rename($picturePath.'/tmp.'.$Extension, $picturePath.'/'.$this->picture) ? true : false;
783 783
         }
784 784
         return false;
785 785
     }
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
         $category = $this->category;
810 810
 
811 811
         // question already exists
812
-        if(!empty($id)) {
812
+        if (!empty($id)) {
813 813
 
814 814
             $params = [
815 815
                 'question' => $question,
@@ -855,12 +855,12 @@  discard block
 block discarded – undo
855 855
                     $TBL_EXERCISE_QUESTION as test_question
856 856
                     WHERE
857 857
                         question.id = test_question.question_id AND
858
-                        test_question.exercice_id = " . intval($exerciseId) . " AND
858
+                        test_question.exercice_id = ".intval($exerciseId)." AND
859 859
                         question.c_id = $c_id AND
860 860
                         test_question.c_id = $c_id ";
861
-            $result	= Database::query($sql);
862
-            $current_position = Database::result($result,0,0);
863
-            $this->updatePosition($current_position+1);
861
+            $result = Database::query($sql);
862
+            $current_position = Database::result($result, 0, 0);
863
+            $this->updatePosition($current_position + 1);
864 864
             $position = $this->position;
865 865
 
866 866
             $params = [
@@ -956,10 +956,10 @@  discard block
 block discarded – undo
956 956
         }
957 957
     }
958 958
 
959
-    public function search_engine_edit($exerciseId, $addQs=false, $rmQs=false)
959
+    public function search_engine_edit($exerciseId, $addQs = false, $rmQs = false)
960 960
     {
961 961
         // update search engine and its values table if enabled
962
-        if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) {
962
+        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
963 963
             $course_id = api_get_course_id();
964 964
             // get search_did
965 965
             $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
@@ -977,8 +977,8 @@  discard block
 block discarded – undo
977 977
             $res = Database::query($sql);
978 978
 
979 979
             if (Database::num_rows($res) > 0 || $addQs) {
980
-                require_once(api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php');
981
-                require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php');
980
+                require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php');
981
+                require_once(api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php');
982 982
 
983 983
                 $di = new ChamiloIndexer();
984 984
                 if ($addQs) {
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 
992 992
                 // retrieve others exercise ids
993 993
                 $se_ref = Database::fetch_array($res);
994
-                $se_doc = $di->get_document((int)$se_ref['search_did']);
994
+                $se_doc = $di->get_document((int) $se_ref['search_did']);
995 995
                 if ($se_doc !== FALSE) {
996 996
                     if (($se_doc_data = $di->get_document_data($se_doc)) !== FALSE) {
997 997
                         $se_doc_data = unserialize($se_doc_data);
@@ -1029,16 +1029,16 @@  discard block
 block discarded – undo
1029 1029
                     SE_DATA => array(
1030 1030
                         'type' => SE_DOCTYPE_EXERCISE_QUESTION,
1031 1031
                         'exercise_ids' => $question_exercises,
1032
-                        'question_id' => (int)$this->id
1032
+                        'question_id' => (int) $this->id
1033 1033
                     ),
1034
-                    SE_USER => (int)api_get_user_id(),
1034
+                    SE_USER => (int) api_get_user_id(),
1035 1035
                 );
1036 1036
                 $ic_slide->xapian_data = serialize($xapian_data);
1037 1037
                 $ic_slide->addValue("content", $this->description);
1038 1038
 
1039 1039
                 //TODO: index answers, see also form validation on question_admin.inc.php
1040 1040
 
1041
-                $di->remove_document((int)$se_ref['search_did']);
1041
+                $di->remove_document((int) $se_ref['search_did']);
1042 1042
                 $di->addChunk($ic_slide);
1043 1043
 
1044 1044
                 //index and return search engine document id
@@ -1117,7 +1117,7 @@  discard block
 block discarded – undo
1117 1117
             $count = $new_exercise->selectNbrQuestions();
1118 1118
             $count++;
1119 1119
             $sql = "INSERT INTO $exerciseRelQuestionTable (c_id, question_id, exercice_id, question_order)
1120
-                    VALUES ({$this->course['real_id']}, " . intval($id) . ", " . intval($exerciseId) . ", '$count')";
1120
+                    VALUES ({$this->course['real_id']}, ".intval($id).", ".intval($exerciseId).", '$count')";
1121 1121
             Database::query($sql);
1122 1122
 
1123 1123
             // we do not want to reindex if we had just saved adnd indexed the question
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
         $course_id = api_get_course_int_id();
1147 1147
 
1148 1148
         // exercise not found
1149
-        if($pos === false) {
1149
+        if ($pos === false) {
1150 1150
             return false;
1151 1151
         } else {
1152 1152
             // deletes the position in the array containing the wanted exercise ID
@@ -1156,17 +1156,17 @@  discard block
 block discarded – undo
1156 1156
                     FROM $TBL_EXERCISE_QUESTION
1157 1157
                     WHERE
1158 1158
                         c_id = $course_id
1159
-                        AND question_id = " . intval($id) . "
1159
+                        AND question_id = ".intval($id)."
1160 1160
                         AND exercice_id = " . intval($exerciseId);
1161 1161
             $res = Database::query($sql);
1162
-            if (Database::num_rows($res)>0) {
1162
+            if (Database::num_rows($res) > 0) {
1163 1163
                 $row = Database::fetch_array($res);
1164 1164
                 if (!empty($row['question_order'])) {
1165 1165
                     $sql = "UPDATE $TBL_EXERCISE_QUESTION
1166 1166
                         SET question_order = question_order-1
1167 1167
                         WHERE
1168 1168
                             c_id = $course_id
1169
-                            AND exercice_id = " . intval($exerciseId) . "
1169
+                            AND exercice_id = ".intval($exerciseId)."
1170 1170
                             AND question_order > " . $row['question_order'];
1171 1171
                     Database::query($sql);
1172 1172
                 }
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
             $sql = "DELETE FROM $TBL_EXERCISE_QUESTION
1176 1176
                     WHERE
1177 1177
                         c_id = $course_id
1178
-                        AND question_id = " . intval($id) . "
1178
+                        AND question_id = ".intval($id)."
1179 1179
                         AND exercice_id = " . intval($exerciseId);
1180 1180
             Database::query($sql);
1181 1181
 
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
                                 SET question_order = question_order-1
1217 1217
                                 WHERE
1218 1218
                                     c_id= $course_id
1219
-                                    AND exercice_id = " . intval($row['exercice_id']) . "
1219
+                                    AND exercice_id = ".intval($row['exercice_id'])."
1220 1220
                                     AND question_order > " . $row['question_order'];
1221 1221
                         Database::query($sql);
1222 1222
                     }
@@ -1224,20 +1224,20 @@  discard block
 block discarded – undo
1224 1224
             }
1225 1225
 
1226 1226
             $sql = "DELETE FROM $TBL_EXERCISE_QUESTION
1227
-                    WHERE c_id = $course_id AND question_id = " . intval($id) . "";
1227
+                    WHERE c_id = $course_id AND question_id = ".intval($id)."";
1228 1228
             Database::query($sql);
1229 1229
 
1230 1230
             $sql = "DELETE FROM $TBL_QUESTIONS
1231
-                    WHERE c_id = $course_id AND id = " . intval($id) . "";
1231
+                    WHERE c_id = $course_id AND id = ".intval($id)."";
1232 1232
             Database::query($sql);
1233 1233
 
1234 1234
             $sql = "DELETE FROM $TBL_REPONSES
1235
-                    WHERE c_id = $course_id AND question_id = " . intval($id) . "";
1235
+                    WHERE c_id = $course_id AND question_id = ".intval($id)."";
1236 1236
             Database::query($sql);
1237 1237
 
1238 1238
             // remove the category of this question in the question_rel_category table
1239 1239
             $sql = "DELETE FROM $TBL_QUIZ_QUESTION_REL_CATEGORY
1240
-                    WHERE c_id = $course_id AND question_id = " . intval($id) . " AND c_id=" . api_get_course_int_id();
1240
+                    WHERE c_id = $course_id AND question_id = ".intval($id)." AND c_id=".api_get_course_int_id();
1241 1241
             Database::query($sql);
1242 1242
 
1243 1243
             api_item_property_update($this->course, TOOL_QUIZ, $id, 'QuizQuestionDeleted', api_get_user_id());
@@ -1394,7 +1394,7 @@  discard block
 block discarded – undo
1394 1394
                 if (class_exists($class_name)) {
1395 1395
                     return new $class_name();
1396 1396
                 } else {
1397
-                    echo 'Can\'t instanciate class ' . $class_name . ' of type ' . $type;
1397
+                    echo 'Can\'t instanciate class '.$class_name.' of type '.$type;
1398 1398
                 }
1399 1399
             }
1400 1400
         }
@@ -1436,7 +1436,7 @@  discard block
 block discarded – undo
1436 1436
 
1437 1437
         // Question type
1438 1438
         $answerType = isset($_REQUEST['answerType']) ? intval($_REQUEST['answerType']) : null;
1439
-        $form->addElement('hidden','answerType', $answerType);
1439
+        $form->addElement('hidden', 'answerType', $answerType);
1440 1440
 
1441 1441
         // html editor
1442 1442
         $editorConfig = array(
@@ -1444,7 +1444,7 @@  discard block
 block discarded – undo
1444 1444
             'Height' => '150'
1445 1445
         );
1446 1446
 
1447
-        if (!api_is_allowed_to_edit(null,true)) {
1447
+        if (!api_is_allowed_to_edit(null, true)) {
1448 1448
             $editorConfig['UserStatus'] = 'student';
1449 1449
         }
1450 1450
 
@@ -1581,7 +1581,7 @@  discard block
 block discarded – undo
1581 1581
 
1582 1582
         if ($feedback_type == 1) {
1583 1583
             //2. but if it is a feedback DIRECT we only show the UNIQUE_ANSWER type that is currently available
1584
-            $question_type_custom_list = array (
1584
+            $question_type_custom_list = array(
1585 1585
                 UNIQUE_ANSWER => self::$questionTypes[UNIQUE_ANSWER],
1586 1586
                 HOT_SPOT_DELINEATION => self::$questionTypes[HOT_SPOT_DELINEATION]
1587 1587
             );
@@ -1597,17 +1597,17 @@  discard block
 block discarded – undo
1597 1597
             require_once $a_type[0];
1598 1598
             // get the picture of the type and the langvar which describes it
1599 1599
             $img = $explanation = '';
1600
-            eval('$img = ' . $a_type[1] . '::$typePicture;');
1601
-            eval('$explanation = get_lang(' . $a_type[1] . '::$explanationLangVar);');
1600
+            eval('$img = '.$a_type[1].'::$typePicture;');
1601
+            eval('$explanation = get_lang('.$a_type[1].'::$explanationLangVar);');
1602 1602
             echo '<li>';
1603 1603
             echo '<div class="icon-image">';
1604 1604
             if ($objExercise->exercise_was_added_in_lp == true) {
1605 1605
                 $img = pathinfo($img);
1606
-                $img = $img['filename'] . '_na.' . $img['extension'];
1606
+                $img = $img['filename'].'_na.'.$img['extension'];
1607 1607
                 echo Display::return_icon($img, $explanation, null, ICON_SIZE_BIG);
1608 1608
             } else {
1609
-                echo '<a href="admin.php?' . api_get_cidreq() . '&newQuestion=yes&answerType=' . $i . '">' .
1610
-                Display::return_icon($img, $explanation, null, ICON_SIZE_BIG) . '</a>';
1609
+                echo '<a href="admin.php?'.api_get_cidreq().'&newQuestion=yes&answerType='.$i.'">'.
1610
+                Display::return_icon($img, $explanation, null, ICON_SIZE_BIG).'</a>';
1611 1611
             }
1612 1612
             echo '</div>';
1613 1613
             echo '</li>';
@@ -1619,9 +1619,9 @@  discard block
 block discarded – undo
1619 1619
             echo Display::return_icon('database_na.png', get_lang('GetExistingQuestion'), null, ICON_SIZE_BIG);
1620 1620
         } else {
1621 1621
             if ($feedback_type == 1) {
1622
-                echo $url = "<a href=\"question_pool.php?" . api_get_cidreq() . "&type=1&fromExercise=$exerciseId\">";
1622
+                echo $url = "<a href=\"question_pool.php?".api_get_cidreq()."&type=1&fromExercise=$exerciseId\">";
1623 1623
             } else {
1624
-                echo $url = '<a href="question_pool.php?' . api_get_cidreq() . '&fromExercise=' . $exerciseId . '">';
1624
+                echo $url = '<a href="question_pool.php?'.api_get_cidreq().'&fromExercise='.$exerciseId.'">';
1625 1625
             }
1626 1626
             echo Display::return_icon('database.png', get_lang('GetExistingQuestion'), null, ICON_SIZE_BIG);
1627 1627
         }
@@ -1758,7 +1758,7 @@  discard block
 block discarded – undo
1758 1758
             $header .= $this->show_media_content();
1759 1759
         }
1760 1760
 
1761
-        $header .= Display::page_subheader2($counter_label . ". " . $question_title);
1761
+        $header .= Display::page_subheader2($counter_label.". ".$question_title);
1762 1762
         $header .= Display::div(
1763 1763
             "<div class=\"rib rib-$class\"><h3>$score_label</h3></div> <h4>{$score['result']}</h4>",
1764 1764
             array('class' => 'ribbon')
@@ -1779,7 +1779,7 @@  discard block
 block discarded – undo
1779 1779
     public function create_question(
1780 1780
         $quiz_id,
1781 1781
         $question_name,
1782
-        $question_description = "" ,
1782
+        $question_description = "",
1783 1783
         $max_score = 0,
1784 1784
         $type = 1,
1785 1785
         $level = 1
@@ -1849,8 +1849,8 @@  discard block
 block discarded – undo
1849 1849
         require_once $tabQuestionList[$type][0];
1850 1850
 
1851 1851
         $img = $explanation = null;
1852
-        eval('$img = ' . $tabQuestionList[$type][1] . '::$typePicture;');
1853
-        eval('$explanation = get_lang(' . $tabQuestionList[$type][1] . '::$explanationLangVar);');
1852
+        eval('$img = '.$tabQuestionList[$type][1].'::$typePicture;');
1853
+        eval('$explanation = get_lang('.$tabQuestionList[$type][1].'::$explanationLangVar);');
1854 1854
         return array($img, $explanation);
1855 1855
     }
1856 1856
 
@@ -1914,7 +1914,7 @@  discard block
 block discarded – undo
1914 1914
         $media_list[0] = get_lang('NoMedia');
1915 1915
 
1916 1916
         if (!empty($medias)) {
1917
-            foreach($medias as $media) {
1917
+            foreach ($medias as $media) {
1918 1918
                 $media_list[$media['id']] = empty($media['question']) ? get_lang('Untitled') : $media['question'];
1919 1919
             }
1920 1920
         }
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -607,10 +607,11 @@
 block discarded – undo
607 607
             $current_width = $current_image_size['width'];
608 608
             $current_height = $current_image_size['height'];
609 609
 
610
-            if ($current_width < $Max && $current_height < $Max)
611
-                return true;
612
-            elseif ($current_height == "")
613
-                return false;
610
+            if ($current_width < $Max && $current_height < $Max) {
611
+                            return true;
612
+            } elseif ($current_height == "") {
613
+                            return false;
614
+            }
614 615
 
615 616
             // Resize according to height.
616 617
             if ($Dimension == "height") {
Please login to merge, or discard this patch.
main/exercice/TestCategory.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -474,6 +474,7 @@  discard block
 block discarded – undo
474 474
 
475 475
 	/**
476 476
 	 * return a tab of $in_number random elements of $in_tab
477
+	 * @param integer $in_number
477 478
 	 */
478 479
     public static function getNElementsFromArray($in_tab, $in_number)
479 480
     {
@@ -650,7 +651,6 @@  discard block
 block discarded – undo
650 651
     /**
651 652
      * Return the id of the test category with title = $in_title
652 653
      * @param $in_title
653
-     * @param int $in_c_id
654 654
      *
655 655
      * @return int is id of test category
656 656
      */
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
      * @param int $questionId
679 679
      * @param int $courseId
680 680
 	 *
681
-	 * @return int
681
+	 * @return string|false
682 682
      */
683 683
     public static function add_category_for_question_id($categoryId, $questionId, $courseId)
684 684
     {
Please login to merge, or discard this patch.
Indentation   +253 added lines, -253 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
     public $name;
14 14
     public $description;
15 15
 
16
-	/**
17
-	 * Constructor of the class Category
18
-	 * If you give an in_id and no in_name, you get info concerning the category of id=in_id
19
-	 * otherwise, you've got an category objet avec your in_id, in_name, in_descr
20
-	 *
16
+    /**
17
+     * Constructor of the class Category
18
+     * If you give an in_id and no in_name, you get info concerning the category of id=in_id
19
+     * otherwise, you've got an category objet avec your in_id, in_name, in_descr
20
+     *
21 21
      * @param int    $id
22 22
      * @param string $name
23 23
      * @param string $description
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
         }
62 62
     }
63 63
 
64
-	/**
64
+    /**
65 65
      * add TestCategory in the database if name doesn't already exists
66
-	 */
66
+     */
67 67
     public function addCategoryInBDD()
68 68
     {
69 69
         $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
 
109 109
             return false;
110 110
         }
111
-	}
111
+    }
112 112
 
113
-	/**
113
+    /**
114 114
      * Removes the category from the database
115 115
      * if there were question in this category, the link between question and category is removed
116
-	 */
116
+     */
117 117
     public function removeCategory()
118 118
     {
119 119
         $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
 
144 144
             return true;
145 145
         }
146
-	}
146
+    }
147 147
 
148
-	/**
148
+    /**
149 149
      * Modify category name or description of category with id=in_id
150
-	 */
150
+     */
151 151
     public function modifyCategory()
152 152
     {
153 153
         $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
@@ -175,40 +175,40 @@  discard block
 block discarded – undo
175 175
 
176 176
             return true;
177 177
         }
178
-	}
178
+    }
179 179
 
180
-	/**
180
+    /**
181 181
      * Gets the number of question of category id=in_id
182
-	 */
182
+     */
183 183
     public function getCategoryQuestionsNumber()
184 184
     {
185
-		$table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
186
-		$in_id = intval($this->id);
187
-		$sql = "SELECT count(*) AS nb
185
+        $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
186
+        $in_id = intval($this->id);
187
+        $sql = "SELECT count(*) AS nb
188 188
 		        FROM $table
189 189
 		        WHERE category_id=$in_id AND c_id=".api_get_course_int_id();
190
-		$res = Database::query($sql);
191
-		$row = Database::fetch_array($res);
190
+        $res = Database::query($sql);
191
+        $row = Database::fetch_array($res);
192 192
 
193
-		return $row['nb'];
194
-	}
193
+        return $row['nb'];
194
+    }
195 195
 
196 196
     /**
197 197
      * @param string $in_color
198 198
      */
199 199
     public function display($in_color="#E0EBF5")
200 200
     {
201
-		echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>";
202
-		print_r($this);
203
-		echo "</textarea>";
204
-	}
201
+        echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>";
202
+        print_r($this);
203
+        echo "</textarea>";
204
+    }
205 205
 
206
-	/**
206
+    /**
207 207
      * Return an array of all Category objects in the database
208
-	 * If in_field=="" Return an array of all category objects in the database
209
-	 * Otherwise, return an array of all in_field value
210
-	 * in the database (in_field = id or name or description)
211
-	 */
208
+     * If in_field=="" Return an array of all category objects in the database
209
+     * Otherwise, return an array of all in_field value
210
+     * in the database (in_field = id or name or description)
211
+     */
212 212
     public static function getCategoryListInfo($in_field = "", $courseId = "")
213 213
     {
214 214
         if (empty($courseId) || $courseId=="") {
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
             }
240 240
         }
241 241
 
242
-		return $tabres;
243
-	}
242
+        return $tabres;
243
+    }
244 244
 
245 245
     /**
246 246
      * Return the TestCategory id for question with question_id = $questionId
@@ -251,196 +251,196 @@  discard block
 block discarded – undo
251 251
      *
252 252
      * @return int
253 253
      */
254
-	public static function getCategoryForQuestion($questionId, $courseId ="")
254
+    public static function getCategoryForQuestion($questionId, $courseId ="")
255 255
     {
256
-		$result = 0;
256
+        $result = 0;
257 257
         if (empty($courseId) || $courseId == "") {
258 258
             $courseId = api_get_course_int_id();
259 259
         }
260
-		$table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
260
+        $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
261 261
         $questionId = intval($questionId);
262
-		$sql = "SELECT category_id
262
+        $sql = "SELECT category_id
263 263
 		        FROM $table
264 264
 		        WHERE question_id = $questionId AND c_id = $courseId";
265
-		$res = Database::query($sql);
266
-		if (Database::num_rows($res) > 0) {
265
+        $res = Database::query($sql);
266
+        if (Database::num_rows($res) > 0) {
267 267
             $data = Database::fetch_array($res);
268
-			$result = $data['category_id'];
269
-		}
268
+            $result = $data['category_id'];
269
+        }
270 270
 
271
-		return $result;
272
-	}
271
+        return $result;
272
+    }
273 273
 
274
-	/**
275
-	 * true if question id has a category
276
-	 */
277
-	public static function isQuestionHasCategory($questionId)
274
+    /**
275
+     * true if question id has a category
276
+     */
277
+    public static function isQuestionHasCategory($questionId)
278 278
     {
279
-		if (TestCategory::getCategoryForQuestion($questionId) > 0) {
280
-			return true;
281
-		}
282
-		return false;
283
-	}
279
+        if (TestCategory::getCategoryForQuestion($questionId) > 0) {
280
+            return true;
281
+        }
282
+        return false;
283
+    }
284 284
 
285
-	/**
285
+    /**
286 286
 	 Return the category name for question with question_id = $questionId
287 287
 	 In this version, a question has only 1 category.
288 288
 	 Return the category id, "" if none
289
-	 */
289
+     */
290 290
     public static function getCategoryNameForQuestion(
291 291
         $questionId,
292 292
         $courseId = ""
293 293
     ) {
294
-		if (empty($courseId) || $courseId=="") {
295
-			$courseId = api_get_course_int_id();
296
-		}
297
-		$catid = TestCategory::getCategoryForQuestion($questionId, $courseId);
298
-		$result = "";	// result
299
-		$table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
300
-		$catid = intval($catid);
301
-		$sql = "SELECT title FROM $table
294
+        if (empty($courseId) || $courseId=="") {
295
+            $courseId = api_get_course_int_id();
296
+        }
297
+        $catid = TestCategory::getCategoryForQuestion($questionId, $courseId);
298
+        $result = "";	// result
299
+        $table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
300
+        $catid = intval($catid);
301
+        $sql = "SELECT title FROM $table
302 302
 		        WHERE id = $catid  AND c_id = $courseId";
303
-		$res = Database::query($sql);
304
-		$data = Database::fetch_array($res);
305
-		if (Database::num_rows($res) > 0) {
306
-			$result = $data['title'];
307
-		}
308
-
309
-		return $result;
310
-	}
311
-
312
-	/**
313
-	 * Return the list of differents categories ID for a test in the current course
314
-	 * input : test_id
315
-	 * return : array of category id (integer)
316
-	 * hubert.borderiou 07-04-2011
317
-	 */
318
-	public static function getListOfCategoriesIDForTest($in_testid)
303
+        $res = Database::query($sql);
304
+        $data = Database::fetch_array($res);
305
+        if (Database::num_rows($res) > 0) {
306
+            $result = $data['title'];
307
+        }
308
+
309
+        return $result;
310
+    }
311
+
312
+    /**
313
+     * Return the list of differents categories ID for a test in the current course
314
+     * input : test_id
315
+     * return : array of category id (integer)
316
+     * hubert.borderiou 07-04-2011
317
+     */
318
+    public static function getListOfCategoriesIDForTest($in_testid)
319 319
     {
320
-		// parcourir les questions d'un test, recup les categories uniques dans un tableau
321
-		$result = array();
322
-		$quiz = new Exercise();
323
-		$quiz->read($in_testid);
324
-		$tabQuestionList = $quiz->selectQuestionList();
325
-		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
326
-		for ($i=1; $i <= count($tabQuestionList); $i++) {
327
-			if (!in_array(TestCategory::getCategoryForQuestion($tabQuestionList[$i]), $result)) {
328
-				$result[] = TestCategory::getCategoryForQuestion($tabQuestionList[$i]);
329
-			}
330
-		}
331
-
332
-		return $result;
333
-	}
334
-
335
-	/**
336
-	 * return the list of different categories NAME for a test
337
-	 * input : test_id
338
-	 * return : array of string
339
-	 * hubert.borderiou 07-04-2011
320
+        // parcourir les questions d'un test, recup les categories uniques dans un tableau
321
+        $result = array();
322
+        $quiz = new Exercise();
323
+        $quiz->read($in_testid);
324
+        $tabQuestionList = $quiz->selectQuestionList();
325
+        // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
326
+        for ($i=1; $i <= count($tabQuestionList); $i++) {
327
+            if (!in_array(TestCategory::getCategoryForQuestion($tabQuestionList[$i]), $result)) {
328
+                $result[] = TestCategory::getCategoryForQuestion($tabQuestionList[$i]);
329
+            }
330
+        }
331
+
332
+        return $result;
333
+    }
334
+
335
+    /**
336
+     * return the list of different categories NAME for a test
337
+     * input : test_id
338
+     * return : array of string
339
+     * hubert.borderiou 07-04-2011
340 340
      * @author function rewrote by jmontoya
341
-	 */
342
-	public static function getListOfCategoriesNameForTest($in_testid)
341
+     */
342
+    public static function getListOfCategoriesNameForTest($in_testid)
343 343
     {
344
-		$tabcatName = array();
345
-		$tabcatID = self::getListOfCategoriesIDForTest($in_testid);
346
-		for ($i=0; $i < count($tabcatID); $i++) {
347
-			$cat = new TestCategory($tabcatID[$i]);
348
-			$tabcatName[$cat->id] = $cat->name;
349
-		}
350
-		return $tabcatName;
351
-	}
352
-
353
-	/**
354
-	 * return the number of differents categories for a test
355
-	 * input : test_id
356
-	 * return : integer
357
-	 * hubert.borderiou 07-04-2011
358
-	 */
359
-	public static function getNumberOfCategoriesForTest($in_testid)
344
+        $tabcatName = array();
345
+        $tabcatID = self::getListOfCategoriesIDForTest($in_testid);
346
+        for ($i=0; $i < count($tabcatID); $i++) {
347
+            $cat = new TestCategory($tabcatID[$i]);
348
+            $tabcatName[$cat->id] = $cat->name;
349
+        }
350
+        return $tabcatName;
351
+    }
352
+
353
+    /**
354
+     * return the number of differents categories for a test
355
+     * input : test_id
356
+     * return : integer
357
+     * hubert.borderiou 07-04-2011
358
+     */
359
+    public static function getNumberOfCategoriesForTest($in_testid)
360 360
     {
361
-		return count(TestCategory::getListOfCategoriesIDForTest($in_testid));
362
-	}
361
+        return count(TestCategory::getListOfCategoriesIDForTest($in_testid));
362
+    }
363 363
 
364
-	/**
365
-	 * return the number of question of a category id in a test
366
-	 * @param int $exerciseId
364
+    /**
365
+     * return the number of question of a category id in a test
366
+     * @param int $exerciseId
367 367
      * @param int $categoryId
368 368
      *
369
-	 * @return integer
369
+     * @return integer
370 370
      *
371
-	 * @author hubert.borderiou 07-04-2011
372
-	 */
373
-	public static function getNumberOfQuestionsInCategoryForTest($exerciseId, $categoryId)
371
+     * @author hubert.borderiou 07-04-2011
372
+     */
373
+    public static function getNumberOfQuestionsInCategoryForTest($exerciseId, $categoryId)
374 374
     {
375
-		$nbCatResult = 0;
376
-		$quiz = new Exercise();
377
-		$quiz->read($exerciseId);
378
-		$tabQuestionList = $quiz->selectQuestionList();
379
-		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ?
380
-		for ($i=1; $i <= count($tabQuestionList); $i++) {
381
-			if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) {
382
-				$nbCatResult++;
383
-			}
384
-		}
385
-
386
-		return $nbCatResult;
387
-	}
388
-
389
-	/**
390
-	 * return the number of question for a test using random by category
391
-	 * input  : test_id, number of random question (min 1)
392
-	 * hubert.borderiou 07-04-2011
393
-	 * question without categories are not counted
394
-	 */
395
-	public static function getNumberOfQuestionRandomByCategory($exerciseId, $in_nbrandom)
375
+        $nbCatResult = 0;
376
+        $quiz = new Exercise();
377
+        $quiz->read($exerciseId);
378
+        $tabQuestionList = $quiz->selectQuestionList();
379
+        // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ?
380
+        for ($i=1; $i <= count($tabQuestionList); $i++) {
381
+            if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) {
382
+                $nbCatResult++;
383
+            }
384
+        }
385
+
386
+        return $nbCatResult;
387
+    }
388
+
389
+    /**
390
+     * return the number of question for a test using random by category
391
+     * input  : test_id, number of random question (min 1)
392
+     * hubert.borderiou 07-04-2011
393
+     * question without categories are not counted
394
+     */
395
+    public static function getNumberOfQuestionRandomByCategory($exerciseId, $in_nbrandom)
396 396
     {
397
-		$nbquestionresult = 0;
398
-		$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
399
-		for ($i=0; $i < count($tabcatid); $i++) {
400
-			if ($tabcatid[$i] > 0) {	// 0 = no category for this questio
401
-				$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
402
-				if ($nbQuestionInThisCat > $in_nbrandom) {
403
-					$nbquestionresult += $in_nbrandom;
404
-				}
405
-				else {
406
-					$nbquestionresult += $nbQuestionInThisCat;
407
-				}
408
-			}
409
-		}
410
-		return $nbquestionresult;
411
-	}
412
-
413
-	/**
414
-	 * Return an array (id=>name)
415
-	 * tabresult[0] = get_lang('NoCategory');
397
+        $nbquestionresult = 0;
398
+        $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
399
+        for ($i=0; $i < count($tabcatid); $i++) {
400
+            if ($tabcatid[$i] > 0) {	// 0 = no category for this questio
401
+                $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
402
+                if ($nbQuestionInThisCat > $in_nbrandom) {
403
+                    $nbquestionresult += $in_nbrandom;
404
+                }
405
+                else {
406
+                    $nbquestionresult += $nbQuestionInThisCat;
407
+                }
408
+            }
409
+        }
410
+        return $nbquestionresult;
411
+    }
412
+
413
+    /**
414
+     * Return an array (id=>name)
415
+     * tabresult[0] = get_lang('NoCategory');
416 416
      *
417 417
      * @param int $courseId
418 418
      *
419 419
      * @return array
420
-	 *
421
-	 */
420
+     *
421
+     */
422 422
     public static function getCategoriesIdAndName($courseId = "")
423 423
     {
424
-		if (empty($courseId)) {
425
-			$courseId = api_get_course_int_id();
426
-		}
427
-	 	$tabcatobject = TestCategory::getCategoryListInfo("", $courseId);
428
-	 	$tabresult = array("0"=>get_lang('NoCategorySelected'));
429
-	 	for ($i=0; $i < count($tabcatobject); $i++) {
430
-	 		$tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name;
431
-	 	}
432
-	 	return $tabresult;
433
-	}
424
+        if (empty($courseId)) {
425
+            $courseId = api_get_course_int_id();
426
+        }
427
+            $tabcatobject = TestCategory::getCategoryListInfo("", $courseId);
428
+            $tabresult = array("0"=>get_lang('NoCategorySelected'));
429
+            for ($i=0; $i < count($tabcatobject); $i++) {
430
+                $tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name;
431
+            }
432
+            return $tabresult;
433
+    }
434 434
 
435 435
     /**
436
-    * return an array of question_id for each category
437
-    * tabres[0] = array of question id with category id = 0 (i.e. no category)
438
-    * tabres[24] = array of question id with category id = 24
439
-    * In this version, a question has 0 or 1 category
440
-    *
441
-    * @param int $exerciseId
442
-    * @return array
443
-    */
436
+     * return an array of question_id for each category
437
+     * tabres[0] = array of question id with category id = 0 (i.e. no category)
438
+     * tabres[24] = array of question id with category id = 24
439
+     * In this version, a question has 0 or 1 category
440
+     *
441
+     * @param int $exerciseId
442
+     * @return array
443
+     */
444 444
     public static function getQuestionsByCat($exerciseId)
445 445
     {
446 446
         $em = Database::getManager();
@@ -469,29 +469,29 @@  discard block
 block discarded – undo
469 469
             }
470 470
             $list[$data['categoryId']][] = $data['questionId'];
471 471
         }
472
-		return $list;
473
-	}
472
+        return $list;
473
+    }
474 474
 
475
-	/**
476
-	 * return a tab of $in_number random elements of $in_tab
477
-	 */
475
+    /**
476
+     * return a tab of $in_number random elements of $in_tab
477
+     */
478 478
     public static function getNElementsFromArray($in_tab, $in_number)
479 479
     {
480
-		$tabres = $in_tab;
481
-		shuffle($tabres);
482
-		if ($in_number < count($tabres)) {
483
-			$tabres = array_slice($tabres, 0, $in_number);
484
-		}
485
-		return $tabres;
486
-	}
487
-
488
-	/**
489
-	 * display the category
490
-	 */
491
-	public static function displayCategoryAndTitle($questionId, $in_display_category_name = 1)
480
+        $tabres = $in_tab;
481
+        shuffle($tabres);
482
+        if ($in_number < count($tabres)) {
483
+            $tabres = array_slice($tabres, 0, $in_number);
484
+        }
485
+        return $tabres;
486
+    }
487
+
488
+    /**
489
+     * display the category
490
+     */
491
+    public static function displayCategoryAndTitle($questionId, $in_display_category_name = 1)
492 492
     {
493 493
         echo self::returnCategoryAndTitle($questionId, $in_display_category_name);
494
-	}
494
+    }
495 495
 
496 496
     /**
497 497
      * @param int $questionId
@@ -507,71 +507,71 @@  discard block
 block discarded – undo
507 507
             $in_display_category_name = $objExercise->display_category_name;
508 508
         }
509 509
         $content = null;
510
-		if (TestCategory::getCategoryNameForQuestion($questionId) != "" && ($in_display_category_name == 1 || !$is_student)) {
510
+        if (TestCategory::getCategoryNameForQuestion($questionId) != "" && ($in_display_category_name == 1 || !$is_student)) {
511 511
             $content .= '<div class="page-header">';
512 512
             $content .= '<h4>'.get_lang('Category').": ".TestCategory::getCategoryNameForQuestion($questionId).'</h4>';
513 513
             $content .= "</div>";
514
-		}
514
+        }
515 515
         return $content;
516
-	}
516
+    }
517 517
 
518 518
     /**
519
-    * Display signs [+] and/or (>0) after question title if question has options
520
-    * scoreAlwaysPositive and/or uncheckedMayScore
521
-    */
519
+     * Display signs [+] and/or (>0) after question title if question has options
520
+     * scoreAlwaysPositive and/or uncheckedMayScore
521
+     */
522 522
     public function displayQuestionOption($in_objQuestion)
523 523
     {
524
-		if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) {
525
-			echo "<span style='font-size:75%'> (>0)</span>";
526
-		}
527
-		if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->uncheckedMayScore) {
528
-			echo "<span style='font-size:75%'> [+]</span>";
529
-		}
530
-	}
531
-
532
-	/**
533
-	 * sortTabByBracketLabel ($tabCategoryQuestions)
534
-	 * key of $tabCategoryQuestions are the category id (0 for not in a category)
535
-	 * value is the array of question id of this category
536
-	 * Sort question by Category
537
-	*/
524
+        if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) {
525
+            echo "<span style='font-size:75%'> (>0)</span>";
526
+        }
527
+        if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->uncheckedMayScore) {
528
+            echo "<span style='font-size:75%'> [+]</span>";
529
+        }
530
+    }
531
+
532
+    /**
533
+     * sortTabByBracketLabel ($tabCategoryQuestions)
534
+     * key of $tabCategoryQuestions are the category id (0 for not in a category)
535
+     * value is the array of question id of this category
536
+     * Sort question by Category
537
+     */
538 538
     public static function sortTabByBracketLabel($in_tab)
539 539
     {
540
-		$tabResult = array();
541
-		$tabCatName = array();	// tab of category name
542
-		while (list($cat_id, $tabquestion) = each($in_tab)) {
543
-			$catTitle = new TestCategory($cat_id);
544
-			$tabCatName[$cat_id] = $catTitle->name;
545
-		}
546
-		reset($in_tab);
547
-		// sort table by value, keeping keys as they are
548
-		asort($tabCatName);
549
-		// keys of $tabCatName are keys order for $in_tab
550
-		while (list($key, $val) = each($tabCatName)) {
551
-			$tabResult[$key] = $in_tab[$key];
552
-		}
553
-		return $tabResult;
554
-	}
540
+        $tabResult = array();
541
+        $tabCatName = array();	// tab of category name
542
+        while (list($cat_id, $tabquestion) = each($in_tab)) {
543
+            $catTitle = new TestCategory($cat_id);
544
+            $tabCatName[$cat_id] = $catTitle->name;
545
+        }
546
+        reset($in_tab);
547
+        // sort table by value, keeping keys as they are
548
+        asort($tabCatName);
549
+        // keys of $tabCatName are keys order for $in_tab
550
+        while (list($key, $val) = each($tabCatName)) {
551
+            $tabResult[$key] = $in_tab[$key];
552
+        }
553
+        return $tabResult;
554
+    }
555 555
 
556 556
     /**
557 557
      * return the number max of question in a category
558 558
      * count the number of questions in all categories, and return the max
559 559
      * @param int $exerciseId
560 560
      * @author - hubert borderiou
561
-    */
561
+     */
562 562
     public static function getNumberMaxQuestionByCat($exerciseId)
563 563
     {
564 564
         $res_num_max = 0;
565 565
         // foreach question
566
-		$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
567
-		for ($i=0; $i < count($tabcatid); $i++) {
568
-			if ($tabcatid[$i] > 0) {	// 0 = no category for this question
569
-				$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
566
+        $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
567
+        for ($i=0; $i < count($tabcatid); $i++) {
568
+            if ($tabcatid[$i] > 0) {	// 0 = no category for this question
569
+                $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
570 570
                 if ($nbQuestionInThisCat > $res_num_max) {
571 571
                     $res_num_max = $nbQuestionInThisCat;
572 572
                 }
573
-			}
574
-		}
573
+            }
574
+        }
575 575
         return $res_num_max;
576 576
     }
577 577
 
@@ -677,8 +677,8 @@  discard block
 block discarded – undo
677 677
      * @param int $categoryId
678 678
      * @param int $questionId
679 679
      * @param int $courseId
680
-	 *
681
-	 * @return int
680
+     *
681
+     * @return int
682 682
      */
683 683
     public static function add_category_for_question_id($categoryId, $questionId, $courseId)
684 684
     {
@@ -686,18 +686,18 @@  discard block
 block discarded – undo
686 686
         // if question doesn't have a category
687 687
         // @todo change for 1.10 when a question can have several categories
688 688
         if (TestCategory::getCategoryForQuestion($questionId, $courseId) == 0 &&
689
-			$questionId > 0 &&
690
-			$courseId > 0
689
+            $questionId > 0 &&
690
+            $courseId > 0
691 691
         ) {
692 692
             $sql = "INSERT INTO $table (c_id, question_id, category_id)
693 693
                     VALUES (".intval($courseId).", ".intval($questionId).", ".intval($categoryId).")";
694 694
             Database::query($sql);
695
-			$id = Database::insert_id();
695
+            $id = Database::insert_id();
696 696
 
697
-			return $id;
697
+            return $id;
698 698
         }
699 699
 
700
-		return false;
700
+        return false;
701 701
     }
702 702
 
703 703
     /**
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
             $row = Database::fetch_array($res);
58 58
             $this->id = $row['id'];
59 59
             $this->name = $row['title'];
60
-            $this->description  = $row['description'];
60
+            $this->description = $row['description'];
61 61
         }
62 62
     }
63 63
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
     /**
197 197
      * @param string $in_color
198 198
      */
199
-    public function display($in_color="#E0EBF5")
199
+    public function display($in_color = "#E0EBF5")
200 200
     {
201 201
 		echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>";
202 202
 		print_r($this);
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	 */
212 212
     public static function getCategoryListInfo($in_field = "", $courseId = "")
213 213
     {
214
-        if (empty($courseId) || $courseId=="") {
214
+        if (empty($courseId) || $courseId == "") {
215 215
             $courseId = api_get_course_int_id();
216 216
         }
217 217
         $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      *
252 252
      * @return int
253 253
      */
254
-	public static function getCategoryForQuestion($questionId, $courseId ="")
254
+	public static function getCategoryForQuestion($questionId, $courseId = "")
255 255
     {
256 256
 		$result = 0;
257 257
         if (empty($courseId) || $courseId == "") {
@@ -291,11 +291,11 @@  discard block
 block discarded – undo
291 291
         $questionId,
292 292
         $courseId = ""
293 293
     ) {
294
-		if (empty($courseId) || $courseId=="") {
294
+		if (empty($courseId) || $courseId == "") {
295 295
 			$courseId = api_get_course_int_id();
296 296
 		}
297 297
 		$catid = TestCategory::getCategoryForQuestion($questionId, $courseId);
298
-		$result = "";	// result
298
+		$result = ""; // result
299 299
 		$table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
300 300
 		$catid = intval($catid);
301 301
 		$sql = "SELECT title FROM $table
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 		$quiz->read($in_testid);
324 324
 		$tabQuestionList = $quiz->selectQuestionList();
325 325
 		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
326
-		for ($i=1; $i <= count($tabQuestionList); $i++) {
326
+		for ($i = 1; $i <= count($tabQuestionList); $i++) {
327 327
 			if (!in_array(TestCategory::getCategoryForQuestion($tabQuestionList[$i]), $result)) {
328 328
 				$result[] = TestCategory::getCategoryForQuestion($tabQuestionList[$i]);
329 329
 			}
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
     {
344 344
 		$tabcatName = array();
345 345
 		$tabcatID = self::getListOfCategoriesIDForTest($in_testid);
346
-		for ($i=0; $i < count($tabcatID); $i++) {
346
+		for ($i = 0; $i < count($tabcatID); $i++) {
347 347
 			$cat = new TestCategory($tabcatID[$i]);
348 348
 			$tabcatName[$cat->id] = $cat->name;
349 349
 		}
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 		$quiz->read($exerciseId);
378 378
 		$tabQuestionList = $quiz->selectQuestionList();
379 379
 		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ?
380
-		for ($i=1; $i <= count($tabQuestionList); $i++) {
380
+		for ($i = 1; $i <= count($tabQuestionList); $i++) {
381 381
 			if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) {
382 382
 				$nbCatResult++;
383 383
 			}
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
     {
397 397
 		$nbquestionresult = 0;
398 398
 		$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
399
-		for ($i=0; $i < count($tabcatid); $i++) {
399
+		for ($i = 0; $i < count($tabcatid); $i++) {
400 400
 			if ($tabcatid[$i] > 0) {	// 0 = no category for this questio
401 401
 				$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
402 402
 				if ($nbQuestionInThisCat > $in_nbrandom) {
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 		}
427 427
 	 	$tabcatobject = TestCategory::getCategoryListInfo("", $courseId);
428 428
 	 	$tabresult = array("0"=>get_lang('NoCategorySelected'));
429
-	 	for ($i=0; $i < count($tabcatobject); $i++) {
429
+	 	for ($i = 0; $i < count($tabcatobject); $i++) {
430 430
 	 		$tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name;
431 431
 	 	}
432 432
 	 	return $tabresult;
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
      */
501 501
     public static function returnCategoryAndTitle($questionId, $in_display_category_name = 1)
502 502
     {
503
-        $is_student = !(api_is_allowed_to_edit(null,true) || api_is_session_admin());
503
+        $is_student = !(api_is_allowed_to_edit(null, true) || api_is_session_admin());
504 504
         // @todo fix $_SESSION['objExercise']
505 505
         $objExercise = isset($_SESSION['objExercise']) ? $_SESSION['objExercise'] : null;
506 506
         if (!empty($objExercise)) {
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
     public static function sortTabByBracketLabel($in_tab)
539 539
     {
540 540
 		$tabResult = array();
541
-		$tabCatName = array();	// tab of category name
541
+		$tabCatName = array(); // tab of category name
542 542
 		while (list($cat_id, $tabquestion) = each($in_tab)) {
543 543
 			$catTitle = new TestCategory($cat_id);
544 544
 			$tabCatName[$cat_id] = $catTitle->name;
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
         $res_num_max = 0;
565 565
         // foreach question
566 566
 		$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
567
-		for ($i=0; $i < count($tabcatid); $i++) {
567
+		for ($i = 0; $i < count($tabcatid); $i++) {
568 568
 			if ($tabcatid[$i] > 0) {	// 0 = no category for this question
569 569
 				$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
570 570
                 if ($nbQuestionInThisCat > $res_num_max) {
@@ -750,20 +750,20 @@  discard block
 block discarded – undo
750 750
             $tmpobj = new TestCategory($category['id']);
751 751
             $nb_question = $tmpobj->getCategoryQuestionsNumber();
752 752
             $rowname = self::protectJSDialogQuote($category['title']);
753
-            $nb_question_label = $nb_question == 1 ? $nb_question . ' ' . get_lang('Question') : $nb_question . ' ' . get_lang('Questions');
753
+            $nb_question_label = $nb_question == 1 ? $nb_question.' '.get_lang('Question') : $nb_question.' '.get_lang('Questions');
754 754
 
755 755
             //$html .= '<div class="sectiontitle" id="id_cat' . $category['id'] . '">';
756
-            $content = "<span style='float:right'>" . $nb_question_label . "</span>";
756
+            $content = "<span style='float:right'>".$nb_question_label."</span>";
757 757
 
758 758
             $content .= '<div class="sectioncomment">';
759 759
             $content .= $category['description'];
760 760
             $content .= '</div>';
761 761
 
762
-            $links = '<a href="' . api_get_self() . '?action=editcategory&category_id=' . $category['id'] . '">' .
763
-                Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
764
-            $links .= ' <a href="' . api_get_self() . '?action=deletecategory&category_id=' . $category['id'] . '" ';
765
-            $links .= 'onclick="return confirmDelete(\'' . self::protectJSDialogQuote(get_lang('DeleteCategoryAreYouSure') . '[' . $rowname) . '] ?\', \'id_cat' . $category['id'] . '\');">';
766
-            $links .= Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
762
+            $links = '<a href="'.api_get_self().'?action=editcategory&category_id='.$category['id'].'">'.
763
+                Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
764
+            $links .= ' <a href="'.api_get_self().'?action=deletecategory&category_id='.$category['id'].'" ';
765
+            $links .= 'onclick="return confirmDelete(\''.self::protectJSDialogQuote(get_lang('DeleteCategoryAreYouSure').'['.$rowname).'] ?\', \'id_cat'.$category['id'].'\');">';
766
+            $links .= Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
767 767
             $html .= Display::panel($content, $category['title'].$links);
768 768
         }
769 769
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -401,8 +401,7 @@
 block discarded – undo
401 401
 				$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
402 402
 				if ($nbQuestionInThisCat > $in_nbrandom) {
403 403
 					$nbquestionresult += $in_nbrandom;
404
-				}
405
-				else {
404
+				} else {
406 405
 					$nbquestionresult += $nbQuestionInThisCat;
407 406
 				}
408 407
 			}
Please login to merge, or discard this patch.
main/exercice/unique_answer.class.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -417,8 +417,8 @@
 block discarded – undo
417 417
      * @param int $question_id  The question ID (to which the answer is attached)
418 418
      * @param string $title The text of the answer
419 419
      * @param string $comment The feedback for the answer
420
-     * @param float|null $score  The score you get when picking this answer
421
-     * @param int|null $correct  Whether this answer is considered *the* correct one (this is the unique answer type)
420
+     * @param double $score  The score you get when picking this answer
421
+     * @param integer $correct  Whether this answer is considered *the* correct one (this is the unique answer type)
422 422
      */
423 423
     public function addAnswer(
424 424
         $id,
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -447,7 +447,7 @@
 block discarded – undo
447 447
         $position = $row_max->max_position + 1;
448 448
 
449 449
         // Insert a new answer
450
-       $params = [
450
+        $params = [
451 451
             'c_id' => $course_id,
452 452
             'id' => $id,
453 453
             'question_id' => $question_id,
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -59,21 +59,21 @@  discard block
 block discarded – undo
59 59
 
60 60
         if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
61 61
             //Scenario
62
-            $comment_title = '<th width="20%">' . get_lang('Comment') . '</th>';
63
-            $feedback_title = '<th width="20%">' . get_lang('Scenario') . '</th>';
62
+            $comment_title = '<th width="20%">'.get_lang('Comment').'</th>';
63
+            $feedback_title = '<th width="20%">'.get_lang('Scenario').'</th>';
64 64
         } else {
65
-            $comment_title = '<th width="40%">' . get_lang('Comment') . '</th>';
65
+            $comment_title = '<th width="40%">'.get_lang('Comment').'</th>';
66 66
         }
67 67
 
68 68
         $html = '<table class="table table-striped table-hover">
69 69
             <thead>
70 70
                 <tr style="text-align: center;">
71
-                    <th width="5%">' . get_lang('Number') . '</th>
72
-                    <th width="5%"> ' . get_lang('True') . '</th>
73
-                    <th width="40%">' . get_lang('Answer') . '</th>
74
-                        ' . $comment_title . '
75
-                        ' . $feedback_title . '
76
-                    <th width="10%">' . get_lang('Weighting') . '</th>
71
+                    <th width="5%">' . get_lang('Number').'</th>
72
+                    <th width="5%"> ' . get_lang('True').'</th>
73
+                    <th width="40%">' . get_lang('Answer').'</th>
74
+                        ' . $comment_title.'
75
+                        ' . $feedback_title.'
76
+                    <th width="10%">' . get_lang('Weighting').'</th>
77 77
                 </tr>
78 78
             </thead>
79 79
             <tbody>';
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
                     continue;
104 104
                 }
105 105
                 $question = Question::read($questionid);
106
-                $select_question[$questionid] = 'Q' . $key . ' :' . cut(
106
+                $select_question[$questionid] = 'Q'.$key.' :'.cut(
107 107
                     $question->selectTitle(), 20
108 108
                 );
109 109
             }
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
                 if ($answer->correct[$i]) {
135 135
                     $correct = $i;
136 136
                 }
137
-                $defaults['answer[' . $i . ']'] = $answer->answer[$i];
138
-                $defaults['comment[' . $i . ']'] = $answer->comment[$i];
139
-                $defaults['weighting[' . $i . ']'] = float_format(
137
+                $defaults['answer['.$i.']'] = $answer->answer[$i];
138
+                $defaults['comment['.$i.']'] = $answer->comment[$i];
139
+                $defaults['weighting['.$i.']'] = float_format(
140 140
                     $answer->weighting[$i],
141 141
                     1
142 142
                 );
@@ -159,18 +159,18 @@  discard block
 block discarded – undo
159 159
                     $url_result = $url;
160 160
                 }
161 161
 
162
-                $temp_scenario['url' . $i] = $url_result;
163
-                $temp_scenario['try' . $i] = $try_result;
164
-                $temp_scenario['lp' . $i] = $lp;
165
-                $temp_scenario['destination' . $i] = $list_dest;
162
+                $temp_scenario['url'.$i] = $url_result;
163
+                $temp_scenario['try'.$i] = $try_result;
164
+                $temp_scenario['lp'.$i] = $lp;
165
+                $temp_scenario['destination'.$i] = $list_dest;
166 166
             } else {
167 167
                 $defaults['answer[1]'] = get_lang('DefaultUniqueAnswer1');
168 168
                 $defaults['weighting[1]'] = 10;
169 169
                 $defaults['answer[2]'] = get_lang('DefaultUniqueAnswer2');
170 170
                 $defaults['weighting[2]'] = 0;
171 171
 
172
-                $temp_scenario['destination' . $i] = array('0');
173
-                $temp_scenario['lp' . $i] = array('0');
172
+                $temp_scenario['destination'.$i] = array('0');
173
+                $temp_scenario['lp'.$i] = array('0');
174 174
             }
175 175
             $defaults['scenario'] = $temp_scenario;
176 176
 
@@ -182,62 +182,62 @@  discard block
 block discarded – undo
182 182
             );
183 183
             $renderer->setElementTemplate(
184 184
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
185
-                'counter[' . $i . ']'
185
+                'counter['.$i.']'
186 186
             );
187 187
             $renderer->setElementTemplate(
188 188
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
189
-                'answer[' . $i . ']'
189
+                'answer['.$i.']'
190 190
             );
191 191
             $renderer->setElementTemplate(
192 192
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
193
-                'comment[' . $i . ']'
193
+                'comment['.$i.']'
194 194
             );
195 195
             $renderer->setElementTemplate(
196 196
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
197
-                'weighting[' . $i . ']'
197
+                'weighting['.$i.']'
198 198
             );
199 199
 
200 200
             $answer_number = $form->addElement(
201
-                'text', 'counter[' . $i . ']', null, ' value = "' . $i . '"'
201
+                'text', 'counter['.$i.']', null, ' value = "'.$i.'"'
202 202
             );
203 203
             $answer_number->freeze();
204 204
             $form->addElement(
205 205
                 'radio', 'correct', null, null, $i, 'class="checkbox"'
206 206
             );
207 207
 
208
-            $form->addHtmlEditor('answer[' . $i . ']', null, null, true, $editor_config);
208
+            $form->addHtmlEditor('answer['.$i.']', null, null, true, $editor_config);
209 209
 
210 210
             $form->addRule(
211
-                'answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required'
211
+                'answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required'
212 212
             );
213 213
 
214 214
             if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
215
-                $form->addHtmlEditor('comment[' . $i . ']', null, null, false, $editor_config);
215
+                $form->addHtmlEditor('comment['.$i.']', null, null, false, $editor_config);
216 216
                 // Direct feedback
217 217
                 //Adding extra feedback fields
218 218
                 $group = array();
219
-                $group['try' . $i] = $form->createElement(
219
+                $group['try'.$i] = $form->createElement(
220 220
                     'checkbox',
221
-                    'try' . $i,
221
+                    'try'.$i,
222 222
                     null,
223 223
                     get_lang('TryAgain')
224 224
                 );
225
-                $group['lp' . $i] = $form->createElement(
225
+                $group['lp'.$i] = $form->createElement(
226 226
                     'select',
227
-                    'lp' . $i,
228
-                    get_lang('SeeTheory') . ': ',
227
+                    'lp'.$i,
228
+                    get_lang('SeeTheory').': ',
229 229
                     $select_lp_id
230 230
                 );
231
-                $group['destination' . $i] = $form->createElement(
231
+                $group['destination'.$i] = $form->createElement(
232 232
                     'select',
233
-                    'destination' . $i,
234
-                    get_lang('GoToQuestion') . ': ',
233
+                    'destination'.$i,
234
+                    get_lang('GoToQuestion').': ',
235 235
                     $select_question
236 236
                 );
237
-                $group['url' . $i] = $form->createElement(
237
+                $group['url'.$i] = $form->createElement(
238 238
                     'text',
239
-                    'url' . $i,
240
-                    get_lang('Other') . ': ',
239
+                    'url'.$i,
240
+                    get_lang('Other').': ',
241 241
                     array(
242 242
                         'class' => 'col-md-2',
243 243
                         'placeholder' => get_lang('Other')
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
                     'scenario'
251 251
                 );
252 252
             } else {
253
-                $form->addHtmlEditor('comment[' . $i . ']', null, null, false, $editor_config);
253
+                $form->addHtmlEditor('comment['.$i.']', null, null, false, $editor_config);
254 254
             }
255
-            $form->addText('weighting[' . $i . ']', null, null, array('value' => '0'));
255
+            $form->addText('weighting['.$i.']', null, null, array('value' => '0'));
256 256
             $form->addHtml('</tr>');
257 257
         }
258 258
 
@@ -306,19 +306,19 @@  discard block
 block discarded – undo
306 306
         $nb_answers = $form->getSubmitValue('nb_answers');
307 307
 
308 308
         for ($i = 1; $i <= $nb_answers; $i++) {
309
-            $answer = trim($form->getSubmitValue('answer[' . $i . ']'));
310
-            $comment = trim($form->getSubmitValue('comment[' . $i . ']'));
311
-            $weighting = trim($form->getSubmitValue('weighting[' . $i . ']'));
309
+            $answer = trim($form->getSubmitValue('answer['.$i.']'));
310
+            $comment = trim($form->getSubmitValue('comment['.$i.']'));
311
+            $weighting = trim($form->getSubmitValue('weighting['.$i.']'));
312 312
 
313 313
             $scenario = $form->getSubmitValue('scenario');
314 314
 
315 315
             //$list_destination = $form -> getSubmitValue('destination'.$i);
316 316
             //$destination_str = $form -> getSubmitValue('destination'.$i);
317 317
 
318
-            $try = $scenario['try' . $i];
319
-            $lp = $scenario['lp' . $i];
320
-            $destination = $scenario['destination' . $i];
321
-            $url = trim($scenario['url' . $i]);
318
+            $try = $scenario['try'.$i];
319
+            $lp = $scenario['lp'.$i];
320
+            $destination = $scenario['destination'.$i];
321
+            $url = trim($scenario['url'.$i]);
322 322
 
323 323
             /*
324 324
             How we are going to parse the destination value
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
             }
367 367
 
368 368
             //1@@1;2;@@2;4;4;@@http://www.chamilo.org
369
-            $dest = $try . '@@' . $lp . '@@' . $destination . '@@' . $url;
369
+            $dest = $try.'@@'.$lp.'@@'.$destination.'@@'.$url;
370 370
             $objAnswer->createAnswer(
371 371
                 $answer,
372 372
                 $goodAnswer,
@@ -400,12 +400,12 @@  discard block
 block discarded – undo
400 400
         $score = null
401 401
     ) {
402 402
         $header = parent::return_header($feedback_type, $counter, $score);
403
-        $header .= '<table class="' . $this->question_table_class . '">
403
+        $header .= '<table class="'.$this->question_table_class.'">
404 404
 			<tr>
405
-				<th>' . get_lang("Choice") . '</th>
406
-				<th>' . get_lang("ExpectedChoice") . '</th>
407
-				<th>' . get_lang("Answer") . '</th>';
408
-        $header .= '<th>' . get_lang("Comment") . '</th>';
405
+				<th>' . get_lang("Choice").'</th>
406
+				<th>' . get_lang("ExpectedChoice").'</th>
407
+				<th>' . get_lang("Answer").'</th>';
408
+        $header .= '<th>'.get_lang("Comment").'</th>';
409 409
         $header .= '</tr>';
410 410
 
411 411
         return $header;
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
         if ($correct) {
470 470
             $sql = "UPDATE $tbl_quiz_question
471 471
                     SET ponderation = (ponderation + $score)
472
-                    WHERE c_id = $course_id AND id = " . $question_id;
472
+                    WHERE c_id = $course_id AND id = ".$question_id;
473 473
             Database::query($sql);
474 474
         }
475 475
     }
Please login to merge, or discard this patch.
main/forum/forumfunction.inc.php 3 patches
Doc Comments   +16 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
  * an up and down icon except for the first (no up icon) and the last (no down icon)
1059 1059
  *          The key of this $list array is the id of the item.
1060 1060
  *
1061
- * @return void HTML
1061
+ * @return string HTML
1062 1062
  **/
1063 1063
 function return_up_down_icon($content, $id, $list)
1064 1064
 {
@@ -2011,7 +2011,7 @@  discard block
 block discarded – undo
2011 2011
  * This function retrieves forum thread users details
2012 2012
  * @param   int Thread ID
2013 2013
  * @param   string  Course DB name (optional)
2014
- * @return  resource array Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[])
2014
+ * @return  Doctrine\DBAL\Driver\Statement|null array Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[])
2015 2015
  * @author Christian Fasanando <[email protected]>,
2016 2016
  * @todo     this function need to be improved
2017 2017
  * @version octubre 2008, dokeos 1.8
@@ -2066,7 +2066,7 @@  discard block
 block discarded – undo
2066 2066
  * This function retrieves forum thread users qualify
2067 2067
  * @param   int Thread ID
2068 2068
  * @param   string  Course DB name (optional)
2069
- * @return  array Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[])
2069
+ * @return  Doctrine\DBAL\Driver\Statement|null Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[])
2070 2070
  * @author Jhon Hinojosa
2071 2071
  * @todo     this function need to be improved
2072 2072
  */
@@ -2133,7 +2133,7 @@  discard block
 block discarded – undo
2133 2133
  * This function retrieves forum thread users not qualify
2134 2134
  * @param   int Thread ID
2135 2135
  * @param   string  Course DB name (optional)
2136
- * @return  array Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[])
2136
+ * @return  Doctrine\DBAL\Driver\Statement|null Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[])
2137 2137
  * @author   Jhon Hinojosa<[email protected]>,
2138 2138
  * @version oct 2008, dokeos 1.8
2139 2139
  */
@@ -3163,6 +3163,10 @@  discard block
 block discarded – undo
3163 3163
  * @param integer contains the information the current user id
3164 3164
  * @param integer contains the information the current thread id
3165 3165
  * @param integer contains the information the current qualify
3166
+ * @param string $option
3167
+ * @param integer $course_id
3168
+ * @param integer $user_id
3169
+ * @param integer $thread_id
3166 3170
  * @return void
3167 3171
  * <code>$option=1 obtained the qualification of the current thread</code>
3168 3172
  * @author Isaac Flores <[email protected]>, U.N.A.S University
@@ -3722,6 +3726,8 @@  discard block
 block discarded – undo
3722 3726
  *
3723 3727
  * @author Patrick Cool <[email protected]>, Ghent University
3724 3728
  * @version february 2006, dokeos 1.8
3729
+ * @param string $last_post_id
3730
+ * @param string $post_date
3725 3731
  */
3726 3732
 function updateThreadInfo($thread_id, $last_post_id, $post_date)
3727 3733
 {
@@ -4025,6 +4031,8 @@  discard block
 block discarded – undo
4025 4031
  *
4026 4032
  * @param string  Content type (post, thread, forum, forum_category)
4027 4033
  * @param int     Item DB ID
4034
+ * @param string $content
4035
+ * @param integer $id
4028 4036
  * @return string language variable
4029 4037
  * @author Patrick Cool <[email protected]>, Ghent University
4030 4038
  * @version february 2006, dokeos 1.8
@@ -4461,6 +4469,7 @@  discard block
 block discarded – undo
4461 4469
 /**
4462 4470
  * Display the search results
4463 4471
  * @param string
4472
+ * @param string $search_term
4464 4473
  * @return void display the results
4465 4474
  * @author Patrick Cool <[email protected]>, Ghent University, Belgium
4466 4475
  * @version march 2008, dokeos 1.8.5
@@ -4590,7 +4599,7 @@  discard block
 block discarded – undo
4590 4599
  * This function adds an attachment file into a forum
4591 4600
  * @param string $file_comment  a comment about file
4592 4601
  * @param int $last_id from forum_post table
4593
- * @return int|bool
4602
+ * @return false|null
4594 4603
  */
4595 4604
 function add_forum_attachment_file($file_comment, $last_id)
4596 4605
 {
@@ -4801,7 +4810,7 @@  discard block
 block discarded – undo
4801 4810
  * @param post id
4802 4811
  * @param int $id_attach
4803 4812
  * @param bool $display to show or not result message
4804
- * @return void
4813
+ * @return integer
4805 4814
  * @author Julio Montoya Dokeos
4806 4815
  * @version october 2014, chamilo 1.9.8
4807 4816
  */
@@ -5083,7 +5092,7 @@  discard block
 block discarded – undo
5083 5092
  * @param integer $forum_id the id of the forum
5084 5093
  * @param integer $thread_id the id of the thread
5085 5094
  * @param integer $post_id the id of the post
5086
- * @return bool
5095
+ * @return false|null
5087 5096
  *
5088 5097
  * @author Patrick Cool <[email protected]>, Ghent University, Belgium
5089 5098
  * @version May 2008, dokeos 1.8.5
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1316,16 +1316,16 @@
 block discarded – undo
1316 1316
     }
1317 1317
 }
1318 1318
 /**
1319
- * Retrieve all the information off the forum categories (or one specific) for the current course.
1320
- * The categories are sorted according to their sorting order (cat_order
1321
- *
1322
- * @param int $id default ''. When an id is passed we only find the information
1323
- * about that specific forum category. If no id is passed we get all the forum categories.
1324
- * @return array containing all the information about all the forum categories
1325
- *
1326
- * @author Patrick Cool <[email protected]>, Ghent University
1327
- * @version february 2006, dokeos 1.8
1328
- */
1319
+     * Retrieve all the information off the forum categories (or one specific) for the current course.
1320
+     * The categories are sorted according to their sorting order (cat_order
1321
+     *
1322
+     * @param int $id default ''. When an id is passed we only find the information
1323
+     * about that specific forum category. If no id is passed we get all the forum categories.
1324
+     * @return array containing all the information about all the forum categories
1325
+     *
1326
+     * @author Patrick Cool <[email protected]>, Ghent University
1327
+     * @version february 2006, dokeos 1.8
1328
+     */
1329 1329
 function get_forum_categories($id = '')
1330 1330
 {
1331 1331
     $table_categories = Database :: get_course_table(TABLE_FORUM_CATEGORY);
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
         var l = $(this);
64 64
         var id = l.closest("tr").attr("id");
65 65
         var filename = l.closest("tr").find(".attachFilename").html();
66
-        if (confirm("' . get_lang('AreYouSureToDeleteJS') . '", filename)) {
66
+        if (confirm("' . get_lang('AreYouSureToDeleteJS').'", filename)) {
67 67
             $.ajax({
68 68
                 type: "POST",
69
-                url: "'.api_get_path(WEB_AJAX_PATH) . 'forum.ajax.php?'.api_get_cidreq().'&a=delete_file&attachId=" + id +"&thread='.$threadId .'&forum='.$forumId .'",
69
+                url: "'.api_get_path(WEB_AJAX_PATH).'forum.ajax.php?'.api_get_cidreq().'&a=delete_file&attachId=" + id +"&thread='.$threadId.'&forum='.$forumId.'",
70 70
                 dataType: "json",
71 71
                 success: function(data) {
72 72
                     if (data.error == false) {
@@ -965,24 +965,24 @@  discard block
 block discarded – undo
965 965
     $html = '';
966 966
     $id = Security::remove_XSS($id);
967 967
     if ($current_visibility_status == '1') {
968
-        $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&';
968
+        $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
969 969
         if (is_array($additional_url_parameters)) {
970 970
             foreach ($additional_url_parameters as $key => $value) {
971
-                $html .= $key . '=' . $value . '&';
971
+                $html .= $key.'='.$value.'&';
972 972
             }
973 973
         }
974
-        $html.='action=invisible&content='.$content.'&id='.$id.'">'.
974
+        $html .= 'action=invisible&content='.$content.'&id='.$id.'">'.
975 975
             Display::return_icon('visible.png', get_lang('MakeInvisible'), array(), ICON_SIZE_SMALL).'</a>';
976 976
     }
977 977
     if ($current_visibility_status == '0') {
978
-        $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&';
978
+        $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
979 979
         if (is_array($additional_url_parameters)) {
980 980
             foreach ($additional_url_parameters as $key => $value) {
981
-                $html .= $key . '=' . $value . '&';
981
+                $html .= $key.'='.$value.'&';
982 982
             }
983 983
         }
984
-        $html .= 'action=visible&content=' . $content . '&id=' . $id . '">' .
985
-            Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_SMALL) . '</a>';
984
+        $html .= 'action=visible&content='.$content.'&id='.$id.'">'.
985
+            Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_SMALL).'</a>';
986 986
     }
987 987
     return $html;
988 988
 }
@@ -1003,21 +1003,21 @@  discard block
 block discarded – undo
1003 1003
         $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
1004 1004
         if (is_array($additional_url_parameters)) {
1005 1005
             foreach ($additional_url_parameters as $key => $value) {
1006
-                $html .= $key . '=' . $value . '&';
1006
+                $html .= $key.'='.$value.'&';
1007 1007
             }
1008 1008
         }
1009
-        $html.= 'action=unlock&content='.$content.'&id='.$id.'">'.
1009
+        $html .= 'action=unlock&content='.$content.'&id='.$id.'">'.
1010 1010
             Display::return_icon('lock.png', get_lang('Unlock'), array(), ICON_SIZE_SMALL).'</a>';
1011 1011
     }
1012 1012
     if ($current_lock_status == '0') {
1013 1013
         $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
1014 1014
         if (is_array($additional_url_parameters)) {
1015 1015
             foreach ($additional_url_parameters as $key => $value) {
1016
-                $html .= $key . '=' . $value . '&';
1016
+                $html .= $key.'='.$value.'&';
1017 1017
             }
1018 1018
         }
1019
-        $html .= 'action=lock&content=' . $content . '&id=' . $id . '">' .
1020
-            Display::return_icon('unlock.png', get_lang('Lock'), array(), ICON_SIZE_SMALL) . '</a>';
1019
+        $html .= 'action=lock&content='.$content.'&id='.$id.'">'.
1020
+            Display::return_icon('unlock.png', get_lang('Lock'), array(), ICON_SIZE_SMALL).'</a>';
1021 1021
     }
1022 1022
     return $html;
1023 1023
 }
@@ -1220,7 +1220,7 @@  discard block
 block discarded – undo
1220 1220
                     forum_categories.c_id = $course_id AND
1221 1221
                     item_properties.c_id = $course_id AND
1222 1222
                     forum_categories.cat_id=item_properties.ref AND
1223
-                    item_properties.tool='" . TOOL_FORUM_CATEGORY . "'
1223
+                    item_properties.tool='".TOOL_FORUM_CATEGORY."'
1224 1224
                 ORDER BY forum_categories.cat_order $sort_direction";
1225 1225
     }
1226 1226
     if ($content == 'forum') {
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
             FROM $table
1229 1229
             WHERE
1230 1230
                 c_id = $course_id AND
1231
-                forum_category='" . Database::escape_string($forum_category) . "'
1231
+                forum_category='".Database::escape_string($forum_category)."'
1232 1232
             ORDER BY forum_order $sort_direction";
1233 1233
     }
1234 1234
     // Finding the items that need to be switched.
@@ -1285,7 +1285,7 @@  discard block
 block discarded – undo
1285 1285
 {
1286 1286
     $current_visibility_status = intval($current_visibility_status);
1287 1287
     if ($current_visibility_status == 0) {
1288
-        $status='invisible';
1288
+        $status = 'invisible';
1289 1289
         return $status;
1290 1290
     }
1291 1291
 }
@@ -2185,7 +2185,7 @@  discard block
 block discarded – undo
2185 2185
 {
2186 2186
     $table_forums = Database :: get_course_table(TABLE_FORUM);
2187 2187
     $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
2188
-    $courseId = empty($courseId) ? api_get_course_int_id(): intval($courseId);
2188
+    $courseId = empty($courseId) ? api_get_course_int_id() : intval($courseId);
2189 2189
     $forum_id = intval($forum_id);
2190 2190
 
2191 2191
     $sql = "SELECT *
@@ -2344,7 +2344,7 @@  discard block
 block discarded – undo
2344 2344
  */
2345 2345
 function store_thread($current_forum, $values, $courseInfo = array(), $showMessage = true)
2346 2346
 {
2347
-    $courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo ;
2347
+    $courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo;
2348 2348
     $_user = api_get_user_info();
2349 2349
     $course_id = $courseInfo['real_id'];
2350 2350
     $courseCode = $courseInfo['code'];
@@ -2588,11 +2588,11 @@  discard block
 block discarded – undo
2588 2588
     $form = new FormValidator(
2589 2589
         'thread',
2590 2590
         'post',
2591
-        api_get_self() . '?' . http_build_query([
2591
+        api_get_self().'?'.http_build_query([
2592 2592
             'forum' => $myForum,
2593 2593
             'gradebook' => $myGradebook,
2594 2594
             'thread' => $myThread,
2595
-        ]) . '&' . api_get_cidreq()
2595
+        ]).'&'.api_get_cidreq()
2596 2596
     );
2597 2597
 
2598 2598
     $form->addElement('header', get_lang('EditThread'));
@@ -2657,7 +2657,7 @@  discard block
 block discarded – undo
2657 2657
     $form->addElement('html', '</div>');
2658 2658
 
2659 2659
     if (!empty($formValues)) {
2660
-        $defaults['thread_qualify_gradebook'] = ($formValues['threadQualifyMax'] > 0 && empty($_POST)) ? 1 : 0 ;
2660
+        $defaults['thread_qualify_gradebook'] = ($formValues['threadQualifyMax'] > 0 && empty($_POST)) ? 1 : 0;
2661 2661
         $defaults['thread_title'] = prepare4display($formValues['threadTitle']);
2662 2662
         $defaults['thread_sticky'] = strval(intval($formValues['threadSticky']));
2663 2663
         $defaults['thread_peer_qualify'] = intval($formValues['threadPeerQualify']);
@@ -2729,13 +2729,13 @@  discard block
 block discarded – undo
2729 2729
     $form = new FormValidator(
2730 2730
         'thread',
2731 2731
         'post',
2732
-        api_get_self() . '?' . http_build_query([
2732
+        api_get_self().'?'.http_build_query([
2733 2733
             'forum' => intval($my_forum),
2734 2734
             'gradebook' => $my_gradebook,
2735 2735
             'thread' => intval($myThread),
2736 2736
             'post' => intval($my_post),
2737 2737
             'action' => $action,
2738
-        ]) . '&' . api_get_cidreq()
2738
+        ]).'&'.api_get_cidreq()
2739 2739
     );
2740 2740
     $form->setConstants(array('forum' => '5'));
2741 2741
 
@@ -2998,7 +2998,7 @@  discard block
 block discarded – undo
2998 2998
 
2999 2999
             if ($row[0] == 0) {
3000 3000
                 $sql = "INSERT INTO $table_threads_qualify (c_id, user_id, thread_id,qualify,qualify_user_id,qualify_time,session_id)
3001
-                        VALUES (".$course_id.", '".$user_id."','".$thread_id."',".(float)$thread_qualify.", '".$currentUserId."','".$qualify_time."','".$session_id."')";
3001
+                        VALUES (".$course_id.", '".$user_id."','".$thread_id."',".(float) $thread_qualify.", '".$currentUserId."','".$qualify_time."','".$session_id."')";
3002 3002
                 Database::query($sql);
3003 3003
 
3004 3004
                 $insertId = Database::insert_id();
@@ -4601,9 +4601,9 @@  discard block
 block discarded – undo
4601 4601
             continue;
4602 4602
         }
4603 4603
 
4604
-        $course_dir = $_course['path'] . '/upload/forum';
4604
+        $course_dir = $_course['path'].'/upload/forum';
4605 4605
         $sys_course_path = api_get_path(SYS_COURSE_PATH);
4606
-        $updir = $sys_course_path . $course_dir;
4606
+        $updir = $sys_course_path.$course_dir;
4607 4607
 
4608 4608
         // Try to add an extension to the file if it hasn't one.
4609 4609
         $new_file_name = add_ext_on_mime(
@@ -4620,7 +4620,7 @@  discard block
 block discarded – undo
4620 4620
         }
4621 4621
 
4622 4622
         $new_file_name = uniqid('');
4623
-        $new_path = $updir . '/' . $new_file_name;
4623
+        $new_path = $updir.'/'.$new_file_name;
4624 4624
         $result = @move_uploaded_file($attachment['tmp_name'], $new_path);
4625 4625
         $safe_file_comment = Database::escape_string($file_comment);
4626 4626
         $safe_file_name = Database::escape_string($file_name);
@@ -4785,16 +4785,16 @@  discard block
 block discarded – undo
4785 4785
     $forum_table_attachment = Database::get_course_table(TABLE_FORUM_ATTACHMENT);
4786 4786
     $course_id = api_get_course_int_id();
4787 4787
 
4788
-    $cond = (!empty($id_attach)) ? " iid = " . (int) $id_attach . "" : " post_id = " . (int) $post_id . "";
4788
+    $cond = (!empty($id_attach)) ? " iid = ".(int) $id_attach."" : " post_id = ".(int) $post_id."";
4789 4789
     $sql = "SELECT path FROM $forum_table_attachment WHERE c_id = $course_id AND $cond";
4790 4790
     $res = Database::query($sql);
4791 4791
     $row = Database::fetch_array($res);
4792 4792
 
4793
-    $course_dir = $_course['path'] . '/upload/forum';
4793
+    $course_dir = $_course['path'].'/upload/forum';
4794 4794
     $sys_course_path = api_get_path(SYS_COURSE_PATH);
4795
-    $updir = $sys_course_path . $course_dir;
4795
+    $updir = $sys_course_path.$course_dir;
4796 4796
     $my_path = isset($row['path']) ? $row['path'] : null;
4797
-    $file = $updir . '/' . $my_path;
4797
+    $file = $updir.'/'.$my_path;
4798 4798
     if (Security::check_abs_path($file, $updir)) {
4799 4799
         @unlink($file);
4800 4800
     }
@@ -5342,35 +5342,35 @@  discard block
 block discarded – undo
5342 5342
                         $post_list = get_thread_user_post_limit($course_code, $thread['thread_id'], $user_id, 1);
5343 5343
                         $post_counter = count($post_list);
5344 5344
                         if (is_array($post_list) && count($post_list) > 0) {
5345
-                            $hand_forums.= '<div id="social-thread">';
5346
-                            $hand_forums.= Display::return_icon('thread.png', get_lang('Thread'), '', ICON_SIZE_MEDIUM);
5347
-                            $hand_forums.= '&nbsp;'.Security::remove_XSS($thread['thread_title'], STUDENT);
5348
-                            $hand_forums.= '</div>';
5345
+                            $hand_forums .= '<div id="social-thread">';
5346
+                            $hand_forums .= Display::return_icon('thread.png', get_lang('Thread'), '', ICON_SIZE_MEDIUM);
5347
+                            $hand_forums .= '&nbsp;'.Security::remove_XSS($thread['thread_title'], STUDENT);
5348
+                            $hand_forums .= '</div>';
5349 5349
 
5350 5350
                             foreach ($post_list as $posts) {
5351
-                                $hand_forums.= '<div id="social-post">';
5352
-                                $hand_forums.= '<strong>'.Security::remove_XSS($posts['post_title'], STUDENT).'</strong>';
5353
-                                $hand_forums.= '<br / >';
5354
-                                $hand_forums.= Security::remove_XSS($posts['post_text'], STUDENT);
5355
-                                $hand_forums.= '</div>';
5356
-                                $hand_forums.= '<br / >';
5351
+                                $hand_forums .= '<div id="social-post">';
5352
+                                $hand_forums .= '<strong>'.Security::remove_XSS($posts['post_title'], STUDENT).'</strong>';
5353
+                                $hand_forums .= '<br / >';
5354
+                                $hand_forums .= Security::remove_XSS($posts['post_text'], STUDENT);
5355
+                                $hand_forums .= '</div>';
5356
+                                $hand_forums .= '<br / >';
5357 5357
                             }
5358 5358
                         }
5359 5359
                     }
5360 5360
                     $i++;
5361 5361
                 }
5362
-                $forum_results .='<div id="social-forum">';
5363
-                $forum_results .='<div class="clear"></div><br />';
5364
-                $forum_results .='<div id="social-forum-title">'.
5362
+                $forum_results .= '<div id="social-forum">';
5363
+                $forum_results .= '<div class="clear"></div><br />';
5364
+                $forum_results .= '<div id="social-forum-title">'.
5365 5365
                     Display::return_icon('forum.gif', get_lang('Forum')).'&nbsp;'.Security::remove_XSS($forum['forum_title'], STUDENT).
5366 5366
                     '<div style="float:right;margin-top:-35px">
5367 5367
                                         <a href="../forum/viewforum.php?cidReq='.$course_code.'&gidReq=&forum='.$forum['forum_id'].' " >'.get_lang('SeeForum').'</a>
5368 5368
                                     </div></div>';
5369
-                $forum_results .='<br / >';
5369
+                $forum_results .= '<br / >';
5370 5370
                 if ($post_counter > 0) {
5371
-                    $forum_results .=$hand_forums;
5371
+                    $forum_results .= $hand_forums;
5372 5372
                 }
5373
-                $forum_results .='</div>';
5373
+                $forum_results .= '</div>';
5374 5374
             }$j++;
5375 5375
         }
5376 5376
     }
@@ -5511,16 +5511,16 @@  discard block
 block discarded – undo
5511 5511
     $courseId = intval($courseId);
5512 5512
     if (empty($courseId)) {
5513 5513
         // $courseId can be null, use api method
5514
-        $courseId= api_get_course_int_id();
5514
+        $courseId = api_get_course_int_id();
5515 5515
     }
5516 5516
     /*
5517 5517
      * Check if Attachment ID and Course ID are greater than zero
5518 5518
      * and array of field values is not empty
5519 5519
      */
5520 5520
     if ($id > 0 && $courseId > 0 && !empty($array) && is_array($array)) {
5521
-        foreach($array as $key => &$item) {
5521
+        foreach ($array as $key => &$item) {
5522 5522
             $item = Database::escape_string($item);
5523
-            $setString .= $key . ' = "' .$item . '", ';
5523
+            $setString .= $key.' = "'.$item.'", ';
5524 5524
         }
5525 5525
         // Delete last comma
5526 5526
         $setString = substr($setString, 0, strlen($setString) - 2);
@@ -5566,7 +5566,7 @@  discard block
 block discarded – undo
5566 5566
         return '';
5567 5567
     }
5568 5568
 
5569
-    $url = api_get_path(WEB_AJAX_PATH).'forum.ajax.php?'.api_get_cidreq().'&forum=' . $forumId . '&thread=' . $threadId . '&postId=' . $postId . '&a=upload_file';
5569
+    $url = api_get_path(WEB_AJAX_PATH).'forum.ajax.php?'.api_get_cidreq().'&forum='.$forumId.'&thread='.$threadId.'&postId='.$postId.'&a=upload_file';
5570 5570
 
5571 5571
     $multipleForm = new FormValidator('post');
5572 5572
     $multipleForm->addMultipleUpload($url);
@@ -5607,10 +5607,10 @@  discard block
 block discarded – undo
5607 5607
         foreach ($uploadedFiles as $k => $uploadedFile) {
5608 5608
             if (!empty($uploadedFile) && in_array($uploadedFile['id'], $attachIds)) {
5609 5609
                 // Buil html table including an input with attachmentID
5610
-                $fileDataContent .= '<tr id="' . $uploadedFile['id'] . '" ><td>' . $uploadedFile['name'] . '</td><td>' . $uploadedFile['size'] . '</td><td>&nbsp;' . $uploadedFile['result'] .
5611
-                    ' </td><td> <input style="width:90%;" type="text" value="' . $uploadedFile['comment'] . '" name="file_comments[]"> </td><td>' .
5612
-                    $uploadedFile['delete'] . '</td>' .
5613
-                    '<input type="hidden" value="' . $uploadedFile['id'] .'" name="file_ids[]">' . '</tr>';
5610
+                $fileDataContent .= '<tr id="'.$uploadedFile['id'].'" ><td>'.$uploadedFile['name'].'</td><td>'.$uploadedFile['size'].'</td><td>&nbsp;'.$uploadedFile['result'].
5611
+                    ' </td><td> <input style="width:90%;" type="text" value="'.$uploadedFile['comment'].'" name="file_comments[]"> </td><td>'.
5612
+                    $uploadedFile['delete'].'</td>'.
5613
+                    '<input type="hidden" value="'.$uploadedFile['id'].'" name="file_ids[]">'.'</tr>';
5614 5614
             } else {
5615 5615
                 /*
5616 5616
                  * If attachment data is empty, then delete it from $_SESSION
@@ -5623,7 +5623,7 @@  discard block
 block discarded – undo
5623 5623
     $style = empty($fileDataContent) ? 'display: none;' : '';
5624 5624
     // Forum attachment Ajax table
5625 5625
     $fileData = '
5626
-    <div class="control-group " style="'. $style . '">
5626
+    <div class="control-group " style="'. $style.'">
5627 5627
         <label class="control-label">'.get_lang('AttachmentList').'</label>
5628 5628
         <div class="controls">
5629 5629
             <table id="attachmentFileList" class="files data_table span10">
@@ -5695,7 +5695,7 @@  discard block
 block discarded – undo
5695 5695
             // name contains an URL to download attachment file and its filename
5696 5696
             $json['name'] = Display::url(
5697 5697
                 api_htmlentities($row['filename']),
5698
-                api_get_path(WEB_CODE_PATH) . 'forum/download.php?file='.$row['path'].'&'.api_get_cidreq(),
5698
+                api_get_path(WEB_CODE_PATH).'forum/download.php?file='.$row['path'].'&'.api_get_cidreq(),
5699 5699
                 array('target'=>'_blank', 'class' => 'attachFilename')
5700 5700
             );
5701 5701
             $json['id'] = $row['iid'];
@@ -5706,9 +5706,9 @@  discard block
 block discarded – undo
5706 5706
             if (!empty($row) && is_array($row)) {
5707 5707
                 // Set result as success and bring delete URL
5708 5708
                 $json['result'] = Display::return_icon('accept.png', get_lang('Uploaded'));
5709
-                $url = api_get_path(WEB_CODE_PATH) . 'forum/viewthread.php?' . api_get_cidreq() . '&action=delete_attach&forum=' . $forumId . '&thread=' . $threadId.'&id_attach=' . $row['iid'];
5709
+                $url = api_get_path(WEB_CODE_PATH).'forum/viewthread.php?'.api_get_cidreq().'&action=delete_attach&forum='.$forumId.'&thread='.$threadId.'&id_attach='.$row['iid'];
5710 5710
                 $json['delete'] = Display::url(
5711
-                    Display::return_icon('delete.png',get_lang('Delete'), array(), ICON_SIZE_SMALL),
5711
+                    Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL),
5712 5712
                     $url,
5713 5713
                     array('class' => 'deleteLink')
5714 5714
                 );
@@ -5797,7 +5797,7 @@  discard block
 block discarded – undo
5797 5797
                 WHERE c_id = $courseId AND post_id = $postId";
5798 5798
         $result = Database::query($sql);
5799 5799
         if ($result !== false && Database::num_rows($result) > 0) {
5800
-            while ($row = Database::fetch_array($result,'ASSOC')) {
5800
+            while ($row = Database::fetch_array($result, 'ASSOC')) {
5801 5801
                 $array[] = $row['id'];
5802 5802
             }
5803 5803
         }
Please login to merge, or discard this patch.
main/gradebook/lib/be/abstractlink.class.php 3 patches
Doc Comments   +15 added lines, -4 removed lines patch added patch discarded remove patch
@@ -193,6 +193,9 @@  discard block
 block discarded – undo
193 193
         $this->visible = $visible;
194 194
     }
195 195
 
196
+    /**
197
+     * @param integer $id
198
+     */
196 199
     public function set_session_id($id)
197 200
     {
198 201
         $this->session_id = $id;
@@ -217,6 +220,12 @@  discard block
 block discarded – undo
217 220
     /**
218 221
      * Retrieve links and return them as an array of extensions of AbstractLink.
219 222
      * To keep consistency, do not call this method but LinkFactory::load instead.
223
+     * @param integer $id
224
+     * @param integer $type
225
+     * @param integer $user_id
226
+     * @param string $course_code
227
+     * @param integer $category_id
228
+     * @param integer $visible
220 229
      */
221 230
     public static function load(
222 231
         $id = null,
@@ -288,7 +297,7 @@  discard block
 block discarded – undo
288 297
     }
289 298
 
290 299
     /**
291
-     * @param $result
300
+     * @param Doctrine\DBAL\Driver\Statement|null $result
292 301
      * @return array
293 302
      */
294 303
     private static function create_objects_from_sql_result($result)
@@ -463,6 +472,7 @@  discard block
 block discarded – undo
463 472
 
464 473
     /**
465 474
      * Internal function used by get_target_categories()
475
+     * @param integer $level
466 476
      */
467 477
     private function add_target_subcategories($targets, $level, $catid)
468 478
     {
@@ -492,6 +502,7 @@  discard block
 block discarded – undo
492 502
      * Find links by name
493 503
      * To keep consistency, do not call this method but LinkFactory::find_links instead.
494 504
      * @todo can be written more efficiently using a new (but very complex) sql query
505
+     * @param string $name_mask
495 506
      */
496 507
     public function find_links ($name_mask,$selectcat)
497 508
     {
@@ -559,21 +570,21 @@  discard block
 block discarded – undo
559 570
     }
560 571
 
561 572
     /**
562
-     * @param $name
573
+     * @param string $name
563 574
      */
564 575
     public function set_name($name)
565 576
     {
566 577
     }
567 578
 
568 579
     /**
569
-     * @param $description
580
+     * @param string $description
570 581
      */
571 582
     public function set_description($description)
572 583
     {
573 584
     }
574 585
 
575 586
     /**
576
-     * @param $max
587
+     * @param integer $max
577 588
      */
578 589
     public function set_max($max)
579 590
     {
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -138,22 +138,22 @@  discard block
 block discarded – undo
138 138
         return $this->visible;
139 139
     }
140 140
 
141
-    public function set_id ($id)
141
+    public function set_id($id)
142 142
     {
143 143
         $this->id = $id;
144 144
     }
145 145
 
146
-    public function set_type ($type)
146
+    public function set_type($type)
147 147
     {
148 148
         $this->type = $type;
149 149
     }
150 150
 
151
-    public function set_ref_id ($ref_id)
151
+    public function set_ref_id($ref_id)
152 152
     {
153 153
         $this->ref_id = $ref_id;
154 154
     }
155 155
 
156
-    public function set_user_id ($user_id)
156
+    public function set_user_id($user_id)
157 157
     {
158 158
         $this->user_id = $user_id;
159 159
     }
@@ -231,29 +231,29 @@  discard block
 block discarded – undo
231 231
         $sql = 'SELECT * FROM '.$tbl_grade_links;
232 232
         $paramcount = 0;
233 233
         if (isset ($id)) {
234
-            $sql.= ' WHERE id = '.intval($id);
235
-            $paramcount ++;
234
+            $sql .= ' WHERE id = '.intval($id);
235
+            $paramcount++;
236 236
         }
237 237
         if (isset ($type)) {
238 238
             if ($paramcount != 0) $sql .= ' AND';
239 239
             else $sql .= ' WHERE';
240 240
             $sql .= ' type = '.intval($type);
241
-            $paramcount ++;
241
+            $paramcount++;
242 242
         }
243 243
         if (isset ($ref_id)) {
244 244
             if ($paramcount != 0) $sql .= ' AND';
245 245
             else $sql .= ' WHERE';
246 246
             $sql .= ' ref_id = '.intval($ref_id);
247
-            $paramcount ++;
247
+            $paramcount++;
248 248
         }
249 249
         if (isset ($user_id)) {
250 250
             if ($paramcount != 0) {
251 251
                 $sql .= ' AND';
252
-            }else {
252
+            } else {
253 253
                 $sql .= ' WHERE';
254 254
             }
255 255
             $sql .= ' user_id = '.intval($user_id);
256
-            $paramcount ++;
256
+            $paramcount++;
257 257
         }
258 258
         if (isset ($course_code)) {
259 259
             if ($paramcount != 0) {
@@ -262,16 +262,16 @@  discard block
 block discarded – undo
262 262
                 $sql .= ' WHERE';
263 263
             }
264 264
             $sql .= " course_code = '".Database::escape_string($course_code)."'";
265
-            $paramcount ++;
265
+            $paramcount++;
266 266
         }
267 267
         if (isset ($category_id)) {
268 268
             if ($paramcount != 0) {
269 269
                 $sql .= ' AND';
270
-            }else {
270
+            } else {
271 271
                 $sql .= ' WHERE';
272 272
             }
273 273
             $sql .= ' category_id = '.intval($category_id);
274
-            $paramcount ++;
274
+            $paramcount++;
275 275
         }
276 276
         if (isset ($visible)) {
277 277
             if ($paramcount != 0) {
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
             $session_id = api_get_session_id();
312 312
 
313 313
             $link->set_session_id($session_id);
314
-            $links[]=$link;
314
+            $links[] = $link;
315 315
         }
316 316
         return $links;
317 317
     }
@@ -402,12 +402,12 @@  discard block
 block discarded – undo
402 402
         $dateobject = AbstractLink::load($idevaluation, null, null, null, null);
403 403
         $current_date_server = api_get_utc_datetime();
404 404
         $arreval = get_object_vars($dateobject[0]);
405
-        $description_log = isset($arreval['description']) ? $arreval['description']:'';
405
+        $description_log = isset($arreval['description']) ? $arreval['description'] : '';
406 406
         if (empty($nameLog)) {
407 407
             if (isset($_POST['name_link'])) {
408 408
                 $name_log = isset($_POST['name_link']) ? $_POST['name_link'] : $arreval['course_code'];
409
-            } elseif (isset($_POST['link_' . $idevaluation]) && $_POST['link_' . $idevaluation]) {
410
-                $name_log = $_POST['link_' . $idevaluation];
409
+            } elseif (isset($_POST['link_'.$idevaluation]) && $_POST['link_'.$idevaluation]) {
410
+                $name_log = $_POST['link_'.$idevaluation];
411 411
             } else {
412 412
                 $name_log = $arreval['course_code'];
413 413
             }
@@ -452,10 +452,10 @@  discard block
 block discarded – undo
452 452
         $targets = array();
453 453
         $level = 0;
454 454
 
455
-        $crscats = Category::load(null,null,$this->get_course_code(),0);
455
+        $crscats = Category::load(null, null, $this->get_course_code(), 0);
456 456
         foreach ($crscats as $cat) {
457
-            $targets[] = array($cat->get_id(), $cat->get_name(), $level+1);
458
-            $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
457
+            $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
458
+            $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
459 459
         }
460 460
 
461 461
         return $targets;
@@ -466,10 +466,10 @@  discard block
 block discarded – undo
466 466
      */
467 467
     private function add_target_subcategories($targets, $level, $catid)
468 468
     {
469
-        $subcats = Category::load(null,null,null,$catid);
469
+        $subcats = Category::load(null, null, null, $catid);
470 470
         foreach ($subcats as $cat) {
471
-            $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
472
-            $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
471
+            $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
472
+            $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
473 473
         }
474 474
         return $targets;
475 475
     }
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
      * To keep consistency, do not call this method but LinkFactory::find_links instead.
494 494
      * @todo can be written more efficiently using a new (but very complex) sql query
495 495
      */
496
-    public function find_links ($name_mask,$selectcat)
496
+    public function find_links($name_mask, $selectcat)
497 497
     {
498 498
         $rootcat = Category::load($selectcat);
499 499
         $links = $rootcat[0]->get_links((api_is_allowed_to_edit() ? null : api_get_user_id()), true);
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -235,21 +235,27 @@  discard block
 block discarded – undo
235 235
             $paramcount ++;
236 236
         }
237 237
         if (isset ($type)) {
238
-            if ($paramcount != 0) $sql .= ' AND';
239
-            else $sql .= ' WHERE';
238
+            if ($paramcount != 0) {
239
+                $sql .= ' AND';
240
+            } else {
241
+                $sql .= ' WHERE';
242
+            }
240 243
             $sql .= ' type = '.intval($type);
241 244
             $paramcount ++;
242 245
         }
243 246
         if (isset ($ref_id)) {
244
-            if ($paramcount != 0) $sql .= ' AND';
245
-            else $sql .= ' WHERE';
247
+            if ($paramcount != 0) {
248
+                $sql .= ' AND';
249
+            } else {
250
+                $sql .= ' WHERE';
251
+            }
246 252
             $sql .= ' ref_id = '.intval($ref_id);
247 253
             $paramcount ++;
248 254
         }
249 255
         if (isset ($user_id)) {
250 256
             if ($paramcount != 0) {
251 257
                 $sql .= ' AND';
252
-            }else {
258
+            } else {
253 259
                 $sql .= ' WHERE';
254 260
             }
255 261
             $sql .= ' user_id = '.intval($user_id);
@@ -267,7 +273,7 @@  discard block
 block discarded – undo
267 273
         if (isset ($category_id)) {
268 274
             if ($paramcount != 0) {
269 275
                 $sql .= ' AND';
270
-            }else {
276
+            } else {
271 277
                 $sql .= ' WHERE';
272 278
             }
273 279
             $sql .= ' category_id = '.intval($category_id);
Please login to merge, or discard this patch.
main/gradebook/lib/be/category.class.php 4 patches
Doc Comments   +22 added lines, -10 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     }
78 78
 
79 79
     /**
80
-     * @return float
80
+     * @return integer|null
81 81
      */
82 82
     public function get_certificate_min_score()
83 83
     {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     }
98 98
 
99 99
     /**
100
-     * @return mixed
100
+     * @return integer
101 101
      */
102 102
     public function get_parent_id()
103 103
     {
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     }
106 106
 
107 107
     /**
108
-     * @return mixed
108
+     * @return integer
109 109
      */
110 110
     public function get_weight()
111 111
     {
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     }
122 122
 
123 123
     /**
124
-     * @return mixed
124
+     * @return boolean
125 125
      */
126 126
     public function is_visible()
127 127
     {
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
     }
245 245
 
246 246
     /**
247
-     * @return null
247
+     * @return null|integer
248 248
      */
249 249
     public function get_grade_model_id()
250 250
     {
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
     }
488 488
 
489 489
     /**
490
-     * @param $result
490
+     * @param Doctrine\DBAL\Driver\Statement|null $result
491 491
      *
492 492
      * @return array
493 493
      */
@@ -863,7 +863,8 @@  discard block
 block discarded – undo
863 863
 
864 864
     /**
865 865
      * Calculate the score of this category
866
-     * @param $stud_id student id (default: all students - then the average is returned)
866
+     * @param integer $stud_id student id (default: all students - then the average is returned)
867
+     * @param integer $session_id
867 868
      * @return    array (score sum, weight sum)
868 869
      *             or null if no scores available
869 870
      */
@@ -1122,6 +1123,9 @@  discard block
 block discarded – undo
1122 1123
      * @param int       student id
1123 1124
      * @param string    Course code
1124 1125
      * @param int       Session id
1126
+     * @param integer $stud_id
1127
+     * @param string $course_code
1128
+     * @param integer $session_id
1125 1129
      */
1126 1130
     public function get_root_categories_for_student($stud_id, $course_code = null, $session_id = null)
1127 1131
     {
@@ -1202,6 +1206,9 @@  discard block
 block discarded – undo
1202 1206
      * @param int user id (to return everything, use 'null' here)
1203 1207
      * @param string course code (optional)
1204 1208
      * @param int session id (optional)
1209
+     * @param integer $user_id
1210
+     * @param string $course_code
1211
+     * @param integer $session_id
1205 1212
      */
1206 1213
     public function get_root_categories_for_teacher($user_id, $course_code = null, $session_id = null)
1207 1214
     {
@@ -1300,6 +1307,7 @@  discard block
 block discarded – undo
1300 1307
 
1301 1308
     /**
1302 1309
      * Internal function used by get_target_categories()
1310
+     * @param integer $level
1303 1311
      */
1304 1312
     private function add_target_subcategories($targets, $level, $catid)
1305 1313
     {
@@ -1399,6 +1407,8 @@  discard block
 block discarded – undo
1399 1407
 
1400 1408
     /**
1401 1409
      * Internal function used by get_tree()
1410
+     * @param integer $level
1411
+     * @param null|integer $visible
1402 1412
      */
1403 1413
     private function add_subtree ($targets, $level, $catid, $visible)
1404 1414
     {
@@ -1416,6 +1426,7 @@  discard block
 block discarded – undo
1416 1426
 
1417 1427
     /**
1418 1428
      * Generate an array of courses that a teacher hasn't created a category for.
1429
+     * @param integer $user_id
1419 1430
      * @return array 2-dimensional array - every element contains 2 subelements (code, title)
1420 1431
      */
1421 1432
     public function get_not_created_course_categories ($user_id)
@@ -1450,6 +1461,7 @@  discard block
 block discarded – undo
1450 1461
 
1451 1462
     /**
1452 1463
      * Generate an array of all courses that a teacher is admin of.
1464
+     * @param integer $user_id
1453 1465
      * @return array 2-dimensional array - every element contains 2 subelements (code, title)
1454 1466
      */
1455 1467
     public function get_all_courses ($user_id)
@@ -1530,7 +1542,7 @@  discard block
 block discarded – undo
1530 1542
     /**
1531 1543
      * Retrieve all categories inside a course independent category
1532 1544
      * that should be visible to a student.
1533
-     * @param $cat_id parent category
1545
+     * @param integer $cat_id parent category
1534 1546
      * @param $stud_id student id
1535 1547
      * @param $cats optional: if defined, the categories will be added to this array
1536 1548
      */
@@ -1851,7 +1863,7 @@  discard block
 block discarded – undo
1851 1863
      * the platform administrator.
1852 1864
      * @param int locked 1 or unlocked 0
1853 1865
 
1854
-     * @return bool
1866
+     * @return boolean|null
1855 1867
      * */
1856 1868
     public function lock($locked)
1857 1869
     {
@@ -2282,7 +2294,7 @@  discard block
 block discarded – undo
2282 2294
      * @param float $score The achieved score
2283 2295
      * @param int $userId The user id
2284 2296
      * @param int $categoryId The gradebook category
2285
-     * @return int The insert id
2297
+     * @return false|string The insert id
2286 2298
      */
2287 2299
     public static function registerCurrentScore($score, $userId, $categoryId)
2288 2300
     {
Please login to merge, or discard this patch.
Indentation   -2 removed lines patch added patch discarded remove patch
@@ -1571,7 +1571,6 @@  discard block
 block discarded – undo
1571 1571
      * @param string $course_code Course code (optional)
1572 1572
      * @param int    $session_id Session ID (optional)
1573 1573
      * @param bool   $order
1574
-
1575 1574
      * @return array Array of subcategories
1576 1575
      */
1577 1576
     public function get_subcategories($stud_id = null, $course_code = null, $session_id = null, $order = null)
@@ -1850,7 +1849,6 @@  discard block
 block discarded – undo
1850 1849
      * This function, locks a category , only one who can unlock it is
1851 1850
      * the platform administrator.
1852 1851
      * @param int locked 1 or unlocked 0
1853
-
1854 1852
      * @return bool
1855 1853
      * */
1856 1854
     public function lock($locked)
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
      */
200 200
     public function set_session_id($session_id = 0)
201 201
     {
202
-        $this->session_id = (int)$session_id;
202
+        $this->session_id = (int) $session_id;
203 203
     }
204 204
 
205 205
     /**
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
         $skills = $this->get_skills();
289 289
         $skill_select = array();
290 290
         if (!empty($skills)) {
291
-            foreach($skills as $skill) {
291
+            foreach ($skills as $skill) {
292 292
                 $skill_select[$skill['id']] = $skill['name'];
293 293
             }
294 294
         }
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
      */
323 323
     public static function load_session_categories($id = null, $session_id = null)
324 324
     {
325
-        if (isset($id) && (int)$id === 0) {
325
+        if (isset($id) && (int) $id === 0) {
326 326
             $cats = array();
327 327
             $cats[] = Category::create_root_category();
328 328
             return $cats;
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
         if (!empty($session_id)) {
336 336
             $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
337 337
             $sql = 'SELECT id, course_code
338
-                    FROM '.$tbl_grade_categories. '
338
+                    FROM '.$tbl_grade_categories.'
339 339
                     WHERE session_id = '.$session_id;
340 340
             $result_session = Database::query($sql);
341 341
             if (Database::num_rows($result_session) > 0) {
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
     ) {
376 376
         //if the category given is explicitly 0 (not null), then create
377 377
         // a root category object (in memory)
378
-        if (isset($id) && (int)$id === 0) {
378
+        if (isset($id) && (int) $id === 0) {
379 379
             $cats = array();
380 380
             $cats[] = Category::create_root_category();
381 381
 
@@ -386,8 +386,8 @@  discard block
 block discarded – undo
386 386
         $sql = 'SELECT * FROM '.$tbl_grade_categories;
387 387
         $paramcount = 0;
388 388
         if (isset($id)) {
389
-            $sql.= ' WHERE id = '.intval($id);
390
-            $paramcount ++;
389
+            $sql .= ' WHERE id = '.intval($id);
390
+            $paramcount++;
391 391
         }
392 392
 
393 393
         if (isset($user_id)) {
@@ -423,10 +423,10 @@  discard block
 block discarded – undo
423 423
             if (empty($session_id)) {
424 424
                 $sql .= ' AND (session_id IS NULL OR session_id = 0) ';
425 425
             } else {
426
-                $sql .= ' AND session_id = '.(int)$session_id.' ';
426
+                $sql .= ' AND session_id = '.(int) $session_id.' ';
427 427
             }
428 428
             //}
429
-            $paramcount ++;
429
+            $paramcount++;
430 430
         }
431 431
 
432 432
         if (isset($parent_id)) {
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
                             $default_weight = $default_weight_setting;
599 599
                         }
600 600
                         foreach ($components as $component) {
601
-                            $gradebook =  new Gradebook();
601
+                            $gradebook = new Gradebook();
602 602
                             $params = array();
603 603
 
604 604
                             $params['name'] = $component['acronym'];
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
                 }
616 616
             }
617 617
 
618
-            $gradebook= new Gradebook();
618
+            $gradebook = new Gradebook();
619 619
             $gradebook->update_skills_to_gradebook($this->id, $this->get_skills(false));
620 620
 
621 621
             return $id;
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
                         $params['description']      = $component['title'];
681 681
                         $params['user_id']          = api_get_user_id();
682 682
                         $params['parent_id']        = $this->id;
683
-                        $params['weight']           = $component['percentage']/100*$default_weight;
683
+                        $params['weight']           = $component['percentage'] / 100 * $default_weight;
684 684
                         $params['session_id']       = api_get_session_id();
685 685
                         $params['course_code']      = $this->get_course_code();
686 686
 
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
             }
691 691
         }
692 692
 
693
-        $gradebook= new Gradebook();
693
+        $gradebook = new Gradebook();
694 694
         $gradebook->update_skills_to_gradebook(
695 695
             $this->id,
696 696
             $this->get_skills(false),
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
         if (!empty($links)) {
711 711
             foreach ($links as $link_item) {
712 712
                 if (isset($link_item)) {
713
-                    $new_item_weight =  $new_weight * $link_item->get_weight() / $old_weight;
713
+                    $new_item_weight = $new_weight * $link_item->get_weight() / $old_weight;
714 714
                     $link_item->set_weight($new_item_weight);
715 715
                     $link_item->save();
716 716
                 }
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
                     visible=3';
752 752
         $res = Database::query($sql);
753 753
         $option = Database::fetch_array($res, 'ASSOC');
754
-        if ($option['num']>=1) {
754
+        if ($option['num'] >= 1) {
755 755
             return '&nbsp;&nbsp;<span class="resource-deleted">(&nbsp;'.get_lang('ResourceDeleted').'&nbsp;)</span>';
756 756
         } else {
757 757
             return false;
@@ -812,9 +812,9 @@  discard block
 block discarded – undo
812 812
             $sql .= ' AND user_id = '.api_get_user_id();
813 813
         }
814 814
         if (!isset ($parent)) {
815
-            $sql.= ' AND parent_id is null';
815
+            $sql .= ' AND parent_id is null';
816 816
         } else {
817
-            $sql.= ' AND parent_id = '.intval($parent);
817
+            $sql .= ' AND parent_id = '.intval($parent);
818 818
         }
819 819
 
820 820
         $result = Database::query($sql);
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
                     }
913 913
 
914 914
                     if (isset($score) && !empty($score[1]) && !empty($catweight)) {
915
-                        $ressum += $score[0]/$score[1] * $catweight;
915
+                        $ressum += $score[0] / $score[1] * $catweight;
916 916
                     }
917 917
                 }
918 918
             }
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
                     }
1002 1002
 
1003 1003
                     if (isset($score) && !empty($score[1]) && !empty($catweight)) {
1004
-                        $ressum += $score[0]/$score[1] * $catweight;
1004
+                        $ressum += $score[0] / $score[1] * $catweight;
1005 1005
 
1006 1006
                         if ($ressum > $bestResult) {
1007 1007
                             $bestResult = $ressum;
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
                 // session, we don't check his registration to these, but this
1141 1141
                 // could be an improvement
1142 1142
                 if (!empty($session_id)) {
1143
-                    $sql .= " AND course_code = '".Database::escape_string($course_code)."' AND session_id = ".(int)$session_id;
1143
+                    $sql .= " AND course_code = '".Database::escape_string($course_code)."' AND session_id = ".(int) $session_id;
1144 1144
                 } else {
1145 1145
                     $sql .= " AND course_code = '".Database::escape_string($course_code)."' AND session_id is null OR session_id=0";
1146 1146
                 }
@@ -1164,9 +1164,9 @@  discard block
 block discarded – undo
1164 1164
                 // could be an improvement
1165 1165
                 $sql .= " AND course_code  = '".Database::escape_string($course_code)."'";
1166 1166
                 if (!empty($session_id)) {
1167
-                    $sql .= " AND session_id = ".(int)$session_id;
1167
+                    $sql .= " AND session_id = ".(int) $session_id;
1168 1168
                 } else {
1169
-                    $sql .="AND session_id IS NULL OR session_id=0";
1169
+                    $sql .= "AND session_id IS NULL OR session_id=0";
1170 1170
                 }
1171 1171
             } else {
1172 1172
                 $sql .= ' AND course_code IN
@@ -1180,10 +1180,10 @@  discard block
 block discarded – undo
1180 1180
                     )';
1181 1181
             }
1182 1182
         }elseif (api_is_platform_admin()) {
1183
-            if (isset($session_id) && $session_id!=0) {
1184
-                $sql.=' AND session_id='.intval($session_id);
1183
+            if (isset($session_id) && $session_id != 0) {
1184
+                $sql .= ' AND session_id='.intval($session_id);
1185 1185
             } else {
1186
-                $sql.=' AND coalesce(session_id,0)=0';
1186
+                $sql .= ' AND coalesce(session_id,0)=0';
1187 1187
             }
1188 1188
         }
1189 1189
         $result = Database::query($sql);
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
 
1192 1192
         // course independent categories
1193 1193
         if (empty($course_code)) {
1194
-            $cats = Category::get_independent_categories_with_result_for_student (0, $stud_id, $cats);
1194
+            $cats = Category::get_independent_categories_with_result_for_student(0, $stud_id, $cats);
1195 1195
         }
1196 1196
 
1197 1197
         return $cats;
@@ -1206,7 +1206,7 @@  discard block
 block discarded – undo
1206 1206
     public function get_root_categories_for_teacher($user_id, $course_code = null, $session_id = null)
1207 1207
     {
1208 1208
         if ($user_id == null) {
1209
-            return Category::load(null,null,$course_code,0,null,$session_id);
1209
+            return Category::load(null, null, $course_code, 0, null, $session_id);
1210 1210
         }
1211 1211
 
1212 1212
         $courseTable = Database :: get_main_table(TABLE_MAIN_COURSE);
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
         if (!empty($course_code)) {
1219 1219
             $sql .= " AND course_code = '".Database::escape_string($course_code)."' ";
1220 1220
             if (!empty($session_id)) {
1221
-                $sql .= " AND session_id = ".(int)$session_id;
1221
+                $sql .= " AND session_id = ".(int) $session_id;
1222 1222
             }
1223 1223
         } else {
1224 1224
             $sql .= ' AND course_code in
@@ -1234,7 +1234,7 @@  discard block
 block discarded – undo
1234 1234
         $cats = Category::create_category_objects_from_sql_result($result);
1235 1235
         // course independent categories
1236 1236
         if (isset($course_code)) {
1237
-            $indcats = Category::load(null,$user_id,$course_code,0,null,$session_id);
1237
+            $indcats = Category::load(null, $user_id, $course_code, 0, null, $session_id);
1238 1238
             $cats = array_merge($cats, $indcats);
1239 1239
         }
1240 1240
 
@@ -1277,20 +1277,20 @@  discard block
 block discarded – undo
1277 1277
             $targets[] = $root;
1278 1278
 
1279 1279
             if (isset($this->course_code) && !empty($this->course_code)) {
1280
-                $crscats = Category::load(null,null,$this->course_code,0);
1280
+                $crscats = Category::load(null, null, $this->course_code, 0);
1281 1281
                 foreach ($crscats as $cat) {
1282 1282
                     if ($this->can_be_moved_to_cat($cat)) {
1283
-                        $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
1284
-                        $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
1283
+                        $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
1284
+                        $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
1285 1285
                     }
1286 1286
                 }
1287 1287
             }
1288 1288
 
1289
-            $indcats = Category::load(null,$user,0,0);
1289
+            $indcats = Category::load(null, $user, 0, 0);
1290 1290
             foreach ($indcats as $cat) {
1291 1291
                 if ($this->can_be_moved_to_cat($cat)) {
1292
-                    $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
1293
-                    $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
1292
+                    $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
1293
+                    $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
1294 1294
                 }
1295 1295
             }
1296 1296
 
@@ -1303,11 +1303,11 @@  discard block
 block discarded – undo
1303 1303
      */
1304 1304
     private function add_target_subcategories($targets, $level, $catid)
1305 1305
     {
1306
-        $subcats = Category::load(null,null,null,$catid);
1306
+        $subcats = Category::load(null, null, null, $catid);
1307 1307
         foreach ($subcats as $cat) {
1308 1308
             if ($this->can_be_moved_to_cat($cat)) {
1309
-                $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
1310
-                $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
1309
+                $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
1310
+                $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
1311 1311
             }
1312 1312
         }
1313 1313
 
@@ -1320,7 +1320,7 @@  discard block
 block discarded – undo
1320 1320
      * Impossible when origin and target are the same... children won't be processed
1321 1321
      * either. (a category can't be moved to one of its own children)
1322 1322
      */
1323
-    private function can_be_moved_to_cat ($cat)
1323
+    private function can_be_moved_to_cat($cat)
1324 1324
     {
1325 1325
         return $cat->get_id() != $this->get_id();
1326 1326
     }
@@ -1349,7 +1349,7 @@  discard block
 block discarded – undo
1349 1349
     {
1350 1350
         $cats = Category::load(null, null, null, $this->id, null);
1351 1351
         $evals = Evaluation::load(null, null, null, $this->id, null);
1352
-        $links = LinkFactory::load(null,null,null,null,null,$this->id,null);
1352
+        $links = LinkFactory::load(null, null, null, null, null, $this->id, null);
1353 1353
 
1354 1354
         foreach ($cats as $cat) {
1355 1355
             $cat->set_course_code($this->get_course_code());
@@ -1382,15 +1382,15 @@  discard block
 block discarded – undo
1382 1382
             $user = (api_is_platform_admin() ? null : api_get_user_id());
1383 1383
             $cats = Category::get_root_categories_for_teacher($user);
1384 1384
             foreach ($cats as $cat) {
1385
-                $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
1386
-                $targets = Category::add_subtree($targets, $level+1, $cat->get_id(),null);
1385
+                $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
1386
+                $targets = Category::add_subtree($targets, $level + 1, $cat->get_id(), null);
1387 1387
             }
1388 1388
         } else {
1389 1389
             // student
1390 1390
             $cats = Category::get_root_categories_for_student(api_get_user_id());
1391 1391
             foreach ($cats as $cat) {
1392
-                $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
1393
-                $targets = Category::add_subtree($targets, $level+1, $cat->get_id(), 1);
1392
+                $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
1393
+                $targets = Category::add_subtree($targets, $level + 1, $cat->get_id(), 1);
1394 1394
             }
1395 1395
         }
1396 1396
 
@@ -1400,14 +1400,14 @@  discard block
 block discarded – undo
1400 1400
     /**
1401 1401
      * Internal function used by get_tree()
1402 1402
      */
1403
-    private function add_subtree ($targets, $level, $catid, $visible)
1403
+    private function add_subtree($targets, $level, $catid, $visible)
1404 1404
     {
1405
-        $subcats = Category::load(null,null,null,$catid,$visible);
1405
+        $subcats = Category::load(null, null, null, $catid, $visible);
1406 1406
 
1407 1407
         if (!empty($subcats)) {
1408 1408
             foreach ($subcats as $cat) {
1409
-                $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
1410
-                $targets = Category::add_subtree($targets, $level+1, $cat->get_id(),$visible);
1409
+                $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
1410
+                $targets = Category::add_subtree($targets, $level + 1, $cat->get_id(), $visible);
1411 1411
             }
1412 1412
         }
1413 1413
 
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
      * Generate an array of courses that a teacher hasn't created a category for.
1419 1419
      * @return array 2-dimensional array - every element contains 2 subelements (code, title)
1420 1420
      */
1421
-    public function get_not_created_course_categories ($user_id)
1421
+    public function get_not_created_course_categories($user_id)
1422 1422
     {
1423 1423
         $tbl_main_courses = Database :: get_main_table(TABLE_MAIN_COURSE);
1424 1424
         $tbl_main_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
@@ -1440,9 +1440,9 @@  discard block
 block discarded – undo
1440 1440
                 )';
1441 1441
         $result = Database::query($sql);
1442 1442
 
1443
-        $cats=array();
1444
-        while ($data=Database::fetch_array($result)) {
1445
-            $cats[] = array ($data['code'], $data['title']);
1443
+        $cats = array();
1444
+        while ($data = Database::fetch_array($result)) {
1445
+            $cats[] = array($data['code'], $data['title']);
1446 1446
         }
1447 1447
 
1448 1448
         return $cats;
@@ -1452,7 +1452,7 @@  discard block
 block discarded – undo
1452 1452
      * Generate an array of all courses that a teacher is admin of.
1453 1453
      * @return array 2-dimensional array - every element contains 2 subelements (code, title)
1454 1454
      */
1455
-    public function get_all_courses ($user_id)
1455
+    public function get_all_courses($user_id)
1456 1456
     {
1457 1457
         $tbl_main_courses = Database :: get_main_table(TABLE_MAIN_COURSE);
1458 1458
         $tbl_main_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
@@ -1466,7 +1466,7 @@  discard block
 block discarded – undo
1466 1466
         $result = Database::query($sql);
1467 1467
         $cats = array();
1468 1468
         while ($data = Database::fetch_array($result)) {
1469
-            $cats[] = array ($data['code'], $data['title']);
1469
+            $cats[] = array($data['code'], $data['title']);
1470 1470
         }
1471 1471
 
1472 1472
         return $cats;
@@ -1479,7 +1479,7 @@  discard block
 block discarded – undo
1479 1479
     {
1480 1480
         $cats = Category::load(null, null, null, $this->id, null);
1481 1481
         $evals = Evaluation::load(null, null, null, $this->id, null);
1482
-        $links = LinkFactory::load(null,null,null,null,null,$this->id,null);
1482
+        $links = LinkFactory::load(null, null, null, null, null, $this->id, null);
1483 1483
         if (!empty($cats)) {
1484 1484
             foreach ($cats as $cat) {
1485 1485
                 $cat->set_visible($this->is_visible());
@@ -1834,7 +1834,7 @@  discard block
 block discarded – undo
1834 1834
      * @param string $name_mask search string
1835 1835
      * @return array category objects matching the search criterium
1836 1836
      */
1837
-    public function find_category($name_mask,$allcat)
1837
+    public function find_category($name_mask, $allcat)
1838 1838
     {
1839 1839
         $foundcats = array();
1840 1840
         foreach ($allcat as $search_cat) {
@@ -1877,9 +1877,9 @@  discard block
 block discarded – undo
1877 1877
                 }
1878 1878
             }
1879 1879
 
1880
-            $link_to_lock= $this->get_links();
1880
+            $link_to_lock = $this->get_links();
1881 1881
             if (!empty($link_to_lock)) {
1882
-                foreach ($link_to_lock as $item ) {
1882
+                foreach ($link_to_lock as $item) {
1883 1883
                     $item->lock($locked);
1884 1884
                 }
1885 1885
             }
@@ -1968,7 +1968,7 @@  discard block
 block discarded – undo
1968 1968
                 return [
1969 1969
                     'badge_link' => Display::url(
1970 1970
                         get_lang('DownloadBadges'),
1971
-                        api_get_path(WEB_CODE_PATH) . "gradebook/get_badges.php?user=$user_id",
1971
+                        api_get_path(WEB_CODE_PATH)."gradebook/get_badges.php?user=$user_id",
1972 1972
                         array(
1973 1973
                             'target' => '_blank',
1974 1974
                             'class' => 'btn btn-default'
@@ -2002,7 +2002,7 @@  discard block
 block discarded – undo
2002 2002
             $fileWasGenerated = $certificate_obj->html_file_is_generated();
2003 2003
 
2004 2004
             if (!empty($fileWasGenerated)) {
2005
-                $url = api_get_path(WEB_PATH) . 'certificates/index.php?id=' . $my_certificate['id'];
2005
+                $url = api_get_path(WEB_PATH).'certificates/index.php?id='.$my_certificate['id'];
2006 2006
 
2007 2007
                 $certificates = Display::url(
2008 2008
                     Display::returnFontAwesomeIcon('download').' '.get_lang('DownloadCertificate'),
@@ -2025,7 +2025,7 @@  discard block
 block discarded – undo
2025 2025
 
2026 2026
                 $hideExportLink = api_get_setting('hide_certificate_export_link');
2027 2027
                 $hideExportLinkStudent = api_get_setting('hide_certificate_export_link_students');
2028
-                if ($hideExportLink === 'true' || (api_is_student() && $hideExportLinkStudent === 'true') ) {
2028
+                if ($hideExportLink === 'true' || (api_is_student() && $hideExportLinkStudent === 'true')) {
2029 2029
                     $exportToPDF = null;
2030 2030
                 }
2031 2031
 
@@ -2038,7 +2038,7 @@  discard block
 block discarded – undo
2038 2038
                 if ($skillToolEnabled && $userHasSkills) {
2039 2039
                     $html['badge_link'] = Display::url(
2040 2040
                         get_lang('DownloadBadges'),
2041
-                        api_get_path(WEB_CODE_PATH) . "gradebook/get_badges.php?user=$user_id",
2041
+                        api_get_path(WEB_CODE_PATH)."gradebook/get_badges.php?user=$user_id",
2042 2042
                         array(
2043 2043
                             'target' => '_blank',
2044 2044
                             'class' => 'btn btn-default'
@@ -2098,7 +2098,7 @@  discard block
 block discarded – undo
2098 2098
                     $certificate_obj = new Certificate($value_certificate['id']);
2099 2099
                     $certificate_obj->generate(array('hide_print_button' => true));
2100 2100
                     if ($certificate_obj->html_file_is_generated()) {
2101
-                        $certificate_path_list[]= $certificate_obj->html_file;
2101
+                        $certificate_path_list[] = $certificate_obj->html_file;
2102 2102
                     }
2103 2103
                 }
2104 2104
             }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1179,7 +1179,7 @@
 block discarded – undo
1179 1179
                             cu.status = '.COURSEMANAGER.'
1180 1180
                     )';
1181 1181
             }
1182
-        }elseif (api_is_platform_admin()) {
1182
+        } elseif (api_is_platform_admin()) {
1183 1183
             if (isset($session_id) && $session_id!=0) {
1184 1184
                 $sql.=' AND session_id='.intval($session_id);
1185 1185
             } else {
Please login to merge, or discard this patch.