Completed
Push — 1.10.x ( d91a6d...49fbc2 )
by Julito
66:49 queued 22:44
created
main/mySpace/current_courses.php 1 patch
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 $filename = 'reporting.xls';
13 13
 
14 14
 if (!api_is_allowed_to_create_course()) {
15
-	api_not_allowed(true);
15
+    api_not_allowed(true);
16 16
 }
17 17
 
18 18
 $user_id = api_get_user_id();
@@ -23,222 +23,222 @@  discard block
 block discarded – undo
23 23
 $session_id = 0;
24 24
 
25 25
 if (!empty($my_courses)) {
26
-	foreach ($my_courses as $course) {
27
-		$course_code = $course['code'];
28
-		$course_id = $course['real_id'];
29
-		$course_info = api_get_course_info($course_code);
30
-
31
-		//Only show open courses
32
-		if ($course_info['visibility'] == 0) {
33
-			continue;
34
-		}
35
-
36
-		$teachers = CourseManager::get_teacher_list_from_course_code($course_code);
37
-		$teacher_list =  array();
38
-
39
-		if (!empty($teachers)) {
40
-			foreach($teachers as $teacher) {
41
-				$teacher_list[]= $teacher['firstname'].' '.$teacher['lastname'];
42
-			}
43
-		}
44
-
45
-		$tmp_students = CourseManager :: get_student_list_from_course_code($course_code, false);
46
-
47
-		//Cleaning students only REAL students
48
-		$students = array();
49
-		foreach ($tmp_students  as $student) {
50
-			$user_info = api_get_user_info($student['user_id']);
51
-			if ($user_info['status'] != STUDENT) {
52
-				continue;
53
-			}
54
-			$students[] = $student['user_id'];
55
-		}
56
-
57
-		$t_lp 	= Database :: get_course_table(TABLE_LP_MAIN);
58
-		$sql_lp = "SELECT lp.name, lp.id FROM $t_lp lp
26
+    foreach ($my_courses as $course) {
27
+        $course_code = $course['code'];
28
+        $course_id = $course['real_id'];
29
+        $course_info = api_get_course_info($course_code);
30
+
31
+        //Only show open courses
32
+        if ($course_info['visibility'] == 0) {
33
+            continue;
34
+        }
35
+
36
+        $teachers = CourseManager::get_teacher_list_from_course_code($course_code);
37
+        $teacher_list =  array();
38
+
39
+        if (!empty($teachers)) {
40
+            foreach($teachers as $teacher) {
41
+                $teacher_list[]= $teacher['firstname'].' '.$teacher['lastname'];
42
+            }
43
+        }
44
+
45
+        $tmp_students = CourseManager :: get_student_list_from_course_code($course_code, false);
46
+
47
+        //Cleaning students only REAL students
48
+        $students = array();
49
+        foreach ($tmp_students  as $student) {
50
+            $user_info = api_get_user_info($student['user_id']);
51
+            if ($user_info['status'] != STUDENT) {
52
+                continue;
53
+            }
54
+            $students[] = $student['user_id'];
55
+        }
56
+
57
+        $t_lp 	= Database :: get_course_table(TABLE_LP_MAIN);
58
+        $sql_lp = "SELECT lp.name, lp.id FROM $t_lp lp
59 59
 				   WHERE c_id = $course_id AND lp.session_id = 0";
60
-		$rs_lp 	= Database::query($sql_lp);
61
-		$t_lpi 	= Database :: get_course_table(TABLE_LP_ITEM);
62
-		$t_news = Database :: get_course_table(TABLE_ANNOUNCEMENT);
63
-
64
-		$total_tools_list = Tracking::get_tools_most_used_by_course(
65
-			$course_id,
66
-			$session_id
67
-		);
68
-
69
-		$total_tools = 0;
70
-		foreach($total_tools_list as $tool) {
71
-			$total_tools += $tool['count_access_tool'];
72
-		}
73
-
74
-		if (Database :: num_rows($rs_lp) > 0) {
75
-			while ($learnpath = Database :: fetch_array($rs_lp)) {
76
-				$lp_id = $learnpath['id'];
77
-
78
-				$lp_items =
79
-				$array[$i]['lp'] = '<a href="'.api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?cidReq='.$course_code.'&amp;action=view&amp;lp_id='.$lp_id.'" target="_blank">'.$learnpath['name'].'</a>';
80
-
81
-				$array[$i]['teachers'] = '';
82
-				if (!empty($teacher_list)) {
83
-					$array[$i]['teachers'] = implode(', ', $teacher_list);
84
-				}
85
-
86
-				$array[$i]['course_name'] = $course['title'];
87
-				$count_students_accessing = 0;
88
-				$count_students_complete_all_activities = 0;
89
-				$count_students_complete_all_activities_at_50 = 0;
90
-				$total_time_spent = 0;
91
-				$total_average_progress = 0;
92
-
93
-				if (!empty($students)) {
94
-					foreach ($students  as $student_id) {
95
-						$avg_student_progress   = Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id), $session_id);
96
-						$myavg_temp 			= Tracking::get_avg_student_score($student_id, $course_code, array($lp_id), $session_id);
97
-						$avg_progress_in_course = Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id), $session_id);
98
-
99
-						if (intval($avg_progress_in_course) == 100) {
100
-							$count_students_complete_all_activities++;
101
-						}
102
-						if (intval($avg_progress_in_course) > 0 && intval($avg_progress_in_course) <= 50) {
103
-							$count_students_complete_all_activities_at_50 ++;
104
-						}
105
-						$total_average_progress +=$avg_progress_in_course;
106
-
107
-						$time_spent = Tracking::get_time_spent_on_the_course($student_id, $course_id, $session_id);
108
-						$total_time_spent += $time_spent;
109
-						if (!empty($time_spent)) {
110
-							$count_students_accessing++;
111
-						}
112
-					}
113
-					//$total_tools += $nb_assignments +  $messages + $links + $chat_last_connection + $documents;
114
-				}
115
-
116
-				$student_count = count($students);
117
-
118
-				$array[$i]['count_students'] = $student_count;
119
-				$array[$i]['count_students_accessing'] = 0;
120
-				$array[$i]['count_students_accessing_percentage'] = 0;
121
-				$array[$i]['count_students_complete_all_activities_at_50'] = 0;
122
-				$array[$i]['count_students_complete_all_activities'] = 0;
123
-				$array[$i]['average_percentage_activities_completed_per_student'] = 0;
124
-				$array[$i]['total_time_spent'] = 0;
125
-				$array[$i]['average_time_spent_per_student'] = 0;
126
-				$array[$i]['total_time_spent'] = 0;
127
-				$array[$i]['average_time_spent_per_student'] = 0;
128
-				//$array[$i]['tools_used'] = 0;
129
-				$array[$i]['learnpath_docs'] = 0;
130
-				$array[$i]['learnpath_exercises'] = 0;
131
-				$array[$i]['learnpath_links'] = 0;
132
-				$array[$i]['learnpath_forums'] = 0;
133
-				$array[$i]['learnpath_assignments'] = 0;
134
-
135
-				//registering the number of each category of
136
-				//items in learning path
137
-				$sql_lpi = "SELECT lpi.item_type FROM $t_lpi lpi
60
+        $rs_lp 	= Database::query($sql_lp);
61
+        $t_lpi 	= Database :: get_course_table(TABLE_LP_ITEM);
62
+        $t_news = Database :: get_course_table(TABLE_ANNOUNCEMENT);
63
+
64
+        $total_tools_list = Tracking::get_tools_most_used_by_course(
65
+            $course_id,
66
+            $session_id
67
+        );
68
+
69
+        $total_tools = 0;
70
+        foreach($total_tools_list as $tool) {
71
+            $total_tools += $tool['count_access_tool'];
72
+        }
73
+
74
+        if (Database :: num_rows($rs_lp) > 0) {
75
+            while ($learnpath = Database :: fetch_array($rs_lp)) {
76
+                $lp_id = $learnpath['id'];
77
+
78
+                $lp_items =
79
+                $array[$i]['lp'] = '<a href="'.api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?cidReq='.$course_code.'&amp;action=view&amp;lp_id='.$lp_id.'" target="_blank">'.$learnpath['name'].'</a>';
80
+
81
+                $array[$i]['teachers'] = '';
82
+                if (!empty($teacher_list)) {
83
+                    $array[$i]['teachers'] = implode(', ', $teacher_list);
84
+                }
85
+
86
+                $array[$i]['course_name'] = $course['title'];
87
+                $count_students_accessing = 0;
88
+                $count_students_complete_all_activities = 0;
89
+                $count_students_complete_all_activities_at_50 = 0;
90
+                $total_time_spent = 0;
91
+                $total_average_progress = 0;
92
+
93
+                if (!empty($students)) {
94
+                    foreach ($students  as $student_id) {
95
+                        $avg_student_progress   = Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id), $session_id);
96
+                        $myavg_temp 			= Tracking::get_avg_student_score($student_id, $course_code, array($lp_id), $session_id);
97
+                        $avg_progress_in_course = Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id), $session_id);
98
+
99
+                        if (intval($avg_progress_in_course) == 100) {
100
+                            $count_students_complete_all_activities++;
101
+                        }
102
+                        if (intval($avg_progress_in_course) > 0 && intval($avg_progress_in_course) <= 50) {
103
+                            $count_students_complete_all_activities_at_50 ++;
104
+                        }
105
+                        $total_average_progress +=$avg_progress_in_course;
106
+
107
+                        $time_spent = Tracking::get_time_spent_on_the_course($student_id, $course_id, $session_id);
108
+                        $total_time_spent += $time_spent;
109
+                        if (!empty($time_spent)) {
110
+                            $count_students_accessing++;
111
+                        }
112
+                    }
113
+                    //$total_tools += $nb_assignments +  $messages + $links + $chat_last_connection + $documents;
114
+                }
115
+
116
+                $student_count = count($students);
117
+
118
+                $array[$i]['count_students'] = $student_count;
119
+                $array[$i]['count_students_accessing'] = 0;
120
+                $array[$i]['count_students_accessing_percentage'] = 0;
121
+                $array[$i]['count_students_complete_all_activities_at_50'] = 0;
122
+                $array[$i]['count_students_complete_all_activities'] = 0;
123
+                $array[$i]['average_percentage_activities_completed_per_student'] = 0;
124
+                $array[$i]['total_time_spent'] = 0;
125
+                $array[$i]['average_time_spent_per_student'] = 0;
126
+                $array[$i]['total_time_spent'] = 0;
127
+                $array[$i]['average_time_spent_per_student'] = 0;
128
+                //$array[$i]['tools_used'] = 0;
129
+                $array[$i]['learnpath_docs'] = 0;
130
+                $array[$i]['learnpath_exercises'] = 0;
131
+                $array[$i]['learnpath_links'] = 0;
132
+                $array[$i]['learnpath_forums'] = 0;
133
+                $array[$i]['learnpath_assignments'] = 0;
134
+
135
+                //registering the number of each category of
136
+                //items in learning path
137
+                $sql_lpi = "SELECT lpi.item_type FROM $t_lpi lpi
138 138
 						    WHERE c_id = $course_id AND lpi.lp_id = $lp_id
