Passed
Push — 1.10.x ( e0e55b...e86630 )
by Angel Fernando Quiroz
63:13 queued 13:24
created
main/exercice/question_pool.php 1 patch
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 }
173 173
 
174 174
 if (isset($_SESSION['gradebook'])){
175
-	$gradebook=	$_SESSION['gradebook'];
175
+    $gradebook=	$_SESSION['gradebook'];
176 176
 }
177 177
 
178 178
 if (!empty($gradebook) && $gradebook=='view') {
179
-	$interbreadcrumb[]= array ('url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('ToolGradebook'));
179
+    $interbreadcrumb[]= array ('url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('ToolGradebook'));
180 180
 }
181 181
 
182 182
 // if admin of course
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
 echo '</div>';
228 228
 
229 229
 if ($displayMessage != "") {
230
-	Display::display_confirmation_message($displayMessage);
231
-	$displayMessage = "";
230
+    Display::display_confirmation_message($displayMessage);
231
+    $displayMessage = "";
232 232
 }
233 233
 
234 234
 // Form
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 // Title
237 237
 echo '<legend>'.$nameTools.' - '.$titleAdd.'</legend>';
238 238
 if (isset($type)) {
239
-	echo '<input type="hidden" name="type" value="1">';
239
+    echo '<input type="hidden" name="type" value="1">';
240 240
 }
241 241
 echo '<input type="hidden" name="fromExercise" value="'.$fromExercise.'">';
242 242
 
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
 foreach ($course_list as $item) {
284 284
     $courseItemId = $item['real_id'];
285 285
     $courseInfo = api_get_course_info_by_id($courseItemId);
286
-	$course_select_list[$courseItemId] = "";
287
-	if ($courseItemId == api_get_course_int_id()) {
288
-		$course_select_list[$courseItemId] = ">&nbsp;&nbsp;&nbsp;&nbsp;";
289
-	}
290
-	$course_select_list[$courseItemId] .= $courseInfo['title'];
286
+    $course_select_list[$courseItemId] = "";
287
+    if ($courseItemId == api_get_course_int_id()) {
288
+        $course_select_list[$courseItemId] = ">&nbsp;&nbsp;&nbsp;&nbsp;";
289
+    }
290
+    $course_select_list[$courseItemId] .= $courseInfo['title'];
291 291
 }
292 292
 
293 293
 $select_course_html =  Display::select(
@@ -304,11 +304,11 @@  discard block
 block discarded – undo
304 304
     // no course selected, reset menu test / difficult� / type de reponse
305 305
     reset_menu_exo_lvl_type();
306 306
 } else {
307
-	$course_info = api_get_course_info_by_id($selected_course);
307
+    $course_info = api_get_course_info_by_id($selected_course);
308 308
 }
309 309
 // If course has changed, reset the menu default
310 310
 if ($course_id_changed) {
311
-	reset_menu_exo_lvl_type();
311
+    reset_menu_exo_lvl_type();
312 312
 }
313 313
 
314 314
 $course_id = $course_info['real_id'];
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 }
357 357
 
358 358
 if ($exercise_id_changed == 1) {
359
-	reset_menu_lvl_type();
359
+    reset_menu_lvl_type();
360 360
 }
361 361
 $select_exercise_html =  Display::select(
362 362
     'exerciseId',
@@ -434,19 +434,19 @@  discard block
 block discarded – undo
434 434
 // if we have selected an exercise in the list-box 'Filter'
435 435
 
436 436
 if ($exerciseId > 0) {
437
-	$where = '';
438
-	$from = '';
439
-	if (isset($courseCategoryId) && $courseCategoryId > 0) {
440
-		$from = ", $TBL_COURSE_REL_CATEGORY crc ";
441
-		$where .= " AND crc.c_id=$selected_course AND crc.question_id=qu.id AND crc.category_id=$courseCategoryId";
442
-	}
443
-	if (isset($exerciseLevel) && $exerciseLevel != -1) {
444
-		$where .= ' AND level='.$exerciseLevel;
445
-	}
446
-	if (isset($answerType) && $answerType > 0) {
447
-		$where .= ' AND type='.$answerType;
448
-	}
449
-	$sql = "SELECT DISTINCT
437
+    $where = '';
438
+    $from = '';
439
+    if (isset($courseCategoryId) && $courseCategoryId > 0) {
440
+        $from = ", $TBL_COURSE_REL_CATEGORY crc ";
441
+        $where .= " AND crc.c_id=$selected_course AND crc.question_id=qu.id AND crc.category_id=$courseCategoryId";
442
+    }
443
+    if (isset($exerciseLevel) && $exerciseLevel != -1) {
444
+        $where .= ' AND level='.$exerciseLevel;
445
+    }
446
+    if (isset($answerType) && $answerType > 0) {
447
+        $where .= ' AND type='.$answerType;
448
+    }
449
+    $sql = "SELECT DISTINCT
450 450
 	            id,
451 451
 	            question,
452 452
 	            type,
@@ -468,22 +468,22 @@  discard block
 block discarded – undo
468 468
         $mainQuestionList[] = $row;
469 469
     }
470 470
 } elseif ($exerciseId == -1) {
471
-	// If we have selected the option 'Orphan questions' in the list-box 'Filter'
472
-	$level_where = '';
473
-	$from = '';
474
-	if (isset($courseCategoryId) && $courseCategoryId > 0) {
475
-		$from = " INNER JOIN  $TBL_COURSE_REL_CATEGORY crc ON crc.question_id=q.id AND crc.c_id= q.c_id ";
476
-		$level_where .= " AND
471
+    // If we have selected the option 'Orphan questions' in the list-box 'Filter'
472
+    $level_where = '';
473
+    $from = '';
474
+    if (isset($courseCategoryId) && $courseCategoryId > 0) {
475
+        $from = " INNER JOIN  $TBL_COURSE_REL_CATEGORY crc ON crc.question_id=q.id AND crc.c_id= q.c_id ";
476
+        $level_where .= " AND
477 477
 		        crc.c_id = $selected_course AND
478 478
 		        crc.category_id = $courseCategoryId";
479
-	}
480
-	if (isset($exerciseLevel) && $exerciseLevel!= -1 ) {
481
-		$level_where = ' AND level='.$exerciseLevel;
482
-	}
483
-	$answer_where = '';
484
-	if (isset($answerType) && $answerType >0 -1 ) {
485
-		$answer_where = ' AND type='.$answerType;
486
-	}
479
+    }
480
+    if (isset($exerciseLevel) && $exerciseLevel!= -1 ) {
481
+        $level_where = ' AND level='.$exerciseLevel;
482
+    }
483
+    $answer_where = '';
484
+    if (isset($answerType) && $answerType >0 -1 ) {
485
+        $answer_where = ' AND type='.$answerType;
486
+    }
487 487
 
488 488
     // @todo fix this query with the new id field
489 489
     $sql = " (
@@ -525,24 +525,24 @@  discard block
 block discarded – undo
525 525
         $mainQuestionList[] = $row;
526 526
     }
527 527
 } else {
528
-	// All tests for selected course
528
+    // All tests for selected course
529 529
     // If we have not selected any option in the list-box 'Filter'
530
-	$filter = '';
531
-	$from = '';
530
+    $filter = '';
531
+    $from = '';
532 532
 
533
-	if (isset($courseCategoryId) && $courseCategoryId > 0) {
534
-		$from = ", $TBL_COURSE_REL_CATEGORY crc ";
535
-		$filter .= " AND
533
+    if (isset($courseCategoryId) && $courseCategoryId > 0) {
534
+        $from = ", $TBL_COURSE_REL_CATEGORY crc ";
535
+        $filter .= " AND
536 536
 		            crc.c_id = $selected_course AND
537 537
 		            crc.question_id = qu.id AND
538 538
 		            crc.category_id = $courseCategoryId";
539
-	}
540
-	if (isset($exerciseLevel) && $exerciseLevel != -1) {
541
-		$filter .= ' AND level='.$exerciseLevel.' ';
542
-	}
543
-	if (isset($answerType) && $answerType > 0) {
544
-		$filter .= ' AND qu.type='.$answerType.' ';
545
-	}
539
+    }
540
+    if (isset($exerciseLevel) && $exerciseLevel != -1) {
541
+        $filter .= ' AND level='.$exerciseLevel.' ';
542
+    }
543
+    if (isset($answerType) && $answerType > 0) {
544
+        $filter .= ' AND qu.type='.$answerType.' ';
545
+    }
546 546
 
547 547
     if (!empty($session_id) && $session_id != '-1') {
548 548
         $mainQuestionList = array();
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
             $mainQuestionList[] = $row;
645 645
         }
646 646
     }
647
-	// forces the value to 0
647
+    // forces the value to 0
648 648
     $exerciseId = 0;
649 649
 }
650 650
 
@@ -670,33 +670,33 @@  discard block
 block discarded – undo
670 670
 //
