Completed
Push — 1.10.x ( c11148...3f49cd )
by Angel Fernando Quiroz
162:29 queued 117:01
created
main/exercice/TestCategory.php 1 patch
Spacing   +24 added lines, -24 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
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 		$categories = self::getListOfCategoriesIDForTestObject($exercise_obj);
402 402
 		foreach ($categories as $cat_id) {
403 403
 			$cat = new TestCategory($cat_id);
404
-			$cat = (array)$cat;
404
+			$cat = (array) $cat;
405 405
 			$cat['iid'] = $cat['id'];
406 406
 			$cat['title'] = $cat['name'];
407 407
 			$result[$cat['id']] = $cat;
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 		$quiz->read($exerciseId);
437 437
 		$tabQuestionList = $quiz->selectQuestionList();
438 438
 		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ?
439
-		for ($i=1; $i <= count($tabQuestionList); $i++) {
439
+		for ($i = 1; $i <= count($tabQuestionList); $i++) {
440 440
 			if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) {
441 441
 				$nbCatResult++;
442 442
 			}
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 		}
490 490
 	 	$tabcatobject = TestCategory::getCategoryListInfo("", $courseId);
491 491
 	 	$tabresult = array("0"=>get_lang('NoCategorySelected'));
492
-	 	for ($i=0; $i < count($tabcatobject); $i++) {
492
+	 	for ($i = 0; $i < count($tabcatobject); $i++) {
493 493
 	 		$tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name;
494 494
 	 	}
495 495
 	 	return $tabresult;
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
      */
614 614
     public static function returnCategoryAndTitle($questionId, $in_display_category_name = 1)
615 615
     {
616
-        $is_student = !(api_is_allowed_to_edit(null,true) || api_is_session_admin());
616
+        $is_student = !(api_is_allowed_to_edit(null, true) || api_is_session_admin());
617 617
         // @todo fix $_SESSION['objExercise']
618 618
         $objExercise = isset($_SESSION['objExercise']) ? $_SESSION['objExercise'] : null;
619 619
         if (!empty($objExercise)) {
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
     public static function sortTabByBracketLabel($in_tab)
652 652
     {
653 653
 		$tabResult = array();
654
-		$tabCatName = array();	// tab of category name
654
+		$tabCatName = array(); // tab of category name
655 655
 		while (list($cat_id, $tabquestion) = each($in_tab)) {
656 656
 			$catTitle = new TestCategory($cat_id);
657 657
 			$tabCatName[$cat_id] = $catTitle->name;
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 	 */
673 673
 	public static function getCatScoreForExeidForUserid($in_cat_id, $in_exe_id, $in_user_id)
674 674
 	{
675
-		$tbl_track_attempt		= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
675
+		$tbl_track_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
676 676
 		$tbl_question_rel_category = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
677 677
 		$in_cat_id = intval($in_cat_id);
678 678
 		$in_exe_id = intval($in_exe_id);
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
 		$table = Database::get_course_table(TABLE_QUIZ_CATEGORY);
783 783
 		$sql = "SELECT * FROM $table ORDER BY title ASC";
784 784
 		$res = Database::query($sql);
785
-		while ($row = Database::fetch_array($res,'ASSOC')) {
785
+		while ($row = Database::fetch_array($res, 'ASSOC')) {
786 786
 			$array[] = $row;
787 787
 		}
788 788
 		return $array;
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
 
850 850
 	public function getForm(& $form, $action = 'new')
851 851
 	{
852
-		switch($action) {
852
+		switch ($action) {
853 853
 			case 'new':
854 854
 				$header = get_lang('AddACategory');
855 855
 				$submit = get_lang('AddTestCategory');
@@ -921,8 +921,8 @@  discard block
 block discarded – undo
921 921
 			$return .= $warning;
922 922
 			$return .= '<table class="data_table">';
923 923
 			$return .= '<tr>';
924
-			$return .= '<th height="24">' . get_lang('Categories') . '</th>';
925
-			$return .= '<th width="70" height="24">' . get_lang('Number') . '</th></tr>';
924
+			$return .= '<th height="24">'.get_lang('Categories').'</th>';
925
+			$return .= '<th width="70" height="24">'.get_lang('Number').'</th></tr>';
926 926
 
927 927
 			$emptyCategory = array(
928 928
 				'id' => '0',
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 				$return .= '</td>';
944 944
 				$return .= '<td>';
945 945
 				$value = isset($saved_categories) && isset($saved_categories[$cat_id]) ? $saved_categories[$cat_id]['count_questions'] : -1;
946
-				$return .= '<input name="category['.$cat_id.']" value="' .$value.'" />';
946
+				$return .= '<input name="category['.$cat_id.']" value="'.$value.'" />';
947 947
 				$return .= '</td>';
948 948
 				$return .= '</tr>';
949 949
 			}
@@ -1090,20 +1090,20 @@  discard block
 block discarded – undo
1090 1090
             $tmpobj = new TestCategory($category['id']);
1091 1091
             $nb_question = $tmpobj->getCategoryQuestionsNumber();
1092 1092
             $rowname = self::protectJSDialogQuote($category['title']);
1093
-            $nb_question_label = $nb_question == 1 ? $nb_question . ' ' . get_lang('Question') : $nb_question . ' ' . get_lang('Questions');
1093
+            $nb_question_label = $nb_question == 1 ? $nb_question.' '.get_lang('Question') : $nb_question.' '.get_lang('Questions');
1094 1094
 
1095 1095
             //$html .= '<div class="sectiontitle" id="id_cat' . $category['id'] . '">';
1096
-            $content = "<span style='float:right'>" . $nb_question_label . "</span>";
1096
+            $content = "<span style='float:right'>".$nb_question_label."</span>";
1097 1097
 
1098 1098
             $content .= '<div class="sectioncomment">';
1099 1099
             $content .= $category['description'];
1100 1100
             $content .= '</div>';
1101 1101
 
1102
-            $links = '<a href="' . api_get_self() . '?action=editcategory&category_id=' . $category['id'] . '">' .
1103
-                Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
1104
-            $links .= ' <a href="' . api_get_self() . '?action=deletecategory&category_id=' . $category['id'] . '" ';
1105
-            $links .= 'onclick="return confirmDelete(\'' . self::protectJSDialogQuote(get_lang('DeleteCategoryAreYouSure') . '[' . $rowname) . '] ?\', \'id_cat' . $category['id'] . '\');">';
1106
-            $links .= Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
1102
+            $links = '<a href="'.api_get_self().'?action=editcategory&category_id='.$category['id'].'">'.
1103
+                Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
1104
+            $links .= ' <a href="'.api_get_self().'?action=deletecategory&category_id='.$category['id'].'" ';
1105
+            $links .= 'onclick="return confirmDelete(\''.self::protectJSDialogQuote(get_lang('DeleteCategoryAreYouSure').'['.$rowname).'] ?\', \'id_cat'.$category['id'].'\');">';
1106
+            $links .= Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
1107 1107
             $html .= Display::panel($content, $category['title'].$links);
1108 1108
         }
1109 1109
 
Please login to merge, or discard this patch.