139 139
 						    ORDER BY item_type";
140
-				$res_lpi = Database::query($sql_lpi);
141
-				while ($row_lpi = Database::fetch_array($res_lpi)) {
142
-					switch($row_lpi['item_type']) {
143
-						case 'document':
144
-							$array[$i]['learnpath_docs']++;
145
-							break;
146
-						case 'quiz':
147
-							$array[$i]['learnpath_exercises']++;
148
-							break;
149
-						case 'link':
150
-							$array[$i]['learnpath_links']++;
151
-							break;
152
-						case 'forum':
153
-						case 'thread':
154
-							$array[$i]['learnpath_forums']++;
155
-							break;
156
-						case 'student_publication':
157
-							$array[$i]['learnpath_assignments']++;
158
-							break;
159
-					}
160
-				}
161
-				// Count announcements
162
-				$array[$i]['total_announcements'] = 0;
163
-				$sql_news = "SELECT count(id) FROM $t_news WHERE c_id = $course_id ";
164
-				$res_news = Database::query($sql_news);
165
-				while ($row_news = Database::fetch_array($res_news)) {
166
-					$array[$i]['total_announcements'] = $row_news[0];
167
-				}
168
-
169
-				//@todo don't know what means this value
170
-				$count_students_complete_all_activities_at_50 = 0;
171
-
172
-				if (!empty($student_count)) {
173
-					$array[$i]['count_students_accessing'] = $count_students_accessing;
174
-					$array[$i]['count_students_accessing_percentage'] = round($count_students_accessing / $student_count *100 , 0);
175
-					$array[$i]['count_students_complete_all_activities_at_50'] = $count_students_complete_all_activities;
176
-					$array[$i]['count_students_complete_all_activities'] = round($count_students_complete_all_activities / $student_count *100 , 0);;
177
-					$array[$i]['average_percentage_activities_completed_per_student'] = round($count_students_complete_all_activities/$student_count*100,2);
178
-					$array[$i]['total_time_spent'] = 0;
179
-					$array[$i]['average_time_spent_per_student'] = 0;
180
-
181
-					if (!empty($total_time_spent)) {
182
-						$array[$i]['total_time_spent'] = api_time_to_hms($total_time_spent);
183
-						$array[$i]['average_time_spent_per_student'] = api_time_to_hms($total_time_spent / $student_count);
184
-					}
185
-					//$array[$i]['tools_used'] = $total_tools;
186
-				}
187
-				$i++;
188
-			}
189
-		}
190
-	}
140
+                $res_lpi = Database::query($sql_lpi);
141
+                while ($row_lpi = Database::fetch_array($res_lpi)) {
142
+                    switch($row_lpi['item_type']) {
143
+                        case 'document':
144
+                            $array[$i]['learnpath_docs']++;
145
+                            break;
146
+                        case 'quiz':
147
+                            $array[$i]['learnpath_exercises']++;
148
+                            break;
149
+                        case 'link':
150
+                            $array[$i]['learnpath_links']++;
151
+                            break;
152
+                        case 'forum':
153
+                        case 'thread':
154
+                            $array[$i]['learnpath_forums']++;
155
+                            break;
156
+                        case 'student_publication':
157
+                            $array[$i]['learnpath_assignments']++;
158
+                            break;
159
+                    }
160
+                }
161
+                // Count announcements
162
+                $array[$i]['total_announcements'] = 0;
163
+                $sql_news = "SELECT count(id) FROM $t_news WHERE c_id = $course_id ";
164
+                $res_news = Database::query($sql_news);
165
+                while ($row_news = Database::fetch_array($res_news)) {
166
+                    $array[$i]['total_announcements'] = $row_news[0];
167
+                }
168
+
169
+                //@todo don't know what means this value
170
+                $count_students_complete_all_activities_at_50 = 0;
171
+
172
+                if (!empty($student_count)) {
173
+                    $array[$i]['count_students_accessing'] = $count_students_accessing;
174
+                    $array[$i]['count_students_accessing_percentage'] = round($count_students_accessing / $student_count *100 , 0);
175
+                    $array[$i]['count_students_complete_all_activities_at_50'] = $count_students_complete_all_activities;
176
+                    $array[$i]['count_students_complete_all_activities'] = round($count_students_complete_all_activities / $student_count *100 , 0);;
177
+                    $array[$i]['average_percentage_activities_completed_per_student'] = round($count_students_complete_all_activities/$student_count*100,2);
178
+                    $array[$i]['total_time_spent'] = 0;
179
+                    $array[$i]['average_time_spent_per_student'] = 0;
180
+
181
+                    if (!empty($total_time_spent)) {
182
+                        $array[$i]['total_time_spent'] = api_time_to_hms($total_time_spent);
183
+                        $array[$i]['average_time_spent_per_student'] = api_time_to_hms($total_time_spent / $student_count);
184
+                    }
185
+                    //$array[$i]['tools_used'] = $total_tools;
186
+                }
187
+                $i++;
188
+            }
189
+        }
190
+    }
191 191
 }