671 671
 if ($fromExercise <= 0) {
672 672
     // NOT IN A TEST - IN THE COURSE
673
-	if ($selected_course == api_get_course_int_id()) {
674
-		$actionLabel = get_lang('Modify');
675
-		$actionIcon1 = "edit";
676
-		$actionIcon2 = "delete";
673
+    if ($selected_course == api_get_course_int_id()) {
674
+        $actionLabel = get_lang('Modify');
675
+        $actionIcon1 = "edit";
676
+        $actionIcon2 = "delete";
677 677
         // We are in the course, question title can be a link to the question edit page
678
-		$questionTagA = 1;
678
+        $questionTagA = 1;
679 679
     } else { // NOT IN A TEST - NOT IN THE COURSE
680
-		$actionLabel = get_lang('Reuse');
681
-		$actionIcon1 = get_lang('MustBeInATest');
682
-		$actionIcon2 = "";
680
+        $actionLabel = get_lang('Reuse');
681
+        $actionIcon1 = get_lang('MustBeInATest');
682
+        $actionIcon2 = "";
683 683
         // We are not in this course, to messy if we link to the question in another course
684
-		$questionTagA = 0;
685
-	}
684
+        $questionTagA = 0;
685
+    }
686 686
 } else {
687 687
     // IN A TEST - IN THE COURSE
688
-	if ($selected_course == api_get_course_int_id()) {
689
-		$actionLabel = get_lang('Reuse');
690
-		$actionIcon1 = "add";
691
-		$actionIcon2 = "";
692
-		$questionTagA = 1;
688
+    if ($selected_course == api_get_course_int_id()) {
689
+        $actionLabel = get_lang('Reuse');
690
+        $actionIcon1 = "add";
691
+        $actionIcon2 = "";
692
+        $questionTagA = 1;
693 693
     } else {
694 694
         // IN A TEST - NOT IN THE COURSE
695
-		$actionLabel = get_lang('Reuse');
696
-		$actionIcon1 = "clone";
697
-		$actionIcon2 = "";
698
-		$questionTagA = 0;
699
-	}
695
+        $actionLabel = get_lang('Reuse');
696
+        $actionIcon1 = "clone";
697
+        $actionIcon2 = "";
698
+        $questionTagA = 0;
699
+    }
700 700
 }
701 701
 // Display table
702 702
 $header = array(
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 );
790 790
 
791 791
 if (!$nbrQuestions) {
792
-	echo get_lang('NoQuestion');
792
+    echo get_lang('NoQuestion');
793 793
 }
794 794
 
795 795
 Display::display_footer();
@@ -801,9 +801,9 @@  discard block
 block discarded – undo
801 801
 */
802 802
 function reset_menu_lvl_type()
803 803
 {
804
-	global $exerciseLevel, $answerType;
805
-	$answerType = -1;
806
-	$exerciseLevel = -1;
804
+    global $exerciseLevel, $answerType;
805
+    $answerType = -1;
806
+    $exerciseLevel = -1;
807 807
 }
808 808
 
809 809
 /**
@@ -813,10 +813,10 @@  discard block
 block discarded – undo
813 813
 */
814 814
 function reset_menu_exo_lvl_type()
815 815
 {
816
-	global $exerciseId, $courseCategoryId;
817
-	reset_menu_lvl_type();
818
-	$exerciseId = 0;
819
-	$courseCategoryId = 0;
816
+    global $exerciseId, $courseCategoryId;
817
+    reset_menu_lvl_type();
818
+    $exerciseId = 0;
819
+    $courseCategoryId = 0;
820 820
 }
821 821
 
822 822
 /**
@@ -838,17 +838,17 @@  discard block
 block discarded – undo
838 838
     $in_questionname,
839 839
     $sessionId
840 840
 ) {
841
-	$res = $in_questionname;
841
+    $res = $in_questionname;
842 842
     $sessionIcon = null;
843
-	if ($in_addA) {
843
+    if ($in_addA) {
844 844
         if (!empty($sessionId) && $sessionId != -1) {
845 845
             $sessionIcon = ' '.Display::return_icon('star.png', get_lang('Session'));
846 846
         }
847
-		$res = "<a href='admin.php?".api_get_cidreq()."&editQuestion=$in_questionid&type=$in_questiontype&fromExercise=$in_fromex'>".
847
+        $res = "<a href='admin.php?".api_get_cidreq()."&editQuestion=$in_questionid&type=$in_questiontype&fromExercise=$in_fromex'>".
848 848
             $res.$sessionIcon.
849 849
             "</a>";
850
-	}
851
-	return $res;
850
+    }
851
+    return $res;
852 852
 }
853 853
 
854 854
 /**
@@ -878,16 +878,16 @@  discard block
 block discarded – undo
878 878
     $in_session_id,
879 879
     $in_exercise_id
880 880
 ) {
881
-	$res = "";
882
-	$getParams = "&selected_course=$in_selected_course&courseCategoryId=$in_courseCategoryId&exerciseId=$in_exercise_id&exerciseLevel=$in_exerciseLevel&answerType=$in_answerType&session_id=$in_session_id";
883
-	switch ($in_action) {
884
-		case "delete" :
885
-			$res = "<a href='".api_get_self()."?".api_get_cidreq().$getParams."&delete=$in_questionid' onclick='return confirm_your_choice()'>";
886
-			$res .= Display::return_icon("delete.png", get_lang('Delete'));
887
-			$res .= "</a>";
888
-			break;
889
-		case "edit" :
890
-			$res = get_a_tag_for_question(
881
+    $res = "";
882
+    $getParams = "&selected_course=$in_selected_course&courseCategoryId=$in_courseCategoryId&exerciseId=$in_exercise_id&exerciseLevel=$in_exerciseLevel&answerType=$in_answerType&session_id=$in_session_id";
883
+    switch ($in_action) {
884
+        case "delete" :
885
+            $res = "<a href='".api_get_self()."?".api_get_cidreq().$getParams."&delete=$in_questionid' onclick='return confirm_your_choice()'>";
886
+            $res .= Display::return_icon("delete.png", get_lang('Delete'));
887
+            $res .= "</a>";
888
+            break;
889
+        case "edit" :
890
+            $res = get_a_tag_for_question(
891 891
                 1,
892 892
                 $from_exercise,
893 893
                 $in_questionid,
@@ -895,33 +895,33 @@  discard block
 block discarded – undo
895 895
                 Display::return_icon("edit.png", get_lang('Modify')),
896 896
                 $in_session_id
897 897
             );
898
-			break;
899
-		case "add":
900
-			// add if question is not already in test
901
-			$myObjEx = new Exercise();
902
-			$myObjEx->read($from_exercise);
903
-			if (!$myObjEx->isInList($in_questionid)) {
904
-				$res = "<a href='".api_get_self()."?".api_get_cidreq().$getParams."&recup=$in_questionid&fromExercise=$from_exercise'>";
905
-				$res .= Display::return_icon("view_more_stats.gif", get_lang('InsertALinkToThisQuestionInTheExercise'));
906
-				$res .= "</a>";
898
+            break;
899
+        case "add":
900
+            // add if question is not already in test
901
+            $myObjEx = new Exercise();
902
+            $myObjEx->read($from_exercise);
903
+            if (!$myObjEx->isInList($in_questionid)) {
904
+                $res = "<a href='".api_get_self()."?".api_get_cidreq().$getParams."&recup=$in_questionid&fromExercise=$from_exercise'>";
905
+                $res .= Display::return_icon("view_more_stats.gif", get_lang('InsertALinkToThisQuestionInTheExercise'));
906
+                $res .= "</a>";
907 907
             } else {
908
-				$res = "-";
909
-			}
910
-			unset($myObjEx);
911
-			break;
912
-		case "clone":
908
+                $res = "-";
909
+            }
910
+            unset($myObjEx);
911
+            break;
912
+        case "clone":
913 913
             $url = api_get_self()."?".api_get_cidreq().$getParams."&question_copy=$in_questionid&course_id=$in_selected_course&fromExercise=$from_exercise";
914 914
             $res = Display::url(
915 915
                 Display::return_icon('cd.gif', get_lang('ReUseACopyInCurrentTest')),
916 916
                 $url
917 917
             );
918
-			break;
919
-		default :
920
-			$res = $in_action;
921
-			break;
922
-	}
918
+            break;
919
+        default :
920
+            $res = $in_action;
921
+            break;
922
+    }
923 923
 
924
-	return $res;
924
+    return $res;
925 925
 }
926 926
 
927 927
 /**
@@ -930,14 +930,14 @@  discard block
 block discarded – undo
930 930
  */
931 931
 function get_question_type_for_question($in_selectedcourse, $in_questionid)
932 932
 {
933
-	$myObjQuestion = Question::read($in_questionid, $in_selectedcourse);
933
+    $myObjQuestion = Question::read($in_questionid, $in_selectedcourse);
934 934
     $questionType = null;
935 935
     if (!empty($myObjQuestion)) {
936 936
         list($typeImg, $typeExpl) = $myObjQuestion->get_type_icon_html();
937 937
         $questionType = Display::tag('div', Display::return_icon($typeImg, $typeExpl, array(), 32), array());
938 938
         unset($myObjQuestion);
939 939
     }
940
-	return $questionType;
940
+    return $questionType;
941 941
 }
942 942
 
943 943
 /**
@@ -946,6 +946,6 @@  discard block
 block discarded – undo
946 946
  */
947 947
 function get_question_categorie_for_question($in_courseid, $in_questionid)
948 948
 {
949
-	$cat = TestCategory::getCategoryNameForQuestion($in_questionid, $in_courseid);
950
-	return $cat;
949
+    $cat = TestCategory::getCategoryNameForQuestion($in_questionid, $in_courseid);
950
+    return $cat;
951 951
 }
Please login to merge, or discard this patch.
main/gradebook/gradebook_display_certificate.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -162,17 +162,17 @@
 block discarded – undo
162 162
 
163 163
     if ($form->validate()) {
164 164
         $officialCode = $form->getSubmitValue('filter');
165
-         if ($officialCode == 'all') {
165
+            if ($officialCode == 'all') {
166 166
             $certificate_list = GradebookUtils::get_list_users_certificates($cat_id);
167 167
         } else {
168
-             $userList = UserManager::getUsersByOfficialCode($officialCode);
169
-             if (!empty($userList)) {
170
-                 $certificate_list = GradebookUtils::get_list_users_certificates(
171
-                     $cat_id,
172
-                     $userList
173
-                 );
174
-             }
175
-         }
168
+                $userList = UserManager::getUsersByOfficialCode($officialCode);
169
+                if (!empty($userList)) {
170
+                    $certificate_list = GradebookUtils::get_list_users_certificates(
171
+                        $cat_id,
172
+                        $userList
173
+                    );
174
+                }
175
+            }
176 176
     } else {
177 177
         $certificate_list = GradebookUtils::get_list_users_certificates($cat_id);
178 178
     }
