@@ -16,7 +16,6 @@ |
||
16 | 16 | * @author Patrick Cool |
17 | 17 | * @author René Haentjens, added CSV file import (October 2004) |
18 | 18 | * @package chamilo.link |
19 | - |
|
20 | 19 | */ |
21 | 20 | |
22 | 21 | // Including libraries |
@@ -18,10 +18,10 @@ |
||
18 | 18 | $file = file(api_get_path(SYS_LANG_PATH).'english/hotspot.inc.php'); |
19 | 19 | |
20 | 20 | foreach ($file as &$value) { |
21 | - $variable = explode('=', $value , 2); |
|
22 | - if (count($variable) > 1) { |
|
23 | - $variable = substr(trim($variable[0]), 1); |
|
24 | - $variable = '&'.$variable.'='.api_utf8_encode(get_lang($variable)).' '; |
|
25 | - echo $variable; |
|
26 | - } |
|
21 | + $variable = explode('=', $value , 2); |
|
22 | + if (count($variable) > 1) { |
|
23 | + $variable = substr(trim($variable[0]), 1); |
|
24 | + $variable = '&'.$variable.'='.api_utf8_encode(get_lang($variable)).' '; |
|
25 | + echo $variable; |
|
26 | + } |
|
27 | 27 | } |
@@ -249,7 +249,7 @@ |
||
249 | 249 | break; |
250 | 250 | case RESULT_DISABLE_SHOW_SCORE_ONLY: |
251 | 251 | if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_END) { |
252 | - $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score')); |
|
252 | + $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score')); |
|
253 | 253 | } |
254 | 254 | else { |
255 | 255 | $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'), get_lang('Details')); |
@@ -14,15 +14,15 @@ 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 | - * @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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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($line,$column,get_lang('Email')); |
|
254 | - $column++; |
|
252 | + if ($with_column_user) { |
|
253 | + $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Email')); |
|
254 | + $column++; |
|
255 | 255 | |
256 | 256 | if (api_is_western_name_order()) { |
257 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
|
258 | - $column++; |
|
257 | + $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
|
258 | + $column++; |
|
259 | 259 | $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('LastName')); |
260 | 260 | $column++; |
261 | 261 | } else { |
@@ -264,36 +264,36 @@ discard block |
||
264 | 264 | $worksheet->SetCellValueByColumnAndRow($line,$column,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($line, $column, 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($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)); |
|
276 | + $column++; |
|
277 | + } |
|
278 | + } |
|
279 | 279 | |
280 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title')); |
|
281 | - $column++; |
|
282 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate')); |
|
280 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title')); |
|
281 | + $column++; |
|
282 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate')); |
|
283 | 283 | $column++; |
284 | 284 | $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('EndDate')); |
285 | 285 | $column++; |
286 | 286 | $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Duration').' ('.get_lang('MinMinutes').')'); |
287 | - $column++; |
|
288 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score')); |
|
289 | - $column++; |
|
290 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total')); |
|
291 | - $column++; |
|
287 | + $column++; |
|
288 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score')); |
|
289 | + $column++; |
|
290 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total')); |
|
291 | + $column++; |
|
292 | 292 | $worksheet->SetCellValueByColumnAndRow($line,$column, 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($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)); |
@@ -310,38 +310,38 @@ discard block |
||
310 | 310 | $worksheet->SetCellValueByColumnAndRow($line,$column,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($line,$column, 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($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
320 | + $column++; |
|
321 | + } |
|
322 | + } |
|
323 | 323 | |
324 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
325 | - $column++; |
|
326 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']); |
|
324 | + $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
325 | + $column++; |
|
326 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']); |
|
327 | 327 | $column++; |
328 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']); |
|
328 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']); |
|
329 | + $column++; |
|
330 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']); |
|
331 | + $column++; |
|
332 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']); |
|
333 | + $column++; |
|
334 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']); |
|
329 | 335 | $column++; |
330 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']); |
|
331 | - $column++; |
|
332 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']); |
|
333 | - $column++; |
|
334 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']); |
|
335 | - $column++; |
|
336 | 336 | $worksheet->SetCellValueByColumnAndRow($line,$column,$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 | } |
@@ -223,10 +223,10 @@ |
||
223 | 223 | |
224 | 224 | $counter++; |
225 | 225 | if ($objExercise->type == ONE_PER_PAGE) { |
226 | - $question_title = Display::url($counter.'. '.cut($objQuestionTmp->selectTitle(), 40), $url); |
|
227 | - $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40); |
|
226 | + $question_title = Display::url($counter.'. '.cut($objQuestionTmp->selectTitle(), 40), $url); |
|
227 | + $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40); |
|
228 | 228 | } else { |
229 | - $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40); |
|
229 | + $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40); |
|
230 | 230 | } |
231 | 231 | //Check if the question doesn't have an answer |
232 | 232 | if (!in_array($questionId, $exercise_result)) { |
@@ -344,7 +344,7 @@ |
||
344 | 344 | if (is_dir($full_name)) { |
345 | 345 | $filelist[] = $file; |
346 | 346 | } |
347 | - } |
|
347 | + } |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | } |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
244 | - * abstract function which creates the form to create / edit the answers of the question |
|
245 | - * @param FormValidator $form |
|
246 | - */ |
|
244 | + * abstract function which creates the form to create / edit the answers of the question |
|
245 | + * @param FormValidator $form |
|
246 | + */ |
|
247 | 247 | public function processAnswersCreation($form) |
248 | 248 | { |
249 | - $questionWeighting = $nbrGoodAnswers = 0; |
|
250 | - $objAnswer = new Answer($this->id); |
|
249 | + $questionWeighting = $nbrGoodAnswers = 0; |
|
250 | + $objAnswer = new Answer($this->id); |
|
251 | 251 | $nb_answers = $form->getSubmitValue('nb_answers'); |
252 | 252 | //$options_count = $form->getSubmitValue('options_count'); |
253 | 253 | $course_id = api_get_course_int_id(); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | $course_id, |
270 | 270 | $i |
271 | 271 | ); |
272 | - $correct[$i] = $last_id; |
|
272 | + $correct[$i] = $last_id; |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | |
281 | 281 | $sorted_by_position = array(); |
282 | 282 | foreach ($new_options as $item) { |
283 | - $sorted_by_position[$item['position']] = $item; |
|
283 | + $sorted_by_position[$item['position']] = $item; |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /* Saving quiz_question.extra values that has the correct scores of |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | } |
294 | 294 | $this->setExtra(implode(':', $extra_values)); |
295 | 295 | |
296 | - for ($i = 1; $i <= $nb_answers; $i++) { |
|
296 | + for ($i = 1; $i <= $nb_answers; $i++) { |
|
297 | 297 | $answer = trim($form->getSubmitValue('answer['.$i.']')); |
298 | 298 | $comment = trim($form->getSubmitValue('comment['.$i.']')); |
299 | 299 | $goodAnswer = trim($form->getSubmitValue('correct['.$i.']')); |
@@ -302,18 +302,18 @@ discard block |
||
302 | 302 | // change the default values from the form 1 and 2 by the correct "option id" registered |
303 | 303 | $goodAnswer = $sorted_by_position[$goodAnswer]['id']; |
304 | 304 | } |
305 | - $questionWeighting += $extra_values[0]; //By default 0 has the correct answers |
|
305 | + $questionWeighting += $extra_values[0]; //By default 0 has the correct answers |
|
306 | 306 | |
307 | - $objAnswer->createAnswer($answer, $goodAnswer, $comment,'',$i); |
|
307 | + $objAnswer->createAnswer($answer, $goodAnswer, $comment,'',$i); |
|
308 | 308 | } |
309 | 309 | |
310 | - // saves the answers into the data base |
|
310 | + // saves the answers into the data base |
|
311 | 311 | $objAnswer->save(); |
312 | 312 | |
313 | 313 | // sets the total weighting of the question |
314 | 314 | $this->updateWeighting($questionWeighting); |
315 | 315 | $this->save(); |
316 | - } |
|
316 | + } |
|
317 | 317 | |
318 | 318 | /** |
319 | 319 | * @param int $feedback_type |
@@ -324,17 +324,17 @@ discard block |
||
324 | 324 | function return_header($feedback_type = null, $counter = null, $score = null) |
325 | 325 | { |
326 | 326 | $header = parent::return_header($feedback_type, $counter, $score); |
327 | - $header .= '<table class="'.$this->question_table_class .'"> |
|
327 | + $header .= '<table class="'.$this->question_table_class .'"> |
|
328 | 328 | <tr> |
329 | 329 | <th>'.get_lang("Choice").'</th> |
330 | 330 | <th>'. get_lang("ExpectedChoice").'</th> |
331 | 331 | <th>'. get_lang("Answer").'</th>'; |
332 | - if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { |
|
333 | - $header .= '<th>'.get_lang("Comment").'</th>'; |
|
334 | - } else { |
|
335 | - $header .= '<th> </th>'; |
|
336 | - } |
|
332 | + if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { |
|
333 | + $header .= '<th>'.get_lang("Comment").'</th>'; |
|
334 | + } else { |
|
335 | + $header .= '<th> </th>'; |
|
336 | + } |
|
337 | 337 | $header .= '</tr>'; |
338 | 338 | return $header; |
339 | - } |
|
339 | + } |
|
340 | 340 | } |
@@ -15,24 +15,24 @@ |
||
15 | 15 | $answerId = intval($_GET['answerId']); |
16 | 16 | |
17 | 17 | if ($_GET['type'] == "square" || $_GET['type'] == "circle") { |
18 | - $hotspot_type = $_GET['type']; |
|
19 | - $hotspot_coordinates = $_GET['x'].";".$_GET['y']."|".$_GET['width']."|".$_GET['height']; |
|
18 | + $hotspot_type = $_GET['type']; |
|
19 | + $hotspot_coordinates = $_GET['x'].";".$_GET['y']."|".$_GET['width']."|".$_GET['height']; |
|
20 | 20 | } |
21 | 21 | if ($_GET['type'] == "poly" || $_GET['type'] == "delineation" || $_GET['type'] == "oar") { |
22 | - $hotspot_type = $_GET['type']; |
|
23 | - $tmp_coord = explode(",",$_GET['co']); |
|
24 | - $i = 0; |
|
25 | - $hotspot_coordinates = ""; |
|
26 | - foreach ($tmp_coord as $coord) { |
|
27 | - if ($i%2 == 0) { |
|
28 | - $delimiter = ";"; |
|
29 | - } else { |
|
30 | - $delimiter = "|"; |
|
31 | - } |
|
32 | - $hotspot_coordinates .= $coord.$delimiter; |
|
33 | - $i++; |
|
34 | - } |
|
35 | - $hotspot_coordinates = api_substr($hotspot_coordinates,0,-2); |
|
22 | + $hotspot_type = $_GET['type']; |
|
23 | + $tmp_coord = explode(",",$_GET['co']); |
|
24 | + $i = 0; |
|
25 | + $hotspot_coordinates = ""; |
|
26 | + foreach ($tmp_coord as $coord) { |
|
27 | + if ($i%2 == 0) { |
|
28 | + $delimiter = ";"; |
|
29 | + } else { |
|
30 | + $delimiter = "|"; |
|
31 | + } |
|
32 | + $hotspot_coordinates .= $coord.$delimiter; |
|
33 | + $i++; |
|
34 | + } |
|
35 | + $hotspot_coordinates = api_substr($hotspot_coordinates,0,-2); |
|
36 | 36 | } |
37 | 37 | $course_id = api_get_course_int_id(); |
38 | 38 | $sql = "UPDATE $TBL_ANSWER SET |
@@ -907,10 +907,10 @@ |
||
907 | 907 | <?php } else { ?> |
908 | 908 | <input class="form-control" type="text" name="weighting[<?php echo $i; ?>]" value="<?php echo (isset($weighting[$i]) ? $weighting[$i] : 10); ?>" /> |
909 | 909 | <?php |
910 | - } |
|
911 | - } |
|
912 | - if ($answerType == HOT_SPOT) { |
|
913 | - ?> |
|
910 | + } |
|
911 | + } |
|
912 | + if ($answerType == HOT_SPOT) { |
|
913 | + ?> |
|
914 | 914 | <input class="form-control" type="text" name="weighting[<?php echo $i; ?>]" value="<?php echo (isset($weighting[$i]) ? $weighting[$i] : 10); ?>" /> |
915 | 915 | <input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]); ?>" /> |
916 | 916 | <input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_type[$i]) ? 'square' : $hotspot_type[$i]); ?>" /> |