192 192
 
193 193
 $headers = array(
194
-	get_lang('LearningPath'),
195
-	get_lang('Teachers'),
196
-	get_lang('Courses'),
197
-	get_lang('NumberOfStudents'),
198
-	get_lang('NumberStudentsAccessingCourse'),
199
-	get_lang('PercentageStudentsAccessingCourse'),
200
-	get_lang('NumberStudentsCompleteAllActivities'),
201
-	get_lang('PercentageStudentsCompleteAllActivities'),
202
-	get_lang('AverageOfActivitiesCompletedPerStudent'),
203
-	get_lang('TotalTimeSpentInTheCourse'),
204
-	get_lang('AverageTimePerStudentInCourse'),
205
-	get_lang('NumberOfDocumentsInLearnpath'),
206
-	get_lang('NumberOfExercisesInLearnpath'),
207
-	get_lang('NumberOfLinksInLearnpath'),
208
-	get_lang('NumberOfForumsInLearnpath'),
209
-	get_lang('NumberOfAssignmentsInLearnpath'),
210
-	get_lang('NumberOfAnnouncementsInCourse'),
194
+    get_lang('LearningPath'),
195
+    get_lang('Teachers'),
196
+    get_lang('Courses'),
197
+    get_lang('NumberOfStudents'),
198
+    get_lang('NumberStudentsAccessingCourse'),
199
+    get_lang('PercentageStudentsAccessingCourse'),
200
+    get_lang('NumberStudentsCompleteAllActivities'),
201
+    get_lang('PercentageStudentsCompleteAllActivities'),
202
+    get_lang('AverageOfActivitiesCompletedPerStudent'),
203
+    get_lang('TotalTimeSpentInTheCourse'),
204
+    get_lang('AverageTimePerStudentInCourse'),
205
+    get_lang('NumberOfDocumentsInLearnpath'),
206
+    get_lang('NumberOfExercisesInLearnpath'),
207
+    get_lang('NumberOfLinksInLearnpath'),
208
+    get_lang('NumberOfForumsInLearnpath'),
209
+    get_lang('NumberOfAssignmentsInLearnpath'),
210
+    get_lang('NumberOfAnnouncementsInCourse'),
211 211
 );
212 212
 
213 213
 if (isset($_GET['export'])) {
214
-	global $charset;
214
+    global $charset;
215 215
     $spreadsheet = new PHPExcel();
216 216
     $spreadsheet->setActiveSheetIndex(0);
217 217
     $worksheet = $spreadsheet->getActiveSheet();
218 218
 
219
-	$line = 0;
220
-	$column = 0; //skip the first column (row titles)
221
-
222
-	foreach ($headers as $header) {
223
-		$worksheet->setCellValueByColumnAndRow($column, $line, $header);
224
-		$column++;
225
-	}
226
-	$line++;
227
-	foreach ($array as $row) {
228
-		$column = 0;
229
-		foreach ($row as $item) {
230
-			$worksheet->setCellValueByColumnAndRow($column, $line, html_entity_decode(strip_tags($item)));
231
-			$column++;
232
-		}
233
-		$line++;
234
-	}
235
-	$line++;
219
+    $line = 0;
220
+    $column = 0; //skip the first column (row titles)
221
+
222
+    foreach ($headers as $header) {
223
+        $worksheet->setCellValueByColumnAndRow($column, $line, $header);
224
+        $column++;
225
+    }
226
+    $line++;
227
+    foreach ($array as $row) {
228
+        $column = 0;
229
+        foreach ($row as $item) {
230
+            $worksheet->setCellValueByColumnAndRow($column, $line, html_entity_decode(strip_tags($item)));
231
+            $column++;
232
+        }
233
+        $line++;
234
+    }
235
+    $line++;
236 236
 
237 237
     $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
238 238
     $writer = new PHPExcel_Writer_Excel2007($spreadsheet);
239 239
     $writer->save($file);
240 240
     DocumentManager::file_send_for_download($file, true, $filename);
241
-	exit;
241
+    exit;
242 242
 }