Please login to merge, or discard this patch.
main/gradebook/gradebook_add_user.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -18,53 +18,53 @@
 block discarded – undo
18 18
 $newstudents = $evaluation[0]->get_not_subscribed_students();
19 19
 
20 20
 if (count($newstudents) == '0') {
21
-	header('Location: gradebook_view_result.php?nouser=&selecteval=' . Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq());
22
-	exit;
21
+    header('Location: gradebook_view_result.php?nouser=&selecteval=' . Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq());
22
+    exit;
23 23
 }
24 24
 $add_user_form= new EvalForm(EvalForm :: TYPE_ADD_USERS_TO_EVAL,
25
-							 $evaluation[0],
26
-							 null,
27
-							 'add_users_to_evaluation',
28
-							 null,
29
-							 api_get_self() . '?selecteval=' . Security::remove_XSS($_GET['selecteval']),
30
-							 Security::remove_XSS($_GET['firstletter']),
31
-							 $newstudents);
25
+                                $evaluation[0],
26
+                                null,
27
+                                'add_users_to_evaluation',
28
+                                null,
29
+                                api_get_self() . '?selecteval=' . Security::remove_XSS($_GET['selecteval']),
30
+                                Security::remove_XSS($_GET['firstletter']),
31
+                                $newstudents);
32 32
 
33 33
 if ( isset($_POST['submit_button']) ) {
34
-	$users= is_array($_POST['add_users']) ? $_POST['add_users'] : array ();
35
-	foreach ($users as $key => $value){
36
-		$users[$key]= intval($value);
37
-	}
34
+    $users= is_array($_POST['add_users']) ? $_POST['add_users'] : array ();
35
+    foreach ($users as $key => $value){
36
+        $users[$key]= intval($value);
37
+    }
38 38
 
39
-	if (count($users) == 0) {
40
-		header('Location: ' . api_get_self() . '?erroroneuser=&selecteval=' .Security::remove_XSS($_GET['selecteval']));
41
-		exit;
42
-	} else {
43
-		foreach ($users as $user_id) {
44
-			$result= new Result();
45
-			$result->set_user_id($user_id);
46
-			$result->set_evaluation_id($_GET['selecteval']);
47
-			$result->add();
48
-			}
49
-		}
50
-	header('Location: gradebook_view_result.php?adduser=&selecteval=' .Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq());
51
-	exit;
52
-	} elseif ($_POST['firstLetterUser']) {
53
-		$firstletter= $_POST['firstLetterUser'];
54
-		if (!empty ($firstletter)) {
55
-			header('Location: ' . api_get_self() . '?firstletter=' . Security::remove_XSS($firstletter) . '&selecteval=' . Security::remove_XSS($_GET['selecteval']));
56
-			exit;
57
-		}
39
+    if (count($users) == 0) {
40
+        header('Location: ' . api_get_self() . '?erroroneuser=&selecteval=' .Security::remove_XSS($_GET['selecteval']));
41
+        exit;
42
+    } else {
43
+        foreach ($users as $user_id) {
44
+            $result= new Result();
45
+            $result->set_user_id($user_id);
46
+            $result->set_evaluation_id($_GET['selecteval']);
47
+            $result->add();
48
+            }
49
+        }
50
+    header('Location: gradebook_view_result.php?adduser=&selecteval=' .Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq());
51
+    exit;
52
+    } elseif ($_POST['firstLetterUser']) {
53
+        $firstletter= $_POST['firstLetterUser'];
54
+        if (!empty ($firstletter)) {
55
+            header('Location: ' . api_get_self() . '?firstletter=' . Security::remove_XSS($firstletter) . '&selecteval=' . Security::remove_XSS($_GET['selecteval']));
56
+            exit;
57
+        }
58 58
 }
59 59
 
60 60
 $interbreadcrumb[]= array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('Gradebook'));
61 61
 $interbreadcrumb[]= array(
62
-	'url' => 'gradebook_view_result.php?selecteval=' .Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq(),
63
-	'name' => get_lang('ViewResult')
62
+    'url' => 'gradebook_view_result.php?selecteval=' .Security::remove_XSS($_GET['selecteval']).'&'.api_get_cidreq(),
63
+    'name' => get_lang('ViewResult')
64 64
 );
65 65
 Display :: display_header(get_lang('AddUserToEval'));
66 66
 if (isset ($_GET['erroroneuser'])){
67
-	Display :: display_warning_message(get_lang('AtLeastOneUser'),false);
67
+    Display :: display_warning_message(get_lang('AtLeastOneUser'),false);
68 68
 }
69 69
 DisplayGradebook :: display_header_result($evaluation[0], null, 0,0);
70 70
 echo '<div class="main">';
Please login to merge, or discard this patch.
main/gradebook/gradebook.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 /**
4
- * Script
5
- * @package chamilo.gradebook
6
- */
4
+     * Script
5
+     * @package chamilo.gradebook
6
+     */
7 7
 // $cidReset : This is the main difference with gradebook.php, here we say,
8 8
 // basically, that we are inside a course, and many things depend from that
9 9
 $cidReset= true;
