@@ -155,12 +155,12 @@ discard block |
||
155 | 155 | return []; |
156 | 156 | } |
157 | 157 | |
158 | - /** |
|
159 | - * returns all answer ids from this question Id |
|
160 | - * |
|
161 | - * @author Yoselyn Castillo |
|
162 | - * @return array - $id (answer ids) |
|
163 | - */ |
|
158 | + /** |
|
159 | + * returns all answer ids from this question Id |
|
160 | + * |
|
161 | + * @author Yoselyn Castillo |
|
162 | + * @return array - $id (answer ids) |
|
163 | + */ |
|
164 | 164 | public function selectAnswerId() |
165 | 165 | { |
166 | 166 | $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | return $id; |
183 | - } |
|
183 | + } |
|
184 | 184 | |
185 | 185 | /** |
186 | 186 | * Reads answer information from the data base ordered by parameter |
@@ -190,23 +190,23 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public function readOrderedBy($field, $order='ASC') |
192 | 192 | { |
193 | - $field = Database::escape_string($field); |
|
194 | - if (empty($field)) { |
|
195 | - $field = 'position'; |
|
196 | - } |
|
193 | + $field = Database::escape_string($field); |
|
194 | + if (empty($field)) { |
|
195 | + $field = 'position'; |
|
196 | + } |
|
197 | 197 | |
198 | - if ($order != 'ASC' && $order!='DESC') { |
|
199 | - $order = 'ASC'; |
|
200 | - } |
|
198 | + if ($order != 'ASC' && $order!='DESC') { |
|
199 | + $order = 'ASC'; |
|
200 | + } |
|
201 | 201 | |
202 | - $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
203 | - $TBL_QUIZ = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
204 | - $questionId = intval($this->questionId); |
|
202 | + $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
203 | + $TBL_QUIZ = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
204 | + $questionId = intval($this->questionId); |
|
205 | 205 | |
206 | - $sql = "SELECT type FROM $TBL_QUIZ |
|
206 | + $sql = "SELECT type FROM $TBL_QUIZ |
|
207 | 207 | WHERE c_id = {$this->course_id} AND id = $questionId"; |
208 | - $result_question = Database::query($sql); |
|
209 | - $questionType = Database::fetch_array($result_question); |
|
208 | + $result_question = Database::query($sql); |
|
209 | + $questionType = Database::fetch_array($result_question); |
|
210 | 210 | |
211 | 211 | if ($questionType['type'] == DRAGGABLE) { |
212 | 212 | // Random is done by submit.js.tpl |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | return true; |
216 | 216 | } |
217 | 217 | |
218 | - $sql = "SELECT |
|
218 | + $sql = "SELECT |
|
219 | 219 | answer, |
220 | 220 | correct, |
221 | 221 | comment, |
@@ -230,16 +230,16 @@ discard block |
||
230 | 230 | c_id = {$this->course_id} AND |
231 | 231 | question_id='".$questionId."' |
232 | 232 | ORDER BY $field $order"; |
233 | - $result=Database::query($sql); |
|
234 | - |
|
235 | - $i = 1; |
|
236 | - // while a record is found |
|
237 | - $doubt_data = null; |
|
238 | - while ($object = Database::fetch_object($result)) { |
|
239 | - if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && $object->position == 666) { |
|
240 | - $doubt_data = $object; |
|
233 | + $result=Database::query($sql); |
|
234 | + |
|
235 | + $i = 1; |
|
236 | + // while a record is found |
|
237 | + $doubt_data = null; |
|
238 | + while ($object = Database::fetch_object($result)) { |
|
239 | + if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && $object->position == 666) { |
|
240 | + $doubt_data = $object; |
|
241 | 241 | continue; |
242 | - } |
|
242 | + } |
|
243 | 243 | $this->answer[$i] = $object->answer; |
244 | 244 | $this->correct[$i] = $object->correct; |
245 | 245 | $this->comment[$i] = $object->comment; |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | $this->destination[$i] = $object->destination; |
249 | 249 | $this->autoId[$i] = $object->id_auto; |
250 | 250 | $i++; |
251 | - } |
|
251 | + } |
|
252 | 252 | |
253 | - if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && !empty($doubt_data)) { |
|
253 | + if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && !empty($doubt_data)) { |
|
254 | 254 | $this->answer[$i] = $doubt_data->answer; |
255 | 255 | $this->correct[$i] = $doubt_data->correct; |
256 | 256 | $this->comment[$i] = $doubt_data->comment; |
@@ -259,86 +259,86 @@ discard block |
||
259 | 259 | $this->destination[$i] = $doubt_data->destination; |
260 | 260 | $this->autoId[$i] = $doubt_data->id_auto; |
261 | 261 | $i++; |
262 | - } |
|
262 | + } |
|
263 | 263 | $this->nbrAnswers = $i-1; |
264 | - } |
|
265 | - |
|
266 | - /** |
|
267 | - * returns the autoincrement id identificator |
|
268 | - * |
|
269 | - * @author Juan Carlos Ra�a |
|
270 | - * @return integer - answer num |
|
271 | - */ |
|
264 | + } |
|
265 | + |
|
266 | + /** |
|
267 | + * returns the autoincrement id identificator |
|
268 | + * |
|
269 | + * @author Juan Carlos Ra�a |
|
270 | + * @return integer - answer num |
|
271 | + */ |
|
272 | 272 | public function selectAutoId($id) |
273 | 273 | { |
274 | - return isset($this->autoId[$id]) ? $this->autoId[$id] : null; |
|
275 | - } |
|
276 | - |
|
277 | - /** |
|
278 | - * returns the number of answers in this question |
|
279 | - * |
|
280 | - * @author Olivier Brouckaert |
|
281 | - * @return integer - number of answers |
|
282 | - */ |
|
283 | - public function selectNbrAnswers() |
|
274 | + return isset($this->autoId[$id]) ? $this->autoId[$id] : null; |
|
275 | + } |
|
276 | + |
|
277 | + /** |
|
278 | + * returns the number of answers in this question |
|
279 | + * |
|
280 | + * @author Olivier Brouckaert |
|
281 | + * @return integer - number of answers |
|
282 | + */ |
|
283 | + public function selectNbrAnswers() |
|
284 | 284 | { |
285 | - return $this->nbrAnswers; |
|
286 | - } |
|
287 | - |
|
288 | - /** |
|
289 | - * returns the question ID which the answers belong to |
|
290 | - * |
|
291 | - * @author Olivier Brouckaert |
|
292 | - * @return integer - the question ID |
|
293 | - */ |
|
294 | - public function selectQuestionId() |
|
285 | + return $this->nbrAnswers; |
|
286 | + } |
|
287 | + |
|
288 | + /** |
|
289 | + * returns the question ID which the answers belong to |
|
290 | + * |
|
291 | + * @author Olivier Brouckaert |
|
292 | + * @return integer - the question ID |
|
293 | + */ |
|
294 | + public function selectQuestionId() |
|
295 | 295 | { |
296 | - return $this->questionId; |
|
297 | - } |
|
298 | - |
|
299 | - /** |
|
300 | - * returns the question ID of the destination question |
|
301 | - * |
|
302 | - * @author Julio Montoya |
|
303 | - * @return integer - the question ID |
|
304 | - */ |
|
305 | - public function selectDestination($id) |
|
296 | + return $this->questionId; |
|
297 | + } |
|
298 | + |
|
299 | + /** |
|
300 | + * returns the question ID of the destination question |
|
301 | + * |
|
302 | + * @author Julio Montoya |
|
303 | + * @return integer - the question ID |
|
304 | + */ |
|
305 | + public function selectDestination($id) |
|
306 | 306 | { |
307 | - return isset($this->destination[$id]) ? $this->destination[$id] : null; |
|
308 | - } |
|
307 | + return isset($this->destination[$id]) ? $this->destination[$id] : null; |
|
308 | + } |
|
309 | 309 | |
310 | 310 | /** |
311 | - * returns the answer title |
|
312 | - * |
|
313 | - * @author Olivier Brouckaert |
|
314 | - * @param - integer $id - answer ID |
|
315 | - * @return string - answer title |
|
316 | - */ |
|
317 | - public function selectAnswer($id) |
|
318 | - { |
|
319 | - return isset($this->answer[$id]) ? $this->answer[$id] : null; |
|
320 | - } |
|
321 | - |
|
322 | - /** |
|
323 | - * return array answer by id else return a bool |
|
324 | - */ |
|
325 | - public function selectAnswerByAutoId($auto_id) |
|
326 | - { |
|
327 | - $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
328 | - |
|
329 | - $auto_id = intval($auto_id); |
|
330 | - $sql = "SELECT id, answer, id_auto FROM $TBL_ANSWER |
|
311 | + * returns the answer title |
|
312 | + * |
|
313 | + * @author Olivier Brouckaert |
|
314 | + * @param - integer $id - answer ID |
|
315 | + * @return string - answer title |
|
316 | + */ |
|
317 | + public function selectAnswer($id) |
|
318 | + { |
|
319 | + return isset($this->answer[$id]) ? $this->answer[$id] : null; |
|
320 | + } |
|
321 | + |
|
322 | + /** |
|
323 | + * return array answer by id else return a bool |
|
324 | + */ |
|
325 | + public function selectAnswerByAutoId($auto_id) |
|
326 | + { |
|
327 | + $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
328 | + |
|
329 | + $auto_id = intval($auto_id); |
|
330 | + $sql = "SELECT id, answer, id_auto FROM $TBL_ANSWER |
|
331 | 331 | WHERE c_id = {$this->course_id} AND id_auto='$auto_id'"; |
332 | - $rs = Database::query($sql); |
|
332 | + $rs = Database::query($sql); |
|
333 | 333 | |
334 | - if (Database::num_rows($rs) > 0) { |
|
335 | - $row = Database::fetch_array($rs, 'ASSOC'); |
|
334 | + if (Database::num_rows($rs) > 0) { |
|
335 | + $row = Database::fetch_array($rs, 'ASSOC'); |
|
336 | 336 | |
337 | - return $row; |
|
338 | - } |
|
337 | + return $row; |
|
338 | + } |
|
339 | 339 | |
340 | - return false; |
|
341 | - } |
|
340 | + return false; |
|
341 | + } |
|
342 | 342 | |
343 | 343 | /** |
344 | 344 | * returns the answer title from an answer's position |
@@ -347,18 +347,18 @@ discard block |
||
347 | 347 | * @param - integer $id - answer ID |
348 | 348 | * @return bool - answer title |
349 | 349 | */ |
350 | - public function selectAnswerIdByPosition($pos) |
|
351 | - { |
|
352 | - foreach ($this->position as $k => $v) { |
|
353 | - if ($v != $pos) { |
|
354 | - continue; |
|
355 | - } |
|
350 | + public function selectAnswerIdByPosition($pos) |
|
351 | + { |
|
352 | + foreach ($this->position as $k => $v) { |
|
353 | + if ($v != $pos) { |
|
354 | + continue; |
|
355 | + } |
|
356 | 356 | |
357 | - return $k; |
|
358 | - } |
|
357 | + return $k; |
|
358 | + } |
|
359 | 359 | |
360 | - return false; |
|
361 | - } |
|
360 | + return false; |
|
361 | + } |
|
362 | 362 | |
363 | 363 | /** |
364 | 364 | * Returns a list of answers |
@@ -367,18 +367,18 @@ discard block |
||
367 | 367 | * of (id, answer, comment, grade) and grade=weighting |
368 | 368 | */ |
369 | 369 | public function getAnswersList($decode = false) |
370 | - { |
|
371 | - $list = array(); |
|
372 | - for ($i = 1; $i <= $this->nbrAnswers; $i++) { |
|
373 | - if (!empty($this->answer[$i])) { |
|
374 | - |
|
375 | - //Avoid problems when parsing elements with accents |
|
376 | - if ($decode) { |
|
377 | - $this->answer[$i] = api_html_entity_decode($this->answer[$i], ENT_QUOTES, api_get_system_encoding()); |
|
378 | - $this->comment[$i] = api_html_entity_decode($this->comment[$i], ENT_QUOTES, api_get_system_encoding()); |
|
379 | - } |
|
380 | - |
|
381 | - $list[] = array( |
|
370 | + { |
|
371 | + $list = array(); |
|
372 | + for ($i = 1; $i <= $this->nbrAnswers; $i++) { |
|
373 | + if (!empty($this->answer[$i])) { |
|
374 | + |
|
375 | + //Avoid problems when parsing elements with accents |
|
376 | + if ($decode) { |
|
377 | + $this->answer[$i] = api_html_entity_decode($this->answer[$i], ENT_QUOTES, api_get_system_encoding()); |
|
378 | + $this->comment[$i] = api_html_entity_decode($this->comment[$i], ENT_QUOTES, api_get_system_encoding()); |
|
379 | + } |
|
380 | + |
|
381 | + $list[] = array( |
|
382 | 382 | 'id' => $i, |
383 | 383 | 'answer' => $this->answer[$i], |
384 | 384 | 'comment' => $this->comment[$i], |
@@ -387,134 +387,134 @@ discard block |
||
387 | 387 | 'hotspot_type' => $this->hotspot_type[$i], |
388 | 388 | 'correct' => $this->correct[$i], |
389 | 389 | 'destination' => $this->destination[$i] |
390 | - ); |
|
390 | + ); |
|
391 | + } |
|
391 | 392 | } |
392 | - } |
|
393 | 393 | |
394 | - return $list; |
|
395 | - } |
|
394 | + return $list; |
|
395 | + } |
|
396 | 396 | |
397 | - /** |
|
398 | - * Returns a list of grades |
|
399 | - * @author Yannick Warnier <[email protected]> |
|
400 | - * @return array List of grades where grade=weighting (?) |
|
401 | - */ |
|
397 | + /** |
|
398 | + * Returns a list of grades |
|
399 | + * @author Yannick Warnier <[email protected]> |
|
400 | + * @return array List of grades where grade=weighting (?) |
|
401 | + */ |
|
402 | 402 | public function getGradesList() |
403 | - { |
|
404 | - $list = array(); |
|
405 | - for ($i = 0; $i<$this->nbrAnswers;$i++){ |
|
406 | - if(!empty($this->answer[$i])){ |
|
407 | - $list[$i] = $this->weighting[$i]; |
|
408 | - } |
|
409 | - } |
|
410 | - return $list; |
|
411 | - } |
|
412 | - |
|
413 | - /** |
|
414 | - * Returns the question type |
|
415 | - * @author Yannick Warnier <[email protected]> |
|
416 | - * @return integer The type of the question this answer is bound to |
|
417 | - */ |
|
403 | + { |
|
404 | + $list = array(); |
|
405 | + for ($i = 0; $i<$this->nbrAnswers;$i++){ |
|
406 | + if(!empty($this->answer[$i])){ |
|
407 | + $list[$i] = $this->weighting[$i]; |
|
408 | + } |
|
409 | + } |
|
410 | + return $list; |
|
411 | + } |
|
412 | + |
|
413 | + /** |
|
414 | + * Returns the question type |
|
415 | + * @author Yannick Warnier <[email protected]> |
|
416 | + * @return integer The type of the question this answer is bound to |
|
417 | + */ |
|
418 | 418 | public function getQuestionType() |
419 | - { |
|
420 | - $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
421 | - $sql = "SELECT type FROM $TBL_QUESTIONS |
|
419 | + { |
|
420 | + $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
421 | + $sql = "SELECT type FROM $TBL_QUESTIONS |
|
422 | 422 | WHERE c_id = {$this->course_id} AND id = '".$this->questionId."'"; |
423 | - $res = Database::query($sql); |
|
424 | - if (Database::num_rows($res)<=0){ |
|
425 | - return null; |
|
426 | - } |
|
427 | - $row = Database::fetch_array($res); |
|
428 | - |
|
429 | - return $row['type']; |
|
430 | - } |
|
431 | - |
|
432 | - |
|
433 | - /** |
|
434 | - * tells if answer is correct or not |
|
435 | - * |
|
436 | - * @author Olivier Brouckaert |
|
437 | - * @param - integer $id - answer ID |
|
438 | - * @return integer - 0 if bad answer, not 0 if good answer |
|
439 | - */ |
|
423 | + $res = Database::query($sql); |
|
424 | + if (Database::num_rows($res)<=0){ |
|
425 | + return null; |
|
426 | + } |
|
427 | + $row = Database::fetch_array($res); |
|
428 | + |
|
429 | + return $row['type']; |
|
430 | + } |
|
431 | + |
|
432 | + |
|
433 | + /** |
|
434 | + * tells if answer is correct or not |
|
435 | + * |
|
436 | + * @author Olivier Brouckaert |
|
437 | + * @param - integer $id - answer ID |
|
438 | + * @return integer - 0 if bad answer, not 0 if good answer |
|
439 | + */ |
|
440 | 440 | public function isCorrect($id) |
441 | - { |
|
442 | - return isset($this->correct[$id]) ? $this->correct[$id] : null; |
|
443 | - } |
|
444 | - |
|
445 | - /** |
|
446 | - * returns answer comment |
|
447 | - * |
|
448 | - * @author Olivier Brouckaert |
|
449 | - * @param - integer $id - answer ID |
|
450 | - * @return string - answer comment |
|
451 | - */ |
|
441 | + { |
|
442 | + return isset($this->correct[$id]) ? $this->correct[$id] : null; |
|
443 | + } |
|
444 | + |
|
445 | + /** |
|
446 | + * returns answer comment |
|
447 | + * |
|
448 | + * @author Olivier Brouckaert |
|
449 | + * @param - integer $id - answer ID |
|
450 | + * @return string - answer comment |
|
451 | + */ |
|
452 | 452 | public function selectComment($id) |
453 | - { |
|
453 | + { |
|
454 | 454 | return isset($this->comment[$id]) ? $this->comment[$id] : null; |
455 | - } |
|
456 | - |
|
457 | - /** |
|
458 | - * returns answer weighting |
|
459 | - * |
|
460 | - * @author Olivier Brouckaert |
|
461 | - * @param - integer $id - answer ID |
|
462 | - * @return integer - answer weighting |
|
463 | - */ |
|
455 | + } |
|
456 | + |
|
457 | + /** |
|
458 | + * returns answer weighting |
|
459 | + * |
|
460 | + * @author Olivier Brouckaert |
|
461 | + * @param - integer $id - answer ID |
|
462 | + * @return integer - answer weighting |
|
463 | + */ |
|
464 | 464 | public function selectWeighting($id) |
465 | - { |
|
466 | - return isset($this->weighting[$id]) ? $this->weighting[$id] : null; |
|
467 | - } |
|
468 | - |
|
469 | - /** |
|
470 | - * returns answer position |
|
471 | - * |
|
472 | - * @author Olivier Brouckaert |
|
473 | - * @param - integer $id - answer ID |
|
474 | - * @return integer - answer position |
|
475 | - */ |
|
476 | - function selectPosition($id) |
|
477 | - { |
|
478 | - return isset($this->position[$id]) ? $this->position[$id] : null; |
|
479 | - } |
|
480 | - |
|
481 | - /** |
|
482 | - * returns answer hotspot coordinates |
|
483 | - * |
|
484 | - * @author Olivier Brouckaert |
|
485 | - * @param integer Answer ID |
|
486 | - * @return integer Answer position |
|
487 | - */ |
|
465 | + { |
|
466 | + return isset($this->weighting[$id]) ? $this->weighting[$id] : null; |
|
467 | + } |
|
468 | + |
|
469 | + /** |
|
470 | + * returns answer position |
|
471 | + * |
|
472 | + * @author Olivier Brouckaert |
|
473 | + * @param - integer $id - answer ID |
|
474 | + * @return integer - answer position |
|
475 | + */ |
|
476 | + function selectPosition($id) |
|
477 | + { |
|
478 | + return isset($this->position[$id]) ? $this->position[$id] : null; |
|
479 | + } |
|
480 | + |
|
481 | + /** |
|
482 | + * returns answer hotspot coordinates |
|
483 | + * |
|
484 | + * @author Olivier Brouckaert |
|
485 | + * @param integer Answer ID |
|
486 | + * @return integer Answer position |
|
487 | + */ |
|
488 | 488 | public function selectHotspotCoordinates($id) |
489 | - { |
|
490 | - return isset($this->hotspot_coordinates[$id]) ? $this->hotspot_coordinates[$id] : null; |
|
491 | - } |
|
492 | - |
|
493 | - /** |
|
494 | - * returns answer hotspot type |
|
495 | - * |
|
496 | - * @author Toon Keppens |
|
497 | - * @param integer Answer ID |
|
498 | - * @return integer Answer position |
|
499 | - */ |
|
489 | + { |
|
490 | + return isset($this->hotspot_coordinates[$id]) ? $this->hotspot_coordinates[$id] : null; |
|
491 | + } |
|
492 | + |
|
493 | + /** |
|
494 | + * returns answer hotspot type |
|
495 | + * |
|
496 | + * @author Toon Keppens |
|
497 | + * @param integer Answer ID |
|
498 | + * @return integer Answer position |
|
499 | + */ |
|
500 | 500 | public function selectHotspotType($id) |
501 | - { |
|
502 | - return isset($this->hotspot_type[$id]) ? $this->hotspot_type[$id] : null; |
|
503 | - } |
|
504 | - |
|
505 | - /** |
|
506 | - * Creates a new answer |
|
507 | - * |
|
508 | - * @author Olivier Brouckaert |
|
509 | - * @param string $answer answer title |
|
510 | - * @param integer $correct 0 if bad answer, not 0 if good answer |
|
511 | - * @param string $comment answer comment |
|
512 | - * @param integer $weighting answer weighting |
|
513 | - * @param integer $position answer position |
|
514 | - * @param array $new_hotspot_coordinates Coordinates for hotspot exercises (optional) |
|
515 | - * @param integer $new_hotspot_type Type for hotspot exercises (optional) |
|
501 | + { |
|
502 | + return isset($this->hotspot_type[$id]) ? $this->hotspot_type[$id] : null; |
|
503 | + } |
|
504 | + |
|
505 | + /** |
|
506 | + * Creates a new answer |
|
507 | + * |
|
508 | + * @author Olivier Brouckaert |
|
509 | + * @param string $answer answer title |
|
510 | + * @param integer $correct 0 if bad answer, not 0 if good answer |
|
511 | + * @param string $comment answer comment |
|
512 | + * @param integer $weighting answer weighting |
|
513 | + * @param integer $position answer position |
|
514 | + * @param array $new_hotspot_coordinates Coordinates for hotspot exercises (optional) |
|
515 | + * @param integer $new_hotspot_type Type for hotspot exercises (optional) |
|
516 | 516 | * @param string $destination |
517 | - */ |
|
517 | + */ |
|
518 | 518 | public function createAnswer( |
519 | 519 | $answer, |
520 | 520 | $correct, |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | $new_hotspot_type = null, |
526 | 526 | $destination = '' |
527 | 527 | ) { |
528 | - $this->new_nbrAnswers++; |
|
528 | + $this->new_nbrAnswers++; |
|
529 | 529 | $id = $this->new_nbrAnswers; |
530 | 530 | $this->new_answer[$id] = $answer; |
531 | 531 | $this->new_correct[$id] = $correct; |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | $this->new_hotspot_coordinates[$id] = $new_hotspot_coordinates; |
536 | 536 | $this->new_hotspot_type[$id] = $new_hotspot_type; |
537 | 537 | $this->new_destination[$id] = $destination; |
538 | - } |
|
538 | + } |
|
539 | 539 | |
540 | 540 | /** |
541 | 541 | * Updates an answer |
@@ -577,31 +577,31 @@ discard block |
||
577 | 577 | ]; |
578 | 578 | |
579 | 579 | Database::update($answerTable, $params, ['id_auto = ?' => $autoId]); |
580 | - } |
|
580 | + } |
|
581 | 581 | |
582 | - /** |
|
583 | - * Records answers into the data base |
|
584 | - * |
|
585 | - * @author Olivier Brouckaert |
|
586 | - */ |
|
582 | + /** |
|
583 | + * Records answers into the data base |
|
584 | + * |
|
585 | + * @author Olivier Brouckaert |
|
586 | + */ |
|
587 | 587 | public function save() |
588 | 588 | { |
589 | - $answerTable = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
590 | - $questionId = intval($this->questionId); |
|
589 | + $answerTable = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
590 | + $questionId = intval($this->questionId); |
|
591 | 591 | |
592 | - $c_id = $this->course['real_id']; |
|
592 | + $c_id = $this->course['real_id']; |
|
593 | 593 | $correctList = []; |
594 | 594 | $answerList = []; |
595 | 595 | |
596 | - for ($i=1; $i <= $this->new_nbrAnswers; $i++) { |
|
597 | - $answer = $this->new_answer[$i]; |
|
598 | - $correct = $this->new_correct[$i]; |
|
599 | - $comment = $this->new_comment[$i]; |
|
600 | - $weighting = $this->new_weighting[$i]; |
|
601 | - $position = $this->new_position[$i]; |
|
602 | - $hotspot_coordinates = $this->new_hotspot_coordinates[$i]; |
|
603 | - $hotspot_type = $this->new_hotspot_type[$i]; |
|
604 | - $destination = $this->new_destination[$i]; |
|
596 | + for ($i=1; $i <= $this->new_nbrAnswers; $i++) { |
|
597 | + $answer = $this->new_answer[$i]; |
|
598 | + $correct = $this->new_correct[$i]; |
|
599 | + $comment = $this->new_comment[$i]; |
|
600 | + $weighting = $this->new_weighting[$i]; |
|
601 | + $position = $this->new_position[$i]; |
|
602 | + $hotspot_coordinates = $this->new_hotspot_coordinates[$i]; |
|
603 | + $hotspot_type = $this->new_hotspot_type[$i]; |
|
604 | + $destination = $this->new_destination[$i]; |
|
605 | 605 | $autoId = $this->selectAutoId($i); |
606 | 606 | |
607 | 607 | if (!isset($this->position[$i])) { |
@@ -698,36 +698,36 @@ discard block |
||
698 | 698 | } |
699 | 699 | } |
700 | 700 | |
701 | - // moves $new_* arrays |
|
702 | - $this->answer = $this->new_answer; |
|
703 | - $this->correct = $this->new_correct; |
|
704 | - $this->comment = $this->new_comment; |
|
705 | - $this->weighting = $this->new_weighting; |
|
706 | - $this->position = $this->new_position; |
|
707 | - $this->hotspot_coordinates = $this->new_hotspot_coordinates; |
|
708 | - $this->hotspot_type = $this->new_hotspot_type; |
|
709 | - |
|
710 | - $this->nbrAnswers = $this->new_nbrAnswers; |
|
711 | - $this->destination = $this->new_destination; |
|
712 | - // clears $new_* arrays |
|
713 | - |
|
714 | - $this->cancel(); |
|
715 | - } |
|
716 | - |
|
717 | - /** |
|
718 | - * Duplicates answers by copying them into another question |
|
719 | - * |
|
720 | - * @author Olivier Brouckaert |
|
721 | - * @param int question id |
|
701 | + // moves $new_* arrays |
|
702 | + $this->answer = $this->new_answer; |
|
703 | + $this->correct = $this->new_correct; |
|
704 | + $this->comment = $this->new_comment; |
|
705 | + $this->weighting = $this->new_weighting; |
|
706 | + $this->position = $this->new_position; |
|
707 | + $this->hotspot_coordinates = $this->new_hotspot_coordinates; |
|
708 | + $this->hotspot_type = $this->new_hotspot_type; |
|
709 | + |
|
710 | + $this->nbrAnswers = $this->new_nbrAnswers; |
|
711 | + $this->destination = $this->new_destination; |
|
712 | + // clears $new_* arrays |
|
713 | + |
|
714 | + $this->cancel(); |
|
715 | + } |
|
716 | + |
|
717 | + /** |
|
718 | + * Duplicates answers by copying them into another question |
|
719 | + * |
|
720 | + * @author Olivier Brouckaert |
|
721 | + * @param int question id |
|
722 | 722 | * @param array destination course info (result of the function api_get_course_info() ) |
723 | - */ |
|
723 | + */ |
|
724 | 724 | public function duplicate($newQuestionId, $course_info = null) |
725 | 725 | { |
726 | 726 | if (empty($course_info)) { |
727 | 727 | $course_info = $this->course; |
728 | 728 | } |
729 | 729 | |
730 | - $TBL_REPONSES = Database :: get_course_table(TABLE_QUIZ_ANSWER); |
|
730 | + $TBL_REPONSES = Database :: get_course_table(TABLE_QUIZ_ANSWER); |
|
731 | 731 | $fixed_list = array(); |
732 | 732 | |
733 | 733 | if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE || |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | |
742 | 742 | if (!empty($origin_options)) { |
743 | 743 | foreach ($origin_options as $item) { |
744 | - $new_option_list[] = $item['id']; |
|
744 | + $new_option_list[] = $item['id']; |
|
745 | 745 | } |
746 | 746 | } |
747 | 747 | |
@@ -755,12 +755,12 @@ discard block |
||
755 | 755 | } |
756 | 756 | } |
757 | 757 | |
758 | - // if at least one answer |
|
759 | - if ($this->nbrAnswers) { |
|
760 | - // inserts new answers into data base |
|
761 | - $c_id = $course_info['real_id']; |
|
758 | + // if at least one answer |
|
759 | + if ($this->nbrAnswers) { |
|
760 | + // inserts new answers into data base |
|
761 | + $c_id = $course_info['real_id']; |
|
762 | 762 | |
763 | - for ($i=1;$i <= $this->nbrAnswers;$i++) { |
|
763 | + for ($i=1;$i <= $this->nbrAnswers;$i++) { |
|
764 | 764 | if ($this->course['id'] != $course_info['id']) { |
765 | 765 | $this->answer[$i] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
766 | 766 | $this->answer[$i], |
@@ -774,8 +774,8 @@ discard block |
||
774 | 774 | ); |
775 | 775 | } |
776 | 776 | |
777 | - $answer = $this->answer[$i]; |
|
778 | - $correct = $this->correct[$i]; |
|
777 | + $answer = $this->answer[$i]; |
|
778 | + $correct = $this->correct[$i]; |
|
779 | 779 | |
780 | 780 | if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE || |
781 | 781 | self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE |
@@ -783,12 +783,12 @@ discard block |
||
783 | 783 | $correct = $fixed_list[intval($correct)]; |
784 | 784 | } |
785 | 785 | |
786 | - $comment = $this->comment[$i]; |
|
787 | - $weighting = $this->weighting[$i]; |
|
788 | - $position = $this->position[$i]; |
|
789 | - $hotspot_coordinates = $this->hotspot_coordinates[$i]; |
|
790 | - $hotspot_type = $this->hotspot_type[$i]; |
|
791 | - $destination = $this->destination[$i]; |
|
786 | + $comment = $this->comment[$i]; |
|
787 | + $weighting = $this->weighting[$i]; |
|
788 | + $position = $this->position[$i]; |
|
789 | + $hotspot_coordinates = $this->hotspot_coordinates[$i]; |
|
790 | + $hotspot_type = $this->hotspot_type[$i]; |
|
791 | + $destination = $this->destination[$i]; |
|
792 | 792 | |
793 | 793 | $params = [ |
794 | 794 | 'c_id' => $c_id, |
@@ -808,9 +808,9 @@ discard block |
||
808 | 808 | $sql = "UPDATE $TBL_REPONSES SET id = iid, id_auto = iid WHERE iid = $id"; |
809 | 809 | Database::query($sql); |
810 | 810 | } |
811 | - } |
|
811 | + } |
|
812 | 812 | } |
813 | - } |
|
813 | + } |
|
814 | 814 | |
815 | 815 | /** |
816 | 816 | * Get the necessary JavaScript for some answers |
@@ -729,43 +729,43 @@ discard block |
||
729 | 729 | } |
730 | 730 | |
731 | 731 | /** |
732 | - * Return an array of student state answers for fill the blank questions |
|
733 | - * for each students that answered the question |
|
734 | - * -2 : didn't answer |
|
735 | - * -1 : student answer is wrong |
|
736 | - * 0 : student answer is correct |
|
737 | - * >0 : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0) |
|
738 | - * |
|
739 | - * @param $testId |
|
740 | - * @param $questionId |
|
741 | - * @param $studentsIdList |
|
742 | - * @param $startDate |
|
743 | - * @param $endDate |
|
744 | - * @param bool $useLastAnswerredAttempt |
|
745 | - * @return array |
|
746 | - * ( |
|
747 | - * [student_id] => Array |
|
748 | - * ( |
|
749 | - * [first fill the blank for question] => -1 |
|
750 | - * [second fill the blank for question] => 2 |
|
751 | - * [third fill the blank for question] => -1 |
|
752 | - * ) |
|
753 | - * ) |
|
754 | - */ |
|
732 | + * Return an array of student state answers for fill the blank questions |
|
733 | + * for each students that answered the question |
|
734 | + * -2 : didn't answer |
|
735 | + * -1 : student answer is wrong |
|
736 | + * 0 : student answer is correct |
|
737 | + * >0 : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0) |
|
738 | + * |
|
739 | + * @param $testId |
|
740 | + * @param $questionId |
|
741 | + * @param $studentsIdList |
|
742 | + * @param $startDate |
|
743 | + * @param $endDate |
|
744 | + * @param bool $useLastAnswerredAttempt |
|
745 | + * @return array |
|
746 | + * ( |
|
747 | + * [student_id] => Array |
|
748 | + * ( |
|
749 | + * [first fill the blank for question] => -1 |
|
750 | + * [second fill the blank for question] => 2 |
|
751 | + * [third fill the blank for question] => -1 |
|
752 | + * ) |
|
753 | + * ) |
|
754 | + */ |
|
755 | 755 | public static function getFillTheBlankTabResult($testId, $questionId, $studentsIdList, $startDate, $endDate, $useLastAnswerredAttempt = true) { |
756 | 756 | |
757 | - $tblTrackEAttempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
758 | - $tblTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
|
759 | - $courseId = api_get_course_int_id(); |
|
757 | + $tblTrackEAttempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
758 | + $tblTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
|
759 | + $courseId = api_get_course_int_id(); |
|
760 | 760 | |
761 | - require_once api_get_path(SYS_PATH).'main/exercice/fill_blanks.class.php'; |
|
761 | + require_once api_get_path(SYS_PATH).'main/exercice/fill_blanks.class.php'; |
|
762 | 762 | |
763 | - // request to have all the answers of student for this question |
|
764 | - // student may have doing it several time |
|
765 | - // student may have not answered the bracket id, in this case, is result of the answer is empty |
|
763 | + // request to have all the answers of student for this question |
|
764 | + // student may have doing it several time |
|
765 | + // student may have not answered the bracket id, in this case, is result of the answer is empty |
|
766 | 766 | |
767 | - // we got the less recent attempt first |
|
768 | - $sql = ' |
|
767 | + // we got the less recent attempt first |
|
768 | + $sql = ' |
|
769 | 769 | SELECT * FROM '.$tblTrackEAttempt.' tea |
770 | 770 | |
771 | 771 | LEFT JOIN '.$tblTrackEExercise.' tee |
@@ -781,49 +781,49 @@ discard block |
||
781 | 781 | ORDER BY user_id, tea.exe_id; |
782 | 782 | '; |
783 | 783 | |
784 | - $res = Database::query($sql); |
|
785 | - $tabUserResult = array(); |
|
786 | - $bracketNumber = 0; |
|
787 | - // foreach attempts for all students starting with his older attempt |
|
788 | - while ($data = Database::fetch_array($res)) { |
|
789 | - $tabAnswer = FillBlanks::getAnswerInfo($data['answer'], true); |
|
784 | + $res = Database::query($sql); |
|
785 | + $tabUserResult = array(); |
|
786 | + $bracketNumber = 0; |
|
787 | + // foreach attempts for all students starting with his older attempt |
|
788 | + while ($data = Database::fetch_array($res)) { |
|
789 | + $tabAnswer = FillBlanks::getAnswerInfo($data['answer'], true); |
|
790 | 790 | |
791 | - // for each bracket to find in this question |
|
792 | - foreach ($tabAnswer['studentanswer'] as $bracketNumber => $studentAnswer) { |
|
791 | + // for each bracket to find in this question |
|
792 | + foreach ($tabAnswer['studentanswer'] as $bracketNumber => $studentAnswer) { |
|
793 | 793 | |
794 | - if ($tabAnswer['studentanswer'][$bracketNumber] != '') { |
|
795 | - // student has answered this bracket, cool |
|
796 | - switch (FillBlanks::getFillTheBlankAnswerType($tabAnswer['tabwords'][$bracketNumber])) { |
|
797 | - case self::FILL_THE_BLANK_MENU : |
|
794 | + if ($tabAnswer['studentanswer'][$bracketNumber] != '') { |
|
795 | + // student has answered this bracket, cool |
|
796 | + switch (FillBlanks::getFillTheBlankAnswerType($tabAnswer['tabwords'][$bracketNumber])) { |
|
797 | + case self::FILL_THE_BLANK_MENU : |
|
798 | 798 | // get the indice of the choosen answer in the menu |
799 | 799 | // we know that the right answer is the first entry of the menu, ie 0 |
800 | 800 | // (remember, menu entries are shuffled when taking the test) |
801 | 801 | $tabUserResult[$data['user_id']][$bracketNumber] = FillBlanks::getFillTheBlankMenuAnswerNum($tabAnswer['tabwords'][$bracketNumber], $tabAnswer['studentanswer'][$bracketNumber]); |
802 | - break; |
|
803 | - default : |
|
802 | + break; |
|
803 | + default : |
|
804 | 804 | if (FillBlanks::isGoodStudentAnswer($tabAnswer['studentanswer'][$bracketNumber], $tabAnswer['tabwords'][$bracketNumber])) { |
805 | - $tabUserResult[$data['user_id']][$bracketNumber] = 0; // right answer |
|
806 | - } else { |
|
807 | - $tabUserResult[$data['user_id']][$bracketNumber] = -1; // wrong answer |
|
808 | - } |
|
809 | - } |
|
810 | - } else { |
|
811 | - // student didn't answer this bracket |
|
812 | - if ($useLastAnswerredAttempt) { |
|
813 | - // if we take into account the last answered attempt |
|
814 | - if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) { |
|
815 | - $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
816 | - } |
|
817 | - } else { |
|
818 | - // we take the last attempt, even if the student answer the question before |
|
819 | - $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
820 | - } |
|
821 | - } |
|
822 | - } |
|
823 | - |
|
824 | - |
|
825 | - } |
|
826 | - return $tabUserResult; |
|
805 | + $tabUserResult[$data['user_id']][$bracketNumber] = 0; // right answer |
|
806 | + } else { |
|
807 | + $tabUserResult[$data['user_id']][$bracketNumber] = -1; // wrong answer |
|
808 | + } |
|
809 | + } |
|
810 | + } else { |
|
811 | + // student didn't answer this bracket |
|
812 | + if ($useLastAnswerredAttempt) { |
|
813 | + // if we take into account the last answered attempt |
|
814 | + if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) { |
|
815 | + $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
816 | + } |
|
817 | + } else { |
|
818 | + // we take the last attempt, even if the student answer the question before |
|
819 | + $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
820 | + } |
|
821 | + } |
|
822 | + } |
|
823 | + |
|
824 | + |
|
825 | + } |
|
826 | + return $tabUserResult; |
|
827 | 827 | } |
828 | 828 | |
829 | 829 |
@@ -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)) { |
@@ -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 | } |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* For licensing terms, see /license.txt */ |
3 | 3 | /** |
4 | - * Adding limits |
|
5 | - * @package chamilo.exercise |
|
6 | - * @deprecated ? |
|
7 | - */ |
|
4 | + * Adding limits |
|
5 | + * @package chamilo.exercise |
|
6 | + * @deprecated ? |
|
7 | + */ |
|
8 | 8 | require_once '../inc/global.inc.php'; |
9 | 9 | |
10 | 10 | $this_section = SECTION_COURSES; |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | $is_allowedToEdit=$is_courseAdmin; |
55 | 55 | |
56 | 56 | if (isset($_SESSION['gradebook'])){ |
57 | - $gradebook= $_SESSION['gradebook']; |
|
57 | + $gradebook= $_SESSION['gradebook']; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | if (!empty($gradebook) && $gradebook=='view') { |
61 | - $interbreadcrumb[]= array ( |
|
62 | - 'url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']), |
|
63 | - 'name' => get_lang('ToolGradebook') |
|
64 | - ); |
|
61 | + $interbreadcrumb[]= array ( |
|
62 | + 'url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']), |
|
63 | + 'name' => get_lang('ToolGradebook') |
|
64 | + ); |
|
65 | 65 | } |
66 | 66 | $nameTools=get_lang('Exercises'); |
67 | 67 | $interbreadcrumb[] = array( |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | Display::display_header($nameTools,"Exercises"); |
72 | 72 | |
73 | 73 | if (isset($_POST['ok'])) { |
74 | - $message = get_lang('TestLimitsAdded'); |
|
75 | - Display::display_normal_message($message); |
|
74 | + $message = get_lang('TestLimitsAdded'); |
|
75 | + Display::display_normal_message($message); |
|
76 | 76 | } |
77 | 77 | ?> |
78 | 78 | <script type="text/javascript"> |
@@ -136,25 +136,25 @@ discard block |
||
136 | 136 | </form> |
137 | 137 | <?php |
138 | 138 | /** |
139 | - * @todo shouldn't this be moved to the part above (around line 111: action handling) |
|
140 | - */ |
|
139 | + * @todo shouldn't this be moved to the part above (around line 111: action handling) |
|
140 | + */ |
|
141 | 141 | if (isset($_POST['ok'])) { |
142 | - $exercise_id = intval($_POST['exe_id']); |
|
143 | - if ($_POST['limit']==1) { |
|
144 | - $minutes = intval($_POST['minutes']); |
|
145 | - $query = "UPDATE ".$TBL_EXERCISES." SET ques_time_limit= $minutes WHERE id= $exercise_id"; |
|
146 | - Database::query($query); |
|
147 | - } else { |
|
148 | - $query = "UPDATE ".$TBL_EXERCISES." SET ques_time_limit= 0 WHERE id= $exercise_id"; |
|
149 | - Database::query($query); |
|
150 | - } |
|
142 | + $exercise_id = intval($_POST['exe_id']); |
|
143 | + if ($_POST['limit']==1) { |
|
144 | + $minutes = intval($_POST['minutes']); |
|
145 | + $query = "UPDATE ".$TBL_EXERCISES." SET ques_time_limit= $minutes WHERE id= $exercise_id"; |
|
146 | + Database::query($query); |
|
147 | + } else { |
|
148 | + $query = "UPDATE ".$TBL_EXERCISES." SET ques_time_limit= 0 WHERE id= $exercise_id"; |
|
149 | + Database::query($query); |
|
150 | + } |
|
151 | 151 | |
152 | - if ($_POST['attempt']==1) { |
|
153 | - $attempts = intval($_POST['attempts']); |
|
154 | - $query = "UPDATE ".$TBL_EXERCISES." SET num_attempts = $attempts WHERE id= $exercise_id"; |
|
155 | - Database::query($query); |
|
156 | - } else { |
|
157 | - $query = "UPDATE ".$TBL_EXERCISES." SET num_attempts = 0 WHERE id= $exercise_id"; |
|
158 | - Database::query($query); |
|
159 | - } |
|
152 | + if ($_POST['attempt']==1) { |
|
153 | + $attempts = intval($_POST['attempts']); |
|
154 | + $query = "UPDATE ".$TBL_EXERCISES." SET num_attempts = $attempts WHERE id= $exercise_id"; |
|
155 | + Database::query($query); |
|
156 | + } else { |
|
157 | + $query = "UPDATE ".$TBL_EXERCISES." SET num_attempts = 0 WHERE id= $exercise_id"; |
|
158 | + Database::query($query); |
|
159 | + } |
|
160 | 160 | } |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /* For licensing terms, see /license.txt */ |
3 | 3 | /** |
4 | - * @package chamilo.exercise |
|
5 | - * @author Claro Team <[email protected]> |
|
6 | - */ |
|
4 | + * @package chamilo.exercise |
|
5 | + * @author Claro Team <[email protected]> |
|
6 | + */ |
|
7 | 7 | /** |
8 | - * Redirection |
|
9 | - */ |
|
8 | + * Redirection |
|
9 | + */ |
|
10 | 10 | header("Location: ../../../"); |
11 | 11 | exit(); |
@@ -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,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 |