243 243
 
244 244
 $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('MySpace'));
@@ -249,20 +249,20 @@  discard block
 block discarded – undo
249 249
 $row = 0;
250 250
 $column = 0;
251 251
 foreach ($headers as $header) {
252
-	$table->setHeaderContents($row, $column, $header);
253
-	$column++;
252
+    $table->setHeaderContents($row, $column, $header);
253
+    $column++;
254 254
 }
255 255
 $row++;
256 256
 
257 257
 foreach ($array as $row_table) {
258
-	$column = 0;
259
-	foreach ($row_table as $cell) {
260
-		$table->setCellContents($row, $column, $cell);
261
-		//$table->updateCellAttributes($row, $column, 'align="center"');
262
-		$column++;
263
-	}
264
-	$table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
265
-	$row++;
258
+    $column = 0;
259
+    foreach ($row_table as $cell) {
260
+        $table->setCellContents($row, $column, $cell);
261
+        //$table->updateCellAttributes($row, $column, 'align="center"');
262
+        $column++;
263
+    }
264
+    $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
265
+    $row++;
266 266
 }
267 267
 
268 268
 echo '<div class="actions">';
Please login to merge, or discard this patch.
main/exercice/exercise_result.class.php 1 patch
Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 */
10 10
 class ExerciseResult
11 11
 {
12
-	private $results = array();
12
+    private $results = array();
13 13
     public $includeAllUsers = false;
14 14
     public $onlyBestAttempts = false;
15 15
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         $exercise_id = 0,
47 47
         $hotpotato_name = null
48 48
     ) {
49
-		$return = array();
49
+        $return = array();
50 50
 
51 51
         $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
52 52
         $TBL_TABLE_LP_MAIN = Database::get_course_table(TABLE_LP_MAIN);
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
             $session_id_and .= " AND exe_exo_id = $exercise_id ";
67 67
         }
68 68
 
69
-		if (empty($user_id)) {
69
+        if (empty($user_id)) {
70 70
             $user_id_and = null;
71
-			$sql = "SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
71
+            $sql = "SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
72 72
 			            official_code,
73 73
                         ce.title as extitle,
74 74
                         te.exe_result as exresult ,
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
                     te.status != 'incomplete' AND
92 92
                     te.c_id = ce.c_id $user_id_and  $session_id_and AND
93 93
                     ce.active <>-1";
94
-		} else {
94
+        } else {
95 95
             $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' ';
96
-			// get only this user's results
96
+            // get only this user's results
97 97
             $sql="SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
98 98
                     official_code,
99 99
                     ce.title as extitle,
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
                         te.c_id = ce.c_id $user_id_and $session_id_and AND
120 120
                         ce.active <>-1 AND
121 121
                     ORDER BY userpart2, te.c_id ASC, ce.title ASC, te.exe_date DESC";
122
-		}
122
+        }
123 123
 
124
-		$results = array();
125
-		$resx = Database::query($sql);
124
+        $results = array();
125
+        $resx = Database::query($sql);
126 126
         $bestAttemptPerUser = array();
127
-		while ($rowx = Database::fetch_array($resx,'ASSOC')) {
127
+        while ($rowx = Database::fetch_array($resx,'ASSOC')) {
128 128
             if ($this->onlyBestAttempts) {
129 129
                 if (!isset($bestAttemptPerUser[$rowx['excruid']])) {
130 130
                     $bestAttemptPerUser[$rowx['excruid']] = $rowx;
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
             } else {
137 137
                 $results[] = $rowx;
138 138
             }
139
-		}
139
+        }
140 140
 
141 141
         if ($this->onlyBestAttempts) {
142 142
             $results = $bestAttemptPerUser;
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
                     continue;
191 191
                 }
192 192
 
193
-				$return[$i] = array();
194
-				if (empty($user_id)) {
193
+                $return[$i] = array();
194
+                if (empty($user_id)) {
195 195
                     $return[$i]['official_code']   = $result['official_code'];
196 196
                     if (api_is_western_name_order()) {
197 197
                         $return[$i]['first_name']   = $results[$i]['userpart1'];
@@ -200,15 +200,15 @@  discard block
 block discarded – undo
200 200
                         $return[$i]['first_name']   = $results[$i]['userpart2'];
201 201
                         $return[$i]['last_name']    = $results[$i]['userpart1'];
202 202
                     }
203
-					$return[$i]['user_id']      = $results[$i]['excruid'];
204
-					$return[$i]['email']        = $results[$i]['exemail'];
205
-				}
206
-				$return[$i]['title'] = $result['extitle'];
207
-				$return[$i]['start_date'] = api_get_local_time($result['exstart']);
203
+                    $return[$i]['user_id']      = $results[$i]['excruid'];
204
+                    $return[$i]['email']        = $results[$i]['exemail'];
205
+                }
206
+                $return[$i]['title'] = $result['extitle'];
207
+                $return[$i]['start_date'] = api_get_local_time($result['exstart']);
208 208
                 $return[$i]['end_date'] = api_get_local_time($result['exdate']);
209 209
                 $return[$i]['duration'] = $result['duration'];
210
-				$return[$i]['result'] = $result['exresult'];
211
-				$return[$i]['max'] = $result['exweight'];
210
+                $return[$i]['result'] = $result['exresult'];
211
+                $return[$i]['max'] = $result['exweight'];
212 212
                 $return[$i]['status'] = $revised ? get_lang('Validated') : get_lang('NotValidated');
213 213
                 $return[$i]['lp_id'] = $result['orig_lp_id'];
214 214
                 $return[$i]['lp_name'] = $result['lp_name'];
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 
222 222
                 $userWithResults[$result['excruid']] = 1;
223 223
                 $i++;
224
-			}
225
-		}
224
+            }
225
+        }
226 226
 
227 227
         if ($this->includeAllUsers) {
228 228
             $latestId = count($return);
@@ -265,18 +265,18 @@  discard block
 block discarded – undo
265 265
             }