Please login to merge, or discard this patch.
main/gradebook/lib/user_data_generator.class.php 1 patch
Indentation   +346 added lines, -346 removed lines patch added patch discarded remove patch
@@ -10,28 +10,28 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class UserDataGenerator
12 12
 {
13
-	// Sorting types constants
14
-	const UDG_SORT_TYPE = 1;
15
-	const UDG_SORT_NAME = 2;
16
-	const UDG_SORT_COURSE = 4;
17
-	const UDG_SORT_CATEGORY = 8;
18
-	const UDG_SORT_AVERAGE = 16;
19
-	const UDG_SORT_SCORE = 32;
20
-	const UDG_SORT_MASK = 64;
21
-
22
-	const UDG_SORT_ASC = 128;
23
-	const UDG_SORT_DESC = 256;
24
-
25
-	private $items;
26
-	private $userid;
27
-
28
-	private $coursecodecache;
29
-	private $categorycache;
30
-	private $scorecache;
31
-	private $avgcache;
32
-
33
-	public function UserDataGenerator($userid, $evals = array(), $links = array())
34
-	{
13
+    // Sorting types constants
14
+    const UDG_SORT_TYPE = 1;
15
+    const UDG_SORT_NAME = 2;
16
+    const UDG_SORT_COURSE = 4;
17
+    const UDG_SORT_CATEGORY = 8;
18
+    const UDG_SORT_AVERAGE = 16;
19
+    const UDG_SORT_SCORE = 32;
20
+    const UDG_SORT_MASK = 64;
21
+
22
+    const UDG_SORT_ASC = 128;
23
+    const UDG_SORT_DESC = 256;
24
+
25
+    private $items;
26
+    private $userid;
27
+
28
+    private $coursecodecache;
29
+    private $categorycache;
30
+    private $scorecache;
31
+    private $avgcache;
32
+
33
+    public function UserDataGenerator($userid, $evals = array(), $links = array())
34
+    {
35 35
         $this->userid = $userid;
36 36
         $evals_filtered = array();
37 37
         $result = array();
@@ -62,330 +62,330 @@  discard block
 block discarded – undo
62 62
         $this->avgcache = null;
63 63
     }
64 64
 
65
-	/**
66
-	 * Get total number of items (rows)
67
-	 */
68
-	public function get_total_items_count()
69
-	{
70
-		return count($this->items);
71
-	}
72
-
73
-	/**
74
-	 * Get actual array data
75
-	 * @return array 2-dimensional array - each array contains the elements:
76
-	 * 0: eval/link object
77
-	 * 1: item name
78
-	 * 2: course name
79
-	 * 3: category name
80
-	 * 4: average score
81
-	 * 5: student's score
82
-	 * 6: student's score as custom display (only if custom scoring enabled)
83
-	 */
84
-	public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false)
85
-	{
86
-		// do some checks on count, redefine if invalid value
87
-		if (!isset($count)) {
88
-			$count = count ($this->items) - $start;
89
-		}
90
-		if ($count < 0) {
91
-			$count = 0;
92
-		}
93
-		$allitems = $this->items;
94
-
95
-		// sort users array
96
-		if ($sorting & self :: UDG_SORT_TYPE) {
97
-			usort($allitems, array('UserDataGenerator', 'sort_by_type'));
98
-		}elseif ($sorting & self :: UDG_SORT_NAME) {
99
-			usort($allitems, array('UserDataGenerator', 'sort_by_name'));
100
-		} elseif ($sorting & self :: UDG_SORT_COURSE) {
101
-			usort($allitems, array('UserDataGenerator', 'sort_by_course'));
102
-		} elseif ($sorting & self :: UDG_SORT_CATEGORY) {
103
-			usort($allitems, array('UserDataGenerator', 'sort_by_category'));
104
-		} elseif ($sorting & self :: UDG_SORT_AVERAGE) {
105
-			// if user sorts on average scores, first calculate them and cache them
106
-			foreach ($allitems as $item) {
107
-				$this->avgcache[$item->get_item_type() . $item->get_id()]= $item->calc_score();
108
-			}
109
-			usort($allitems, array('UserDataGenerator', 'sort_by_average'));
110
-		} elseif ($sorting & self :: UDG_SORT_SCORE) {
111
-			// if user sorts on student's scores, first calculate them and cache them
112
-			foreach ($allitems as $item) {
113
-				$this->scorecache[$item->get_item_type() . $item->get_id()]
114
-					= $item->calc_score($this->userid);
115
-			}
116
-			usort($allitems, array('UserDataGenerator', 'sort_by_score'));
117
-		} elseif ($sorting & self :: UDG_SORT_MASK) {
118
-			// if user sorts on student's masks, first calculate scores and cache them
119
-			foreach ($allitems as $item) {
120
-				$this->scorecache[$item->get_item_type() . $item->get_id()]
121
-					= $item->calc_score($this->userid);
122
-			}
123
-			usort($allitems, array('UserDataGenerator', 'sort_by_mask'));
124
-		}
125
-
126
-		if ($sorting & self :: UDG_SORT_DESC) {
127
-			$allitems = array_reverse($allitems);
128
-		}
129
-		// select the items we have to display
130
-		$visibleitems = array_slice($allitems, $start, $count);
131
-
132
-		// fill score cache if not done yet
133
-		if (!isset ($this->scorecache)) {
134
-			foreach ($visibleitems as $item) {
135
-				$this->scorecache[$item->get_item_type() . $item->get_id()]
136
-					= $item->calc_score($this->userid);
137
-			}
138
-
139
-		}
140
-		// generate the data to display
141
-		$scoredisplay = ScoreDisplay :: instance();
142
-		$data = array();
143
-		foreach ($visibleitems as $item) {
144
-			$row = array ();
145
-			$row[] = $item;
146
-			$row[] = $item->get_name();
147
-			$row[] = $this->build_course_name($item);
148
-			$row[] = $this->build_category_name($item);
149
-			$row[] = $this->build_average_column($item, $ignore_score_color);
150
-			$row[] = $this->build_result_column($item, $ignore_score_color);
151
-			if ($scoredisplay->is_custom())
152
-				$row[] = $this->build_mask_column($item, $ignore_score_color);
153
-			$data[] = $row;
154
-		}
155
-		return $data;
156
-	}
157
-
158
-	/**
159
-	 * @param $item1
160
-	 * @param $item2
161
-	 * @return int
162
-	 */
163
-	function sort_by_type($item1, $item2)
164
-	{
165
-		if ($item1->get_item_type() == $item2->get_item_type()) {
166
-			return $this->sort_by_name($item1,$item2);
167
-		} else {
168
-			return ($item1->get_item_type() < $item2->get_item_type() ? -1 : 1);
169
-		}
170
-	}
171
-
172
-	/**
173
-	 * @param $item1
174
-	 * @param $item2
175
-	 * @return int
176
-	 */
177
-	function sort_by_course($item1, $item2)
178
-	{
179
-		$name1 = api_strtolower($this->get_course_name_from_code_cached($item1->get_course_code()));
180
-		$name2 = api_strtolower($this->get_course_name_from_code_cached($item2->get_course_code()));
181
-		return api_strnatcmp($name1, $name2);
182
-	}
183
-
184
-	/**
185
-	 * @param $item1
186
-	 * @param $item2
187
-	 * @return int
188
-	 */
189
-	function sort_by_category($item1, $item2)
190
-	{
191
-		$cat1 = $this->get_category_cached($item1->get_category_id());
192
-		$cat2 = $this->get_category_cached($item2->get_category_id());
193
-		$name1 = api_strtolower($this->get_category_name_to_display($cat1));
194
-		$name2 = api_strtolower($this->get_category_name_to_display($cat2));
195
-
196
-		return api_strnatcmp($name1, $name2);
197
-	}
198
-
199
-	/**
200
-	 * @param $item1
201
-	 * @param $item2
202
-	 * @return int
203
-	 */
204
-	function sort_by_name($item1, $item2)
205
-	{
206
-		return api_strnatcmp($item1->get_name(),$item2->get_name());
207
-	}
208
-
209
-	/**
210
-	 * @param $item1
211
-	 * @param $item2
212
-	 * @return int
213
-	 */
214
-	function sort_by_average($item1, $item2)
215
-	{
216
-		$score1 = $this->avgcache[$item1->get_item_type() . $item1->get_id()];
217
-		$score2 = $this->avgcache[$item2->get_item_type() . $item2->get_id()];
218
-
219
-		return $this->compare_scores($score1, $score2);
220
-	}
221
-
222
-	/**
223
-	 * @param $item1
224
-	 * @param $item2
225
-	 * @return int
226
-	 */
227
-	function sort_by_score($item1, $item2)
228
-	{
229
-		$score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()];
230
-		$score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()];
231
-
232
-		return $this->compare_scores($score1, $score2);
233
-	}
234
-
235
-	/**
236
-	 * @param $item1
237
-	 * @param $item2
238
-	 * @return int
239
-	 */
240
-	function sort_by_mask($item1, $item2)
241
-	{
242
-		$score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()];
243
-		$score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()];
244
-
245
-		return ScoreDisplay :: compare_scores_by_custom_display($score1, $score2);
246
-	}
247
-
248
-	/**
249
-	 * @param $score1
250
-	 * @param $score2
251
-	 * @return int
252
-	 */
253
-	function compare_scores($score1, $score2)
254
-	{
255
-		if (!isset($score1)) {
256
-			return (isset($score2) ? 1 : 0);
257
-		} elseif (!isset($score2)) {
258
-			return -1;
259
-		} elseif (($score1[0]/$score1[1]) == ($score2[0]/$score2[1])) {
260
-			return 0;
261
-		} else {
262
-			return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1);
263
-		}
264
-	}
265
-
266
-	/**
267
-	 * @param $item
268
-	 * @return mixed
269
-	 */
270
-	private function build_course_name($item)
271
-	{
272
-		return $this->get_course_name_from_code_cached($item->get_course_code());
273
-	}
274
-
275
-	/**
276
-	 * @param $item
277
-	 * @return string
278
-	 */
279
-	private function build_category_name($item)
280
-	{
281
-		$cat = $this->get_category_cached($item->get_category_id());
282
-
283
-		return $this->get_category_name_to_display($cat);
284
-	}
285
-
286
-	/**
287
-	 * @param $item
288
-	 * @param $ignore_score_color
289
-	 * @return string
290
-	 */
291
-	private function build_average_column($item, $ignore_score_color)
292
-	{
293
-		if (isset($this->avgcache)) {
294
-			$avgscore = $this->avgcache[$item->get_item_type() . $item->get_id()];
295
-		} else {
296
-			$avgscore = $item->calc_score();
297
-		}
298
-
299
-		$scoredisplay = ScoreDisplay :: instance();
300
-		$displaytype = SCORE_AVERAGE;
301
-		/*if ($ignore_score_color)
65
+    /**
66
+     * Get total number of items (rows)
67
+     */
68
+    public function get_total_items_count()
69
+    {
70
+        return count($this->items);
71
+    }
72
+
73
+    /**
74
+     * Get actual array data
75
+     * @return array 2-dimensional array - each array contains the elements:
76
+     * 0: eval/link object
77
+     * 1: item name
78
+     * 2: course name
79
+     * 3: category name
80
+     * 4: average score
81
+     * 5: student's score
82
+     * 6: student's score as custom display (only if custom scoring enabled)
83
+     */
84
+    public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false)
85
+    {
86
+        // do some checks on count, redefine if invalid value
87
+        if (!isset($count)) {
88
+            $count = count ($this->items) - $start;
89
+        }
90
+        if ($count < 0) {
91
+            $count = 0;
92
+        }
93
+        $allitems = $this->items;
94
+
95
+        // sort users array
96
+        if ($sorting & self :: UDG_SORT_TYPE) {
97
+            usort($allitems, array('UserDataGenerator', 'sort_by_type'));
98
+        }elseif ($sorting & self :: UDG_SORT_NAME) {
99
+            usort($allitems, array('UserDataGenerator', 'sort_by_name'));
100
+        } elseif ($sorting & self :: UDG_SORT_COURSE) {
101
+            usort($allitems, array('UserDataGenerator', 'sort_by_course'));
102
+        } elseif ($sorting & self :: UDG_SORT_CATEGORY) {
103
+            usort($allitems, array('UserDataGenerator', 'sort_by_category'));
104
+        } elseif ($sorting & self :: UDG_SORT_AVERAGE) {
105
+            // if user sorts on average scores, first calculate them and cache them
106
+            foreach ($allitems as $item) {
107
+                $this->avgcache[$item->get_item_type() . $item->get_id()]= $item->calc_score();
108
+            }
109
+            usort($allitems, array('UserDataGenerator', 'sort_by_average'));
110
+        } elseif ($sorting & self :: UDG_SORT_SCORE) {
111
+            // if user sorts on student's scores, first calculate them and cache them
112
+            foreach ($allitems as $item) {
113
+                $this->scorecache[$item->get_item_type() . $item->get_id()]
114
+                    = $item->calc_score($this->userid);
115
+            }
116
+            usort($allitems, array('UserDataGenerator', 'sort_by_score'));
117
+        } elseif ($sorting & self :: UDG_SORT_MASK) {
118
+            // if user sorts on student's masks, first calculate scores and cache them
119
+            foreach ($allitems as $item) {
120
+                $this->scorecache[$item->get_item_type() . $item->get_id()]
121
+                    = $item->calc_score($this->userid);
122
+            }
123
+            usort($allitems, array('UserDataGenerator', 'sort_by_mask'));
124
+        }
125
+
126
+        if ($sorting & self :: UDG_SORT_DESC) {
127
+            $allitems = array_reverse($allitems);
128
+        }
129
+        // select the items we have to display
130
+        $visibleitems = array_slice($allitems, $start, $count);
131
+
132
+        // fill score cache if not done yet
133
+        if (!isset ($this->scorecache)) {
134
+            foreach ($visibleitems as $item) {
135
+                $this->scorecache[$item->get_item_type() . $item->get_id()]
136
+                    = $item->calc_score($this->userid);
137
+            }
138
+
139
+        }
140
+        // generate the data to display
141
+        $scoredisplay = ScoreDisplay :: instance();
142
+        $data = array();
143
+        foreach ($visibleitems as $item) {
144
+            $row = array ();
145
+            $row[] = $item;
146
+            $row[] = $item->get_name();
147
+            $row[] = $this->build_course_name($item);
148
+            $row[] = $this->build_category_name($item);
149
+            $row[] = $this->build_average_column($item, $ignore_score_color);
150
+            $row[] = $this->build_result_column($item, $ignore_score_color);
151
+            if ($scoredisplay->is_custom())
152
+                $row[] = $this->build_mask_column($item, $ignore_score_color);
153
+            $data[] = $row;
154
+        }
155
+        return $data;
156
+    }
157
+
158
+    /**
159
+     * @param $item1
160
+     * @param $item2
161
+     * @return int
162
+     */
163
+    function sort_by_type($item1, $item2)
164
+    {
165
+        if ($item1->get_item_type() == $item2->get_item_type()) {
166
+            return $this->sort_by_name($item1,$item2);
167
+        } else {
168
+            return ($item1->get_item_type() < $item2->get_item_type() ? -1 : 1);
169
+        }
170
+    }
171
+
172
+    /**
173
+     * @param $item1
174
+     * @param $item2
175
+     * @return int
176
+     */
177
+    function sort_by_course($item1, $item2)
178
+    {
179
+        $name1 = api_strtolower($this->get_course_name_from_code_cached($item1->get_course_code()));
180
+        $name2 = api_strtolower($this->get_course_name_from_code_cached($item2->get_course_code()));
181
+        return api_strnatcmp($name1, $name2);
182
+    }
183
+
184
+    /**
185
+     * @param $item1
186
+     * @param $item2
187
+     * @return int
188
+     */
189
+    function sort_by_category($item1, $item2)
190
+    {
191
+        $cat1 = $this->get_category_cached($item1->get_category_id());
192
+        $cat2 = $this->get_category_cached($item2->get_category_id());
193
+        $name1 = api_strtolower($this->get_category_name_to_display($cat1));
194
+        $name2 = api_strtolower($this->get_category_name_to_display($cat2));
195
+
196
+        return api_strnatcmp($name1, $name2);
197
+    }
198
+
199
+    /**
200
+     * @param $item1
201
+     * @param $item2
202
+     * @return int
203
+     */
204
+    function sort_by_name($item1, $item2)
205
+    {
206
+        return api_strnatcmp($item1->get_name(),$item2->get_name());
207
+    }
208
+
209
+    /**
210
+     * @param $item1
211
+     * @param $item2
212
+     * @return int
213
+     */
214
+    function sort_by_average($item1, $item2)
215
+    {
216
+        $score1 = $this->avgcache[$item1->get_item_type() . $item1->get_id()];
217
+        $score2 = $this->avgcache[$item2->get_item_type() . $item2->get_id()];
218
+
219
+        return $this->compare_scores($score1, $score2);
220
+    }
221
+
222
+    /**
223
+     * @param $item1
224
+     * @param $item2
225
+     * @return int
226
+     */
227
+    function sort_by_score($item1, $item2)
228
+    {
229
+        $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()];
230
+        $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()];
231
+
232
+        return $this->compare_scores($score1, $score2);
233
+    }
234
+
235
+    /**
236
+     * @param $item1
237
+     * @param $item2
238
+     * @return int
239
+     */
240
+    function sort_by_mask($item1, $item2)
241
+    {
242
+        $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()];
243
+        $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()];
244
+
245
+        return ScoreDisplay :: compare_scores_by_custom_display($score1, $score2);
246
+    }
247
+
248
+    /**
249
+     * @param $score1
250
+     * @param $score2
251
+     * @return int
252
+     */
253
+    function compare_scores($score1, $score2)
254
+    {
255
+        if (!isset($score1)) {
256
+            return (isset($score2) ? 1 : 0);
257
+        } elseif (!isset($score2)) {
258
+            return -1;
259
+        } elseif (($score1[0]/$score1[1]) == ($score2[0]/$score2[1])) {
260
+            return 0;
261
+        } else {
262
+            return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1);
263
+        }
264
+    }
265
+
266
+    /**
267
+     * @param $item
268
+     * @return mixed
269
+     */
270
+    private function build_course_name($item)
271
+    {
272
+        return $this->get_course_name_from_code_cached($item->get_course_code());
273
+    }
274
+
275
+    /**
276
+     * @param $item
277
+     * @return string
278
+     */
279
+    private function build_category_name($item)
280
+    {
281
+        $cat = $this->get_category_cached($item->get_category_id());
282
+
283
+        return $this->get_category_name_to_display($cat);
284
+    }
285
+
286
+    /**
287
+     * @param $item
288
+     * @param $ignore_score_color
289
+     * @return string
290
+     */
291
+    private function build_average_column($item, $ignore_score_color)
292
+    {
293
+        if (isset($this->avgcache)) {
294
+            $avgscore = $this->avgcache[$item->get_item_type() . $item->get_id()];
295
+        } else {
296
+            $avgscore = $item->calc_score();
297
+        }
298
+
299
+        $scoredisplay = ScoreDisplay :: instance();
300
+        $displaytype = SCORE_AVERAGE;
301
+        /*if ($ignore_score_color)
302 302
 			$displaytype |= SCORE_IGNORE_SPLIT;
303 303
         */
304
-		return $scoredisplay->display_score($avgscore, $displaytype);
305
-	}
306
-
307
-	/**
308
-	 * @param $item
309
-	 * @param $ignore_score_color
310
-	 * @return string
311
-	 */
312
-	private function build_result_column($item, $ignore_score_color)
313
-	{
314
-		$studscore = $this->scorecache[$item->get_item_type() . $item->get_id()];
315
-		$scoredisplay = ScoreDisplay :: instance();
316
-		$displaytype = SCORE_DIV_PERCENT;
317
-		if ($ignore_score_color) {
318
-			$displaytype |= SCORE_IGNORE_SPLIT;
319
-		}
320
-
321
-		return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_DEFAULT);
322
-	}
323
-
324
-	/**
325
-	 * @param $item
326
-	 * @param $ignore_score_color
327
-	 * @return string
328
-	 */
329
-	private function build_mask_column($item, $ignore_score_color)
330
-	{
331
-		$studscore = $this->scorecache[$item->get_item_type() . $item->get_id()];
332
-		$scoredisplay = ScoreDisplay :: instance();
333
-		$displaytype = SCORE_DIV_PERCENT;
334
-		if ($ignore_score_color) {
335
-			$displaytype |= SCORE_IGNORE_SPLIT;
336
-		}
337
-		return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_CUSTOM);
338
-	}
339
-
340
-	/**
341
-	 * @param $coursecode
342
-	 * @return mixed
343
-	 */
344
-	private function get_course_name_from_code_cached($coursecode)
345
-	{
346
-		if (isset ($this->coursecodecache)
347
-			&& isset ($this->coursecodecache[$coursecode])) {
348
-			return $this->coursecodecache[$coursecode];
349
-		} else {
350
-			$name = CourseManager::getCourseNameFromCode($coursecode);
351
-			$this->coursecodecache[$coursecode] = $name;
352
-			return $name;
353
-		}
354
-	}
355
-
356
-	/**
357
-	 * @param $category_id
358
-	 * @return null
359
-	 */
360
-	private function get_category_cached($category_id)
361
-	{
362
-		if (isset ($this->categorycache)
363
-			&& isset ($this->categorycache[$category_id])) {
364
-			return $this->categorycache[$category_id];
365
-		}else {
366
-			$cat = Category::load($category_id);
367
-			if (isset($cat)){
368
-				$this->categorycache[$category_id] = $cat[0];
369
-				return $cat[0];
370
-			}else
371
-				return null;
372
-		}
373
-	}
374
-
375
-	/**
376
-	 * @param $cat
377
-	 * @return string
378
-	 */
379
-	private function get_category_name_to_display($cat)
380
-	{
381
-		if (isset($cat)) {
382
-			if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null){
383
-				return '';
384
-			} else {
385
-				return $cat->get_name();
386
-			}
387
-		} else {
388
-			return '';
389
-		}
390
-	}
304
+        return $scoredisplay->display_score($avgscore, $displaytype);
305
+    }
306
+
307
+    /**
308
+     * @param $item
309
+     * @param $ignore_score_color
310
+     * @return string
311
+     */
312
+    private function build_result_column($item, $ignore_score_color)
313
+    {
314
+        $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()];
315
+        $scoredisplay = ScoreDisplay :: instance();
316
+        $displaytype = SCORE_DIV_PERCENT;
317
+        if ($ignore_score_color) {
318
+            $displaytype |= SCORE_IGNORE_SPLIT;
319
+        }
320
+
321
+        return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_DEFAULT);
322
+    }
323
+
324
+    /**
325
+     * @param $item
326
+     * @param $ignore_score_color
327
+     * @return string
328
+     */
329
+    private function build_mask_column($item, $ignore_score_color)
330
+    {
331
+        $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()];
332
+        $scoredisplay = ScoreDisplay :: instance();
333
+        $displaytype = SCORE_DIV_PERCENT;
334
+        if ($ignore_score_color) {
335
+            $displaytype |= SCORE_IGNORE_SPLIT;
336
+        }
337
+        return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_CUSTOM);
338
+    }
339
+
340
+    /**
341
+     * @param $coursecode
342
+     * @return mixed
343
+     */
344
+    private function get_course_name_from_code_cached($coursecode)
345
+    {
346
+        if (isset ($this->coursecodecache)
347
+            && isset ($this->coursecodecache[$coursecode])) {
348
+            return $this->coursecodecache[$coursecode];
349
+        } else {
350
+            $name = CourseManager::getCourseNameFromCode($coursecode);
351
+            $this->coursecodecache[$coursecode] = $name;
352
+            return $name;
353
+        }
354
+    }
355
+
356
+    /**
357
+     * @param $category_id
358
+     * @return null
359
+     */
360
+    private function get_category_cached($category_id)
361
+    {
362
+        if (isset ($this->categorycache)
363
+            && isset ($this->categorycache[$category_id])) {
364
+            return $this->categorycache[$category_id];
365
+        }else {
366
+            $cat = Category::load($category_id);
367
+            if (isset($cat)){
368
+                $this->categorycache[$category_id] = $cat[0];
369
+                return $cat[0];
370
+            }else
371
+                return null;
372
+        }
373
+    }
374
+
375
+    /**
376
+     * @param $cat
377
+     * @return string
378
+     */
379
+    private function get_category_name_to_display($cat)
380
+    {
381
+        if (isset($cat)) {
382
+            if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null){
383
+                return '';
384
+            } else {
385
+                return $cat->get_name();
386
+            }
387
+        } else {
388
+            return '';
389
+        }
390
+    }
391 391
 }
