Passed
Push — 1.10.x ( 10729d...9f4f4a )
by Angel Fernando Quiroz
142:16 queued 95:50
created
main/exercice/overview.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -249,7 +249,7 @@
 block discarded – undo
249 249
             break;
250 250
         case RESULT_DISABLE_SHOW_SCORE_ONLY:
251 251
             if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_END) {
252
-               $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'));
252
+                $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'));
253 253
             }
254 254
             else {
255 255
                 $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'), get_lang('Details'));
Please login to merge, or discard this patch.
main/exercice/TestCategory.php 1 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.
main/exercice/multiple_answer_combination.class.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
     }
179 179
 
180 180
     /**
181
-	 * abstract function which creates the form to create/edit the answers of the question
182
-	 * @param FormValidator $form
183
-	 */
181
+     * abstract function which creates the form to create/edit the answers of the question
182
+     * @param FormValidator $form
183
+     */
184 184
     public function processAnswersCreation($form)
185 185
     {
186 186
         $questionWeighting = $nbrGoodAnswers = 0;
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
         // sets the total weighting of the question
222 222
         $this->updateWeighting($questionWeighting);
223 223
         $this->save();
224
-	}
224
+    }
225 225
 
226 226
     function return_header($feedback_type = null, $counter = null, $score = null)