266 266
         }
267 267
 
268
-		$this->results = $return;
268
+        $this->results = $return;
269 269
 
270
-		return true;
271
-	}
270
+        return true;
271
+    }
272 272
 
273
-	/**
274
-	 * Exports the complete report as a CSV file
275
-	 * @param	string		Document path inside the document tool
276
-	 * @param	integer		Optional user ID
277
-	 * @param	boolean		Whether to include user fields or not
278
-	 * @return	boolean		False on error
279
-	 */
273
+    /**
274
+     * Exports the complete report as a CSV file
275
+     * @param	string		Document path inside the document tool
276
+     * @param	integer		Optional user ID
277
+     * @param	boolean		Whether to include user fields or not
278
+     * @return	boolean		False on error
279
+     */
280 280
     public function exportCompleteReportCSV(
281 281
         $document_path = '',
282 282
         $user_id = null,
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
         $exercise_id = 0,
286 286
         $hotpotato_name = null
287 287
     ) {
288
-		global $charset;
289
-		$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
290
-
291
-		$filename = 'exercise_results_'.date('YmdGis').'.csv';
292
-		if(!empty($user_id)) {
293
-			$filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
294
-		}
295
-		$data = '';
288
+        global $charset;
289
+        $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
290
+
291
+        $filename = 'exercise_results_'.date('YmdGis').'.csv';
292
+        if(!empty($user_id)) {
293
+            $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
294
+        }
295
+        $data = '';
296 296
         if (api_is_western_name_order()) {
297 297
             if(!empty($this->results[0]['first_name'])) {
298 298
                 $data .= get_lang('FirstName').';';
@@ -316,28 +316,28 @@  discard block
 block discarded – undo
316 316
         $data .= get_lang('Email').';';
317 317
         $data .= get_lang('Groups').';';
318 318
 
319
-		if ($export_user_fields) {
320
-			//show user fields section with a big th colspan that spans over all fields
321
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
322
-			$num = count($extra_user_fields);
323
-			foreach($extra_user_fields as $field) {
324
-				$data .= '"'.str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)).'";';
325
-			}
326
-		}
327
-
328
-		$data .= get_lang('Title').';';
329
-		$data .= get_lang('StartDate').';';
319
+        if ($export_user_fields) {
320
+            //show user fields section with a big th colspan that spans over all fields
321
+            $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
322
+            $num = count($extra_user_fields);
323
+            foreach($extra_user_fields as $field) {
324
+                $data .= '"'.str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)).'";';
325
+            }
326
+        }
327
+
328
+        $data .= get_lang('Title').';';
329
+        $data .= get_lang('StartDate').';';
330 330
         $data .= get_lang('EndDate').';';
331 331
         $data .= get_lang('Duration'). ' ('.get_lang('MinMinutes').') ;';
332
-		$data .= get_lang('Score').';';
333
-		$data .= get_lang('Total').';';
332
+        $data .= get_lang('Score').';';
333
+        $data .= get_lang('Total').';';
334 334
         $data .= get_lang('Status').';';
335 335
         $data .= get_lang('ToolLearnpath').';';
336 336
         $data .= get_lang('UserIsCurrentlySubscribed').';';
337
-		$data .= "\n";
337
+        $data .= "\n";
338 338
 
339
-		//results
340
-		foreach ($this->results as $row) {
339
+        //results
340
+        foreach ($this->results as $row) {
341 341
 
342 342
             if (api_is_western_name_order()) {
343 343
                 $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
@@ -354,51 +354,51 @@  discard block
 block discarded – undo
354 354
             $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
355 355
             $data .= str_replace("\r\n",'  ',implode(", ", GroupManager :: get_user_group_name($row['user_id']))).';';
356 356
 
357
-			if ($export_user_fields) {
358
-				//show user fields data, if any, for this user
359
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
360
-				foreach($user_fields_values as $value) {
361
-					$data .= '"'.str_replace('"','""',api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)).'";';
362
-				}
363
-			}
357
+            if ($export_user_fields) {
358
+                //show user fields data, if any, for this user
359
+                $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
360
+                foreach($user_fields_values as $value) {
361
+                    $data .= '"'.str_replace('"','""',api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)).'";';
362
+                }
363
+            }
364 364
 
365
-			$data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
366
-			$data .= str_replace("\r\n",'  ',$row['start_date']).';';
365
+            $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
366
+            $data .= str_replace("\r\n",'  ',$row['start_date']).';';
367 367
             $data .= str_replace("\r\n",'  ',$row['end_date']).';';
368 368
             $data .= str_replace("\r\n",'  ',$row['duration']).';';
369
-			$data .= str_replace("\r\n",'  ',$row['result']).';';
370
-			$data .= str_replace("\r\n",'  ',$row['max']).';';
369
+            $data .= str_replace("\r\n",'  ',$row['result']).';';
370
+            $data .= str_replace("\r\n",'  ',$row['max']).';';
371 371
             $data .= str_replace("\r\n",'  ',$row['status']).';';
372 372
             $data .= str_replace("\r\n",'  ',$row['lp_name']).';';
373 373
             $data .= str_replace("\r\n",'  ',$row['is_user_subscribed']).';';
374
-			$data .= "\n";
375
-		}
376
-
377
-		//output the results
378
-		$len = strlen($data);
379
-		header('Content-type: application/octet-stream');
380
-		header('Content-Type: application/force-download');
381
-		header('Content-length: '.$len);
382
-		if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
383
-			header('Content-Disposition: filename= '.$filename);
384
-		} else {
385
-			header('Content-Disposition: attachment; filename= '.$filename);
386
-		}
387
-		if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
388
-			header('Pragma: ');
389
-			header('Cache-Control: ');
390
-			header('Cache-Control: public'); // IE cannot download from sessions without a cache
391
-		}
392
-		header('Content-Description: '.$filename);
393
-		header('Content-transfer-encoding: binary');
394
-		echo $data;
395
-		return true;
396
-	}
397
-
398
-	/**
399
-	 * Exports the complete report as an XLS file
400
-	 * @return	boolean		False on error
401
-	 */
374
+            $data .= "\n";
375
+        }
376
+
377
+        //output the results
378
+        $len = strlen($data);
379
+        header('Content-type: application/octet-stream');
380
+        header('Content-Type: application/force-download');
381
+        header('Content-length: '.$len);
382
+        if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
383
+            header('Content-Disposition: filename= '.$filename);
384
+        } else {
385
+            header('Content-Disposition: attachment; filename= '.$filename);
386
+        }
387
+        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
388
+            header('Pragma: ');
389
+            header('Cache-Control: ');
390
+            header('Cache-Control: public'); // IE cannot download from sessions without a cache
391
+        }
392
+        header('Content-Description: '.$filename);
393
+        header('Content-transfer-encoding: binary');
394
+        echo $data;
395
+        return true;
396
+    }
397
+
398
+    /**
399
+     * Exports the complete report as an XLS file
400
+     * @return	boolean		False on error
401
+     */
402 402
     public function exportCompleteReportXLS(
403 403
         $document_path = '',
404 404
         $user_id = null,
@@ -407,35 +407,35 @@  discard block
 block discarded – undo
407 407
         $exercise_id = 0,
408 408
         $hotpotato_name = null
409 409
     ) {
410
-		global $charset;
411
-		$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
412
-		$filename = 'exercise_results_'.api_get_local_time().'.xls';
413
-		if (!empty($user_id)) {
414
-			$filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
415
-		}
410
+        global $charset;
411
+        $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
412
+        $filename = 'exercise_results_'.api_get_local_time().'.xls';
413
+        if (!empty($user_id)) {
414
+            $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
415
+        }
416 416
 
417 417
         $spreadsheet = new PHPExcel();
418 418
         $spreadsheet->setActiveSheetIndex(0);
419 419
         $worksheet = $spreadsheet->getActiveSheet();
420 420
 
421
-		$line = 0;
422
-		$column = 0; //skip the first column (row titles)
421
+        $line = 0;
422
+        $column = 0; //skip the first column (row titles)
423 423
 
424
-		// check if exists column 'user'
425
-		$with_column_user = false;
426
-		foreach ($this->results as $result) {
427
-			if (!empty($result['last_name']) && !empty($result['first_name'])) {
428
-				$with_column_user = true;
429
-				break;
430
-			}
431
-		}
424
+        // check if exists column 'user'
425
+        $with_column_user = false;
426
+        foreach ($this->results as $result) {
427
+            if (!empty($result['last_name']) && !empty($result['first_name'])) {
428
+                $with_column_user = true;
429
+                break;
430
+            }
431
+        }
432 432
 
433 433
         $officialCodeInList = api_get_setting('show_official_code_exercise_result_list');
434 434
 
435
-		if ($with_column_user) {
435
+        if ($with_column_user) {
436 436
             if (api_is_western_name_order()) {
437
-    			$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
438
-    			$column++;
437
+                $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
438
+                $column++;
439 439
                 $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('LastName'));
440 440
                 $column++;
441 441
             } else {
@@ -451,17 +451,17 @@  discard block
 block discarded – undo
451 451
             }
452 452
 
453 453
             $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Email'));
454
-		    $column++;
455
-		}
454
+            $column++;
455
+        }
456 456
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Groups'));
457
-	    $column++;
457
+        $column++;
458 458
 