Please login to merge, or discard this patch.
main/gradebook/lib/fe/userform.class.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -9,71 +9,71 @@
 block discarded – undo
9 9
  */
10 10
 class UserForm extends FormValidator
11 11
 {
12
-	const TYPE_USER_INFO= 1;
13
-	const TYPE_SIMPLE_SEARCH = 3;
14
-	/**
15
-	 * Builds a form containing form items based on a given parameter
16
-	 * @param int form_type 1 = user_info
17
-	 * @param user array
18
-	 * @param string form name
19
-	 * @param method
20
-	 * @param action
21
-	 */
22
-	public function UserForm($form_type, $user, $form_name, $method= 'post', $action= null)
23
-	{
24
-		parent :: __construct($form_name, $method, $action);
25
-		$this->form_type= $form_type;
26
-		if (isset ($user)) {
27
-			$this->user_info= $user;
28
-		}
29
-		if (isset ($result_object)) {
30
-			$this->result_object= $result_object;
31
-		}
32
-		if ($this->form_type == self :: TYPE_USER_INFO) {
33
-			$this->build_user_info_form();
34
-		}
35
-		elseif ($this->form_type == self :: TYPE_SIMPLE_SEARCH) {
36
-			$this->build_simple_search();
37
-		}
38
-		$this->setDefaults();
39
-	}
12
+    const TYPE_USER_INFO= 1;
13
+    const TYPE_SIMPLE_SEARCH = 3;
14
+    /**
15
+     * Builds a form containing form items based on a given parameter
16
+     * @param int form_type 1 = user_info
17
+     * @param user array
18
+     * @param string form name
19
+     * @param method
20
+     * @param action
21
+     */
22
+    public function UserForm($form_type, $user, $form_name, $method= 'post', $action= null)
23
+    {
24
+        parent :: __construct($form_name, $method, $action);
25
+        $this->form_type= $form_type;
26
+        if (isset ($user)) {
27
+            $this->user_info= $user;
28
+        }
29
+        if (isset ($result_object)) {
30
+            $this->result_object= $result_object;
31
+        }
32
+        if ($this->form_type == self :: TYPE_USER_INFO) {
33
+            $this->build_user_info_form();
34
+        }
35
+        elseif ($this->form_type == self :: TYPE_SIMPLE_SEARCH) {
36
+            $this->build_simple_search();
37
+        }
38
+        $this->setDefaults();
39
+    }
40 40
 
41
-	protected function build_simple_search()
42
-	{
43
-		if (isset($_GET['search']) && (!empty($_GET['search']))) {
44
-			$this->setDefaults(array(
45
-				'keyword' => Security::remove_XSS($_GET['search'])
46
-			));
47
-		}
48
-		$renderer =& $this->defaultRenderer();
49
-		$renderer->setCustomElementTemplate('<span>{element}</span> ');
50
-		$this->addElement('text','keyword','');
51
-		$this->addButtonSearch(get_lang('Search'), 'submit');
52
-	}
41
+    protected function build_simple_search()
42
+    {
43
+        if (isset($_GET['search']) && (!empty($_GET['search']))) {
44
+            $this->setDefaults(array(
45
+                'keyword' => Security::remove_XSS($_GET['search'])
46
+            ));
47
+        }
48
+        $renderer =& $this->defaultRenderer();
49
+        $renderer->setCustomElementTemplate('<span>{element}</span> ');
50
+        $this->addElement('text','keyword','');
51
+        $this->addButtonSearch(get_lang('Search'), 'submit');
52
+    }
53 53
 
54
-	protected function build_user_info_form()
55
-	{
56
-		if (api_is_western_name_order()) {
57
-			$this->addElement('static', 'fname', get_lang('FirstName'), $this->user_info['firstname']);
58
-			$this->addElement('static', 'lname', get_lang('LastName'), $this->user_info['lastname']);
59
-		} else {
60
-			$this->addElement('static', 'lname', get_lang('LastName'), $this->user_info['lastname']);
61
-			$this->addElement('static', 'fname', get_lang('FirstName'), $this->user_info['firstname']);
62
-		}
63
-		$this->addElement('static', 'uname', get_lang('UserName'), $this->user_info['username']);
64
-		$this->addElement('static', 'email', get_lang('Email'), '<a href="mailto:' . $this->user_info['email'] . '">' . $this->user_info['email'] . '</a>');
65
-		$this->addElement('static', 'ofcode', get_lang('OfficialCode'), $this->user_info['official_code']);
66
-		$this->addElement('static', 'phone', get_lang('Phone'), $this->user_info['phone']);
67
-		$this->addButtonSave(get_lang('Back'), 'submit');
68
-	}
54
+    protected function build_user_info_form()
55
+    {
56
+        if (api_is_western_name_order()) {
57
+            $this->addElement('static', 'fname', get_lang('FirstName'), $this->user_info['firstname']);
58
+            $this->addElement('static', 'lname', get_lang('LastName'), $this->user_info['lastname']);
59
+        } else {
60
+            $this->addElement('static', 'lname', get_lang('LastName'), $this->user_info['lastname']);
61
+            $this->addElement('static', 'fname', get_lang('FirstName'), $this->user_info['firstname']);
62
+        }
63
+        $this->addElement('static', 'uname', get_lang('UserName'), $this->user_info['username']);
64
+        $this->addElement('static', 'email', get_lang('Email'), '<a href="mailto:' . $this->user_info['email'] . '">' . $this->user_info['email'] . '</a>');
65
+        $this->addElement('static', 'ofcode', get_lang('OfficialCode'), $this->user_info['official_code']);
66
+        $this->addElement('static', 'phone', get_lang('Phone'), $this->user_info['phone']);
67
+        $this->addButtonSave(get_lang('Back'), 'submit');
68
+    }
69 69
 
70
-	function display()
71
-	{
72
-		parent :: display();
73
-	}
70
+    function display()
71
+    {
72
+        parent :: display();
73
+    }
74 74
 
75
-	function setDefaults($defaults= array(), $filter = null)
76
-	{
77
-		parent :: setDefaults($defaults, $filter);
78
-	}
75
+    function setDefaults($defaults= array(), $filter = null)
76
+    {
77
+        parent :: setDefaults($defaults, $filter);
78
+    }
79 79
 }
