@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | $gradebook = ''; |
61 | 61 | if (isset($_SESSION['gradebook'])) { |
62 | - $gradebook= $_SESSION['gradebook']; |
|
62 | + $gradebook= $_SESSION['gradebook']; |
|
63 | 63 | } |
64 | 64 | if (!empty($gradebook) && $gradebook=='view') { |
65 | 65 | $interbreadcrumb[] = array( |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | $htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">'; |
80 | 80 | |
81 | 81 | if ($origin != 'learnpath') { |
82 | - // So we are not in learnpath tool |
|
83 | - Display::display_header($nameTools, get_lang('Exercise')); |
|
82 | + // So we are not in learnpath tool |
|
83 | + Display::display_header($nameTools, get_lang('Exercise')); |
|
84 | 84 | } else { |
85 | 85 | $htmlHeadXtra[] = " |
86 | 86 | <style> |
@@ -94,19 +94,19 @@ discard block |
||
94 | 94 | |
95 | 95 | // I'm in a preview mode as course admin. Display the action menu. |
96 | 96 | if (api_is_course_admin() && $origin != 'learnpath') { |
97 | - echo '<div class="actions">'; |
|
98 | - echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'. |
|
97 | + echo '<div class="actions">'; |
|
98 | + echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'. |
|
99 | 99 | Display::return_icon('back.png', get_lang('GoBackToQuestionList'), array(), 32).'</a>'; |
100 | - echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'. |
|
100 | + echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'. |
|
101 | 101 | Display::return_icon('edit.png', get_lang('ModifyExercise'), array(), 32).'</a>'; |
102 | - echo '</div>'; |
|
102 | + echo '</div>'; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | $feedback_type = $objExercise->feedback_type; |
106 | 106 | $exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id); |
107 | 107 | |
108 | 108 | if (!empty($exercise_stat_info['data_tracking'])) { |
109 | - $question_list = explode(',', $exercise_stat_info['data_tracking']); |
|
109 | + $question_list = explode(',', $exercise_stat_info['data_tracking']); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | $learnpath_id = $exercise_stat_info['orig_lp_id']; |
@@ -180,19 +180,19 @@ discard block |
||
180 | 180 | Session::erase('exe_id'); |
181 | 181 | } |
182 | 182 | |
183 | - Display::display_footer(); |
|
183 | + Display::display_footer(); |
|
184 | 184 | } else { |
185 | - $lp_mode = isset($_SESSION['lp_mode']) ? $_SESSION['lp_mode'] : null; |
|
186 | - $url = '../newscorm/lp_controller.php?cidReq='.api_get_course_id().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exercise_stat_info['exe_id'].'&fb_type='.$objExercise->feedback_type; |
|
187 | - $href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'"'; |
|
185 | + $lp_mode = isset($_SESSION['lp_mode']) ? $_SESSION['lp_mode'] : null; |
|
186 | + $url = '../newscorm/lp_controller.php?cidReq='.api_get_course_id().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exercise_stat_info['exe_id'].'&fb_type='.$objExercise->feedback_type; |
|
187 | + $href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'"'; |
|
188 | 188 | |
189 | 189 | if (api_is_allowed_to_session_edit()) { |
190 | 190 | Session::erase('objExercise'); |
191 | 191 | Session::erase('exe_id'); |
192 | 192 | } |
193 | 193 | |
194 | - // Record the results in the learning path, using the SCORM interface (API) |
|
195 | - echo "<script>window.parent.API.void_save_asset('$total_score', '$max_score', 0, 'completed');</script>"; |
|
194 | + // Record the results in the learning path, using the SCORM interface (API) |
|
195 | + echo "<script>window.parent.API.void_save_asset('$total_score', '$max_score', 0, 'completed');</script>"; |
|
196 | 196 | echo '<script type="text/javascript">'.$href.'</script>'; |
197 | - echo '</body></html>'; |
|
197 | + echo '</body></html>'; |
|
198 | 198 | } |
@@ -9,7 +9,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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($line, $column,get_lang('FirstName')); |
|
438 | - $column++; |
|
437 | + $worksheet->SetCellValueByColumnAndRow($line, $column,get_lang('FirstName')); |
|
438 | + $column++; |
|
439 | 439 | $worksheet->SetCellValueByColumnAndRow($line, $column,get_lang('LastName')); |
440 | 440 | $column++; |
441 | 441 | } else { |
@@ -451,43 +451,43 @@ discard block |
||
451 | 451 | } |
452 | 452 | |
453 | 453 | $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Email')); |
454 | - $column++; |
|
455 | - } |
|
454 | + $column++; |
|
455 | + } |
|
456 | 456 | $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Groups')); |
457 | - $column++; |
|
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); |
|
462 | - |
|
463 | - //show the fields names for user fields |
|
464 | - foreach ($extra_user_fields as $field) { |
|
465 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)); |
|
466 | - $column++; |
|
467 | - } |
|
468 | - } |
|
469 | - |
|
470 | - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Title')); |
|
471 | - $column++; |
|
472 | - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('StartDate')); |
|
457 | + $column++; |
|
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); |
|
462 | + |
|
463 | + //show the fields names for user fields |
|
464 | + foreach ($extra_user_fields as $field) { |
|
465 | + $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)); |
|
466 | + $column++; |
|
467 | + } |
|
468 | + } |
|
469 | + |
|
470 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Title')); |
|
471 | + $column++; |
|
472 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('StartDate')); |
|
473 | 473 | $column++; |
474 | 474 | $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('EndDate')); |
475 | 475 | $column++; |
476 | 476 | $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Duration').' ('.get_lang('MinMinutes').')'); |
477 | - $column++; |
|
478 | - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Score')); |
|
479 | - $column++; |
|
480 | - $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Total')); |
|
481 | - $column++; |
|
477 | + $column++; |
|
478 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Score')); |
|
479 | + $column++; |
|
480 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Total')); |
|
481 | + $column++; |
|
482 | 482 | $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Status')); |
483 | - $column++; |
|
483 | + $column++; |
|
484 | 484 | $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('ToolLearnpath')); |
485 | 485 | $column++; |
486 | 486 | $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('UserIsCurrentlySubscribed')); |
487 | - $line++; |
|
487 | + $line++; |
|
488 | 488 | |
489 | - foreach ($this->results as $row) { |
|
490 | - $column = 0; |
|
489 | + foreach ($this->results as $row) { |
|
490 | + $column = 0; |
|
491 | 491 | |
492 | 492 | if ($with_column_user) { |
493 | 493 | if (api_is_western_name_order()) { |
@@ -509,22 +509,22 @@ discard block |
||
509 | 509 | |
510 | 510 | $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)); |
511 | 511 | $column++; |
512 | - } |
|
512 | + } |
|
513 | 513 | |
514 | 514 | $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags(implode(", ", GroupManager :: get_user_group_name($row['user_id']))), ENT_QUOTES, $charset)); |
515 | 515 | $column++; |
516 | 516 | |
517 | - if ($export_user_fields) { |
|
518 | - //show user fields data, if any, for this user |
|
519 | - $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
|
520 | - foreach($user_fields_values as $value) { |
|
521 | - $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
522 | - $column++; |
|
523 | - } |
|
524 | - } |
|
525 | - |
|
526 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
527 | - $column++; |
|
517 | + if ($export_user_fields) { |
|
518 | + //show user fields data, if any, for this user |
|
519 | + $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
|
520 | + foreach($user_fields_values as $value) { |
|
521 | + $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
522 | + $column++; |
|
523 | + } |
|
524 | + } |
|
525 | + |
|
526 | + $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
527 | + $column++; |
|
528 | 528 | $worksheet->SetCellValueByColumnAndRow($line, $column, $row['start_date']); |
529 | 529 | $column++; |
530 | 530 | $worksheet->SetCellValueByColumnAndRow($line, $column, $row['end_date']); |
@@ -540,14 +540,14 @@ discard block |
||
540 | 540 | $worksheet->SetCellValueByColumnAndRow($line, $column, $row['lp_name']); |
541 | 541 | $column++; |
542 | 542 | $worksheet->SetCellValueByColumnAndRow($line, $column, $row['is_user_subscribed']); |
543 | - $line++; |
|
544 | - } |
|
543 | + $line++; |
|
544 | + } |
|
545 | 545 | |
546 | 546 | $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename); |
547 | 547 | $writer = new PHPExcel_Writer_Excel2007($spreadsheet); |
548 | 548 | $writer->save($file); |
549 | 549 | DocumentManager::file_send_for_download($file, true, $filename); |
550 | 550 | |
551 | - return true; |
|
552 | - } |
|
551 | + return true; |
|
552 | + } |
|
553 | 553 | } |
@@ -55,18 +55,18 @@ discard block |
||
55 | 55 | |
56 | 56 | function createAnswersForm($form) |
57 | 57 | { |
58 | - return true; |
|
58 | + return true; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | function processAnswersCreation($form) |
62 | 62 | { |
63 | - return true; |
|
63 | + return true; |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | /** |
67 | - * Class |
|
68 | - * @package chamilo.exercise |
|
69 | - */ |
|
67 | + * Class |
|
68 | + * @package chamilo.exercise |
|
69 | + */ |
|
70 | 70 | class ImsAnswerMultipleChoice extends Answer |
71 | 71 | { |
72 | 72 | /** |
@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | public function imsExportResponses($questionIdent, $questionStatment) |
77 | 77 | { |
78 | 78 | // @todo getAnswersList() converts the answers using api_html_entity_decode() |
79 | - $this->answerList = $this->getAnswersList(true); |
|
79 | + $this->answerList = $this->getAnswersList(true); |
|
80 | 80 | $out = ' <choiceInteraction responseIdentifier="' . $questionIdent . '" >' . "\n"; |
81 | 81 | $out .= ' <prompt><![CDATA['.formatExerciseQtiTitle($questionStatment) . ']]></prompt>'. "\n"; |
82 | - if (is_array($this->answerList)) { |
|
83 | - foreach ($this->answerList as $current_answer) { |
|
84 | - $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false"> |
|
82 | + if (is_array($this->answerList)) { |
|
83 | + foreach ($this->answerList as $current_answer) { |
|
84 | + $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false"> |
|
85 | 85 | <![CDATA['.formatExerciseQtiTitle($current_answer['answer']).']]>'; |
86 | - if (isset($current_answer['comment']) && $current_answer['comment'] != '') { |
|
87 | - $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '"> |
|
86 | + if (isset($current_answer['comment']) && $current_answer['comment'] != '') { |
|
87 | + $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '"> |
|
88 | 88 | <![CDATA['.formatExerciseQtiTitle($current_answer['comment']).']]> |
89 | 89 | </feedbackInline>'; |
90 | - } |
|
91 | - $out .= '</simpleChoice>'. "\n"; |
|
92 | - } |
|
93 | - } |
|
90 | + } |
|
91 | + $out .= '</simpleChoice>'. "\n"; |
|
92 | + } |
|
93 | + } |
|
94 | 94 | $out .= ' </choiceInteraction>'. "\n"; |
95 | 95 | |
96 | 96 | return $out; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function imsExportResponsesDeclaration($questionIdent) |
104 | 104 | { |
105 | - $this->answerList = $this->getAnswersList(true); |
|
106 | - $type = $this->getQuestionType(); |
|
105 | + $this->answerList = $this->getAnswersList(true); |
|
106 | + $type = $this->getQuestionType(); |
|
107 | 107 | if ($type == MCMA) $cardinality = 'multiple'; else $cardinality = 'single'; |
108 | 108 | |
109 | 109 | $out = ' <responseDeclaration identifier="' . $questionIdent . '" cardinality="' . $cardinality . '" baseType="identifier">' . "\n"; |
@@ -111,25 +111,25 @@ discard block |
||
111 | 111 | // Match the correct answers. |
112 | 112 | |
113 | 113 | $out .= ' <correctResponse>'. "\n"; |
114 | - if (is_array($this->answerList)) { |
|
115 | - foreach($this->answerList as $current_answer) { |
|
116 | - if ($current_answer['correct']) { |
|
117 | - $out .= ' <value>answer_'. $current_answer['id'] .'</value>'. "\n"; |
|
118 | - } |
|
119 | - } |
|
120 | - } |
|
114 | + if (is_array($this->answerList)) { |
|
115 | + foreach($this->answerList as $current_answer) { |
|
116 | + if ($current_answer['correct']) { |
|
117 | + $out .= ' <value>answer_'. $current_answer['id'] .'</value>'. "\n"; |
|
118 | + } |
|
119 | + } |
|
120 | + } |
|
121 | 121 | $out .= ' </correctResponse>'. "\n"; |
122 | 122 | |
123 | 123 | //Add the grading |
124 | 124 | |
125 | 125 | $out .= ' <mapping>'. "\n"; |
126 | - if (is_array($this->answerList)) { |
|
127 | - foreach($this->answerList as $current_answer) { |
|
128 | - if (isset($current_answer['grade'])) { |
|
129 | - $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n"; |
|
130 | - } |
|
131 | - } |
|
132 | - } |
|
126 | + if (is_array($this->answerList)) { |
|
127 | + foreach($this->answerList as $current_answer) { |
|
128 | + if (isset($current_answer['grade'])) { |
|
129 | + $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n"; |
|
130 | + } |
|
131 | + } |
|
132 | + } |
|
133 | 133 | $out .= ' </mapping>'. "\n"; |
134 | 134 | $out .= ' </responseDeclaration>'. "\n"; |
135 | 135 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function imsExportResponses($questionIdent, $questionStatment) |
152 | 152 | { |
153 | - $this->answerList = $this->getAnswersList(true); |
|
153 | + $this->answerList = $this->getAnswersList(true); |
|
154 | 154 | $text = ''; |
155 | 155 | $text .= $this->answerText; |
156 | 156 | if (is_array($this->answerList)) { |
@@ -171,28 +171,28 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function imsExportResponsesDeclaration($questionIdent) |
173 | 173 | { |
174 | - $this->answerList = $this->getAnswersList(true); |
|
175 | - $this->gradeList = $this->getGradesList(); |
|
174 | + $this->answerList = $this->getAnswersList(true); |
|
175 | + $this->gradeList = $this->getGradesList(); |
|
176 | 176 | $out = ''; |
177 | - if (is_array($this->answerList)) { |
|
178 | - foreach ($this->answerList as $answer) { |
|
179 | - $answerKey = $answer['id']; |
|
180 | - $answer = $answer['answer']; |
|
181 | - $out .= ' <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n"; |
|
182 | - $out .= ' <correctResponse>'. "\n"; |
|
177 | + if (is_array($this->answerList)) { |
|
178 | + foreach ($this->answerList as $answer) { |
|
179 | + $answerKey = $answer['id']; |
|
180 | + $answer = $answer['answer']; |
|
181 | + $out .= ' <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n"; |
|
182 | + $out .= ' <correctResponse>'. "\n"; |
|
183 | 183 | $out .= ' <value><![CDATA['.formatExerciseQtiTitle($answer).']]></value>'. "\n"; |
184 | - $out .= ' </correctResponse>'. "\n"; |
|
185 | - if (isset($this->gradeList[$answerKey])) { |
|
186 | - $out .= ' <mapping>'. "\n"; |
|
187 | - $out .= ' <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n"; |
|
188 | - $out .= ' </mapping>'. "\n"; |
|
189 | - } |
|
190 | - |
|
191 | - $out .= ' </responseDeclaration>'. "\n"; |
|
192 | - } |
|
193 | - } |
|
194 | - |
|
195 | - return $out; |
|
184 | + $out .= ' </correctResponse>'. "\n"; |
|
185 | + if (isset($this->gradeList[$answerKey])) { |
|
186 | + $out .= ' <mapping>'. "\n"; |
|
187 | + $out .= ' <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n"; |
|
188 | + $out .= ' </mapping>'. "\n"; |
|
189 | + } |
|
190 | + |
|
191 | + $out .= ' </responseDeclaration>'. "\n"; |
|
192 | + } |
|
193 | + } |
|
194 | + |
|
195 | + return $out; |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function imsExportResponses($questionIdent, $questionStatment) |
209 | 209 | { |
210 | - $this->answerList = $this->getAnswersList(true); |
|
211 | - $maxAssociation = max(count($this->leftList), count($this->rightList)); |
|
210 | + $this->answerList = $this->getAnswersList(true); |
|
211 | + $maxAssociation = max(count($this->leftList), count($this->rightList)); |
|
212 | 212 | |
213 | 213 | $out = ""; |
214 | 214 | |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | //add left column |
219 | 219 | |
220 | 220 | $out .= ' <simpleMatchSet>'. "\n"; |
221 | - if (is_array($this->leftList)) { |
|
222 | - foreach ($this->leftList as $leftKey=>$leftElement) { |
|
223 | - $out .= ' |
|
221 | + if (is_array($this->leftList)) { |
|
222 | + foreach ($this->leftList as $leftKey=>$leftElement) { |
|
223 | + $out .= ' |
|
224 | 224 | <simpleAssociableChoice identifier="left_'.$leftKey.'" > |
225 | 225 | <![CDATA['.formatExerciseQtiTitle($leftElement['answer']).']]> |
226 | 226 | </simpleAssociableChoice>'. "\n"; |
227 | - } |
|
228 | - } |
|
227 | + } |
|
228 | + } |
|
229 | 229 | |
230 | 230 | $out .= ' </simpleMatchSet>'. "\n"; |
231 | 231 | |
@@ -235,14 +235,14 @@ discard block |
||
235 | 235 | |
236 | 236 | $i = 0; |
237 | 237 | |
238 | - if (is_array($this->rightList)) { |
|
239 | - foreach($this->rightList as $rightKey=>$rightElement) { |
|
240 | - $out .= '<simpleAssociableChoice identifier="right_'.$i.'" > |
|
238 | + if (is_array($this->rightList)) { |
|
239 | + foreach($this->rightList as $rightKey=>$rightElement) { |
|
240 | + $out .= '<simpleAssociableChoice identifier="right_'.$i.'" > |
|
241 | 241 | <![CDATA['.formatExerciseQtiTitle($rightElement['answer']).']]> |
242 | 242 | </simpleAssociableChoice>'. "\n"; |
243 | - $i++; |
|
244 | - } |
|
245 | - } |
|
243 | + $i++; |
|
244 | + } |
|
245 | + } |
|
246 | 246 | $out .= ' </simpleMatchSet>'. "\n"; |
247 | 247 | $out .= '</matchInteraction>'. "\n"; |
248 | 248 | |
@@ -254,30 +254,30 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public function imsExportResponsesDeclaration($questionIdent) |
256 | 256 | { |
257 | - $this->answerList = $this->getAnswersList(true); |
|
257 | + $this->answerList = $this->getAnswersList(true); |
|
258 | 258 | $out = ' <responseDeclaration identifier="' . $questionIdent . '" cardinality="single" baseType="identifier">' . "\n"; |
259 | 259 | $out .= ' <correctResponse>' . "\n"; |
260 | 260 | |
261 | 261 | $gradeArray = array(); |
262 | - if (is_array($this->leftList)) { |
|
263 | - foreach ($this->leftList as $leftKey=>$leftElement) { |
|
264 | - $i=0; |
|
265 | - foreach ($this->rightList as $rightKey=>$rightElement) { |
|
266 | - if (($leftElement['match'] == $rightElement['code'])) { |
|
267 | - $out .= ' <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n"; |
|
268 | - |
|
269 | - $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade']; |
|
270 | - } |
|
271 | - $i++; |
|
272 | - } |
|
273 | - } |
|
274 | - } |
|
262 | + if (is_array($this->leftList)) { |
|
263 | + foreach ($this->leftList as $leftKey=>$leftElement) { |
|
264 | + $i=0; |
|
265 | + foreach ($this->rightList as $rightKey=>$rightElement) { |
|
266 | + if (($leftElement['match'] == $rightElement['code'])) { |
|
267 | + $out .= ' <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n"; |
|
268 | + |
|
269 | + $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade']; |
|
270 | + } |
|
271 | + $i++; |
|
272 | + } |
|
273 | + } |
|
274 | + } |
|
275 | 275 | $out .= ' </correctResponse>'. "\n"; |
276 | 276 | $out .= ' <mapping>' . "\n"; |
277 | 277 | if (is_array($gradeArray)) { |
278 | - foreach ($gradeArray as $gradeKey=>$grade) { |
|
279 | - $out .= ' <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n"; |
|
280 | - } |
|
278 | + foreach ($gradeArray as $gradeKey=>$grade) { |
|
279 | + $out .= ' <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n"; |
|
280 | + } |
|
281 | 281 | } |
282 | 282 | $out .= ' </mapping>' . "\n"; |
283 | 283 | $out .= ' </responseDeclaration>'. "\n"; |
@@ -298,49 +298,49 @@ discard block |
||
298 | 298 | */ |
299 | 299 | public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='') |
300 | 300 | { |
301 | - $this->answerList = $this->getAnswersList(true); |
|
302 | - $questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia; |
|
303 | - $mimetype = mime_content_type($questionMedia); |
|
304 | - if(empty($mimetype)){ |
|
305 | - $mimetype = 'image/jpeg'; |
|
306 | - } |
|
307 | - |
|
308 | - $text = ' <p>'.$questionStatment.'</p>'."\n"; |
|
309 | - $text .= ' <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n"; |
|
310 | - $text .= ' <prompt>'.$questionDesc.'</prompt>'."\n"; |
|
311 | - $text .= ' <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n"; |
|
301 | + $this->answerList = $this->getAnswersList(true); |
|
302 | + $questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia; |
|
303 | + $mimetype = mime_content_type($questionMedia); |
|
304 | + if(empty($mimetype)){ |
|
305 | + $mimetype = 'image/jpeg'; |
|
306 | + } |
|
307 | + |
|
308 | + $text = ' <p>'.$questionStatment.'</p>'."\n"; |
|
309 | + $text .= ' <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n"; |
|
310 | + $text .= ' <prompt>'.$questionDesc.'</prompt>'."\n"; |
|
311 | + $text .= ' <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n"; |
|
312 | 312 | if (is_array($this->answerList)) { |
313 | - foreach ($this->answerList as $key=>$answer) { |
|
314 | - $key = $answer['id']; |
|
315 | - $answerTxt = $answer['answer']; |
|
316 | - $len = api_strlen($answerTxt); |
|
317 | - //coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663 |
|
318 | - $coords = ''; |
|
319 | - $type = 'default'; |
|
320 | - switch($answer['hotspot_type']){ |
|
321 | - case 'square': |
|
322 | - $type = 'rect'; |
|
323 | - $res = array(); |
|
324 | - $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
325 | - $coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]); |
|
326 | - break; |
|
327 | - case 'circle': |
|
328 | - $type = 'circle'; |
|
329 | - $res = array(); |
|
330 | - $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
331 | - $coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4]))); |
|
332 | - break; |
|
333 | - case 'poly': |
|
334 | - $type = 'poly'; |
|
335 | - $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
336 | - break; |
|
337 | - case 'delineation' : |
|
338 | - $type = 'delineation'; |
|
339 | - $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
340 | - break; |
|
341 | - } |
|
342 | - $text .= ' <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n"; |
|
343 | - } |
|
313 | + foreach ($this->answerList as $key=>$answer) { |
|
314 | + $key = $answer['id']; |
|
315 | + $answerTxt = $answer['answer']; |
|
316 | + $len = api_strlen($answerTxt); |
|
317 | + //coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663 |
|
318 | + $coords = ''; |
|
319 | + $type = 'default'; |
|
320 | + switch($answer['hotspot_type']){ |
|
321 | + case 'square': |
|
322 | + $type = 'rect'; |
|
323 | + $res = array(); |
|
324 | + $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
325 | + $coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]); |
|
326 | + break; |
|
327 | + case 'circle': |
|
328 | + $type = 'circle'; |
|
329 | + $res = array(); |
|
330 | + $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res); |
|
331 | + $coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4]))); |
|
332 | + break; |
|
333 | + case 'poly': |
|
334 | + $type = 'poly'; |
|
335 | + $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
336 | + break; |
|
337 | + case 'delineation' : |
|
338 | + $type = 'delineation'; |
|
339 | + $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']); |
|
340 | + break; |
|
341 | + } |
|
342 | + $text .= ' <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n"; |
|
343 | + } |
|
344 | 344 | } |
345 | 345 | $text .= ' </graphicOrderInteraction>'."\n"; |
346 | 346 | $out = $text; |
@@ -353,23 +353,23 @@ discard block |
||
353 | 353 | */ |
354 | 354 | public function imsExportResponsesDeclaration($questionIdent) |
355 | 355 | { |
356 | - $this->answerList = $this->getAnswersList(true); |
|
357 | - $this->gradeList = $this->getGradesList(); |
|
356 | + $this->answerList = $this->getAnswersList(true); |
|
357 | + $this->gradeList = $this->getGradesList(); |
|
358 | 358 | $out = ''; |
359 | 359 | $out .= ' <responseDeclaration identifier="hotspot_'.$questionIdent.'" cardinality="ordered" baseType="identifier">' . "\n"; |
360 | 360 | $out .= ' <correctResponse>'. "\n"; |
361 | 361 | |
362 | - if (is_array($this->answerList)) { |
|
363 | - foreach ($this->answerList as $answerKey=>$answer) { |
|
364 | - $answerKey = $answer['id']; |
|
365 | - $answer = $answer['answer']; |
|
366 | - $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>'; |
|
367 | - } |
|
368 | - } |
|
362 | + if (is_array($this->answerList)) { |
|
363 | + foreach ($this->answerList as $answerKey=>$answer) { |
|
364 | + $answerKey = $answer['id']; |
|
365 | + $answer = $answer['answer']; |
|
366 | + $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>'; |
|
367 | + } |
|
368 | + } |
|
369 | 369 | $out .= ' </correctResponse>'. "\n"; |
370 | 370 | $out .= ' </responseDeclaration>'. "\n"; |
371 | 371 | |
372 | - return $out; |
|
372 | + return $out; |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
@@ -384,14 +384,14 @@ discard block |
||
384 | 384 | * Export the question part as a matrix-choice, with only one possible answer per line. |
385 | 385 | */ |
386 | 386 | public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='') |
387 | - { |
|
388 | - return ''; |
|
389 | - } |
|
387 | + { |
|
388 | + return ''; |
|
389 | + } |
|
390 | 390 | /** |
391 | 391 | * |
392 | 392 | */ |
393 | 393 | public function imsExportResponsesDeclaration($questionIdent) |
394 | 394 | { |
395 | - return ''; |
|
395 | + return ''; |
|
396 | 396 | } |
397 | 397 | } |
@@ -1,15 +1,15 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* For licensing terms, see /license.txt */ |
3 | 3 | /** |
4 | - * Library for the import of Aiken format |
|
5 | - * @author claro team <[email protected]> |
|
6 | - * @author Guillaume Lederer <[email protected]> |
|
7 | - * @author César Perales <[email protected]> Parse function for Aiken format |
|
8 | - * @package chamilo.exercise |
|
9 | - */ |
|
4 | + * Library for the import of Aiken format |
|
5 | + * @author claro team <[email protected]> |
|
6 | + * @author Guillaume Lederer <[email protected]> |
|
7 | + * @author César Perales <[email protected]> Parse function for Aiken format |
|
8 | + * @package chamilo.exercise |
|
9 | + */ |
|
10 | 10 | /** |
11 | - * Security check |
|
12 | - */ |
|
11 | + * Security check |
|
12 | + */ |
|
13 | 13 | if (count(get_included_files()) == 1) |
14 | 14 | die('---'); |
15 | 15 | |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | } |
79 | 79 | } |
80 | 80 | /** |
81 | - * Main function to import the Aiken exercise |
|
82 | - * @return mixed True on success, error message on failure |
|
83 | - */ |
|
81 | + * Main function to import the Aiken exercise |
|
82 | + * @return mixed True on success, error message on failure |
|
83 | + */ |
|
84 | 84 | function aiken_import_exercise($file) |
85 | 85 | { |
86 | 86 | global $exercise_info; |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $correct_answer_index = array_search($matches[1], $answers_array); |
282 | 282 | $exercise_info['question'][$question_index]['title'] = $matches[1]; |
283 | 283 | } elseif (preg_match('/^TAGS:\s?([A-Z])\s?/', $info, $matches)) { |
284 | - //TAGS for chamilo >= 1.10 |
|
284 | + //TAGS for chamilo >= 1.10 |
|
285 | 285 | $exercise_info['question'][$question_index]['answer_tags'] = explode(',', $matches[1]); |
286 | 286 | } elseif (preg_match('/^ETIQUETAS:\s?([A-Z])\s?/', $info, $matches)) { |
287 | 287 | //TAGS for chamilo >= 1.10 (Spanish e-ducativa format) |
@@ -1,18 +1,18 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* For licensing terms, see /license.txt */ |
3 | 3 | /** |
4 | - * @author Claro Team <[email protected]> |
|
5 | - * @author Yannick Warnier <[email protected]> - updated ImsAnswerHotspot to match QTI norms |
|
6 | - * @author César Perales <[email protected]> Updated function names and import files for Aiken format support |
|
7 | - * @package chamilo.exercise |
|
8 | - */ |
|
4 | + * @author Claro Team <[email protected]> |
|
5 | + * @author Yannick Warnier <[email protected]> - updated ImsAnswerHotspot to match QTI norms |
|
6 | + * @author César Perales <[email protected]> Updated function names and import files for Aiken format support |
|
7 | + * @package chamilo.exercise |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | if ( count( get_included_files() ) == 1 ) die( '---' ); |
11 | 11 | |
12 | 12 | if (!function_exists('mime_content_type')) { |
13 | - function mime_content_type($filename) { |
|
14 | - return DocumentManager::file_get_mime_type((string)$filename); |
|
15 | - } |
|
13 | + function mime_content_type($filename) { |
|
14 | + return DocumentManager::file_get_mime_type((string)$filename); |
|
15 | + } |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | case MCUA : |
31 | 31 | $answer = new AikenAnswerMultipleChoice($this->id); |
32 | - return $answer; |
|
32 | + return $answer; |
|
33 | 33 | default : |
34 | 34 | $answer = null; |
35 | 35 | break; |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | } |
39 | 39 | function createAnswersForm($form) |
40 | 40 | { |
41 | - return true; |
|
41 | + return true; |
|
42 | 42 | } |
43 | 43 | function processAnswersCreation($form) |
44 | 44 | { |
45 | - return true; |
|
45 | + return true; |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 |
@@ -447,7 +447,7 @@ |
||
447 | 447 | $position = $row_max->max_position + 1; |
448 | 448 | |
449 | 449 | // Insert a new answer |
450 | - $params = [ |
|
450 | + $params = [ |
|
451 | 451 | 'c_id' => $course_id, |
452 | 452 | 'id' => $id, |
453 | 453 | 'question_id' => $question_id, |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | |
31 | 31 | // Query db for answers |
32 | 32 | if ($answer_type==HOT_SPOT_DELINEATION) { |
33 | - $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS |
|
33 | + $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS |
|
34 | 34 | WHERE c_id = $course_id AND question_id = ".intval($questionId)." AND hotspot_type = 'delineation' ORDER BY id"; |
35 | 35 | } else { |
36 | - $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS |
|
36 | + $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS |
|
37 | 37 | WHERE c_id = $course_id AND question_id = ".intval($questionId)." ORDER BY id"; |
38 | 38 | } |
39 | 39 | $result = Database::query($sql); |
@@ -74,37 +74,37 @@ discard block |
||
74 | 74 | $hotSpot['id'] = $hotspot['id']; |
75 | 75 | $hotSpot['answer'] = $hotspot['answer']; |
76 | 76 | |
77 | - // Square or rectancle |
|
78 | - if ($hotspot['hotspot_type'] == 'square' ) |
|
79 | - { |
|
77 | + // Square or rectancle |
|
78 | + if ($hotspot['hotspot_type'] == 'square' ) |
|
79 | + { |
|
80 | 80 | $hotSpot['type'] = 'square'; |
81 | - } |
|
82 | - // Circle or ovale |
|
83 | - if ($hotspot['hotspot_type'] == 'circle') |
|
84 | - { |
|
81 | + } |
|
82 | + // Circle or ovale |
|
83 | + if ($hotspot['hotspot_type'] == 'circle') |
|
84 | + { |
|
85 | 85 | $hotSpot['type'] = 'circle'; |
86 | - } |
|
87 | - // Polygon |
|
88 | - if ($hotspot['hotspot_type'] == 'poly') |
|
89 | - { |
|
86 | + } |
|
87 | + // Polygon |
|
88 | + if ($hotspot['hotspot_type'] == 'poly') |
|
89 | + { |
|
90 | 90 | $hotSpot['type'] = 'poly'; |
91 | - } |
|
92 | - // Delineation |
|
93 | - if ($hotspot['hotspot_type'] == 'delineation') |
|
94 | - { |
|
91 | + } |
|
92 | + // Delineation |
|
93 | + if ($hotspot['hotspot_type'] == 'delineation') |
|
94 | + { |
|
95 | 95 | $hotSpot['type'] = 'delineation'; |
96 | - } |
|
97 | - // No error |
|
98 | - if ($hotspot['hotspot_type'] == 'noerror') |
|
99 | - { |
|
96 | + } |
|
97 | + // No error |
|
98 | + if ($hotspot['hotspot_type'] == 'noerror') |
|
99 | + { |
|
100 | 100 | $hotSpot['type'] = 'noerror'; |
101 | - } |
|
101 | + } |
|
102 | 102 | |
103 | - // This is a good answer, count + 1 for nmbr of clicks |
|
104 | - if ($hotspot['hotspot_type'] > 0) |
|
105 | - { |
|
106 | - $nmbrTries++; |
|
107 | - } |
|
103 | + // This is a good answer, count + 1 for nmbr of clicks |
|
104 | + if ($hotspot['hotspot_type'] > 0) |
|
105 | + { |
|
106 | + $nmbrTries++; |
|
107 | + } |
|
108 | 108 | |
109 | 109 | $hotSpot['coord'] = $hotspot['hotspot_coordinates']; |
110 | 110 |
@@ -14,14 +14,14 @@ discard block |
||
14 | 14 | //stores the results |
15 | 15 | private $results = array(); |
16 | 16 | |
17 | - /** |
|
18 | - * Gets the results of all students (or just one student if access is limited) |
|
19 | - * @param string The document path (for HotPotatoes retrieval) |
|
20 | - * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null |
|
21 | - */ |
|
22 | - public function getExercisesReporting($document_path, $hotpotato_name) |
|
17 | + /** |
|
18 | + * Gets the results of all students (or just one student if access is limited) |
|
19 | + * @param string The document path (for HotPotatoes retrieval) |
|
20 | + * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null |
|
21 | + */ |
|
22 | + public function getExercisesReporting($document_path, $hotpotato_name) |
|
23 | 23 | { |
24 | - $return = array(); |
|
24 | + $return = array(); |
|
25 | 25 | $TBL_USER = Database::get_main_table(TABLE_MAIN_USER); |
26 | 26 | $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); |
27 | 27 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $hotpotato_name = Database::escape_string($hotpotato_name); |
34 | 34 | |
35 | 35 | if (!empty($exercise_id)) { |
36 | - $session_id_and .= " AND exe_exo_id = $exercise_id "; |
|
36 | + $session_id_and .= " AND exe_exo_id = $exercise_id "; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | if (empty($user_id)) { |
@@ -110,25 +110,25 @@ discard block |
||
110 | 110 | $this->results = $return; |
111 | 111 | |
112 | 112 | return true; |
113 | - } |
|
113 | + } |
|
114 | 114 | |
115 | 115 | |
116 | - /** |
|
117 | - * Exports the complete report as a CSV file |
|
118 | - * @param string Document path inside the document tool |
|
119 | - * @param integer Optional user ID |
|
120 | - * @param boolean Whether to include user fields or not |
|
121 | - * @return boolean False on error |
|
122 | - */ |
|
123 | - public function exportCompleteReportCSV($document_path='', $hotpotato_name) |
|
116 | + /** |
|
117 | + * Exports the complete report as a CSV file |
|
118 | + * @param string Document path inside the document tool |
|
119 | + * @param integer Optional user ID |
|
120 | + * @param boolean Whether to include user fields or not |
|
121 | + * @return boolean False on error |
|
122 | + */ |
|
123 | + public function exportCompleteReportCSV($document_path='', $hotpotato_name) |
|
124 | 124 | { |
125 | - global $charset; |
|
126 | - $this->getExercisesReporting($document_path, $hotpotato_name); |
|
127 | - $filename = 'exercise_results_'.date('YmdGis').'.csv'; |
|
128 | - if (!empty($user_id)) { |
|
129 | - $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv'; |
|
130 | - } |
|
131 | - $data = ''; |
|
125 | + global $charset; |
|
126 | + $this->getExercisesReporting($document_path, $hotpotato_name); |
|
127 | + $filename = 'exercise_results_'.date('YmdGis').'.csv'; |
|
128 | + if (!empty($user_id)) { |
|
129 | + $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv'; |
|
130 | + } |
|
131 | + $data = ''; |
|
132 | 132 | |
133 | 133 | if (api_is_western_name_order()) { |
134 | 134 | if(!empty($this->results[0]['first_name'])) { |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | $data .= get_lang('Email').';'; |
149 | 149 | |
150 | - /*if ($export_user_fields) { |
|
150 | + /*if ($export_user_fields) { |
|
151 | 151 | //show user fields section with a big th colspan that spans over all fields |
152 | 152 | $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
153 | 153 | $num = count($extra_user_fields); |
@@ -156,25 +156,25 @@ discard block |
||
156 | 156 | } |
157 | 157 | }*/ |
158 | 158 | |
159 | - $data .= get_lang('Title').';'; |
|
160 | - $data .= get_lang('StartDate').';'; |
|
161 | - $data .= get_lang('Score').';'; |
|
162 | - $data .= get_lang('Total').';'; |
|
163 | - $data .= "\n"; |
|
159 | + $data .= get_lang('Title').';'; |
|
160 | + $data .= get_lang('StartDate').';'; |
|
161 | + $data .= get_lang('Score').';'; |
|
162 | + $data .= get_lang('Total').';'; |
|
163 | + $data .= "\n"; |
|
164 | 164 | |
165 | - //results |
|
166 | - foreach($this->results as $row) { |
|
165 | + //results |
|
166 | + foreach($this->results as $row) { |
|
167 | 167 | if (api_is_western_name_order()) { |
168 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
169 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
168 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
169 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
170 | 170 | } else { |
171 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
172 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
171 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
172 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';'; |
176 | 176 | |
177 | - /*if ($export_user_fields) { |
|
177 | + /*if ($export_user_fields) { |
|
178 | 178 | //show user fields data, if any, for this user |
179 | 179 | $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
180 | 180 | foreach($user_fields_values as $value) { |
@@ -182,40 +182,40 @@ discard block |
||
182 | 182 | } |
183 | 183 | }*/ |
184 | 184 | |
185 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';'; |
|
186 | - $data .= str_replace("\r\n",' ',$row['exe_date']).';'; |
|
187 | - $data .= str_replace("\r\n",' ',$row['result']).';'; |
|
188 | - $data .= str_replace("\r\n",' ',$row['max']).';'; |
|
189 | - $data .= "\n"; |
|
190 | - } |
|
191 | - |
|
192 | - //output the results |
|
193 | - $len = strlen($data); |
|
194 | - header('Content-type: application/octet-stream'); |
|
195 | - header('Content-Type: application/force-download'); |
|
196 | - header('Content-length: '.$len); |
|
197 | - if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) { |
|
198 | - header('Content-Disposition: filename= '.$filename); |
|
199 | - } else { |
|
200 | - header('Content-Disposition: attachment; filename= '.$filename); |
|
201 | - } |
|
202 | - if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { |
|
203 | - header('Pragma: '); |
|
204 | - header('Cache-Control: '); |
|
205 | - header('Cache-Control: public'); // IE cannot download from sessions without a cache |
|
206 | - } |
|
207 | - header('Content-Description: '.$filename); |
|
208 | - header('Content-transfer-encoding: binary'); |
|
209 | - // @todo add this utf-8 header for all csv files |
|
210 | - echo "\xEF\xBB\xBF"; // force utf-8 header of csv file |
|
211 | - echo $data; |
|
212 | - return true; |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * Exports the complete report as an XLS file |
|
217 | - * @return boolean False on error |
|
218 | - */ |
|
185 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';'; |
|
186 | + $data .= str_replace("\r\n",' ',$row['exe_date']).';'; |
|
187 | + $data .= str_replace("\r\n",' ',$row['result']).';'; |
|
188 | + $data .= str_replace("\r\n",' ',$row['max']).';'; |
|
189 | + $data .= "\n"; |
|
190 | + } |
|
191 | + |
|
192 | + //output the results |
|
193 | + $len = strlen($data); |
|
194 | + header('Content-type: application/octet-stream'); |
|
195 | + header('Content-Type: application/force-download'); |
|
196 | + header('Content-length: '.$len); |
|
197 | + if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) { |
|
198 | + header('Content-Disposition: filename= '.$filename); |
|
199 | + } else { |
|
200 | + header('Content-Disposition: attachment; filename= '.$filename); |
|
201 | + } |
|
202 | + if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { |
|
203 | + header('Pragma: '); |
|
204 | + header('Cache-Control: '); |
|
205 | + header('Cache-Control: public'); // IE cannot download from sessions without a cache |
|
206 | + } |
|
207 | + header('Content-Description: '.$filename); |
|
208 | + header('Content-transfer-encoding: binary'); |
|
209 | + // @todo add this utf-8 header for all csv files |
|
210 | + echo "\xEF\xBB\xBF"; // force utf-8 header of csv file |
|
211 | + echo $data; |
|
212 | + return true; |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * Exports the complete report as an XLS file |
|
217 | + * @return boolean False on error |
|
218 | + */ |
|
219 | 219 | public function exportCompleteReportXLS( |
220 | 220 | $document_path = '', |
221 | 221 | $user_id = null, |
@@ -224,37 +224,37 @@ discard block |
||
224 | 224 | $exercise_id = 0, |
225 | 225 | $hotpotato_name = null |
226 | 226 | ) { |
227 | - global $charset; |
|
228 | - $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name); |
|
229 | - $filename = 'exercise_results_'.api_get_local_time().'.xls'; |
|
230 | - if (!empty($user_id)) { |
|
231 | - $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls'; |
|
232 | - } |
|
227 | + global $charset; |
|
228 | + $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name); |
|
229 | + $filename = 'exercise_results_'.api_get_local_time().'.xls'; |
|
230 | + if (!empty($user_id)) { |
|
231 | + $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls'; |
|
232 | + } |
|
233 | 233 | |
234 | 234 | $spreadsheet = new PHPExcel(); |
235 | 235 | $spreadsheet->setActiveSheetIndex(0); |
236 | 236 | $worksheet = $spreadsheet->getActiveSheet(); |
237 | 237 | |
238 | 238 | |
239 | - $line = 0; |
|
240 | - $column = 0; //skip the first column (row titles) |
|
239 | + $line = 0; |
|
240 | + $column = 0; //skip the first column (row titles) |
|
241 | 241 | |
242 | - // check if exists column 'user' |
|
243 | - $with_column_user = false; |
|
244 | - foreach ($this->results as $result) { |
|
245 | - if (!empty($result['last_name']) && !empty($result['first_name'])) { |
|
246 | - $with_column_user = true; |
|
247 | - break; |
|
248 | - } |
|
249 | - } |
|
242 | + // check if exists column 'user' |
|
243 | + $with_column_user = false; |
|
244 | + foreach ($this->results as $result) { |
|
245 | + if (!empty($result['last_name']) && !empty($result['first_name'])) { |
|
246 | + $with_column_user = true; |
|
247 | + break; |
|
248 | + } |
|
249 | + } |
|
250 | 250 | |
251 | - if ($with_column_user) { |
|
252 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Email')); |
|
253 | - $column++; |
|
251 | + if ($with_column_user) { |
|
252 | + $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Email')); |
|
253 | + $column++; |
|
254 | 254 | |
255 | 255 | if (api_is_western_name_order()) { |
256 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
|
257 | - $column++; |
|
256 | + $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
|
257 | + $column++; |
|
258 | 258 | $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('LastName')); |
259 | 259 | $column++; |
260 | 260 | } else { |
@@ -263,36 +263,36 @@ discard block |
||
263 | 263 | $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
264 | 264 | $column++; |
265 | 265 | } |
266 | - } |
|
266 | + } |
|
267 | 267 | |
268 | - if ($export_user_fields) { |
|
269 | - //show user fields section with a big th colspan that spans over all fields |
|
270 | - $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
|
268 | + if ($export_user_fields) { |
|
269 | + //show user fields section with a big th colspan that spans over all fields |
|
270 | + $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
|
271 | 271 | |
272 | - //show the fields names for user fields |
|
273 | - foreach ($extra_user_fields as $field) { |
|
274 | - $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)); |
|
275 | - $column++; |
|
276 | - } |
|
277 | - } |
|
272 | + //show the fields names for user fields |
|
273 | + foreach ($extra_user_fields as $field) { |
|
274 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)); |
|
275 | + $column++; |
|
276 | + } |
|
277 | + } |
|
278 | 278 | |
279 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title')); |
|
280 | - $column++; |
|
281 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate')); |
|
279 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title')); |
|
280 | + $column++; |
|
281 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate')); |
|
282 | 282 | $column++; |
283 | 283 | $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('EndDate')); |
284 | 284 | $column++; |
285 | 285 | $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Duration').' ('.get_lang('MinMinutes').')'); |
286 | - $column++; |
|
287 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score')); |
|
288 | - $column++; |
|
289 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total')); |
|
290 | - $column++; |
|
286 | + $column++; |
|
287 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score')); |
|
288 | + $column++; |
|
289 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total')); |
|
290 | + $column++; |
|
291 | 291 | $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Status')); |
292 | - $line++; |
|
292 | + $line++; |
|
293 | 293 | |
294 | - foreach ($this->results as $row) { |
|
295 | - $column = 0; |
|
294 | + foreach ($this->results as $row) { |
|
295 | + $column = 0; |
|
296 | 296 | |
297 | 297 | if ($with_column_user) { |
298 | 298 | $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)); |
@@ -309,38 +309,38 @@ discard block |
||
309 | 309 | $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); |
310 | 310 | $column++; |
311 | 311 | } |
312 | - } |
|
312 | + } |
|
313 | 313 | |
314 | - if ($export_user_fields) { |
|
315 | - //show user fields data, if any, for this user |
|
316 | - $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
|
317 | - foreach($user_fields_values as $value) { |
|
318 | - $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
319 | - $column++; |
|
320 | - } |
|
321 | - } |
|
314 | + if ($export_user_fields) { |
|
315 | + //show user fields data, if any, for this user |
|
316 | + $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
|
317 | + foreach($user_fields_values as $value) { |
|
318 | + $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
319 | + $column++; |
|
320 | + } |
|
321 | + } |
|
322 | 322 | |
323 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
324 | - $column++; |
|
325 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']); |
|
323 | + $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
324 | + $column++; |
|
325 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']); |
|
326 | 326 | $column++; |
327 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']); |
|
327 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']); |
|
328 | + $column++; |
|
329 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']); |
|
330 | + $column++; |
|
331 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']); |
|
332 | + $column++; |
|
333 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']); |
|
328 | 334 | $column++; |
329 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']); |
|
330 | - $column++; |
|
331 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']); |
|
332 | - $column++; |
|
333 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']); |
|
334 | - $column++; |
|
335 | 335 | $worksheet->SetCellValueByColumnAndRow($line,$column,$row['status']); |
336 | - $line++; |
|
337 | - } |
|
336 | + $line++; |
|
337 | + } |
|
338 | 338 | |
339 | 339 | $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename); |
340 | 340 | $writer = new PHPExcel_Writer_Excel2007($spreadsheet); |
341 | 341 | $writer->save($file); |
342 | 342 | DocumentManager::file_send_for_download($file, true, $filename); |
343 | 343 | |
344 | - return true; |
|
345 | - } |
|
344 | + return true; |
|
345 | + } |
|
346 | 346 | } |
@@ -98,10 +98,10 @@ |
||
98 | 98 | }*/ |
99 | 99 | } |
100 | 100 | |
101 | - // This is a good answer, count + 1 for nmbr of clicks |
|
102 | - if ($answers['weighting'][$i] > 0) { |
|
103 | - $nmbrTries++; |
|
104 | - } |
|
101 | + // This is a good answer, count + 1 for nmbr of clicks |
|
102 | + if ($answers['weighting'][$i] > 0) { |
|
103 | + $nmbrTries++; |
|
104 | + } |
|
105 | 105 | |
106 | 106 | $hotSpot['coord'] = $answers['hotspot_coordinates'][$i]; |
107 | 107 | $data['hotspots'][] = $hotSpot; |