459
-		if ($export_user_fields) {
460
-			//show user fields section with a big th colspan that spans over all fields
461
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
459
+        if ($export_user_fields) {
460
+            //show user fields section with a big th colspan that spans over all fields
461
+            $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
462 462
 
463
-			//show the fields names for user fields
464
-			foreach ($extra_user_fields as $field) {
463
+            //show the fields names for user fields
464
+            foreach ($extra_user_fields as $field) {
465 465
                 $worksheet->setCellValueByColumnAndRow(
466 466
                     $column,
467 467
                     $line,
@@ -471,31 +471,31 @@  discard block
 block discarded – undo
471 471
                         $charset
472 472
                     )
473 473
                 );
474
-				$column++;
475
-			}
476
-		}
474
+                $column++;
475
+            }
476
+        }
477 477
 
478
-		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Title'));
479
-		$column++;
480
-		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('StartDate'));
478
+        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Title'));
479
+        $column++;
480
+        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('StartDate'));
481 481
         $column++;
482 482
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('EndDate'));
483 483
         $column++;
484 484
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Duration').' ('.get_lang('MinMinutes').')');
485
-		$column++;
486
-		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Score'));
487
-		$column++;
488
-		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Total'));
489
-		$column++;
485
+        $column++;
486
+        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Score'));
487
+        $column++;
488
+        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Total'));
489
+        $column++;
490 490
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Status'));
491
-		$column++;
491
+        $column++;
492 492
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('ToolLearnpath'));
493 493
         $column++;
494 494
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('UserIsCurrentlySubscribed'));
495
-		$line++;
495
+        $line++;
496 496
 
497
-		foreach ($this->results as $row) {
498
-			$column = 0;
497
+        foreach ($this->results as $row) {
498
+            $column = 0;
499 499
 
500 500
             if ($with_column_user) {
501 501
                 if (api_is_western_name_order()) {
@@ -517,15 +517,15 @@  discard block
 block discarded – undo
517 517
 
518 518
                 $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset));
519 519
                 $column++;
520
-			}
520
+            }
521 521
 
522 522
             $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags(implode(", ", GroupManager :: get_user_group_name($row['user_id']))), ENT_QUOTES, $charset));
523 523
             $column++;
524 524
 
525
-			if ($export_user_fields) {
526
-				//show user fields data, if any, for this user
527
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
528
-				foreach($user_fields_values as $value) {
525
+            if ($export_user_fields) {
526
+                //show user fields data, if any, for this user
527
+                $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
528
+                foreach($user_fields_values as $value) {
529 529
                     $worksheet->setCellValueByColumnAndRow(
530 530
                         $column,
531 531
                         $line,
@@ -535,12 +535,12 @@  discard block
 block discarded – undo
535 535
                             $charset
536 536
                         )
537 537
                     );
538
-					$column++;
539
-				}
540
-			}
538
+                    $column++;
539
+                }
540
+            }
541 541
 
542
-			$worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
543
-			$column++;
542
+            $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
543
+            $column++;
544 544
             $worksheet->setCellValueByColumnAndRow($column, $line, $row['start_date']);
545 545
             $column++;
546 546
             $worksheet->setCellValueByColumnAndRow($column, $line, $row['end_date']);
@@ -556,14 +556,14 @@  discard block
 block discarded – undo
556 556
             $worksheet->setCellValueByColumnAndRow($column, $line, $row['lp_name']);
557 557
             $column++;
558 558
             $worksheet->setCellValueByColumnAndRow($column, $line, $row['is_user_subscribed']);
559
-			$line++;
560
-		}
559
+            $line++;
560
+        }
561 561
 
562 562
         $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
563 563
         $writer = new PHPExcel_Writer_Excel2007($spreadsheet);