Please login to merge, or discard this patch.
main/gradebook/lib/fe/displaygradebook.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -558,7 +558,7 @@
 block discarded – undo
558 558
                     $my_api_cidreq = 'cidReq=' . $my_category['course_code'];
559 559
                 }
560 560
                 if ($show_add_link && !$message_resource) {
561
-                   $actionsLeft .= '<a href="gradebook_add_eval.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '" >' .
561
+                    $actionsLeft .= '<a href="gradebook_add_eval.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '" >' .
562 562
                         Display::return_icon('new_evaluation.png', get_lang('NewEvaluation'), '', ICON_SIZE_MEDIUM) . '</a>';
563 563
                     $cats = Category :: load($selectcat);
564 564
 
Please login to merge, or discard this patch.
main/gradebook/lib/fe/linkform.class.php 1 patch
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -10,133 +10,133 @@
 block discarded – undo
10 10
  */
11 11
 class LinkForm extends FormValidator
12 12
 {
13
-	const TYPE_CREATE = 1;
14
-	const TYPE_MOVE = 2;
15
-	/** @var Category */
16
-	private $category_object;
17
-	private $link_object;
18
-	private $extra;
13
+    const TYPE_CREATE = 1;
14
+    const TYPE_MOVE = 2;
15
+    /** @var Category */
16
+    private $category_object;
17
+    private $link_object;
18
+    private $extra;
19 19
 
20
-	/**
21
-	 * Builds a form containing form items based on a given parameter
22
-	 * @param int form_type 1=choose link
23
-	 * @param obj cat_obj the category object
24
-	 * @param string form name
25
-	 * @param method
26
-	 * @param action
27
-	 */
28
-	public function LinkForm(
29
-		$form_type,
30
-		$category_object,
31
-		$link_object,
32
-		$form_name,
33
-		$method = 'post',
34
-		$action = null,
35
-		$extra = null
36
-	) {
37
-		parent :: __construct($form_name, $method, $action);
20
+    /**
21
+     * Builds a form containing form items based on a given parameter
22
+     * @param int form_type 1=choose link
23
+     * @param obj cat_obj the category object
24
+     * @param string form name
25
+     * @param method
26
+     * @param action
27
+     */
28
+    public function LinkForm(
29
+        $form_type,
30
+        $category_object,
31
+        $link_object,
32
+        $form_name,
33
+        $method = 'post',
34
+        $action = null,
35
+        $extra = null
36
+    ) {
37
+        parent :: __construct($form_name, $method, $action);
38 38
 
39
-		if (isset ($category_object)) {
40
-			$this->category_object = $category_object;
41
-		} else {
42
-			if (isset($link_object)) {
43
-				$this->link_object = $link_object;
44
-			}
45
-		}
39
+        if (isset ($category_object)) {
40
+            $this->category_object = $category_object;
41
+        } else {
42
+            if (isset($link_object)) {
43
+                $this->link_object = $link_object;
44
+            }
45
+        }
46 46
 
47
-		if (isset ($extra)) {
48
-			$this->extra = $extra;
49
-		}
50
-		if ($form_type == self :: TYPE_CREATE) {
51
-			$this->build_create();
52
-		} elseif ($form_type == self :: TYPE_MOVE) {
53
-			$this->build_move();
54
-		}
55
-	}
47
+        if (isset ($extra)) {
48
+            $this->extra = $extra;
49
+        }
50
+        if ($form_type == self :: TYPE_CREATE) {
51
+            $this->build_create();
52
+        } elseif ($form_type == self :: TYPE_MOVE) {
53
+            $this->build_move();
54
+        }
55
+    }
56 56
 
57
-	protected function build_move()
58
-	{
59
-		$renderer =& $this->defaultRenderer();
60
-		$renderer->setCustomElementTemplate('<span>{element}</span> ');
61
-		$this->addElement('static',null,null,'"'.$this->link_object->get_name().'" ');
62
-		$this->addElement('static',null,null,get_lang('MoveTo').' : ');
63
-		$select = $this->addElement('select','move_cat',null,null);
64
-		$line = '';
65
-		foreach ($this->link_object->get_target_categories() as $cat) {
66
-			for ($i=0;$i<$cat[2];$i++) {
67
-				$line .= '&mdash;';
68
-			}
69
-			$select->addoption($line.' '.$cat[1],$cat[0]);
70
-			$line = '';
71
-		}
72
-		$this->addElement('submit', null, get_lang('Ok'));
73
-	}
57
+    protected function build_move()
58
+    {
59
+        $renderer =& $this->defaultRenderer();
60
+        $renderer->setCustomElementTemplate('<span>{element}</span> ');
61
+        $this->addElement('static',null,null,'"'.$this->link_object->get_name().'" ');
62
+        $this->addElement('static',null,null,get_lang('MoveTo').' : ');
63
+        $select = $this->addElement('select','move_cat',null,null);
64
+        $line = '';
65
+        foreach ($this->link_object->get_target_categories() as $cat) {
66
+            for ($i=0;$i<$cat[2];$i++) {
67
+                $line .= '&mdash;';
68
+            }
69
+            $select->addoption($line.' '.$cat[1],$cat[0]);
70
+            $line = '';
71
+        }
72
+        $this->addElement('submit', null, get_lang('Ok'));
73
+    }
74 74
 
75
-	/**
76
-	 * Builds the form
77
-	 */
78
-	protected function build_create()
79
-	{
80
-		$this->addElement('header', get_lang('MakeLink'));
81
-		$select = $this->addElement(
82
-			'select',
83
-			'select_link',
84
-			get_lang('ChooseLink'),
85
-			null,
86
-			array('onchange' => 'document.create_link.submit()')
87
-		);
75
+    /**
76
+     * Builds the form
77
+     */
78
+    protected function build_create()
79
+    {
80
+        $this->addElement('header', get_lang('MakeLink'));
81
+        $select = $this->addElement(
82
+            'select',
83
+            'select_link',
84
+            get_lang('ChooseLink'),
85
+            null,
86
+            array('onchange' => 'document.create_link.submit()')
87
+        );
88 88
 
89
-		$linkTypes = LinkFactory::get_all_types();
89
+        $linkTypes = LinkFactory::get_all_types();
90 90
 
91
-		$select->addoption('['.get_lang('ChooseLink').']', 0);
91
+        $select->addoption('['.get_lang('ChooseLink').']', 0);
92 92
 
93
-		$courseCode = $this->category_object->get_course_code();
93
+        $courseCode = $this->category_object->get_course_code();
94 94
 
95
-		foreach ($linkTypes as $linkType) {
96
-			// The hot potatoe link will be added "inside" the exercise option.
97
-			if ($linkType == LINK_HOTPOTATOES) {
98
-				continue;
99
-			}
100
-			$link = $this->createLink($linkType, $courseCode);
101
-			// disable this element if the link works with a dropdownlist
102
-			// and if there are no links left
103
-			if (!$link->needs_name_and_description() && count($link->get_all_links()) == '0') {
104
-				$select->addoption($link->get_type_name(), $linkType, 'disabled');
105
-			} else {
106
-				if ($link->get_type() == LINK_EXERCISE) {
107
-					// Adding exercise
108
-					$select->addoption($link->get_type_name(), $linkType);
109
-					// Adding hot potatoes
110
-					$linkHot = $this->createLink(LINK_HOTPOTATOES, $courseCode);
111
-					$select->addoption(
112
-						'&nbsp;&nbsp;&nbsp;'.$linkHot->get_type_name(),
113
-						LINK_HOTPOTATOES
114
-					);
115
-				} else {
116
-					$select->addoption($link->get_type_name(), $linkType);
117
-				}
118
-			}
119
-		}
95
+        foreach ($linkTypes as $linkType) {
96
+            // The hot potatoe link will be added "inside" the exercise option.
97
+            if ($linkType == LINK_HOTPOTATOES) {
98
+                continue;
99
+            }
100
+            $link = $this->createLink($linkType, $courseCode);
101
+            // disable this element if the link works with a dropdownlist
102
+            // and if there are no links left
103
+            if (!$link->needs_name_and_description() && count($link->get_all_links()) == '0') {
104
+                $select->addoption($link->get_type_name(), $linkType, 'disabled');
105
+            } else {
106
+                if ($link->get_type() == LINK_EXERCISE) {
107
+                    // Adding exercise
108
+                    $select->addoption($link->get_type_name(), $linkType);
109
+                    // Adding hot potatoes
110
+                    $linkHot = $this->createLink(LINK_HOTPOTATOES, $courseCode);
111
+                    $select->addoption(
112
+                        '&nbsp;&nbsp;&nbsp;'.$linkHot->get_type_name(),
113
+                        LINK_HOTPOTATOES
114
+                    );
115
+                } else {
116
+                    $select->addoption($link->get_type_name(), $linkType);
117
+                }
118
+            }
119
+        }
120 120
 
121
-		if (isset($this->extra)) {
122
-			$this->setDefaults(array('select_link' => $this->extra));
123
-		}
124
-	}
121
+        if (isset($this->extra)) {
122
+            $this->setDefaults(array('select_link' => $this->extra));
123
+        }
124
+    }
125 125
 
126
-	/**
127
-	 * @param $link
128
-	 * @param $courseCode
129
-	 * @return AttendanceLink|DropboxLink|ExerciseLink|ForumThreadLink|LearnpathLink|null|StudentPublicationLink|SurveyLink
130
-	 */
131
-	private function createLink($link, $courseCode)
132
-	{
133
-		$link = LinkFactory::create($link);
134
-		if (!empty($courseCode)) {
135
-			$link->set_course_code($courseCode);
136
-		} elseif(!empty($_GET['course_code'])) {
137
-			$link->set_course_code(Database::escape_string($_GET['course_code'], null, false));
138
-		}
126
+    /**
127
+     * @param $link
128
+     * @param $courseCode
129
+     * @return AttendanceLink|DropboxLink|ExerciseLink|ForumThreadLink|LearnpathLink|null|StudentPublicationLink|SurveyLink
130
+     */
131
+    private function createLink($link, $courseCode)
132
+    {
133
+        $link = LinkFactory::create($link);
134
+        if (!empty($courseCode)) {
135
+            $link->set_course_code($courseCode);
136
+        } elseif(!empty($_GET['course_code'])) {
137
+            $link->set_course_code(Database::escape_string($_GET['course_code'], null, false));
138
+        }
139 139
 
140
-		return $link;
141
-	}
140
+        return $link;
141
+    }
142 142
 }
Please login to merge, or discard this patch.
main/gradebook/lib/fe/resulttable.class.php 1 patch
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -10,162 +10,162 @@
 block discarded – undo
10 10
  */
11 11
 class ResultTable extends SortableTable
12 12
 {
13
-	private $datagen;
14
-	private $evaluation;
15
-	private $allresults;
16
-	private $iscourse;
17
-
18
-	/**
19
-	 * Constructor
20
-	 */
13
+    private $datagen;
14
+    private $evaluation;
15
+    private $allresults;
16
+    private $iscourse;
17
+
18
+    /**
19
+     * Constructor
20
+     */
21 21
     public function ResultTable ($evaluation, $results = array(), $iscourse, $addparams = null,$forprint = false)
22
-	{
23
-    	parent :: __construct ('resultlist', null, null, (api_is_western_name_order() xor api_sort_by_first_name()) ? 2 : 1);
24
-
25
-		$this->datagen = new ResultsDataGenerator($evaluation, $results, true);
26
-
27
-		$this->evaluation = $evaluation;
28
-		$this->iscourse = $iscourse;
29
-		$this->forprint = $forprint;
30
-
31
-		if (isset ($addparams))  {
32
-			$this->set_additional_parameters($addparams);
33
-		}
34
-		$scoredisplay = ScoreDisplay :: instance();
35
-		$column= 0;
36
-		if ($this->iscourse == '1') {
37
-			$this->set_header($column++, '', false);
38
-			$this->set_form_actions(array (
39
-					'delete' => get_lang('Delete')
40
-			));
41
-		}
42
-		if (api_is_western_name_order()) {
43
-			$this->set_header($column++, get_lang('FirstName'));
44
-			$this->set_header($column++, get_lang('LastName'));
45
-		} else {
46
-			$this->set_header($column++, get_lang('LastName'));
47
-			$this->set_header($column++, get_lang('FirstName'));
48
-		}
49
-		$this->set_header($column++, get_lang('Score'));
50
-		if ($scoredisplay->is_custom()) {
51
-			$this->set_header($column++, get_lang('Display'));
52
-		}
53
-		if (!$this->forprint) {
54
-			$this->set_header($column++, get_lang('Modify'),false);
55
-		}
22
+    {
23
+        parent :: __construct ('resultlist', null, null, (api_is_western_name_order() xor api_sort_by_first_name()) ? 2 : 1);
24
+
25
+        $this->datagen = new ResultsDataGenerator($evaluation, $results, true);
26
+
27
+        $this->evaluation = $evaluation;
28
+        $this->iscourse = $iscourse;
29
+        $this->forprint = $forprint;
30
+
31
+        if (isset ($addparams))  {
32
+            $this->set_additional_parameters($addparams);
33
+        }
34
+        $scoredisplay = ScoreDisplay :: instance();
35
+        $column= 0;
36
+        if ($this->iscourse == '1') {
37
+            $this->set_header($column++, '', false);
38
+            $this->set_form_actions(array (
39
+                    'delete' => get_lang('Delete')
40
+            ));
41
+        }
42
+        if (api_is_western_name_order()) {
43
+            $this->set_header($column++, get_lang('FirstName'));
44
+            $this->set_header($column++, get_lang('LastName'));
45
+        } else {
46
+            $this->set_header($column++, get_lang('LastName'));
47
+            $this->set_header($column++, get_lang('FirstName'));
48
+        }
49
+        $this->set_header($column++, get_lang('Score'));
50
+        if ($scoredisplay->is_custom()) {
51
+            $this->set_header($column++, get_lang('Display'));
52
+        }
53
+        if (!$this->forprint) {
54
+            $this->set_header($column++, get_lang('Modify'),false);
55
+        }
56 56
     }
57 57
 
58 58
 
59
-	/**
60
-	 * Function used by SortableTable to get total number of items in the table
61
-	 */
62
-	function get_total_number_of_items () {
63
-		return $this->datagen->get_total_results_count();
64
-	}
65
-
66
-	/**
67
-	 * Function used by SortableTable to generate the data to display
68
-	 */
69
-	function get_table_data ($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) {
70
-
71
-		$is_western_name_order = api_is_western_name_order();
72
-		$scoredisplay = ScoreDisplay :: instance();
73
-
74
-		// determine sorting type
75
-		$col_adjust = $this->iscourse == '1' ? 1 : 0;
76
-
77
-		switch ($this->column) {
78
-			// first name or last name
79
-			case (0 + $col_adjust):
80
-				if ($is_western_name_order) {
81
-					$sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME;
82
-				} else {
83
-					$sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME;
84
-				}
85
-				break;
59
+    /**
60
+     * Function used by SortableTable to get total number of items in the table
61
+     */
62
+    function get_total_number_of_items () {
63
+        return $this->datagen->get_total_results_count();
64
+    }
65
+
66
+    /**
67
+     * Function used by SortableTable to generate the data to display
68
+     */
69
+    function get_table_data ($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) {
70
+
71
+        $is_western_name_order = api_is_western_name_order();
72
+        $scoredisplay = ScoreDisplay :: instance();
73
+
74
+        // determine sorting type
75
+        $col_adjust = $this->iscourse == '1' ? 1 : 0;
76
+
77
+        switch ($this->column) {
86 78
             // first name or last name
87
-			case (1 + $col_adjust):
88
-				if ($is_western_name_order) {
89
-					$sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME;
90
-				} else {
91
-					$sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME;
92
-				}
93
-				break;
79
+            case (0 + $col_adjust):
80
+                if ($is_western_name_order) {
81
+                    $sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME;
82
+                } else {
83
+                    $sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME;
84
+                }
85
+                break;
86
+            // first name or last name
87
+            case (1 + $col_adjust):
88
+                if ($is_western_name_order) {
89
+                    $sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME;
90
+                } else {
91
+                    $sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME;
92
+                }
93
+                break;
94 94
             //Score
95
-			case (2 + $col_adjust):
96
-				$sorting = ResultsDataGenerator :: RDG_SORT_SCORE;
97
-				break;
98
-			case (3 + $col_adjust):
99
-				$sorting = ResultsDataGenerator :: RDG_SORT_MASK;
100
-				break;
101
-		}
102
-
103
-		if ($this->direction == 'DESC') {
104
-			$sorting |= ResultsDataGenerator :: RDG_SORT_DESC;
105
-		} else {
106
-			$sorting |= ResultsDataGenerator :: RDG_SORT_ASC;
107
-		}
108
-
109
-		$data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
110
-
111
-		// generate the data to display
112
-		$sortable_data = array();
113
-		foreach ($data_array as $item) {
114
-			$row = array ();
115
-			if ($this->iscourse == '1') {
116
-				 $row[] = $item['result_id'];
117
-			}
118
-			if ($is_western_name_order) {
119
-				$row[] = $item['firstname'];
120
-				$row[] = $item['lastname'];
121
-			} else {
122
-				$row[] = $item['lastname'];
123
-				$row[] = $item['firstname'];
124
-			}
125
-
126
-			$row[] =  Display::bar_progress($item['percentage_score'], false, $item['score']);
95
+            case (2 + $col_adjust):
96
+                $sorting = ResultsDataGenerator :: RDG_SORT_SCORE;
97
+                break;
98
+            case (3 + $col_adjust):
99
+                $sorting = ResultsDataGenerator :: RDG_SORT_MASK;
100
+                break;
101
+        }
102
+
103
+        if ($this->direction == 'DESC') {
104
+            $sorting |= ResultsDataGenerator :: RDG_SORT_DESC;
105
+        } else {
106
+            $sorting |= ResultsDataGenerator :: RDG_SORT_ASC;
107
+        }
108
+
109
+        $data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
110
+
111
+        // generate the data to display
112
+        $sortable_data = array();
113
+        foreach ($data_array as $item) {
114
+            $row = array ();
115
+            if ($this->iscourse == '1') {
116
+                    $row[] = $item['result_id'];
117
+            }
118
+            if ($is_western_name_order) {
119
+                $row[] = $item['firstname'];
120
+                $row[] = $item['lastname'];
121
+            } else {
122
+                $row[] = $item['lastname'];
123
+                $row[] = $item['firstname'];
124
+            }
125
+
126
+            $row[] =  Display::bar_progress($item['percentage_score'], false, $item['score']);
127 127
             //$row[] =  Display::bar_progress($item['percentage_score'], true);
128
-			if ($scoredisplay->is_custom()) {
129
-				$row[] = $item['display'];
130
-			}
131
-			if (!$this->forprint) {
132
-				$row[] = $this->build_edit_column ($item);
133
-			}
134
-			$sortable_data[] = $row;
135
-		}
136
-
137
-		return $sortable_data;
138
-	}
139
-
140
-	private function build_edit_column ($item)
141
-	{
142
-		$status=CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
143
-		$locked_status = $this->evaluation->get_locked();
144
-		if (api_is_allowed_to_edit(null, true) && $locked_status == 0) {
145
-			//api_is_course_admin()
146
-			$edit_column = '<a href="' . api_get_self() . '?editres=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'.
147
-				Display::return_icon('edit.png', get_lang('Modify'),'','22').'</a>';
148
-			$edit_column .= ' <a href="' . api_get_self() . '?delete_mark=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'.
149
-				Display::return_icon('delete.png', get_lang('Delete'),'','22').'</a>';
150
-		}
151
-		if ($this->evaluation->get_course_code() == null) {
152
-			$edit_column.= '&nbsp;<a href="' . api_get_self() . '?resultdelete=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id() . '" onclick="return confirmationuser();">
128
+            if ($scoredisplay->is_custom()) {
129
+                $row[] = $item['display'];
130
+            }
131
+            if (!$this->forprint) {
132
+                $row[] = $this->build_edit_column ($item);
133
+            }
134
+            $sortable_data[] = $row;
135
+        }
136
+
137
+        return $sortable_data;
138
+    }
139
+
140
+    private function build_edit_column ($item)
141
+    {
142
+        $status=CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
143
+        $locked_status = $this->evaluation->get_locked();
144
+        if (api_is_allowed_to_edit(null, true) && $locked_status == 0) {
145
+            //api_is_course_admin()
146
+            $edit_column = '<a href="' . api_get_self() . '?editres=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'.
147
+                Display::return_icon('edit.png', get_lang('Modify'),'','22').'</a>';
148
+            $edit_column .= ' <a href="' . api_get_self() . '?delete_mark=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'.
149
+                Display::return_icon('delete.png', get_lang('Delete'),'','22').'</a>';
150
+        }
151
+        if ($this->evaluation->get_course_code() == null) {
152
+            $edit_column.= '&nbsp;<a href="' . api_get_self() . '?resultdelete=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id() . '" onclick="return confirmationuser();">
153 153
 			<img src="../img/delete.gif" border="0" title="' . get_lang('Delete') . '" alt="" /></a>';
154
-		    $edit_column.= '&nbsp;<a href="user_stats.php?userid=' . $item['id'] . '&selecteval=' . $this->evaluation->get_id() . '&'.api_get_cidreq().'">
154
+            $edit_column.= '&nbsp;<a href="user_stats.php?userid=' . $item['id'] . '&selecteval=' . $this->evaluation->get_id() . '&'.api_get_cidreq().'">
155 155
 		    <img src="../img/statistics.gif" width="17px" border="0" title="' . get_lang('Statistics') . '" alt="" /></a>';
156
-		}
157
-		// Evaluation's origin is a link
158
-		if ($this->evaluation->get_category_id() < 0) {
159
-			$link = LinkFactory :: get_evaluation_link ($this->evaluation->get_id());
160
-
161
-			$doc_url = $link->get_view_url($item['id']);
162
-
163
-			if ($doc_url != null) {
164
-				$edit_column .= '&nbsp;<a href="'. $doc_url . '" target="_blank">'
165
-								.'<img src="'. api_get_path(WEB_CODE_PATH) . 'img/link.gif" border="0" title="' . get_lang('OpenDocument') . '" alt="" />'
166
-								.'</a>';
167
-			}
168
-		}
169
-		return $edit_column;
170
-	}
156
+        }
157
+        // Evaluation's origin is a link
158
+        if ($this->evaluation->get_category_id() < 0) {
159
+            $link = LinkFactory :: get_evaluation_link ($this->evaluation->get_id());
160
+
161
+            $doc_url = $link->get_view_url($item['id']);
162
+
163
+            if ($doc_url != null) {
164
+                $edit_column .= '&nbsp;<a href="'. $doc_url . '" target="_blank">'
165
+                                .'<img src="'. api_get_path(WEB_CODE_PATH) . 'img/link.gif" border="0" title="' . get_lang('OpenDocument') . '" alt="" />'
166
+                                .'</a>';
167
+            }
168
+        }
169
+        return $edit_column;
170
+    }
171 171
 }
Please login to merge, or discard this patch.