227 227
     {
Please login to merge, or discard this patch.
main/exercice/live_stats.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 $result = $objExercise->read($exercise_id);
18 18
 
19 19
 if (!$result) {
20
-	api_not_allowed(true);
20
+    api_not_allowed(true);
21 21
 }
22 22
 
23 23
 $interbreadcrumb[] = array(
Please login to merge, or discard this patch.
main/exercice/feedback.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
 $nameTools=get_lang('ExerciseManagement');
14 14
 
15 15
 if (isset($_SESSION['gradebook'])){
16
-	$gradebook=	$_SESSION['gradebook'];
16
+    $gradebook=	$_SESSION['gradebook'];
17 17
 }
18 18
 
19 19
 if (!empty($gradebook) && $gradebook=='view') {
20
-	$interbreadcrumb[]= array (
21
-			'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
22
-			'name' => get_lang('ToolGradebook')
23
-		);
20
+    $interbreadcrumb[]= array (
21
+            'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
22
+            'name' => get_lang('ToolGradebook')
23
+        );
24 24
 }
25 25
 
26 26
 $interbreadcrumb[]=array("url" => "exercise.php","name" => get_lang('Exercises'));
@@ -31,24 +31,24 @@  discard block
 block discarded – undo
31 31
   <?php echo "Add Feedback"; ?>
32 32
 </h4>
33 33
 <?php
34
-	$id = $_REQUEST['question'];
35
-	$objQuestionTmp = Question::read($id);
36
-	echo "<tr><td><b>".get_lang('Question')." : </b>";
37
-	echo $objQuestionTmp->selectTitle();
38
-	echo "</td></tr>";
39
-	echo " <br><tr><td><b><br>".get_lang('Answer')." : </b></td></tr>";
40
-	$objAnswerTmp=new Answer($id);
41
-	$num = $objAnswerTmp->selectNbrAnswers();
42
-	$objAnswerTmp->read();
43
-	for($i=1;$i<=$num;$i++)
44
-	{
45
-	echo "<tr><td width='10%'> ";
46
-	$ans =  $objAnswerTmp->answer[$i];
34
+    $id = $_REQUEST['question'];
35
+    $objQuestionTmp = Question::read($id);
36
+    echo "<tr><td><b>".get_lang('Question')." : </b>";
37
+    echo $objQuestionTmp->selectTitle();
38
+    echo "</td></tr>";
39
+    echo " <br><tr><td><b><br>".get_lang('Answer')." : </b></td></tr>";
40
+    $objAnswerTmp=new Answer($id);
41
+    $num = $objAnswerTmp->selectNbrAnswers();
42
+    $objAnswerTmp->read();
43
+    for($i=1;$i<=$num;$i++)
44
+    {
45
+    echo "<tr><td width='10%'> ";
46
+    $ans =  $objAnswerTmp->answer[$i];
47 47
 
48
-	$form = new FormValidator('feedbackform','post',api_get_self()."?".api_get_cidreq()."&modifyQuestion=".$modifyQuestion."&newQuestion=".$newQuestion);
49
-	$obj_registration_form = new HTML_QuickForm('frmRegistration', 'POST');
50
-	$renderer =& $obj_registration_form->defaultRenderer();
51
-	$renderer->setCustomElementTemplate(
48
+    $form = new FormValidator('feedbackform','post',api_get_self()."?".api_get_cidreq()."&modifyQuestion=".$modifyQuestion."&newQuestion=".$newQuestion);
49
+    $obj_registration_form = new HTML_QuickForm('frmRegistration', 'POST');
50
+    $renderer =& $obj_registration_form->defaultRenderer();
51
+    $renderer->setCustomElementTemplate(
52 52
 '<tr>
53 53
 	<td align="left" style="" valign="top" width=30%>{label}
54 54
 		<!-- BEGIN required --><span style="color: #ff0000">*</span><!-- END required -->
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
 		<!-- BEGIN error --><br /><span style="color: #ff0000;font-size:10px">{error}</span><!-- END error -->
58 58
 	</td>
59 59
 </tr>');
60
-	$form->addHtmlEditor('Feedback', $i.'.'.$ans, false, false, array('ToolbarSet' => 'TestAnswerFeedback', 'Width' => '600', 'Height' => '200'));
61
-	$form->display();
62
-	echo "</td>";
63
-	}?>
60
+    $form->addHtmlEditor('Feedback', $i.'.'.$ans, false, false, array('ToolbarSet' => 'TestAnswerFeedback', 'Width' => '600', 'Height' => '200'));
61
+    $form->display();
62
+    echo "</td>";
63
+    }?>
64 64
 	<form name="frm" action="javascript: void(0);" method="post">
65 65
 	 Click Ok to finish <input  type="submit" value="Ok" />
66 66
 	</form>
Please login to merge, or discard this patch.
main/exercice/hotspot_lang_conversion.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -14,19 +14,19 @@  discard block
 block discarded – undo
14 14
 $hotspot_lang_file = api_get_path(SYS_LANG_PATH);
15 15
 
16 16
 if(isset($_GET['lang'])) {
17
-	//$search = array('../','\\0','\\');
18
-	$lang = urldecode($_GET['lang']);
19
-	if (preg_match('/^[a-zA-Z0-9\._-]+$/', $lang)) {
20
-		//$lang = str_replace($search,$replace,urldecode($_GET['lang']));
21
-		if(file_exists($hotspot_lang_file . $lang . '/hotspot.inc.php'))
22
-			$hotspot_lang_file .= $lang . '/hotspot.inc.php';
23
-		else
24
-			$hotspot_lang_file .= 'english/hotspot.inc.php';
25
-	} else {
26
-		$hotspot_lang_file .= 'english/hotspot.inc.php';
27
-	}
17
+    //$search = array('../','\\0','\\');
18
+    $lang = urldecode($_GET['lang']);
19
+    if (preg_match('/^[a-zA-Z0-9\._-]+$/', $lang)) {
20
+        //$lang = str_replace($search,$replace,urldecode($_GET['lang']));
21
+        if(file_exists($hotspot_lang_file . $lang . '/hotspot.inc.php'))
22
+            $hotspot_lang_file .= $lang . '/hotspot.inc.php';
23
+        else
24
+            $hotspot_lang_file .= 'english/hotspot.inc.php';
25
+    } else {
26
+        $hotspot_lang_file .= 'english/hotspot.inc.php';
27
+    }
28 28
 } else {
29
-	$hotspot_lang_file .= 'english/hotspot.inc.php';
29
+    $hotspot_lang_file .= 'english/hotspot.inc.php';
30 30
 }
31 31
 
32 32
 $file = file($hotspot_lang_file);
@@ -35,23 +35,23 @@  discard block
 block discarded – undo
35 35
 
36 36
 foreach($file as $value)
37 37
 {
38
-	$explode = explode('=', $value);
38
+    $explode = explode('=', $value);
39 39
 
40
-	if(count($explode) > 1)
41
-	{
42
-		$explode[0] = trim($explode[0]);
43
-		$explode[0] = '&' . substr($explode[0], 1, strlen($explode[0]));
40
+    if(count($explode) > 1)
41
+    {
42
+        $explode[0] = trim($explode[0]);
43
+        $explode[0] = '&' . substr($explode[0], 1, strlen($explode[0]));
44 44
 
45
-		$explode[1] = trim($explode[1]);
46
-		$explode[1] = substr($explode[1], 0, strlen($explode[1]) - 1);
47
-		$explode[1] = str_replace('"', '', $explode[1]);
45
+        $explode[1] = trim($explode[1]);
46
+        $explode[1] = substr($explode[1], 0, strlen($explode[1]) - 1);
47
+        $explode[1] = str_replace('"', '', $explode[1]);
48 48
 
49
-		$temp[] = $explode[0] . '=' . $explode[1];
50
-	}
49
+        $temp[] = $explode[0] . '=' . $explode[1];
50
+    }
51 51
 }
52 52
 
53 53
 foreach($temp as $value)
54 54
 {
55
-	echo $value . ' ';
55
+    echo $value . ' ';
56 56
 }
57 57
 ?>
Please login to merge, or discard this patch.
main/exercice/stats.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 $result = $objExercise->read($exercise_id);
13 13
 
14 14
 if (!$result) {
15
-	api_not_allowed(true);
15
+    api_not_allowed(true);
16 16
 }
17 17
 
18 18
 $sessionId = api_get_session_id();
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
 $data = array();
30 30
 // Question title 	# of students who tool it 	Lowest score 	Average 	Highest score 	Maximum score
31 31
 $headers = array(
32
-	get_lang('Question'),
32
+    get_lang('Question'),
33 33
     get_lang('QuestionType'),
34 34
     get_lang('NumberStudentWhoSelectedIt'),
35
-	get_lang('LowestScore'),
36
-	get_lang('AverageScore'),
37
-	get_lang('HighestScore'),
38
-	get_lang('Weighting')
35
+    get_lang('LowestScore'),
36
+    get_lang('AverageScore'),
37
+    get_lang('HighestScore'),
38
+    get_lang('Weighting')
39 39
 );
40 40
 
41 41
 if (!empty($question_list)) {
42
-	foreach ($question_list as $question_id) {
42
+    foreach ($question_list as $question_id) {
43 43
         $question_obj = Question::read($question_id);
44 44
 
45 45
         $exercise_stats = ExerciseLib::get_student_stats_by_question(
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         $data[$question_id]['average_score'] = round($exercise_stats['average'], 2);
74 74
         $data[$question_id]['highest_score'] = round($exercise_stats['max'], 2);
75 75
         $data[$question_id]['max_score'] = round($question_obj->weighting, 2);
76
-	}
76
+    }
77 77
 }
78 78
 
79 79
 // Format A table
@@ -81,37 +81,37 @@  discard block
 block discarded – undo
81 81
 $row = 0;
82 82
 $column = 0;
83 83
 foreach ($headers as $header) {
84
-	$table->setHeaderContents($row, $column, $header);
85
-	$column++;
84
+    $table->setHeaderContents($row, $column, $header);
85
+    $column++;
86 86
 }
87 87
 $row++;
88 88
 foreach ($data as $row_table) {
89
-	$column = 0;
90
-	foreach ($row_table as $cell) {
91
-		$table->setCellContents($row, $column, $cell);
92
-		$table->updateCellAttributes($row, $column, 'align="center"');
93
-		$column++;
94
-	}
95
-	$table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
96
-	$row++;
89
+    $column = 0;
90
+    foreach ($row_table as $cell) {
91
+        $table->setCellContents($row, $column, $cell);
92
+        $table->updateCellAttributes($row, $column, 'align="center"');
93
+        $column++;
94
+    }
95
+    $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
96
+    $row++;
97 97
 }
98 98
 $content = $table->toHtml();
99 99
 
100 100
 // Format B
101 101
 
102 102
 $headers = array(
103
-	get_lang('Question'),
104
-	get_lang('Answer'),
105
-	get_lang('Correct'),
106
-	get_lang('NumberStudentWhoSelectedIt')
103
+    get_lang('Question'),
104
+    get_lang('Answer'),
105
+    get_lang('Correct'),
106
+    get_lang('NumberStudentWhoSelectedIt')
107 107
 );
108 108
 
109 109
 $data = array();
110 110
 
111 111
 if (!empty($question_list)) {
112 112
     $id = 0;
113
-	foreach ($question_list as $question_id) {
114
-		$question_obj = Question::read($question_id);
113
+    foreach ($question_list as $question_id) {
114
+        $question_obj = Question::read($question_id);
115 115
         $exercise_stats = ExerciseLib::get_student_stats_by_question(
116 116
             $question_id,
117 117
             $exercise_id,
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         );
121 121
 
122 122
         $answer = new Answer($question_id);
123
-		$answer_count = $answer->selectNbrAnswers();
123
+        $answer_count = $answer->selectNbrAnswers();
124 124
 
125 125
         for ($answer_id = 1; $answer_id <= $answer_count; $answer_id++) {
126 126
             $answer_info = $answer->selectAnswer($answer_id);
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
                         $correct = '';
176 176
 
177 177
                         for ($i = 1; $i <= $answer_count; $i++) {
178
-                             $is_correct_i = $answer->isCorrect($i);
179
-                             if ($is_correct_i != 0 && $is_correct_i == $answer_id) {
180
-                                 $correct = $answer->selectAnswer($i);
181
-                                 break;
182
-                             }
178
+                                $is_correct_i = $answer->isCorrect($i);
179
+                                if ($is_correct_i != 0 && $is_correct_i == $answer_id) {
180
+                                    $correct = $answer->selectAnswer($i);
181
+                                    break;
182
+                                }
183 183
                         }
184 184
                         $data[$id]['answer'] = $correct;
185 185
                         $data[$id]['correct'] = $answer_info;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
             }
246 246
             $id++;
247 247
         }
248
-	}
248
+    }
249 249
 }
250 250
 
251 251
 // Format A table
@@ -253,19 +253,19 @@  discard block
 block discarded – undo
253 253
 $row = 0;
254 254
 $column = 0;
255 255
 foreach ($headers as $header) {
256
-	$table->setHeaderContents($row, $column, $header);
257
-	$column++;
256
+    $table->setHeaderContents($row, $column, $header);
257
+    $column++;
258 258
 }
259 259
 $row++;
260 260
 foreach ($data as $row_table) {
261
-	$column = 0;
262
-	foreach ($row_table as $cell) {
263
-		$table->setCellContents($row, $column, $cell);
264
-		$table->updateCellAttributes($row, $column, 'align="center"');
265
-		$column++;
266
-	}
267
-	$table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
268
-	$row++;
261
+    $column = 0;
262
+    foreach ($row_table as $cell) {
263
+        $table->setCellContents($row, $column, $cell);
264
+        $table->updateCellAttributes($row, $column, 'align="center"');
265
+        $column++;
266
+    }
267
+    $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
268
+    $row++;
269 269
 }
270 270
 $content .= $table->toHtml();
271 271
 
Please login to merge, or discard this patch.
main/exercice/qti2.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 /**
4
- *	Code for Qti2 import integration.
5
- *	@package chamilo.exercise
6
- * 	@author Ronny Velasquez
7
- * 	@version $Id: qti2.php  2010-03-12 12:14:25Z $
8
- */
4
+     *	Code for Qti2 import integration.
5
+     *	@package chamilo.exercise
6
+     * 	@author Ronny Velasquez
7
+     * 	@version $Id: qti2.php  2010-03-12 12:14:25Z $
8
+     */
9 9
 /**
10
- * Code
11
- */
10
+     * Code
11
+     */
12 12
 // including the global Chamilo file
13 13
 require_once '../inc/global.inc.php';
14 14
 
Please login to merge, or discard this patch.
main/exercice/multiple_answer_true_false.class.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -241,13 +241,13 @@  discard block
 block discarded – undo
241 241
     }
242 242
 
243 243
     /**
244
-	 * abstract function which creates the form to create / edit the answers of the question
245
-	 * @param FormValidator $form
246
-	 */
244
+     * abstract function which creates the form to create / edit the answers of the question
245
+     * @param FormValidator $form
246
+     */
247 247
     public function processAnswersCreation($form)
248 248
     {
249
-		$questionWeighting = $nbrGoodAnswers = 0;
250
-		$objAnswer = new Answer($this->id);
249
+        $questionWeighting = $nbrGoodAnswers = 0;
250
+        $objAnswer = new Answer($this->id);
251 251
         $nb_answers = $form->getSubmitValue('nb_answers');
252 252
         //$options_count    = $form->getSubmitValue('options_count');
253 253
         $course_id = api_get_course_int_id();
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
                     $course_id,
270 270
                     $i
271 271
                 );
272
-               $correct[$i] = $last_id;
272
+                $correct[$i] = $last_id;
273 273
             }
274 274
         }
275 275
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 
281 281
         $sorted_by_position = array();
282 282
         foreach ($new_options as $item) {
283
-        	$sorted_by_position[$item['position']] = $item;
283
+            $sorted_by_position[$item['position']] = $item;
284 284
         }
285 285
 
286 286
         /* Saving quiz_question.extra values that has the correct scores of
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
         }
294 294
         $this->setExtra(implode(':', $extra_values));
295 295
 
296
-		for ($i = 1; $i <= $nb_answers; $i++) {
296
+        for ($i = 1; $i <= $nb_answers; $i++) {
297 297
             $answer = trim($form->getSubmitValue('answer['.$i.']'));
298 298
             $comment = trim($form->getSubmitValue('comment['.$i.']'));
299 299
             $goodAnswer = trim($form->getSubmitValue('correct['.$i.']'));
@@ -302,18 +302,18 @@  discard block
 block discarded – undo
302 302
                 // change the default values from the form 1 and 2 by the correct "option id" registered
303 303
                 $goodAnswer = $sorted_by_position[$goodAnswer]['id'];
304 304
             }
305
-    	    $questionWeighting += $extra_values[0]; //By default 0 has the correct answers
305
+            $questionWeighting += $extra_values[0]; //By default 0 has the correct answers
306 306
 
307
-        	$objAnswer->createAnswer($answer, $goodAnswer, $comment,'',$i);
307
+            $objAnswer->createAnswer($answer, $goodAnswer, $comment,'',$i);
308 308
         }
309 309
 
310
-    	// saves the answers into the data base
310
+        // saves the answers into the data base
311 311
         $objAnswer->save();
312 312
 
313 313
         // sets the total weighting of the question
314 314
         $this->updateWeighting($questionWeighting);
315 315
         $this->save();
316
-	}
316
+    }
317 317
 
318 318
     /**
319 319
      * @param int $feedback_type
@@ -324,17 +324,17 @@  discard block
 block discarded – undo
324 324
     function return_header($feedback_type = null, $counter = null, $score = null)
325 325
     {
326 326
         $header = parent::return_header($feedback_type, $counter, $score);
327
-  	    $header .= '<table class="'.$this->question_table_class .'">
327
+            $header .= '<table class="'.$this->question_table_class .'">
328 328
 		<tr>
329 329
 			<th>'.get_lang("Choice").'</th>
330 330
 			<th>'. get_lang("ExpectedChoice").'</th>
331 331
 			<th>'. get_lang("Answer").'</th>';
332
-			if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
333
-				$header .= '<th>'.get_lang("Comment").'</th>';
334
-			} else {
335
-				$header .= '<th>&nbsp;</th>';
336
-			}
332
+            if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
333
+                $header .= '<th>'.get_lang("Comment").'</th>';
334
+            } else {
335
+                $header .= '<th>&nbsp;</th>';
336
+            }
337 337
         $header .= '</tr>';
338 338
         return $header;
339
-	}
339
+    }
340 340
 }
Please login to merge, or discard this patch.