564 564
         $writer->save($file);
565 565
         DocumentManager::file_send_for_download($file, true, $filename);
566 566
 
567
-		return true;
568
-	}
567
+        return true;
568
+    }
569 569
 }
Please login to merge, or discard this patch.
main/exercice/hotpotatoes_exercise_result.class.php 1 patch
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
     //stores the results
15 15
     private $results = array();
16 16
 
17
-	/**
18
-	 * Gets the results of all students (or just one student if access is limited)
19
-	 * @param	string		The document path (for HotPotatoes retrieval)
20
-	 * @param	integer		User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
21
-	 * @param string $document_path
22
-	 */
23
-	public function getExercisesReporting($document_path, $hotpotato_name)
17
+    /**
18
+     * Gets the results of all students (or just one student if access is limited)
19
+     * @param	string		The document path (for HotPotatoes retrieval)
20
+     * @param	integer		User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
21
+     * @param string $document_path
22
+     */
23
+    public function getExercisesReporting($document_path, $hotpotato_name)
24 24
     {
25
-		$return = array();
25
+        $return = array();
26 26
         $TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
27 27
         $TBL_TRACK_HOTPOTATOES	= Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
28 28
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         $hotpotato_name  = Database::escape_string($hotpotato_name);
35 35
 
36 36
         if (!empty($exercise_id)) {
37
-          $session_id_and .= " AND exe_exo_id = $exercise_id ";
37
+            $session_id_and .= " AND exe_exo_id = $exercise_id ";
38 38
         }
39 39
 
40 40
         if (empty($user_id)) {
@@ -111,25 +111,25 @@  discard block
 block discarded – undo
111 111
         $this->results = $return;
112 112
 
113 113
         return true;
114
-	}
114
+    }
115 115
 
116 116
 
117
-	/**
118
-	 * Exports the complete report as a CSV file
119
-	 * @param	string		Document path inside the document tool
120
-	 * @param	integer		Optional user ID
121
-	 * @param	boolean		Whether to include user fields or not
122
-	 * @return	boolean		False on error
123
-	 */
124
-	public function exportCompleteReportCSV($document_path = '', $hotpotato_name)
117
+    /**
118
+     * Exports the complete report as a CSV file
119
+     * @param	string		Document path inside the document tool
120
+     * @param	integer		Optional user ID
121
+     * @param	boolean		Whether to include user fields or not
122
+     * @return	boolean		False on error
123
+     */
124
+    public function exportCompleteReportCSV($document_path = '', $hotpotato_name)
125 125
     {
126
-		global $charset;
127
-		$this->getExercisesReporting($document_path, $hotpotato_name);
128
-		$filename = 'exercise_results_'.date('YmdGis').'.csv';
129
-		if (!empty($user_id)) {
130
-			$filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
131
-		}
132
-		$data = '';
126
+        global $charset;
127
+        $this->getExercisesReporting($document_path, $hotpotato_name);
128
+        $filename = 'exercise_results_'.date('YmdGis').'.csv';
129
+        if (!empty($user_id)) {
130
+            $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
131
+        }
132
+        $data = '';
133 133
 
134 134
         if (api_is_western_name_order()) {
135 135
             if(!empty($this->results[0]['first_name'])) {
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         }
149 149
         $data .= get_lang('Email').';';
150 150
 
151
-		/*if ($export_user_fields) {
151
+        /*if ($export_user_fields) {
152 152
 			//show user fields section with a big th colspan that spans over all fields
153 153
 			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
154 154
 			$num = count($extra_user_fields);
@@ -157,25 +157,25 @@  discard block
 block discarded – undo
157 157
 			}
158 158
 		}*/
159 159
 
160
-		$data .= get_lang('Title').';';
161
-		$data .= get_lang('StartDate').';';
162
-		$data .= get_lang('Score').';';
163
-		$data .= get_lang('Total').';';
164
-		$data .= "\n";
160
+        $data .= get_lang('Title').';';
161
+        $data .= get_lang('StartDate').';';
162
+        $data .= get_lang('Score').';';
163
+        $data .= get_lang('Total').';';
164
+        $data .= "\n";
165 165
 
166
-		//results
167
-		foreach($this->results as $row) {
166
+        //results
167
+        foreach($this->results as $row) {
168 168
             if (api_is_western_name_order()) {
169
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
170
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
169
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
170
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
171 171
             } else {
172
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
173
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
172
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
173
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
174 174
             }
175 175
 
176 176
             $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
177 177
 
178
-			/*if ($export_user_fields) {
178
+            /*if ($export_user_fields) {
179 179
 				//show user fields data, if any, for this user
180 180
 				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
181 181
 				foreach($user_fields_values as $value) {
@@ -183,40 +183,40 @@  discard block
 block discarded – undo
183 183
 				}
184 184
 			}*/
185 185
 
186
-			$data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
187
-			$data .= str_replace("\r\n",'  ',$row['exe_date']).';';
188
-			$data .= str_replace("\r\n",'  ',$row['result']).';';
189
-			$data .= str_replace("\r\n",'  ',$row['max']).';';
190
-			$data .= "\n";
191
-		}
192
-
193
-		//output the results
194
-		$len = strlen($data);
195
-		header('Content-type: application/octet-stream');
196
-		header('Content-Type: application/force-download');
197
-		header('Content-length: '.$len);
198
-		if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
199
-			header('Content-Disposition: filename= '.$filename);
200
-		} else {
201
-			header('Content-Disposition: attachment; filename= '.$filename);
202
-		}
203
-		if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
204
-			header('Pragma: ');
205
-			header('Cache-Control: ');
206
-			header('Cache-Control: public'); // IE cannot download from sessions without a cache
207
-		}
208
-		header('Content-Description: '.$filename);
209
-		header('Content-transfer-encoding: binary');
210
-		// @todo add this utf-8 header for all csv files
211
-		echo "\xEF\xBB\xBF";  // force utf-8 header of csv file
212
-		echo $data;
213
-		return true;
214
-	}
215
-
216
-	/**
217
-	 * Exports the complete report as an XLS file
218
-	 * @return	boolean		False on error
219
-	 */
186
+            $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
187
+            $data .= str_replace("\r\n",'  ',$row['exe_date']).';';
188
+            $data .= str_replace("\r\n",'  ',$row['result']).';';
189
+            $data .= str_replace("\r\n",'  ',$row['max']).';';
190
+            $data .= "\n";
191
+        }
192
+
193
+        //output the results
194
+        $len = strlen($data);
195
+        header('Content-type: application/octet-stream');
196
+        header('Content-Type: application/force-download');
197
+        header('Content-length: '.$len);
198
+        if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
199
+            header('Content-Disposition: filename= '.$filename);
200
+        } else {
201
+            header('Content-Disposition: attachment; filename= '.$filename);
202
+        }
203
+        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
204
+            header('Pragma: ');
205
+            header('Cache-Control: ');
206
+            header('Cache-Control: public'); // IE cannot download from sessions without a cache
207
+        }
208
+        header('Content-Description: '.$filename);
209
+        header('Content-transfer-encoding: binary');
210
+        // @todo add this utf-8 header for all csv files
211
+        echo "\xEF\xBB\xBF";  // force utf-8 header of csv file
212
+        echo $data;
213
+        return true;
214
+    }
215
+
216
+    /**
217
+     * Exports the complete report as an XLS file
218
+     * @return	boolean		False on error
219
+     */
220 220
     public function exportCompleteReportXLS(
221 221
         $document_path = '',
222 222
         $user_id = null,
@@ -225,37 +225,37 @@  discard block
 block discarded – undo
225 225
         $exercise_id = 0,
226 226
         $hotpotato_name = null
227 227
     ) {
228
-		global $charset;
229
-		$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
230
-		$filename = 'exercise_results_'.api_get_local_time().'.xls';
231
-		if (!empty($user_id)) {
232
-			$filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
233
-		}
228
+        global $charset;
229
+        $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
230
+        $filename = 'exercise_results_'.api_get_local_time().'.xls';
231
+        if (!empty($user_id)) {
232
+            $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
233
+        }
234 234
 
235 235
         $spreadsheet = new PHPExcel();
236 236
         $spreadsheet->setActiveSheetIndex(0);
237 237
         $worksheet = $spreadsheet->getActiveSheet();
238 238
 
239 239
 
240
-		$line = 0;
241
-		$column = 0; //skip the first column (row titles)
240
+        $line = 0;
241
+        $column = 0; //skip the first column (row titles)
242 242
 
243
-		// check if exists column 'user'
244
-		$with_column_user = false;
245
-		foreach ($this->results as $result) {
246
-			if (!empty($result['last_name']) && !empty($result['first_name'])) {
247
-				$with_column_user = true;
248
-				break;
249
-			}
250
-		}
243
+        // check if exists column 'user'
244
+        $with_column_user = false;
245
+        foreach ($this->results as $result) {
246
+            if (!empty($result['last_name']) && !empty($result['first_name'])) {
247
+                $with_column_user = true;
248
+                break;
249
+            }
250
+        }
251 251
 
252
-		if ($with_column_user) {
253
-		    $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Email'));
254
-		    $column++;
252
+        if ($with_column_user) {
253
+            $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Email'));
254
+            $column++;
255 255
 
256 256
             if (api_is_western_name_order()) {
257
-    			$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
258
-    			$column++;
257
+                $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
258
+                $column++;
259 259
                 $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('LastName'));
260 260
                 $column++;
261 261
             } else {
@@ -264,36 +264,36 @@  discard block
 block discarded – undo
264 264
                 $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
265 265
                 $column++;
266 266
             }
267
-		}
267
+        }
268 268
 
269
-		if ($export_user_fields) {
270
-			//show user fields section with a big th colspan that spans over all fields
271
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
269
+        if ($export_user_fields) {
270
+            //show user fields section with a big th colspan that spans over all fields
271
+            $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
272 272
 
273
-			//show the fields names for user fields
274
-			foreach ($extra_user_fields as $field) {
275
-				$worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
276
-				$column++;
277
-			}
278
-		}
273
+            //show the fields names for user fields
274
+            foreach ($extra_user_fields as $field) {
275
+                $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
276
+                $column++;
277
+            }
278
+        }
279 279
 
280
-		$worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Title'));
281
-		$column++;
282
-		$worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('StartDate'));
280
+        $worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Title'));
281
+        $column++;
282
+        $worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('StartDate'));
283 283
         $column++;
284 284
         $worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('EndDate'));
285 285
         $column++;
286 286
         $worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Duration').' ('.get_lang('MinMinutes').')');
287
-		$column++;
288
-		$worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Score'));
289
-		$column++;
290
-		$worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Total'));
291
-		$column++;
287
+        $column++;
288
+        $worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Score'));
289
+        $column++;
290
+        $worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Total'));
291
+        $column++;
292 292
         $worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Status'));
293
-		$line++;
293
+        $line++;
294 294
 
295
-		foreach ($this->results as $row) {
296
-			$column = 0;
295
+        foreach ($this->results as $row) {
296
+            $column = 0;
297 297
 
298 298
             if ($with_column_user) {
299 299
                 $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset));
@@ -310,38 +310,38 @@  discard block
 block discarded – undo
310 310
                     $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
311 311
                     $column++;
312 312
                 }
313
-			}
313
+            }
314 314
 
315
-			if ($export_user_fields) {
316
-				//show user fields data, if any, for this user
317
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
318
-				foreach($user_fields_values as $value) {
319
-					$worksheet->setCellValueByColumnAndRow($column, $line,  api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
320
-					$column++;
321
-				}
322
-			}
315
+            if ($export_user_fields) {
316
+                //show user fields data, if any, for this user
317
+                $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
318
+                foreach($user_fields_values as $value) {
319
+                    $worksheet->setCellValueByColumnAndRow($column, $line,  api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
320
+                    $column++;
321
+                }
322
+            }
323 323
 
324
-			$worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
325
-			$column++;
326
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['start_date']);
324
+            $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
325
+            $column++;
326
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['start_date']);
327 327
             $column++;
328
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['end_date']);
328
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['end_date']);
329
+            $column++;
330
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['duration']);
331
+            $column++;
332
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['result']);
333
+            $column++;
334
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['max']);
329 335
             $column++;
330
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['duration']);
331
-			$column++;
332
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['result']);
333
-			$column++;
334
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['max']);
335
-			$column++;
336 336
             $worksheet->setCellValueByColumnAndRow($column, $line, $row['status']);
337
-			$line++;
338
-		}
337
+            $line++;
338
+        }
339 339
 
340 340
         $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
341 341
         $writer = new PHPExcel_Writer_Excel2007($spreadsheet);
342 342
         $writer->save($file);
343 343
         DocumentManager::file_send_for_download($file, true, $filename);
344 344
 
345
-		return true;
346
-	}
345
+        return true;
346
+    }
347 347
 }
Please login to merge, or discard this patch.