@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | * @param string $author |
267 | 267 | * @param string $filename |
268 | 268 | * @param int $filesize |
269 | - * @param array $recipient_ids |
|
269 | + * @param unknown_type|null $recipient_ids |
|
270 | 270 | */ |
271 | 271 | public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids) |
272 | 272 | { |
@@ -584,6 +584,7 @@ discard block |
||
584 | 584 | |
585 | 585 | /** |
586 | 586 | * Deletes all the received categories and work of this person |
587 | + * @param integer $id |
|
587 | 588 | */ |
588 | 589 | function deleteReceivedWorkFolder($id) |
589 | 590 | { |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | $action = isset($_GET['action']) ? $_GET['action'] : null; |
185 | 185 | |
186 | 186 | // Do some sanity checks |
187 | - $id = intval($id); |
|
187 | + $id = intval($id); |
|
188 | 188 | |
189 | 189 | // Get the data from DB |
190 | 190 | $sql = "SELECT uploader_id, filename, filesize, title, description, author, upload_date, last_upload_date, cat_id |
@@ -226,14 +226,14 @@ discard block |
||
226 | 226 | $row_feedback['feedback'] = Security::remove_XSS($row_feedback['feedback']); |
227 | 227 | $feedback2[] = $row_feedback; |
228 | 228 | } |
229 | - $this->feedback2= $feedback2; |
|
229 | + $this->feedback2 = $feedback2; |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | } |
233 | 233 | |
234 | 234 | class Dropbox_SentWork extends Dropbox_Work |
235 | 235 | { |
236 | - public $recipients; //array of ['id']['name'] arrays |
|
236 | + public $recipients; //array of ['id']['name'] arrays |
|
237 | 237 | |
238 | 238 | /** |
239 | 239 | * Constructor calls private functions to create a new work or retreive an existing work from DB |
@@ -290,15 +290,15 @@ discard block |
||
290 | 290 | settype($uploader_id, 'integer') or die(get_lang('GeneralError').' (code 208)'); // Set $uploader_id to correct type |
291 | 291 | |
292 | 292 | $justSubmit = false; |
293 | - if ( is_int($recipient_ids)) { |
|
293 | + if (is_int($recipient_ids)) { |
|
294 | 294 | $justSubmit = true; |
295 | 295 | $recipient_ids = array($recipient_ids + $this->id); |
296 | - } elseif ( count($recipient_ids) == 0) { |
|
296 | + } elseif (count($recipient_ids) == 0) { |
|
297 | 297 | $justSubmit = true; |
298 | 298 | $recipient_ids = array($uploader_id); |
299 | 299 | } |
300 | 300 | |
301 | - if (! is_array($recipient_ids) || count($recipient_ids) == 0) { |
|
301 | + if (!is_array($recipient_ids) || count($recipient_ids) == 0) { |
|
302 | 302 | die(get_lang('GeneralError').' (code 209)'); |
303 | 303 | } |
304 | 304 | |
@@ -313,11 +313,11 @@ discard block |
||
313 | 313 | $table_person = $dropbox_cnf['tbl_person']; |
314 | 314 | $session_id = api_get_session_id(); |
315 | 315 | $uploader_id = $this->uploader_id; |
316 | - $user = api_get_user_id(); |
|
316 | + $user = api_get_user_id(); |
|
317 | 317 | // Insert data in dropbox_post and dropbox_person table for each recipient |
318 | 318 | foreach ($this->recipients as $rec) { |
319 | - $file_id = (int)$this->id; |
|
320 | - $user_id = (int)$rec['id']; |
|
319 | + $file_id = (int) $this->id; |
|
320 | + $user_id = (int) $rec['id']; |
|
321 | 321 | $sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id) |
322 | 322 | VALUES ($course_id, $file_id, $user_id, $session_id)"; |
323 | 323 | Database::query($sql); |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | |
334 | 334 | // Do not add recipient in person table if mailing zip or just upload. |
335 | 335 | if (!$justSubmit) { |
336 | - Database::query($sql); // If work already exists no error is generated |
|
336 | + Database::query($sql); // If work already exists no error is generated |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $ownerid = getUserOwningThisMailing($ownerid); |
343 | 343 | } |
344 | 344 | if (($recipid = $rec["id"]) > $dropbox_cnf['mailingIdBase']) { |
345 | - $recipid = $ownerid; // mailing file recipient = mailing id, not a person |
|
345 | + $recipid = $ownerid; // mailing file recipient = mailing id, not a person |
|
346 | 346 | } |
347 | 347 | api_item_property_update( |
348 | 348 | $_course, |
@@ -401,13 +401,13 @@ discard block |
||
401 | 401 | class Dropbox_Person |
402 | 402 | { |
403 | 403 | // The receivedWork and the sentWork arrays are sorted. |
404 | - public $receivedWork; // an array of Dropbox_Work objects |
|
405 | - public $sentWork; // an array of Dropbox_SentWork objects |
|
404 | + public $receivedWork; // an array of Dropbox_Work objects |
|
405 | + public $sentWork; // an array of Dropbox_SentWork objects |
|
406 | 406 | |
407 | 407 | public $userId = 0; |
408 | 408 | public $isCourseAdmin = false; |
409 | 409 | public $isCourseTutor = false; |
410 | - public $_orderBy = ''; // private property that determines by which field |
|
410 | + public $_orderBy = ''; // private property that determines by which field |
|
411 | 411 | |
412 | 412 | /** |
413 | 413 | * Constructor for recreating the Dropbox_Person object |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | */ |
507 | 507 | function orderSentWork($sort) |
508 | 508 | { |
509 | - switch($sort) { |
|
509 | + switch ($sort) { |
|
510 | 510 | case 'lastDate': |
511 | 511 | $this->_orderBy = 'last_upload_date'; |
512 | 512 | break; |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | */ |
540 | 540 | function orderReceivedWork($sort) |
541 | 541 | { |
542 | - switch($sort) { |
|
542 | + switch ($sort) { |
|
543 | 543 | case 'lastDate': |
544 | 544 | $this->_orderBy = 'last_upload_date'; |
545 | 545 | break; |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']." |
633 | 633 | WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'"; |
634 | 634 | Database::query($sql); |
635 | - removeUnusedFiles(); // Check for unused files |
|
635 | + removeUnusedFiles(); // Check for unused files |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | /** |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | Database::query($sql); |
650 | 650 | removeMoreIfMailing($w->id); |
651 | 651 | } |
652 | - removeUnusedFiles(); // Check for unused files |
|
652 | + removeUnusedFiles(); // Check for unused files |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | /** |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'"; |
684 | 684 | Database::query($sql); |
685 | 685 | removeMoreIfMailing($id); |
686 | - removeUnusedFiles(); // Check for unused files |
|
686 | + removeUnusedFiles(); // Check for unused files |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | /** |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | $wi = -1; |
706 | 706 | foreach ($this->receivedWork as $w) { |
707 | 707 | $wi++; |
708 | - if ($w->id == $id){ |
|
708 | + if ($w->id == $id) { |
|
709 | 709 | $found = true; |
710 | 710 | break; |
711 | 711 | } // foreach (... as $wi -> $w) gives error 221! (no idea why...) |
@@ -303,7 +303,9 @@ discard block |
||
303 | 303 | } |
304 | 304 | |
305 | 305 | foreach ($recipient_ids as $rec) { |
306 | - if (empty($rec)) die(get_lang('GeneralError').' (code 210)'); |
|
306 | + if (empty($rec)) { |
|
307 | + die(get_lang('GeneralError').' (code 210)'); |
|
308 | + } |
|
307 | 309 | //if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course |
308 | 310 | //this check is done when validating submitted data |
309 | 311 | $this->recipients[] = array('id' => $rec, 'name' => getUserNameFromId($rec)); |
@@ -593,13 +595,19 @@ discard block |
||
593 | 595 | $id = intval($id); |
594 | 596 | $sql = "DELETE FROM ".$dropbox_cnf['tbl_file']." |
595 | 597 | WHERE c_id = $course_id AND cat_id = '".$id."' "; |
596 | - if (!Database::query($sql)) return false; |
|
598 | + if (!Database::query($sql)) { |
|
599 | + return false; |
|
600 | + } |
|
597 | 601 | $sql = "DELETE FROM ".$dropbox_cnf['tbl_category']." |
598 | 602 | WHERE c_id = $course_id AND cat_id = '".$id."' "; |
599 | - if (!Database::query($sql)) return false; |
|
603 | + if (!Database::query($sql)) { |
|
604 | + return false; |
|
605 | + } |
|
600 | 606 | $sql = "DELETE FROM ".$dropbox_cnf['tbl_post']." |
601 | 607 | WHERE c_id = $course_id AND cat_id = '".$id."' "; |
602 | - if (!Database::query($sql)) return false; |
|
608 | + if (!Database::query($sql)) { |
|
609 | + return false; |
|
610 | + } |
|
603 | 611 | return true; |
604 | 612 | } |
605 | 613 |
@@ -77,20 +77,20 @@ discard block |
||
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | - /** |
|
81 | - * private function creating a new work object |
|
82 | - * |
|
83 | - * @param int $uploader_id |
|
84 | - * @param string $title |
|
85 | - * @param string $description |
|
86 | - * @param string $author |
|
87 | - * @param string $filename |
|
88 | - * @param int $filesize |
|
89 | - * |
|
90 | - * @todo $author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads) |
|
91 | - * As a consequence this parameter can be removed |
|
92 | - */ |
|
93 | - public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize) |
|
80 | + /** |
|
81 | + * private function creating a new work object |
|
82 | + * |
|
83 | + * @param int $uploader_id |
|
84 | + * @param string $title |
|
85 | + * @param string $description |
|
86 | + * @param string $author |
|
87 | + * @param string $filename |
|
88 | + * @param int $filesize |
|
89 | + * |
|
90 | + * @todo $author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads) |
|
91 | + * As a consequence this parameter can be removed |
|
92 | + */ |
|
93 | + public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize) |
|
94 | 94 | { |
95 | 95 | $dropbox_cnf = getDropboxConf(); |
96 | 96 | |
@@ -108,17 +108,17 @@ discard block |
||
108 | 108 | // Check if object exists already. If it does, the old object is used |
109 | 109 | // with updated information (authors, description, upload_date) |
110 | 110 | $this->isOldWork = false; |
111 | - $sql = "SELECT id, upload_date FROM ".$dropbox_cnf['tbl_file']." |
|
111 | + $sql = "SELECT id, upload_date FROM ".$dropbox_cnf['tbl_file']." |
|
112 | 112 | WHERE c_id = $course_id AND filename = '".Database::escape_string($this->filename)."'"; |
113 | 113 | $result = Database::query($sql); |
114 | - $res = Database::fetch_array($result); |
|
115 | - if ($res) { |
|
116 | - $this->isOldWork = true; |
|
117 | - } |
|
118 | - // Insert or update the dropbox_file table and set the id property |
|
119 | - if ($this->isOldWork) { |
|
120 | - $this->id = $res['id']; |
|
121 | - $this->upload_date = $res['upload_date']; |
|
114 | + $res = Database::fetch_array($result); |
|
115 | + if ($res) { |
|
116 | + $this->isOldWork = true; |
|
117 | + } |
|
118 | + // Insert or update the dropbox_file table and set the id property |
|
119 | + if ($this->isOldWork) { |
|
120 | + $this->id = $res['id']; |
|
121 | + $this->upload_date = $res['upload_date']; |
|
122 | 122 | |
123 | 123 | $params = [ |
124 | 124 | 'filesize' => $this->filesize, |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | ['c_id = ? AND id = ?' => [$course_id, $this->id]] |
136 | 136 | ); |
137 | 137 | |
138 | - } else { |
|
139 | - $this->upload_date = $this->last_upload_date; |
|
140 | - $params = [ |
|
138 | + } else { |
|
139 | + $this->upload_date = $this->last_upload_date; |
|
140 | + $params = [ |
|
141 | 141 | 'c_id' => $course_id, |
142 | 142 | 'uploader_id' => $this->uploader_id, |
143 | 143 | 'filename' => $this->filename, |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | 'upload_date' => $this->upload_date, |
149 | 149 | 'last_upload_date' => $this->last_upload_date, |
150 | 150 | 'session_id' => api_get_session_id(), |
151 | - ]; |
|
152 | - $this->id = Database::insert($dropbox_cnf['tbl_file'], $params); |
|
151 | + ]; |
|
152 | + $this->id = Database::insert($dropbox_cnf['tbl_file'], $params); |
|
153 | 153 | |
154 | - if ($this->id) { |
|
155 | - $sql = "UPDATE ".$dropbox_cnf['tbl_file']." SET id = iid WHERE iid = {$this->id}"; |
|
156 | - Database::query($sql); |
|
157 | - } |
|
158 | - } |
|
154 | + if ($this->id) { |
|
155 | + $sql = "UPDATE ".$dropbox_cnf['tbl_file']." SET id = iid WHERE iid = {$this->id}"; |
|
156 | + Database::query($sql); |
|
157 | + } |
|
158 | + } |
|
159 | 159 | |
160 | 160 | $sql = "SELECT count(file_id) as count |
161 | 161 | FROM ".$dropbox_cnf['tbl_person']." |
@@ -169,16 +169,16 @@ discard block |
||
169 | 169 | VALUES ($course_id, ".intval($this->id)." , ".intval($this->uploader_id).")"; |
170 | 170 | Database::query($sql); |
171 | 171 | } |
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * private function creating existing object by retreiving info from db |
|
176 | - * |
|
177 | - * @param int $id |
|
178 | - */ |
|
179 | - public function _createExistingWork($id) |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * private function creating existing object by retreiving info from db |
|
176 | + * |
|
177 | + * @param int $id |
|
178 | + */ |
|
179 | + public function _createExistingWork($id) |
|
180 | 180 | { |
181 | - $course_id = api_get_course_int_id(); |
|
181 | + $course_id = api_get_course_int_id(); |
|
182 | 182 | $dropbox_cnf = getDropboxConf(); |
183 | 183 | |
184 | 184 | $action = isset($_GET['action']) ? $_GET['action'] : null; |
@@ -228,52 +228,52 @@ discard block |
||
228 | 228 | } |
229 | 229 | $this->feedback2= $feedback2; |
230 | 230 | } |
231 | - } |
|
231 | + } |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | class Dropbox_SentWork extends Dropbox_Work |
235 | 235 | { |
236 | - public $recipients; //array of ['id']['name'] arrays |
|
237 | - |
|
238 | - /** |
|
239 | - * Constructor calls private functions to create a new work or retreive an existing work from DB |
|
240 | - * depending on the number of parameters |
|
241 | - * |
|
242 | - * @param unknown_type $arg1 |
|
243 | - * @param unknown_type $arg2 |
|
244 | - * @param unknown_type $arg3 |
|
245 | - * @param unknown_type $arg4 |
|
246 | - * @param unknown_type $arg5 |
|
247 | - * @param unknown_type $arg6 |
|
248 | - * @param unknown_type $arg7 |
|
249 | - * @return Dropbox_SentWork |
|
250 | - */ |
|
251 | - function Dropbox_SentWork($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null) |
|
236 | + public $recipients; //array of ['id']['name'] arrays |
|
237 | + |
|
238 | + /** |
|
239 | + * Constructor calls private functions to create a new work or retreive an existing work from DB |
|
240 | + * depending on the number of parameters |
|
241 | + * |
|
242 | + * @param unknown_type $arg1 |
|
243 | + * @param unknown_type $arg2 |
|
244 | + * @param unknown_type $arg3 |
|
245 | + * @param unknown_type $arg4 |
|
246 | + * @param unknown_type $arg5 |
|
247 | + * @param unknown_type $arg6 |
|
248 | + * @param unknown_type $arg7 |
|
249 | + * @return Dropbox_SentWork |
|
250 | + */ |
|
251 | + function Dropbox_SentWork($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null) |
|
252 | 252 | { |
253 | - if (func_num_args() > 1) { |
|
254 | - $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7); |
|
255 | - } else { |
|
256 | - $this->_createExistingSentWork($arg1); |
|
257 | - } |
|
258 | - } |
|
259 | - |
|
260 | - /** |
|
261 | - * private function creating a new SentWork object |
|
262 | - * |
|
263 | - * @param int $uploader_id |
|
264 | - * @param string $title |
|
265 | - * @param string $description |
|
266 | - * @param string $author |
|
267 | - * @param string $filename |
|
268 | - * @param int $filesize |
|
269 | - * @param array $recipient_ids |
|
270 | - */ |
|
271 | - public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids) |
|
253 | + if (func_num_args() > 1) { |
|
254 | + $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7); |
|
255 | + } else { |
|
256 | + $this->_createExistingSentWork($arg1); |
|
257 | + } |
|
258 | + } |
|
259 | + |
|
260 | + /** |
|
261 | + * private function creating a new SentWork object |
|
262 | + * |
|
263 | + * @param int $uploader_id |
|
264 | + * @param string $title |
|
265 | + * @param string $description |
|
266 | + * @param string $author |
|
267 | + * @param string $filename |
|
268 | + * @param int $filesize |
|
269 | + * @param array $recipient_ids |
|
270 | + */ |
|
271 | + public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids) |
|
272 | 272 | { |
273 | 273 | $dropbox_cnf = getDropboxConf(); |
274 | 274 | $_course = api_get_course_info(); |
275 | 275 | |
276 | - // Call constructor of Dropbox_Work object |
|
276 | + // Call constructor of Dropbox_Work object |
|
277 | 277 | $this->Dropbox_Work( |
278 | 278 | $uploader_id, |
279 | 279 | $title, |
@@ -283,44 +283,44 @@ discard block |
||
283 | 283 | $filesize |
284 | 284 | ); |
285 | 285 | |
286 | - $course_id = api_get_course_int_id(); |
|
287 | - |
|
288 | - // Do sanity checks on recipient_ids array & property fillin |
|
289 | - // The sanity check for ex-coursemembers is already done in base constructor |
|
290 | - settype($uploader_id, 'integer') or die(get_lang('GeneralError').' (code 208)'); // Set $uploader_id to correct type |
|
286 | + $course_id = api_get_course_int_id(); |
|
291 | 287 | |
292 | - $justSubmit = false; |
|
293 | - if ( is_int($recipient_ids)) { |
|
294 | - $justSubmit = true; |
|
295 | - $recipient_ids = array($recipient_ids + $this->id); |
|
296 | - } elseif ( count($recipient_ids) == 0) { |
|
297 | - $justSubmit = true; |
|
298 | - $recipient_ids = array($uploader_id); |
|
299 | - } |
|
288 | + // Do sanity checks on recipient_ids array & property fillin |
|
289 | + // The sanity check for ex-coursemembers is already done in base constructor |
|
290 | + settype($uploader_id, 'integer') or die(get_lang('GeneralError').' (code 208)'); // Set $uploader_id to correct type |
|
291 | + |
|
292 | + $justSubmit = false; |
|
293 | + if ( is_int($recipient_ids)) { |
|
294 | + $justSubmit = true; |
|
295 | + $recipient_ids = array($recipient_ids + $this->id); |
|
296 | + } elseif ( count($recipient_ids) == 0) { |
|
297 | + $justSubmit = true; |
|
298 | + $recipient_ids = array($uploader_id); |
|
299 | + } |
|
300 | 300 | |
301 | - if (! is_array($recipient_ids) || count($recipient_ids) == 0) { |
|
302 | - die(get_lang('GeneralError').' (code 209)'); |
|
303 | - } |
|
301 | + if (! is_array($recipient_ids) || count($recipient_ids) == 0) { |
|
302 | + die(get_lang('GeneralError').' (code 209)'); |
|
303 | + } |
|
304 | 304 | |
305 | - foreach ($recipient_ids as $rec) { |
|
306 | - if (empty($rec)) die(get_lang('GeneralError').' (code 210)'); |
|
307 | - //if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course |
|
308 | - //this check is done when validating submitted data |
|
309 | - $this->recipients[] = array('id' => $rec, 'name' => getUserNameFromId($rec)); |
|
310 | - } |
|
305 | + foreach ($recipient_ids as $rec) { |
|
306 | + if (empty($rec)) die(get_lang('GeneralError').' (code 210)'); |
|
307 | + //if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course |
|
308 | + //this check is done when validating submitted data |
|
309 | + $this->recipients[] = array('id' => $rec, 'name' => getUserNameFromId($rec)); |
|
310 | + } |
|
311 | 311 | |
312 | 312 | $table_post = $dropbox_cnf['tbl_post']; |
313 | 313 | $table_person = $dropbox_cnf['tbl_person']; |
314 | 314 | $session_id = api_get_session_id(); |
315 | 315 | $uploader_id = $this->uploader_id; |
316 | 316 | $user = api_get_user_id(); |
317 | - // Insert data in dropbox_post and dropbox_person table for each recipient |
|
318 | - foreach ($this->recipients as $rec) { |
|
317 | + // Insert data in dropbox_post and dropbox_person table for each recipient |
|
318 | + foreach ($this->recipients as $rec) { |
|
319 | 319 | $file_id = (int)$this->id; |
320 | 320 | $user_id = (int)$rec['id']; |
321 | - $sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id) |
|
321 | + $sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id) |
|
322 | 322 | VALUES ($course_id, $file_id, $user_id, $session_id)"; |
323 | - Database::query($sql); |
|
323 | + Database::query($sql); |
|
324 | 324 | // If work already exists no error is generated |
325 | 325 | |
326 | 326 | /** |
@@ -337,13 +337,13 @@ discard block |
||
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | - // Update item_property table for each recipient |
|
341 | - if (($ownerid = $this->uploader_id) > $dropbox_cnf['mailingIdBase']) { |
|
342 | - $ownerid = getUserOwningThisMailing($ownerid); |
|
343 | - } |
|
344 | - if (($recipid = $rec["id"]) > $dropbox_cnf['mailingIdBase']) { |
|
345 | - $recipid = $ownerid; // mailing file recipient = mailing id, not a person |
|
346 | - } |
|
340 | + // Update item_property table for each recipient |
|
341 | + if (($ownerid = $this->uploader_id) > $dropbox_cnf['mailingIdBase']) { |
|
342 | + $ownerid = getUserOwningThisMailing($ownerid); |
|
343 | + } |
|
344 | + if (($recipid = $rec["id"]) > $dropbox_cnf['mailingIdBase']) { |
|
345 | + $recipid = $ownerid; // mailing file recipient = mailing id, not a person |
|
346 | + } |
|
347 | 347 | api_item_property_update( |
348 | 348 | $_course, |
349 | 349 | TOOL_DROPBOX, |
@@ -353,92 +353,92 @@ discard block |
||
353 | 353 | null, |
354 | 354 | $recipid |
355 | 355 | ); |
356 | - } |
|
357 | - } |
|
358 | - |
|
359 | - /** |
|
360 | - * private function creating existing object by retreiving info from db |
|
361 | - * |
|
362 | - * @param unknown_type $id |
|
363 | - */ |
|
364 | - function _createExistingSentWork($id) |
|
356 | + } |
|
357 | + } |
|
358 | + |
|
359 | + /** |
|
360 | + * private function creating existing object by retreiving info from db |
|
361 | + * |
|
362 | + * @param unknown_type $id |
|
363 | + */ |
|
364 | + function _createExistingSentWork($id) |
|
365 | 365 | { |
366 | 366 | $dropbox_cnf = getDropboxConf(); |
367 | 367 | $id = intval($id); |
368 | 368 | |
369 | - $course_id = api_get_course_int_id(); |
|
369 | + $course_id = api_get_course_int_id(); |
|
370 | 370 | |
371 | - // Call constructor of Dropbox_Work object |
|
372 | - $this->Dropbox_Work($id); |
|
371 | + // Call constructor of Dropbox_Work object |
|
372 | + $this->Dropbox_Work($id); |
|
373 | 373 | |
374 | - // Fill in recipients array |
|
375 | - $this->recipients = array(); |
|
376 | - $sql = "SELECT dest_user_id, feedback_date, feedback |
|
374 | + // Fill in recipients array |
|
375 | + $this->recipients = array(); |
|
376 | + $sql = "SELECT dest_user_id, feedback_date, feedback |
|
377 | 377 | FROM ".$dropbox_cnf['tbl_post']." |
378 | 378 | WHERE c_id = $course_id AND file_id = ".intval($id).""; |
379 | 379 | $result = Database::query($sql); |
380 | - while ($res = Database::fetch_array($result, 'ASSOC')) { |
|
381 | - |
|
382 | - // Check for deleted users |
|
383 | - $dest_user_id = $res['dest_user_id']; |
|
384 | - $user_info = api_get_user_info($dest_user_id); |
|
385 | - //$this->category = $res['cat_id']; |
|
386 | - if (!$user_info) { |
|
387 | - $this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', '')); |
|
388 | - } else { |
|
389 | - $this->recipients[] = array( |
|
380 | + while ($res = Database::fetch_array($result, 'ASSOC')) { |
|
381 | + |
|
382 | + // Check for deleted users |
|
383 | + $dest_user_id = $res['dest_user_id']; |
|
384 | + $user_info = api_get_user_info($dest_user_id); |
|
385 | + //$this->category = $res['cat_id']; |
|
386 | + if (!$user_info) { |
|
387 | + $this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', '')); |
|
388 | + } else { |
|
389 | + $this->recipients[] = array( |
|
390 | 390 | 'id' => $dest_user_id, |
391 | 391 | 'name' => $user_info['complete_name'], |
392 | 392 | 'user_id' => $dest_user_id, |
393 | - 'feedback_date' => $res['feedback_date'], |
|
393 | + 'feedback_date' => $res['feedback_date'], |
|
394 | 394 | 'feedback' => $res['feedback'] |
395 | 395 | ); |
396 | - } |
|
397 | - } |
|
398 | - } |
|
396 | + } |
|
397 | + } |
|
398 | + } |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | class Dropbox_Person |
402 | 402 | { |
403 | - // The receivedWork and the sentWork arrays are sorted. |
|
404 | - public $receivedWork; // an array of Dropbox_Work objects |
|
405 | - public $sentWork; // an array of Dropbox_SentWork objects |
|
406 | - |
|
407 | - public $userId = 0; |
|
408 | - public $isCourseAdmin = false; |
|
409 | - public $isCourseTutor = false; |
|
410 | - public $_orderBy = ''; // private property that determines by which field |
|
411 | - |
|
412 | - /** |
|
413 | - * Constructor for recreating the Dropbox_Person object |
|
414 | - * |
|
415 | - * @param int $userId |
|
416 | - * @param bool $isCourseAdmin |
|
417 | - * @param bool $isCourseTutor |
|
418 | - * @return Dropbox_Person |
|
419 | - */ |
|
420 | - function Dropbox_Person($userId, $isCourseAdmin, $isCourseTutor) |
|
403 | + // The receivedWork and the sentWork arrays are sorted. |
|
404 | + public $receivedWork; // an array of Dropbox_Work objects |
|
405 | + public $sentWork; // an array of Dropbox_SentWork objects |
|
406 | + |
|
407 | + public $userId = 0; |
|
408 | + public $isCourseAdmin = false; |
|
409 | + public $isCourseTutor = false; |
|
410 | + public $_orderBy = ''; // private property that determines by which field |
|
411 | + |
|
412 | + /** |
|
413 | + * Constructor for recreating the Dropbox_Person object |
|
414 | + * |
|
415 | + * @param int $userId |
|
416 | + * @param bool $isCourseAdmin |
|
417 | + * @param bool $isCourseTutor |
|
418 | + * @return Dropbox_Person |
|
419 | + */ |
|
420 | + function Dropbox_Person($userId, $isCourseAdmin, $isCourseTutor) |
|
421 | 421 | { |
422 | - $course_id = api_get_course_int_id(); |
|
422 | + $course_id = api_get_course_int_id(); |
|
423 | 423 | |
424 | - // Fill in properties |
|
424 | + // Fill in properties |
|
425 | 425 | $this->userId = $userId; |
426 | 426 | $this->isCourseAdmin = $isCourseAdmin; |
427 | 427 | $this->isCourseTutor = $isCourseTutor; |
428 | 428 | $this->receivedWork = array(); |
429 | 429 | $this->sentWork = array(); |
430 | 430 | |
431 | - // Note: perhaps include an ex coursemember check to delete old files |
|
431 | + // Note: perhaps include an ex coursemember check to delete old files |
|
432 | 432 | |
433 | - $session_id = api_get_session_id(); |
|
434 | - $condition_session = api_get_session_condition($session_id); |
|
433 | + $session_id = api_get_session_id(); |
|
434 | + $condition_session = api_get_session_condition($session_id); |
|
435 | 435 | |
436 | - $post_tbl = Database::get_course_table(TABLE_DROPBOX_POST); |
|
437 | - $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON); |
|
438 | - $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE); |
|
436 | + $post_tbl = Database::get_course_table(TABLE_DROPBOX_POST); |
|
437 | + $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON); |
|
438 | + $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE); |
|
439 | 439 | |
440 | 440 | // Find all entries where this person is the recipient |
441 | - $sql = "SELECT DISTINCT r.file_id, r.cat_id |
|
441 | + $sql = "SELECT DISTINCT r.file_id, r.cat_id |
|
442 | 442 | FROM $post_tbl r |
443 | 443 | INNER JOIN $person_tbl p |
444 | 444 | ON (r.file_id = p.file_id AND r.c_id = $course_id AND p.c_id = $course_id ) |
@@ -447,12 +447,12 @@ discard block |
||
447 | 447 | r.dest_user_id = ".intval($this->userId)." $condition_session "; |
448 | 448 | |
449 | 449 | $result = Database::query($sql); |
450 | - while ($res = Database::fetch_array($result)) { |
|
451 | - $temp = new Dropbox_Work($res['file_id']); |
|
452 | - $temp->category = $res['cat_id']; |
|
453 | - $this->receivedWork[] = $temp; |
|
454 | - } |
|
455 | - // Find all entries where this person is the sender/uploader |
|
450 | + while ($res = Database::fetch_array($result)) { |
|
451 | + $temp = new Dropbox_Work($res['file_id']); |
|
452 | + $temp->category = $res['cat_id']; |
|
453 | + $this->receivedWork[] = $temp; |
|
454 | + } |
|
455 | + // Find all entries where this person is the sender/uploader |
|
456 | 456 | $sql = "SELECT DISTINCT f.id |
457 | 457 | FROM $file_tbl f |
458 | 458 | INNER JOIN $person_tbl p |
@@ -463,260 +463,260 @@ discard block |
||
463 | 463 | $condition_session |
464 | 464 | "; |
465 | 465 | $result = Database::query($sql); |
466 | - while ($res = Database::fetch_array($result)) { |
|
467 | - $this->sentWork[] = new Dropbox_SentWork($res['id']); |
|
468 | - } |
|
469 | - } |
|
470 | - |
|
471 | - /** |
|
472 | - * This private method is used by the usort function in the |
|
473 | - * orderSentWork and orderReceivedWork methods. |
|
474 | - * It compares 2 work-objects by 1 of the properties of that object, dictated by the |
|
475 | - * private property _orderBy |
|
476 | - * |
|
477 | - * @param unknown_type $a |
|
478 | - * @param unknown_type $b |
|
479 | - * @return -1, 0 or 1 dependent of the result of the comparison. |
|
480 | - */ |
|
481 | - function _cmpWork($a, $b) |
|
466 | + while ($res = Database::fetch_array($result)) { |
|
467 | + $this->sentWork[] = new Dropbox_SentWork($res['id']); |
|
468 | + } |
|
469 | + } |
|
470 | + |
|
471 | + /** |
|
472 | + * This private method is used by the usort function in the |
|
473 | + * orderSentWork and orderReceivedWork methods. |
|
474 | + * It compares 2 work-objects by 1 of the properties of that object, dictated by the |
|
475 | + * private property _orderBy |
|
476 | + * |
|
477 | + * @param unknown_type $a |
|
478 | + * @param unknown_type $b |
|
479 | + * @return -1, 0 or 1 dependent of the result of the comparison. |
|
480 | + */ |
|
481 | + function _cmpWork($a, $b) |
|
482 | 482 | { |
483 | - $sort = $this->_orderBy; |
|
484 | - $aval = $a->$sort; |
|
485 | - $bval = $b->$sort; |
|
486 | - if ($sort == 'recipients') { |
|
487 | - // The recipients property is an array so we do the comparison based |
|
488 | - // on the first item of the recipients array |
|
489 | - $aval = $aval[0]['name']; |
|
490 | - $bval = $bval[0]['name']; |
|
491 | - } |
|
492 | - if ($sort == 'filesize') { // Filesize is not a string, so we use other comparison technique |
|
493 | - return $aval < $bval ? -1 : 1; |
|
494 | - } elseif ($sort == 'title') { // Natural order for sorting titles is more "human-friendly" |
|
495 | - return api_strnatcmp($aval, $bval); |
|
496 | - } else { |
|
497 | - return api_strcasecmp($aval, $bval); |
|
498 | - } |
|
499 | - } |
|
500 | - |
|
501 | - /** |
|
502 | - * A method that sorts the objects in the sentWork array, dependent on the $sort parameter. |
|
503 | - * $sort can be lastDate, firstDate, title, size, ... |
|
504 | - * |
|
505 | - * @param unknown_type $sort |
|
506 | - */ |
|
507 | - function orderSentWork($sort) |
|
483 | + $sort = $this->_orderBy; |
|
484 | + $aval = $a->$sort; |
|
485 | + $bval = $b->$sort; |
|
486 | + if ($sort == 'recipients') { |
|
487 | + // The recipients property is an array so we do the comparison based |
|
488 | + // on the first item of the recipients array |
|
489 | + $aval = $aval[0]['name']; |
|
490 | + $bval = $bval[0]['name']; |
|
491 | + } |
|
492 | + if ($sort == 'filesize') { // Filesize is not a string, so we use other comparison technique |
|
493 | + return $aval < $bval ? -1 : 1; |
|
494 | + } elseif ($sort == 'title') { // Natural order for sorting titles is more "human-friendly" |
|
495 | + return api_strnatcmp($aval, $bval); |
|
496 | + } else { |
|
497 | + return api_strcasecmp($aval, $bval); |
|
498 | + } |
|
499 | + } |
|
500 | + |
|
501 | + /** |
|
502 | + * A method that sorts the objects in the sentWork array, dependent on the $sort parameter. |
|
503 | + * $sort can be lastDate, firstDate, title, size, ... |
|
504 | + * |
|
505 | + * @param unknown_type $sort |
|
506 | + */ |
|
507 | + function orderSentWork($sort) |
|
508 | 508 | { |
509 | - switch($sort) { |
|
510 | - case 'lastDate': |
|
511 | - $this->_orderBy = 'last_upload_date'; |
|
512 | - break; |
|
513 | - case 'firstDate': |
|
514 | - $this->_orderBy = 'upload_date'; |
|
515 | - break; |
|
516 | - case 'title': |
|
517 | - $this->_orderBy = 'title'; |
|
518 | - break; |
|
519 | - case 'size': |
|
520 | - $this->_orderBy = 'filesize'; |
|
521 | - break; |
|
522 | - case 'author': |
|
523 | - $this->_orderBy = 'author'; |
|
524 | - break; |
|
525 | - case 'recipient': |
|
526 | - $this->_orderBy = 'recipients'; |
|
527 | - break; |
|
528 | - default: |
|
529 | - $this->_orderBy = 'last_upload_date'; |
|
530 | - } |
|
531 | - |
|
532 | - usort($this->sentWork, array($this, '_cmpWork')); |
|
533 | - } |
|
534 | - |
|
535 | - /** |
|
536 | - * method that sorts the objects in the receivedWork array, dependent on the $sort parameter. |
|
537 | - * $sort can be lastDate, firstDate, title, size, ... |
|
538 | - * @param unknown_type $sort |
|
539 | - */ |
|
540 | - function orderReceivedWork($sort) |
|
509 | + switch($sort) { |
|
510 | + case 'lastDate': |
|
511 | + $this->_orderBy = 'last_upload_date'; |
|
512 | + break; |
|
513 | + case 'firstDate': |
|
514 | + $this->_orderBy = 'upload_date'; |
|
515 | + break; |
|
516 | + case 'title': |
|
517 | + $this->_orderBy = 'title'; |
|
518 | + break; |
|
519 | + case 'size': |
|
520 | + $this->_orderBy = 'filesize'; |
|
521 | + break; |
|
522 | + case 'author': |
|
523 | + $this->_orderBy = 'author'; |
|
524 | + break; |
|
525 | + case 'recipient': |
|
526 | + $this->_orderBy = 'recipients'; |
|
527 | + break; |
|
528 | + default: |
|
529 | + $this->_orderBy = 'last_upload_date'; |
|
530 | + } |
|
531 | + |
|
532 | + usort($this->sentWork, array($this, '_cmpWork')); |
|
533 | + } |
|
534 | + |
|
535 | + /** |
|
536 | + * method that sorts the objects in the receivedWork array, dependent on the $sort parameter. |
|
537 | + * $sort can be lastDate, firstDate, title, size, ... |
|
538 | + * @param unknown_type $sort |
|
539 | + */ |
|
540 | + function orderReceivedWork($sort) |
|
541 | 541 | { |
542 | - switch($sort) { |
|
543 | - case 'lastDate': |
|
544 | - $this->_orderBy = 'last_upload_date'; |
|
545 | - break; |
|
546 | - case 'firstDate': |
|
547 | - $this->_orderBy = 'upload_date'; |
|
548 | - break; |
|
549 | - case 'title': |
|
550 | - $this->_orderBy = 'title'; |
|
551 | - break; |
|
552 | - case 'size': |
|
553 | - $this->_orderBy = 'filesize'; |
|
554 | - break; |
|
555 | - case 'author': |
|
556 | - $this->_orderBy = 'author'; |
|
557 | - break; |
|
558 | - case 'sender': |
|
559 | - $this->_orderBy = 'uploaderName'; |
|
560 | - break; |
|
561 | - default: |
|
562 | - $this->_orderBy = 'last_upload_date'; |
|
563 | - } |
|
564 | - |
|
565 | - usort($this->receivedWork, array($this, '_cmpWork')); |
|
566 | - } |
|
567 | - |
|
568 | - /** |
|
569 | - * Deletes all the received work of this person |
|
570 | - */ |
|
571 | - function deleteAllReceivedWork() |
|
542 | + switch($sort) { |
|
543 | + case 'lastDate': |
|
544 | + $this->_orderBy = 'last_upload_date'; |
|
545 | + break; |
|
546 | + case 'firstDate': |
|
547 | + $this->_orderBy = 'upload_date'; |
|
548 | + break; |
|
549 | + case 'title': |
|
550 | + $this->_orderBy = 'title'; |
|
551 | + break; |
|
552 | + case 'size': |
|
553 | + $this->_orderBy = 'filesize'; |
|
554 | + break; |
|
555 | + case 'author': |
|
556 | + $this->_orderBy = 'author'; |
|
557 | + break; |
|
558 | + case 'sender': |
|
559 | + $this->_orderBy = 'uploaderName'; |
|
560 | + break; |
|
561 | + default: |
|
562 | + $this->_orderBy = 'last_upload_date'; |
|
563 | + } |
|
564 | + |
|
565 | + usort($this->receivedWork, array($this, '_cmpWork')); |
|
566 | + } |
|
567 | + |
|
568 | + /** |
|
569 | + * Deletes all the received work of this person |
|
570 | + */ |
|
571 | + function deleteAllReceivedWork() |
|
572 | 572 | { |
573 | - $course_id = api_get_course_int_id(); |
|
573 | + $course_id = api_get_course_int_id(); |
|
574 | 574 | $dropbox_cnf = getDropboxConf(); |
575 | - // Delete entries in person table concerning received works |
|
576 | - foreach ($this->receivedWork as $w) { |
|
575 | + // Delete entries in person table concerning received works |
|
576 | + foreach ($this->receivedWork as $w) { |
|
577 | 577 | $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']." |
578 | 578 | WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'"; |
579 | - Database::query($sql); |
|
580 | - } |
|
579 | + Database::query($sql); |
|
580 | + } |
|
581 | 581 | // Check for unused files |
582 | - removeUnusedFiles(); |
|
583 | - } |
|
582 | + removeUnusedFiles(); |
|
583 | + } |
|
584 | 584 | |
585 | - /** |
|
586 | - * Deletes all the received categories and work of this person |
|
587 | - */ |
|
588 | - function deleteReceivedWorkFolder($id) |
|
585 | + /** |
|
586 | + * Deletes all the received categories and work of this person |
|
587 | + */ |
|
588 | + function deleteReceivedWorkFolder($id) |
|
589 | 589 | { |
590 | 590 | $dropbox_cnf = getDropboxConf(); |
591 | 591 | $course_id = api_get_course_int_id(); |
592 | 592 | |
593 | - $id = intval($id); |
|
594 | - $sql = "DELETE FROM ".$dropbox_cnf['tbl_file']." |
|
593 | + $id = intval($id); |
|
594 | + $sql = "DELETE FROM ".$dropbox_cnf['tbl_file']." |
|
595 | 595 | WHERE c_id = $course_id AND cat_id = '".$id."' "; |
596 | - if (!Database::query($sql)) return false; |
|
597 | - $sql = "DELETE FROM ".$dropbox_cnf['tbl_category']." |
|
596 | + if (!Database::query($sql)) return false; |
|
597 | + $sql = "DELETE FROM ".$dropbox_cnf['tbl_category']." |
|
598 | 598 | WHERE c_id = $course_id AND cat_id = '".$id."' "; |
599 | - if (!Database::query($sql)) return false; |
|
600 | - $sql = "DELETE FROM ".$dropbox_cnf['tbl_post']." |
|
599 | + if (!Database::query($sql)) return false; |
|
600 | + $sql = "DELETE FROM ".$dropbox_cnf['tbl_post']." |
|
601 | 601 | WHERE c_id = $course_id AND cat_id = '".$id."' "; |
602 | - if (!Database::query($sql)) return false; |
|
603 | - return true; |
|
604 | - } |
|
605 | - |
|
606 | - /** |
|
607 | - * Deletes a received dropbox file of this person with id=$id |
|
608 | - * |
|
609 | - * @param integer $id |
|
610 | - */ |
|
611 | - function deleteReceivedWork($id) |
|
602 | + if (!Database::query($sql)) return false; |
|
603 | + return true; |
|
604 | + } |
|
605 | + |
|
606 | + /** |
|
607 | + * Deletes a received dropbox file of this person with id=$id |
|
608 | + * |
|
609 | + * @param integer $id |
|
610 | + */ |
|
611 | + function deleteReceivedWork($id) |
|
612 | 612 | { |
613 | - $course_id = api_get_course_int_id(); |
|
613 | + $course_id = api_get_course_int_id(); |
|
614 | 614 | $dropbox_cnf = getDropboxConf(); |
615 | - $id = intval($id); |
|
616 | - |
|
617 | - // index check |
|
618 | - $found = false; |
|
619 | - foreach ($this->receivedWork as $w) { |
|
620 | - if ($w->id == $id) { |
|
621 | - $found = true; |
|
622 | - break; |
|
623 | - } |
|
624 | - } |
|
625 | - |
|
626 | - if (!$found) { |
|
627 | - if (!$this->deleteReceivedWorkFolder($id)) { |
|
628 | - die(get_lang('GeneralError').' (code 216)'); |
|
629 | - } |
|
630 | - } |
|
631 | - // Delete entries in person table concerning received works |
|
615 | + $id = intval($id); |
|
616 | + |
|
617 | + // index check |
|
618 | + $found = false; |
|
619 | + foreach ($this->receivedWork as $w) { |
|
620 | + if ($w->id == $id) { |
|
621 | + $found = true; |
|
622 | + break; |
|
623 | + } |
|
624 | + } |
|
625 | + |
|
626 | + if (!$found) { |
|
627 | + if (!$this->deleteReceivedWorkFolder($id)) { |
|
628 | + die(get_lang('GeneralError').' (code 216)'); |
|
629 | + } |
|
630 | + } |
|
631 | + // Delete entries in person table concerning received works |
|
632 | 632 | $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']." |
633 | 633 | WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'"; |
634 | - Database::query($sql); |
|
635 | - removeUnusedFiles(); // Check for unused files |
|
636 | - } |
|
637 | - |
|
638 | - /** |
|
639 | - * Deletes all the sent dropbox files of this person |
|
640 | - */ |
|
641 | - function deleteAllSentWork() |
|
634 | + Database::query($sql); |
|
635 | + removeUnusedFiles(); // Check for unused files |
|
636 | + } |
|
637 | + |
|
638 | + /** |
|
639 | + * Deletes all the sent dropbox files of this person |
|
640 | + */ |
|
641 | + function deleteAllSentWork() |
|
642 | 642 | { |
643 | - $course_id = api_get_course_int_id(); |
|
643 | + $course_id = api_get_course_int_id(); |
|
644 | 644 | $dropbox_cnf = getDropboxConf(); |
645 | - //delete entries in person table concerning sent works |
|
646 | - foreach ($this->sentWork as $w) { |
|
645 | + //delete entries in person table concerning sent works |
|
646 | + foreach ($this->sentWork as $w) { |
|
647 | 647 | $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']." |
648 | 648 | WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'"; |
649 | - Database::query($sql); |
|
650 | - removeMoreIfMailing($w->id); |
|
651 | - } |
|
652 | - removeUnusedFiles(); // Check for unused files |
|
653 | - } |
|
654 | - |
|
655 | - /** |
|
656 | - * Deletes a sent dropbox file of this person with id=$id |
|
657 | - * |
|
658 | - * @param unknown_type $id |
|
659 | - */ |
|
660 | - function deleteSentWork($id) |
|
649 | + Database::query($sql); |
|
650 | + removeMoreIfMailing($w->id); |
|
651 | + } |
|
652 | + removeUnusedFiles(); // Check for unused files |
|
653 | + } |
|
654 | + |
|
655 | + /** |
|
656 | + * Deletes a sent dropbox file of this person with id=$id |
|
657 | + * |
|
658 | + * @param unknown_type $id |
|
659 | + */ |
|
660 | + function deleteSentWork($id) |
|
661 | 661 | { |
662 | - $course_id = api_get_course_int_id(); |
|
662 | + $course_id = api_get_course_int_id(); |
|
663 | 663 | $dropbox_cnf = getDropboxConf(); |
664 | 664 | |
665 | - $id = intval($id); |
|
666 | - |
|
667 | - // index check |
|
668 | - $found = false; |
|
669 | - foreach ($this->sentWork as $w) { |
|
670 | - if ($w->id == $id) { |
|
671 | - $found = true; |
|
672 | - break; |
|
673 | - } |
|
674 | - } |
|
675 | - if (!$found) { |
|
676 | - if (!$this->deleteReceivedWorkFolder($id)) { |
|
677 | - die(get_lang('GeneralError').' (code 219)'); |
|
678 | - } |
|
679 | - } |
|
680 | - //$file_id = $this->sentWork[$index]->id; |
|
681 | - // Delete entries in person table concerning sent works |
|
665 | + $id = intval($id); |
|
666 | + |
|
667 | + // index check |
|
668 | + $found = false; |
|
669 | + foreach ($this->sentWork as $w) { |
|
670 | + if ($w->id == $id) { |
|
671 | + $found = true; |
|
672 | + break; |
|
673 | + } |
|
674 | + } |
|
675 | + if (!$found) { |
|
676 | + if (!$this->deleteReceivedWorkFolder($id)) { |
|
677 | + die(get_lang('GeneralError').' (code 219)'); |
|
678 | + } |
|
679 | + } |
|
680 | + //$file_id = $this->sentWork[$index]->id; |
|
681 | + // Delete entries in person table concerning sent works |
|
682 | 682 | $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']." |
683 | 683 | WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'"; |
684 | - Database::query($sql); |
|
685 | - removeMoreIfMailing($id); |
|
686 | - removeUnusedFiles(); // Check for unused files |
|
687 | - } |
|
688 | - |
|
689 | - /** |
|
690 | - * Updates feedback for received work of this person with id=$id |
|
691 | - * |
|
692 | - * @param string $id |
|
693 | - * @param string $text |
|
694 | - */ |
|
695 | - function updateFeedback($id, $text) |
|
684 | + Database::query($sql); |
|
685 | + removeMoreIfMailing($id); |
|
686 | + removeUnusedFiles(); // Check for unused files |
|
687 | + } |
|
688 | + |
|
689 | + /** |
|
690 | + * Updates feedback for received work of this person with id=$id |
|
691 | + * |
|
692 | + * @param string $id |
|
693 | + * @param string $text |
|
694 | + */ |
|
695 | + function updateFeedback($id, $text) |
|
696 | 696 | { |
697 | - $course_id = api_get_course_int_id(); |
|
697 | + $course_id = api_get_course_int_id(); |
|
698 | 698 | $_course = api_get_course_info(); |
699 | 699 | $dropbox_cnf = getDropboxConf(); |
700 | 700 | |
701 | - $id = intval($id); |
|
702 | - |
|
703 | - // index check |
|
704 | - $found = false; |
|
705 | - $wi = -1; |
|
706 | - foreach ($this->receivedWork as $w) { |
|
707 | - $wi++; |
|
708 | - if ($w->id == $id){ |
|
709 | - $found = true; |
|
710 | - break; |
|
711 | - } // foreach (... as $wi -> $w) gives error 221! (no idea why...) |
|
712 | - } |
|
713 | - if (!$found) { |
|
714 | - die(get_lang('GeneralError').' (code 221)'); |
|
715 | - } |
|
716 | - |
|
717 | - $feedback_date = api_get_utc_datetime(); |
|
718 | - $this->receivedWork[$wi]->feedback_date = $feedback_date; |
|
719 | - $this->receivedWork[$wi]->feedback = $text; |
|
701 | + $id = intval($id); |
|
702 | + |
|
703 | + // index check |
|
704 | + $found = false; |
|
705 | + $wi = -1; |
|
706 | + foreach ($this->receivedWork as $w) { |
|
707 | + $wi++; |
|
708 | + if ($w->id == $id){ |
|
709 | + $found = true; |
|
710 | + break; |
|
711 | + } // foreach (... as $wi -> $w) gives error 221! (no idea why...) |
|
712 | + } |
|
713 | + if (!$found) { |
|
714 | + die(get_lang('GeneralError').' (code 221)'); |
|
715 | + } |
|
716 | + |
|
717 | + $feedback_date = api_get_utc_datetime(); |
|
718 | + $this->receivedWork[$wi]->feedback_date = $feedback_date; |
|
719 | + $this->receivedWork[$wi]->feedback = $text; |
|
720 | 720 | |
721 | 721 | $params = [ |
722 | 722 | 'feedback_date' => $feedback_date, |
@@ -734,11 +734,11 @@ discard block |
||
734 | 734 | ] |
735 | 735 | ); |
736 | 736 | |
737 | - // Update item_property table |
|
737 | + // Update item_property table |
|
738 | 738 | |
739 | - if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $dropbox_cnf['mailingIdBase']) { |
|
740 | - $ownerid = getUserOwningThisMailing($ownerid); |
|
741 | - } |
|
739 | + if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $dropbox_cnf['mailingIdBase']) { |
|
740 | + $ownerid = getUserOwningThisMailing($ownerid); |
|
741 | + } |
|
742 | 742 | api_item_property_update( |
743 | 743 | $_course, |
744 | 744 | TOOL_DROPBOX, |
@@ -749,31 +749,31 @@ discard block |
||
749 | 749 | $ownerid |
750 | 750 | ); |
751 | 751 | |
752 | - } |
|
752 | + } |
|
753 | 753 | |
754 | - /** |
|
755 | - * Filter the received work |
|
756 | - * @param string $type |
|
757 | - * @param string $value |
|
758 | - */ |
|
759 | - function filter_received_work($type, $value) |
|
754 | + /** |
|
755 | + * Filter the received work |
|
756 | + * @param string $type |
|
757 | + * @param string $value |
|
758 | + */ |
|
759 | + function filter_received_work($type, $value) |
|
760 | 760 | { |
761 | 761 | $dropbox_cnf = getDropboxConf(); |
762 | - $new_received_work = array(); |
|
763 | - foreach ($this->receivedWork as $work) { |
|
764 | - switch ($type) { |
|
765 | - case 'uploader_id': |
|
766 | - if ($work->uploader_id == $value || |
|
767 | - ($work->uploader_id > $dropbox_cnf['mailingIdBase'] && |
|
762 | + $new_received_work = array(); |
|
763 | + foreach ($this->receivedWork as $work) { |
|
764 | + switch ($type) { |
|
765 | + case 'uploader_id': |
|
766 | + if ($work->uploader_id == $value || |
|
767 | + ($work->uploader_id > $dropbox_cnf['mailingIdBase'] && |
|
768 | 768 | getUserOwningThisMailing($work->uploader_id) == $value) |
769 | 769 | ) { |
770 | - $new_received_work[] = $work; |
|
771 | - } |
|
772 | - break; |
|
773 | - default: |
|
774 | - $new_received_work[] = $work; |
|
775 | - } |
|
776 | - } |
|
777 | - $this->receivedWork = $new_received_work; |
|
778 | - } |
|
770 | + $new_received_work[] = $work; |
|
771 | + } |
|
772 | + break; |
|
773 | + default: |
|
774 | + $new_received_work[] = $work; |
|
775 | + } |
|
776 | + } |
|
777 | + $this->receivedWork = $new_received_work; |
|
778 | + } |
|
779 | 779 | } |
@@ -186,6 +186,7 @@ discard block |
||
186 | 186 | * Reads answer information from the data base ordered by parameter |
187 | 187 | * @param string Field we want to order by |
188 | 188 | * @param string DESC or ASC |
189 | + * @param string $field |
|
189 | 190 | * @author Frederic Vauthier |
190 | 191 | */ |
191 | 192 | public function readOrderedBy($field, $order='ASC') |
@@ -300,6 +301,7 @@ discard block |
||
300 | 301 | * returns the question ID of the destination question |
301 | 302 | * |
302 | 303 | * @author Julio Montoya |
304 | + * @param integer $id |
|
303 | 305 | * @return integer - the question ID |
304 | 306 | */ |
305 | 307 | public function selectDestination($id) |
@@ -321,6 +323,7 @@ discard block |
||
321 | 323 | |
322 | 324 | /** |
323 | 325 | * return array answer by id else return a bool |
326 | + * @param integer $auto_id |
|
324 | 327 | */ |
325 | 328 | public function selectAnswerByAutoId($auto_id) |
326 | 329 | { |
@@ -435,6 +438,7 @@ discard block |
||
435 | 438 | * |
436 | 439 | * @author Olivier Brouckaert |
437 | 440 | * @param - integer $id - answer ID |
441 | + * @param integer $id |
|
438 | 442 | * @return integer - 0 if bad answer, not 0 if good answer |
439 | 443 | */ |
440 | 444 | public function isCorrect($id) |
@@ -447,6 +451,7 @@ discard block |
||
447 | 451 | * |
448 | 452 | * @author Olivier Brouckaert |
449 | 453 | * @param - integer $id - answer ID |
454 | + * @param integer $id |
|
450 | 455 | * @return string - answer comment |
451 | 456 | */ |
452 | 457 | public function selectComment($id) |
@@ -459,6 +464,7 @@ discard block |
||
459 | 464 | * |
460 | 465 | * @author Olivier Brouckaert |
461 | 466 | * @param - integer $id - answer ID |
467 | + * @param integer $id |
|
462 | 468 | * @return integer - answer weighting |
463 | 469 | */ |
464 | 470 | public function selectWeighting($id) |
@@ -483,6 +489,7 @@ discard block |
||
483 | 489 | * |
484 | 490 | * @author Olivier Brouckaert |
485 | 491 | * @param integer Answer ID |
492 | + * @param integer $id |
|
486 | 493 | * @return integer Answer position |
487 | 494 | */ |
488 | 495 | public function selectHotspotCoordinates($id) |
@@ -495,6 +502,7 @@ discard block |
||
495 | 502 | * |
496 | 503 | * @author Toon Keppens |
497 | 504 | * @param integer Answer ID |
505 | + * @param integer $id |
|
498 | 506 | * @return integer Answer position |
499 | 507 | */ |
500 | 508 | public function selectHotspotType($id) |
@@ -550,6 +558,7 @@ discard block |
||
550 | 558 | * @param string $destination |
551 | 559 | * @param string $hotspot_coordinates |
552 | 560 | * @param string $hotspot_type |
561 | + * @param integer $autoId |
|
553 | 562 | */ |
554 | 563 | public function updateAnswers( |
555 | 564 | $autoId, |
@@ -720,6 +729,7 @@ discard block |
||
720 | 729 | * @author Olivier Brouckaert |
721 | 730 | * @param int question id |
722 | 731 | * @param array destination course info (result of the function api_get_course_info() ) |
732 | + * @param string $newQuestionId |
|
723 | 733 | */ |
724 | 734 | public function duplicate($newQuestionId, $course_info = null) |
725 | 735 | { |
@@ -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 |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $objExercise->read($exerciseId); |
74 | 74 | |
75 | 75 | if ($objExercise->random_answers == '1') { |
76 | - $this->readOrderedBy('rand()', '');// randomize answers |
|
76 | + $this->readOrderedBy('rand()', ''); // randomize answers |
|
77 | 77 | } else { |
78 | 78 | $this->read(); // natural order |
79 | 79 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | ORDER BY position"; |
115 | 115 | |
116 | 116 | $result = Database::query($sql); |
117 | - $i=1; |
|
117 | + $i = 1; |
|
118 | 118 | |
119 | 119 | // while a record is found |
120 | 120 | while ($object = Database::fetch_object($result)) { |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $this->autoId[$i] = $object->id_auto; |
131 | 131 | $i++; |
132 | 132 | } |
133 | - $this->nbrAnswers = $i-1; |
|
133 | + $this->nbrAnswers = $i - 1; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | { |
143 | 143 | foreach ($this->autoId as $key => $autoId) { |
144 | 144 | if ($autoId == $id) { |
145 | - $result = [ |
|
145 | + $result = [ |
|
146 | 146 | 'answer' => $this->answer[$key], |
147 | 147 | 'correct' => $this->correct[$key], |
148 | 148 | 'comment' => $this->comment[$key], |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER); |
167 | 167 | $questionId = $this->questionId; |
168 | 168 | |
169 | - $sql="SELECT id FROM |
|
169 | + $sql = "SELECT id FROM |
|
170 | 170 | $TBL_ANSWER |
171 | 171 | WHERE c_id = {$this->course_id} AND question_id ='".$questionId."'"; |
172 | 172 | |
@@ -188,14 +188,14 @@ discard block |
||
188 | 188 | * @param string DESC or ASC |
189 | 189 | * @author Frederic Vauthier |
190 | 190 | */ |
191 | - public function readOrderedBy($field, $order='ASC') |
|
191 | + public function readOrderedBy($field, $order = 'ASC') |
|
192 | 192 | { |
193 | 193 | $field = Database::escape_string($field); |
194 | 194 | if (empty($field)) { |
195 | 195 | $field = 'position'; |
196 | 196 | } |
197 | 197 | |
198 | - if ($order != 'ASC' && $order!='DESC') { |
|
198 | + if ($order != 'ASC' && $order != 'DESC') { |
|
199 | 199 | $order = 'ASC'; |
200 | 200 | } |
201 | 201 | |
@@ -230,7 +230,7 @@ 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); |
|
233 | + $result = Database::query($sql); |
|
234 | 234 | |
235 | 235 | $i = 1; |
236 | 236 | // while a record is found |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | $this->autoId[$i] = $doubt_data->id_auto; |
261 | 261 | $i++; |
262 | 262 | } |
263 | - $this->nbrAnswers = $i-1; |
|
263 | + $this->nbrAnswers = $i - 1; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -402,8 +402,8 @@ discard block |
||
402 | 402 | public function getGradesList() |
403 | 403 | { |
404 | 404 | $list = array(); |
405 | - for ($i = 0; $i<$this->nbrAnswers;$i++){ |
|
406 | - if(!empty($this->answer[$i])){ |
|
405 | + for ($i = 0; $i < $this->nbrAnswers; $i++) { |
|
406 | + if (!empty($this->answer[$i])) { |
|
407 | 407 | $list[$i] = $this->weighting[$i]; |
408 | 408 | } |
409 | 409 | } |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | $sql = "SELECT type FROM $TBL_QUESTIONS |
422 | 422 | WHERE c_id = {$this->course_id} AND id = '".$this->questionId."'"; |
423 | 423 | $res = Database::query($sql); |
424 | - if (Database::num_rows($res)<=0){ |
|
424 | + if (Database::num_rows($res) <= 0) { |
|
425 | 425 | return null; |
426 | 426 | } |
427 | 427 | $row = Database::fetch_array($res); |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | $correctList = []; |
594 | 594 | $answerList = []; |
595 | 595 | |
596 | - for ($i=1; $i <= $this->new_nbrAnswers; $i++) { |
|
596 | + for ($i = 1; $i <= $this->new_nbrAnswers; $i++) { |
|
597 | 597 | $answer = $this->new_answer[$i]; |
598 | 598 | $correct = $this->new_correct[$i]; |
599 | 599 | $comment = $this->new_comment[$i]; |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | $destination_options = Question::readQuestionOption($newQuestionId, $course_info['real_id']); |
749 | 749 | $i = 0; |
750 | 750 | if (!empty($destination_options)) { |
751 | - foreach($destination_options as $item) { |
|
751 | + foreach ($destination_options as $item) { |
|
752 | 752 | $fixed_list[$new_option_list[$i]] = $item['id']; |
753 | 753 | $i++; |
754 | 754 | } |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | // inserts new answers into data base |
761 | 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], |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
286 | - * @return int |
|
286 | + * @return string |
|
287 | 287 | */ |
288 | 288 | public function selectPassPercentage() |
289 | 289 | { |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * tells if questions are selected randomly, and if so returns the draws |
379 | 379 | * |
380 | 380 | * @author Olivier Brouckaert |
381 | - * @return integer - 0 if not random, otherwise the draws |
|
381 | + * @return boolean - 0 if not random, otherwise the draws |
|
382 | 382 | */ |
383 | 383 | public function isRandom() |
384 | 384 | { |
@@ -1856,7 +1856,7 @@ discard block |
||
1856 | 1856 | * @param int int lp id |
1857 | 1857 | * @param int int lp item id |
1858 | 1858 | * @param int int lp item_view id |
1859 | - * @param float $weight |
|
1859 | + * @param integer $weight |
|
1860 | 1860 | * @param array question list |
1861 | 1861 | */ |
1862 | 1862 | public function save_stat_track_exercise_info( |
@@ -4121,6 +4121,7 @@ discard block |
||
4121 | 4121 | /** |
4122 | 4122 | * Sends a notification when a user ends an examn |
4123 | 4123 | * |
4124 | + * @param integer $exe_id |
|
4124 | 4125 | */ |
4125 | 4126 | public function send_mail_notification_for_exam($question_list_answers, $origin, $exe_id) |
4126 | 4127 | { |
@@ -4201,6 +4202,7 @@ discard block |
||
4201 | 4202 | /** |
4202 | 4203 | * Sends a notification when a user ends an examn |
4203 | 4204 | * |
4205 | + * @param integer $exe_id |
|
4204 | 4206 | */ |
4205 | 4207 | function send_notification_for_open_questions($question_list_answers, $origin, $exe_id) |
4206 | 4208 | { |
@@ -4298,6 +4300,9 @@ discard block |
||
4298 | 4300 | } |
4299 | 4301 | } |
4300 | 4302 | |
4303 | + /** |
|
4304 | + * @param integer $exe_id |
|
4305 | + */ |
|
4301 | 4306 | function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id) |
4302 | 4307 | { |
4303 | 4308 | if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) { |
@@ -4391,7 +4396,7 @@ discard block |
||
4391 | 4396 | |
4392 | 4397 | /** |
4393 | 4398 | * @param array $user_data result of api_get_user_info() |
4394 | - * @param null $start_date |
|
4399 | + * @param string $start_date |
|
4395 | 4400 | * @param null $duration |
4396 | 4401 | * @param string $ip Optional. The user IP |
4397 | 4402 | * @return string |
@@ -4449,7 +4454,7 @@ discard block |
||
4449 | 4454 | * @param int Maximum number of attempts (0 if no limit) |
4450 | 4455 | * @param int Feedback type |
4451 | 4456 | * @todo this was function was added due the import exercise via CSV |
4452 | - * @return int New exercise ID |
|
4457 | + * @return string New exercise ID |
|
4453 | 4458 | */ |
4454 | 4459 | public function createExercise( |
4455 | 4460 | $title, |
@@ -1966,7 +1966,7 @@ discard block |
||
1966 | 1966 | $label = get_lang('NextQuestion'); |
1967 | 1967 | $class = 'btn btn-primary'; |
1968 | 1968 | } |
1969 | - $class .= ' question-validate-btn'; // used to select it with jquery |
|
1969 | + $class .= ' question-validate-btn'; // used to select it with jquery |
|
1970 | 1970 | if ($this->type == ONE_PER_PAGE) { |
1971 | 1971 | if ($questionNum != 1) { |
1972 | 1972 | $prev_question = $questionNum - 2; |
@@ -1991,7 +1991,7 @@ discard block |
||
1991 | 1991 | $all_label = get_lang('EndTest'); |
1992 | 1992 | $class = 'btn btn-warning'; |
1993 | 1993 | } |
1994 | - $class .= ' question-validate-btn'; // used to select it with jquery |
|
1994 | + $class .= ' question-validate-btn'; // used to select it with jquery |
|
1995 | 1995 | $all_button = ' <a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>'; |
1996 | 1996 | $all_button .= ' ' . Display::span(null, ['id' => 'save_all_reponse']); |
1997 | 1997 | $html .= $all_button; |
@@ -3774,7 +3774,7 @@ discard block |
||
3774 | 3774 | |
3775 | 3775 | //Fixes multiple answer question in order to be exact |
3776 | 3776 | //if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) { |
3777 | - /* if ($answerType == GLOBAL_MULTIPLE_ANSWER) { |
|
3777 | + /* if ($answerType == GLOBAL_MULTIPLE_ANSWER) { |
|
3778 | 3778 | $diff = @array_diff($answer_correct_array, $real_answers); |
3779 | 3779 | |
3780 | 3780 | // All good answers or nothing works like exact |
@@ -5073,8 +5073,8 @@ discard block |
||
5073 | 5073 | } |
5074 | 5074 | |
5075 | 5075 | /** |
5076 | - * @return string |
|
5077 | - */ |
|
5076 | + * @return string |
|
5077 | + */ |
|
5078 | 5078 | public function get_formated_title() |
5079 | 5079 | { |
5080 | 5080 | return api_html_entity_decode($this->selectTitle()); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | public $feedback_type; |
28 | 28 | public $end_time; |
29 | 29 | public $start_time; |
30 | - public $questionList; // array with the list of this exercise's questions |
|
30 | + public $questionList; // array with the list of this exercise's questions |
|
31 | 31 | public $results_disabled; |
32 | 32 | public $expired_time; |
33 | 33 | public $course; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST); |
98 | 98 | $table_lp_item = Database::get_course_table(TABLE_LP_ITEM); |
99 | 99 | |
100 | - $id = intval($id); |
|
100 | + $id = intval($id); |
|
101 | 101 | if (empty($this->course_id)) { |
102 | 102 | return false; |
103 | 103 | } |
@@ -154,17 +154,17 @@ discard block |
||
154 | 154 | } |
155 | 155 | |
156 | 156 | if ($object->end_time != '0000-00-00 00:00:00') { |
157 | - $this->end_time = $object->end_time; |
|
157 | + $this->end_time = $object->end_time; |
|
158 | 158 | } |
159 | 159 | if ($object->start_time != '0000-00-00 00:00:00') { |
160 | - $this->start_time = $object->start_time; |
|
160 | + $this->start_time = $object->start_time; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | //control time |
164 | - $this->expired_time = $object->expired_time; |
|
164 | + $this->expired_time = $object->expired_time; |
|
165 | 165 | |
166 | 166 | //Checking if question_order is correctly set |
167 | - $this->questionList = $this->selectQuestionList(true); |
|
167 | + $this->questionList = $this->selectQuestionList(true); |
|
168 | 168 | |
169 | 169 | //overload questions list with recorded questions list |
170 | 170 | //load questions only for exercises of type 'one question per page' |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | */ |
383 | 383 | public function isRandom() |
384 | 384 | { |
385 | - if($this->random > 0 || $this->random == -1) { |
|
385 | + if ($this->random > 0 || $this->random == -1) { |
|
386 | 386 | return true; |
387 | 387 | } else { |
388 | 388 | return false; |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | public function selectQuestionList($from_db = false) |
428 | 428 | { |
429 | 429 | if ($from_db && !empty($this->id)) { |
430 | - $TBL_EXERCISE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
430 | + $TBL_EXERCISE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
431 | 431 | $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); |
432 | 432 | |
433 | 433 | $sql = "SELECT DISTINCT e.question_order |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | $question_list = array(); |
455 | 455 | |
456 | 456 | while ($new_object = Database::fetch_object($result)) { |
457 | - $question_list[$new_object->question_order]= $new_object->question_id; |
|
457 | + $question_list[$new_object->question_order] = $new_object->question_id; |
|
458 | 458 | $temp_question_list[$counter] = $new_object->question_id; |
459 | 459 | $counter++; |
460 | 460 | } |
@@ -500,16 +500,16 @@ discard block |
||
500 | 500 | */ |
501 | 501 | public function selectRandomList() |
502 | 502 | { |
503 | - $nbQuestions = $this->selectNbrQuestions(); |
|
504 | - $temp_list = $this->questionList; |
|
503 | + $nbQuestions = $this->selectNbrQuestions(); |
|
504 | + $temp_list = $this->questionList; |
|
505 | 505 | |
506 | 506 | //Not a random exercise, or if there are not at least 2 questions |
507 | - if($this->random == 0 || $nbQuestions < 2) { |
|
507 | + if ($this->random == 0 || $nbQuestions < 2) { |
|
508 | 508 | return $this->questionList; |
509 | 509 | } |
510 | 510 | if ($nbQuestions != 0) { |
511 | 511 | shuffle($temp_list); |
512 | - $my_random_list = array_combine(range(1,$nbQuestions),$temp_list); |
|
512 | + $my_random_list = array_combine(range(1, $nbQuestions), $temp_list); |
|
513 | 513 | $my_question_list = array(); |
514 | 514 | // $this->random == -1 if random with all questions |
515 | 515 | if ($this->random > 0) { |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | public function isInList($questionId) |
540 | 540 | { |
541 | 541 | if (is_array($this->questionList)) |
542 | - return in_array($questionId,$this->questionList); |
|
542 | + return in_array($questionId, $this->questionList); |
|
543 | 543 | else |
544 | 544 | return false; |
545 | 545 | } |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | */ |
553 | 553 | public function updateTitle($title) |
554 | 554 | { |
555 | - $this->exercise=$title; |
|
555 | + $this->exercise = $title; |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | /** |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | */ |
563 | 563 | public function updateAttempts($attempts) |
564 | 564 | { |
565 | - $this->attempts=$attempts; |
|
565 | + $this->attempts = $attempts; |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | /** |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | */ |
573 | 573 | public function updateFeedbackType($feedback_type) |
574 | 574 | { |
575 | - $this->feedback_type=$feedback_type; |
|
575 | + $this->feedback_type = $feedback_type; |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | /** |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | */ |
584 | 584 | public function updateDescription($description) |
585 | 585 | { |
586 | - $this->description=$description; |
|
586 | + $this->description = $description; |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | /** |
@@ -628,23 +628,23 @@ discard block |
||
628 | 628 | * @param string $sound - exercise sound file |
629 | 629 | * @param string $delete - ask to delete the file |
630 | 630 | */ |
631 | - public function updateSound($sound,$delete) |
|
631 | + public function updateSound($sound, $delete) |
|
632 | 632 | { |
633 | 633 | global $audioPath, $documentPath; |
634 | 634 | $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); |
635 | 635 | |
636 | - if ($sound['size'] && (strstr($sound['type'],'audio') || strstr($sound['type'],'video'))) { |
|
637 | - $this->sound=$sound['name']; |
|
636 | + if ($sound['size'] && (strstr($sound['type'], 'audio') || strstr($sound['type'], 'video'))) { |
|
637 | + $this->sound = $sound['name']; |
|
638 | 638 | |
639 | - if (@move_uploaded_file($sound['tmp_name'],$audioPath.'/'.$this->sound)) { |
|
639 | + if (@move_uploaded_file($sound['tmp_name'], $audioPath.'/'.$this->sound)) { |
|
640 | 640 | $query = "SELECT 1 FROM $TBL_DOCUMENT |
641 | - WHERE c_id = ".$this->course_id." AND path='".str_replace($documentPath,'',$audioPath).'/'.$this->sound."'"; |
|
642 | - $result=Database::query($query); |
|
641 | + WHERE c_id = ".$this->course_id." AND path='".str_replace($documentPath, '', $audioPath).'/'.$this->sound."'"; |
|
642 | + $result = Database::query($query); |
|
643 | 643 | |
644 | 644 | if (!Database::num_rows($result)) { |
645 | 645 | $id = add_document( |
646 | 646 | $this->course, |
647 | - str_replace($documentPath,'',$audioPath).'/'.$this->sound, |
|
647 | + str_replace($documentPath, '', $audioPath).'/'.$this->sound, |
|
648 | 648 | 'file', |
649 | 649 | $sound['size'], |
650 | 650 | $sound['name'] |
@@ -663,8 +663,8 @@ discard block |
||
663 | 663 | ); |
664 | 664 | } |
665 | 665 | } |
666 | - } elseif($delete && is_file($audioPath.'/'.$this->sound)) { |
|
667 | - $this->sound=''; |
|
666 | + } elseif ($delete && is_file($audioPath.'/'.$this->sound)) { |
|
667 | + $this->sound = ''; |
|
668 | 668 | } |
669 | 669 | } |
670 | 670 | |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | */ |
677 | 677 | public function updateType($type) |
678 | 678 | { |
679 | - $this->type=$type; |
|
679 | + $this->type = $type; |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | /** |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | */ |
713 | 713 | public function enable() |
714 | 714 | { |
715 | - $this->active=1; |
|
715 | + $this->active = 1; |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | /** |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | */ |
723 | 723 | public function disable() |
724 | 724 | { |
725 | - $this->active=0; |
|
725 | + $this->active = 0; |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | /** |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | api_get_user_id() |
847 | 847 | ); |
848 | 848 | |
849 | - if (api_get_setting('search_enabled')=='true') { |
|
849 | + if (api_get_setting('search_enabled') == 'true') { |
|
850 | 850 | $this->search_engine_edit(); |
851 | 851 | } |
852 | 852 | } else { |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | public function removeFromList($questionId) |
986 | 986 | { |
987 | 987 | // searches the position of the question ID in the list |
988 | - $pos = array_search($questionId,$this->questionList); |
|
988 | + $pos = array_search($questionId, $this->questionList); |
|
989 | 989 | |
990 | 990 | // question not found |
991 | 991 | if ($pos === false) { |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | api_item_property_update($this->course, TOOL_QUIZ, $this->id, 'QuizDeleted', api_get_user_id()); |
1021 | 1021 | api_item_property_update($this->course, TOOL_QUIZ, $this->id, 'delete', api_get_user_id()); |
1022 | 1022 | |
1023 | - if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian') ) { |
|
1023 | + if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) { |
|
1024 | 1024 | $this->search_engine_delete(); |
1025 | 1025 | } |
1026 | 1026 | } |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | * Creates the form to create / edit an exercise |
1030 | 1030 | * @param FormValidator $form |
1031 | 1031 | */ |
1032 | - public function createForm($form, $type='full') |
|
1032 | + public function createForm($form, $type = 'full') |
|
1033 | 1033 | { |
1034 | 1034 | if (empty($type)) { |
1035 | 1035 | $type = 'full'; |
@@ -1060,7 +1060,7 @@ discard block |
||
1060 | 1060 | 'Width' => '100%', |
1061 | 1061 | 'Height' => '150', |
1062 | 1062 | ); |
1063 | - if (is_array($type)){ |
|
1063 | + if (is_array($type)) { |
|
1064 | 1064 | $editor_config = array_merge($editor_config, $type); |
1065 | 1065 | } |
1066 | 1066 | |
@@ -1114,13 +1114,13 @@ discard block |
||
1114 | 1114 | '2', |
1115 | 1115 | array('id' => 'exerciseType_2') |
1116 | 1116 | ); |
1117 | - $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'),get_lang('FeedbackDisplayOptions')), ''); |
|
1117 | + $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')), ''); |
|
1118 | 1118 | |
1119 | 1119 | // Type of results display on the final page |
1120 | 1120 | $radios_results_disabled = array(); |
1121 | 1121 | $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0')); |
1122 | - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()')); |
|
1123 | - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2')); |
|
1122 | + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()')); |
|
1123 | + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2')); |
|
1124 | 1124 | //$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ExamModeWithFinalScoreShowOnlyFinalScoreWithCategoriesIfAvailable'), '3', array('id'=>'result_disabled_3','onclick' => 'check_results_disabled()')); |
1125 | 1125 | |
1126 | 1126 | $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), ''); |
@@ -1128,8 +1128,8 @@ discard block |
||
1128 | 1128 | // Type of questions disposition on page |
1129 | 1129 | $radios = array(); |
1130 | 1130 | |
1131 | - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all')); |
|
1132 | - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one')); |
|
1131 | + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all')); |
|
1132 | + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one')); |
|
1133 | 1133 | |
1134 | 1134 | $form->addGroup($radios, null, get_lang('QuestionsPerPage'), ''); |
1135 | 1135 | |
@@ -1139,33 +1139,33 @@ discard block |
||
1139 | 1139 | |
1140 | 1140 | // feedback type |
1141 | 1141 | $radios_feedback = array(); |
1142 | - $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'),'0',array('id' =>'exerciseType_0', 'onclick' => 'check_feedback()')); |
|
1142 | + $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'), '0', array('id' =>'exerciseType_0', 'onclick' => 'check_feedback()')); |
|
1143 | 1143 | |
1144 | 1144 | if (api_get_setting('enable_quiz_scenario') == 'true') { |
1145 | - $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' =>'exerciseType_1' , 'onclick' => 'check_direct_feedback()')); |
|
1145 | + $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' =>'exerciseType_1', 'onclick' => 'check_direct_feedback()')); |
|
1146 | 1146 | } |
1147 | - $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'),'2',array('id' =>'exerciseType_2')); |
|
1148 | - $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'),get_lang('FeedbackDisplayOptions'))); |
|
1147 | + $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'), '2', array('id' =>'exerciseType_2')); |
|
1148 | + $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions'))); |
|
1149 | 1149 | |
1150 | 1150 | //$form->addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"'); |
1151 | 1151 | $radios_results_disabled = array(); |
1152 | 1152 | $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0')); |
1153 | - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()')); |
|
1154 | - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2',array('id'=>'result_disabled_2','onclick' => 'check_results_disabled()')); |
|
1155 | - $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'),''); |
|
1153 | + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()')); |
|
1154 | + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2', 'onclick' => 'check_results_disabled()')); |
|
1155 | + $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), ''); |
|
1156 | 1156 | |
1157 | 1157 | // Type of questions disposition on page |
1158 | 1158 | $radios = array(); |
1159 | - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1'); |
|
1160 | - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2'); |
|
1159 | + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1'); |
|
1160 | + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2'); |
|
1161 | 1161 | $form->addGroup($radios, null, get_lang('ExerciseType')); |
1162 | 1162 | |
1163 | 1163 | } else { |
1164 | 1164 | //Show options freeze |
1165 | 1165 | $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0')); |
1166 | - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()')); |
|
1167 | - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2',array('id'=>'result_disabled_2','onclick' => 'check_results_disabled()')); |
|
1168 | - $result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'),''); |
|
1166 | + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()')); |
|
1167 | + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2', 'onclick' => 'check_results_disabled()')); |
|
1168 | + $result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), ''); |
|
1169 | 1169 | $result_disable_group->freeze(); |
1170 | 1170 | |
1171 | 1171 | //we force the options to the DirectFeedback exercisetype |
@@ -1173,8 +1173,8 @@ discard block |
||
1173 | 1173 | $form->addElement('hidden', 'exerciseType', ONE_PER_PAGE); |
1174 | 1174 | |
1175 | 1175 | // Type of questions disposition on page |
1176 | - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all')); |
|
1177 | - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one')); |
|
1176 | + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all')); |
|
1177 | + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one')); |
|
1178 | 1178 | |
1179 | 1179 | $type_group = $form->addGroup($radios, null, get_lang('QuestionsPerPage'), ''); |
1180 | 1180 | $type_group->freeze(); |
@@ -1183,26 +1183,26 @@ discard block |
||
1183 | 1183 | |
1184 | 1184 | // number of random question |
1185 | 1185 | |
1186 | - $max = ($this->id > 0) ? $this->selectNbrQuestions() : 10 ; |
|
1187 | - $option = range(0,$max); |
|
1186 | + $max = ($this->id > 0) ? $this->selectNbrQuestions() : 10; |
|
1187 | + $option = range(0, $max); |
|
1188 | 1188 | $option[0] = get_lang('No'); |
1189 | 1189 | $option[-1] = get_lang('AllQuestionsShort'); |
1190 | - $form->addElement('select', 'randomQuestions',array(get_lang('RandomQuestions'), get_lang('RandomQuestionsHelp')), $option, array('id'=>'randomQuestions')); |
|
1190 | + $form->addElement('select', 'randomQuestions', array(get_lang('RandomQuestions'), get_lang('RandomQuestionsHelp')), $option, array('id'=>'randomQuestions')); |
|
1191 | 1191 | |
1192 | 1192 | // Random answers |
1193 | 1193 | $radios_random_answers = array(); |
1194 | - $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('Yes'),'1'); |
|
1195 | - $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('No'),'0'); |
|
1194 | + $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('Yes'), '1'); |
|
1195 | + $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('No'), '0'); |
|
1196 | 1196 | $form->addGroup($radios_random_answers, null, get_lang('RandomAnswers'), ''); |
1197 | 1197 | |
1198 | 1198 | // Random by category |
1199 | - $form->addElement('html','<div class="clear"> </div>'); |
|
1199 | + $form->addElement('html', '<div class="clear"> </div>'); |
|
1200 | 1200 | $radiocat = array(); |
1201 | - $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesShuffled'),'1'); |
|
1202 | - $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesSorted'),'2'); |
|
1203 | - $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('No'),'0'); |
|
1201 | + $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesShuffled'), '1'); |
|
1202 | + $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesSorted'), '2'); |
|
1203 | + $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('No'), '0'); |
|
1204 | 1204 | $radioCatGroup = $form->addGroup($radiocat, null, get_lang('RandomQuestionByCategory'), ''); |
1205 | - $form->addElement('html','<div class="clear"> </div>'); |
|
1205 | + $form->addElement('html', '<div class="clear"> </div>'); |
|
1206 | 1206 | |
1207 | 1207 | // add the radio display the category name for student |
1208 | 1208 | $radio_display_cat_name = array(); |
@@ -1223,36 +1223,36 @@ discard block |
||
1223 | 1223 | ); |
1224 | 1224 | |
1225 | 1225 | // Exercise time limit |
1226 | - $form->addElement('checkbox', 'activate_start_date_check',null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()')); |
|
1226 | + $form->addElement('checkbox', 'activate_start_date_check', null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()')); |
|
1227 | 1227 | |
1228 | 1228 | $var = Exercise::selectTimeLimit(); |
1229 | 1229 | |
1230 | 1230 | if (($this->start_time != '0000-00-00 00:00:00')) |
1231 | - $form->addElement('html','<div id="start_date_div" style="display:block;">'); |
|
1231 | + $form->addElement('html', '<div id="start_date_div" style="display:block;">'); |
|
1232 | 1232 | else |
1233 | - $form->addElement('html','<div id="start_date_div" style="display:none;">'); |
|
1233 | + $form->addElement('html', '<div id="start_date_div" style="display:none;">'); |
|
1234 | 1234 | |
1235 | 1235 | $form->addElement('date_time_picker', 'start_time'); |
1236 | 1236 | |
1237 | - $form->addElement('html','</div>'); |
|
1237 | + $form->addElement('html', '</div>'); |
|
1238 | 1238 | |
1239 | - $form->addElement('checkbox', 'activate_end_date_check', null , get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()')); |
|
1239 | + $form->addElement('checkbox', 'activate_end_date_check', null, get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()')); |
|
1240 | 1240 | |
1241 | 1241 | if (($this->end_time != '0000-00-00 00:00:00')) |
1242 | - $form->addElement('html','<div id="end_date_div" style="display:block;">'); |
|
1242 | + $form->addElement('html', '<div id="end_date_div" style="display:block;">'); |
|
1243 | 1243 | else |
1244 | - $form->addElement('html','<div id="end_date_div" style="display:none;">'); |
|
1244 | + $form->addElement('html', '<div id="end_date_div" style="display:none;">'); |
|
1245 | 1245 | |
1246 | 1246 | $form->addElement('date_time_picker', 'end_time'); |
1247 | - $form->addElement('html','</div>'); |
|
1247 | + $form->addElement('html', '</div>'); |
|
1248 | 1248 | |
1249 | 1249 | //$check_option=$this->selectType(); |
1250 | 1250 | $diplay = 'block'; |
1251 | 1251 | $form->addElement('checkbox', 'propagate_neg', null, get_lang('PropagateNegativeResults')); |
1252 | - $form->addElement('html','<div class="clear"> </div>'); |
|
1252 | + $form->addElement('html', '<div class="clear"> </div>'); |
|
1253 | 1253 | $form->addElement('checkbox', 'review_answers', null, get_lang('ReviewAnswers')); |
1254 | 1254 | |
1255 | - $form->addElement('html','<div id="divtimecontrol" style="display:'.$diplay.';">'); |
|
1255 | + $form->addElement('html', '<div id="divtimecontrol" style="display:'.$diplay.';">'); |
|
1256 | 1256 | |
1257 | 1257 | //Timer control |
1258 | 1258 | //$time_hours_option = range(0,12); |
@@ -1268,12 +1268,12 @@ discard block |
||
1268 | 1268 | 'onload' => 'check_load_time()', |
1269 | 1269 | ) |
1270 | 1270 | ); |
1271 | - $expired_date = (int)$this->selectExpiredTime(); |
|
1271 | + $expired_date = (int) $this->selectExpiredTime(); |
|
1272 | 1272 | |
1273 | - if (($expired_date!='0')) { |
|
1274 | - $form->addElement('html','<div id="timercontrol" style="display:block;">'); |
|
1273 | + if (($expired_date != '0')) { |
|
1274 | + $form->addElement('html', '<div id="timercontrol" style="display:block;">'); |
|
1275 | 1275 | } else { |
1276 | - $form->addElement('html','<div id="timercontrol" style="display:none;">'); |
|
1276 | + $form->addElement('html', '<div id="timercontrol" style="display:none;">'); |
|
1277 | 1277 | } |
1278 | 1278 | $form->addText( |
1279 | 1279 | 'enabletimercontroltotalminutes', |
@@ -1284,7 +1284,7 @@ discard block |
||
1284 | 1284 | 'cols-size' => [2, 2, 8] |
1285 | 1285 | ] |
1286 | 1286 | ); |
1287 | - $form->addElement('html','</div>'); |
|
1287 | + $form->addElement('html', '</div>'); |
|
1288 | 1288 | |
1289 | 1289 | $form->addElement( |
1290 | 1290 | 'text', |
@@ -1306,18 +1306,18 @@ discard block |
||
1306 | 1306 | $defaults = array(); |
1307 | 1307 | |
1308 | 1308 | if (api_get_setting('search_enabled') === 'true') { |
1309 | - require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
1309 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
1310 | 1310 | |
1311 | - $form->addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument')); |
|
1312 | - $form->addElement ('select_language', 'language', get_lang('SearchFeatureDocumentLanguage')); |
|
1311 | + $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument')); |
|
1312 | + $form->addElement('select_language', 'language', get_lang('SearchFeatureDocumentLanguage')); |
|
1313 | 1313 | |
1314 | 1314 | $specific_fields = get_specific_field_list(); |
1315 | 1315 | |
1316 | 1316 | foreach ($specific_fields as $specific_field) { |
1317 | - $form->addElement ('text', $specific_field['code'], $specific_field['name']); |
|
1318 | - $filter = array('c_id'=> "'". api_get_course_int_id() ."'", 'field_id' => $specific_field['id'], 'ref_id' => $this->id, 'tool_id' => '\''. TOOL_QUIZ .'\''); |
|
1317 | + $form->addElement('text', $specific_field['code'], $specific_field['name']); |
|
1318 | + $filter = array('c_id'=> "'".api_get_course_int_id()."'", 'field_id' => $specific_field['id'], 'ref_id' => $this->id, 'tool_id' => '\''.TOOL_QUIZ.'\''); |
|
1319 | 1319 | $values = get_specific_field_values_list($filter, array('value')); |
1320 | - if ( !empty($values) ) { |
|
1320 | + if (!empty($values)) { |
|
1321 | 1321 | $arr_str_values = array(); |
1322 | 1322 | foreach ($values as $value) { |
1323 | 1323 | $arr_str_values[] = $value['value']; |
@@ -1328,8 +1328,8 @@ discard block |
||
1328 | 1328 | //$form->addElement ('html','</div>'); |
1329 | 1329 | } |
1330 | 1330 | |
1331 | - $form->addElement('html','</div>'); //End advanced setting |
|
1332 | - $form->addElement('html','</div>'); |
|
1331 | + $form->addElement('html', '</div>'); //End advanced setting |
|
1332 | + $form->addElement('html', '</div>'); |
|
1333 | 1333 | } |
1334 | 1334 | |
1335 | 1335 | // submit |
@@ -1349,10 +1349,10 @@ discard block |
||
1349 | 1349 | } |
1350 | 1350 | |
1351 | 1351 | // defaults |
1352 | - if ($type=='full') { |
|
1352 | + if ($type == 'full') { |
|
1353 | 1353 | if ($this->id > 0) { |
1354 | 1354 | if ($this->random > $this->selectNbrQuestions()) { |
1355 | - $defaults['randomQuestions'] = $this->selectNbrQuestions(); |
|
1355 | + $defaults['randomQuestions'] = $this->selectNbrQuestions(); |
|
1356 | 1356 | } else { |
1357 | 1357 | $defaults['randomQuestions'] = $this->random; |
1358 | 1358 | } |
@@ -1378,8 +1378,8 @@ discard block |
||
1378 | 1378 | $defaults['activate_end_date_check'] = 1; |
1379 | 1379 | } |
1380 | 1380 | |
1381 | - $defaults['start_time'] = ($this->start_time!='0000-00-00 00:00:00') ? api_get_local_time($this->start_time) : date('Y-m-d 12:00:00'); |
|
1382 | - $defaults['end_time'] = ($this->end_time!='0000-00-00 00:00:00') ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time()+84600); |
|
1381 | + $defaults['start_time'] = ($this->start_time != '0000-00-00 00:00:00') ? api_get_local_time($this->start_time) : date('Y-m-d 12:00:00'); |
|
1382 | + $defaults['end_time'] = ($this->end_time != '0000-00-00 00:00:00') ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time() + 84600); |
|
1383 | 1383 | |
1384 | 1384 | // Get expired time |
1385 | 1385 | if ($this->expired_time != '0') { |
@@ -1400,7 +1400,7 @@ discard block |
||
1400 | 1400 | $defaults['text_when_finished'] = ""; |
1401 | 1401 | $defaults['start_time'] = date('Y-m-d 12:00:00'); |
1402 | 1402 | $defaults['display_category_name'] = 1; |
1403 | - $defaults['end_time'] = date('Y-m-d 12:00:00', time()+84600); |
|
1403 | + $defaults['end_time'] = date('Y-m-d 12:00:00', time() + 84600); |
|
1404 | 1404 | $defaults['pass_percentage'] = ''; |
1405 | 1405 | } |
1406 | 1406 | } else { |
@@ -1467,7 +1467,7 @@ discard block |
||
1467 | 1467 | $end_time = $form->getSubmitValue('end_time'); |
1468 | 1468 | $this->end_time = api_get_utc_datetime($end_time); |
1469 | 1469 | } else { |
1470 | - $this->end_time = '0000-00-00 00:00:00'; |
|
1470 | + $this->end_time = '0000-00-00 00:00:00'; |
|
1471 | 1471 | } |
1472 | 1472 | |
1473 | 1473 | if ($form->getSubmitValue('enabletimercontrol') == 1) { |
@@ -1480,9 +1480,9 @@ discard block |
||
1480 | 1480 | } |
1481 | 1481 | |
1482 | 1482 | if ($form->getSubmitValue('randomAnswers') == 1) { |
1483 | - $this->random_answers=1; |
|
1483 | + $this->random_answers = 1; |
|
1484 | 1484 | } else { |
1485 | - $this->random_answers=0; |
|
1485 | + $this->random_answers = 0; |
|
1486 | 1486 | } |
1487 | 1487 | $this->save($type); |
1488 | 1488 | } |
@@ -1494,9 +1494,9 @@ discard block |
||
1494 | 1494 | } |
1495 | 1495 | $course_id = api_get_course_id(); |
1496 | 1496 | |
1497 | - require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'; |
|
1498 | - require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php'; |
|
1499 | - require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
1497 | + require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'; |
|
1498 | + require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php'; |
|
1499 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
1500 | 1500 | |
1501 | 1501 | $specific_fields = get_specific_field_list(); |
1502 | 1502 | $ic_slide = new IndexableChunk(); |
@@ -1506,7 +1506,7 @@ discard block |
||
1506 | 1506 | if (isset($_REQUEST[$specific_field['code']])) { |
1507 | 1507 | $sterms = trim($_REQUEST[$specific_field['code']]); |
1508 | 1508 | if (!empty($sterms)) { |
1509 | - $all_specific_terms .= ' '. $sterms; |
|
1509 | + $all_specific_terms .= ' '.$sterms; |
|
1510 | 1510 | $sterms = explode(',', $sterms); |
1511 | 1511 | foreach ($sterms as $sterm) { |
1512 | 1512 | $ic_slide->addTerm(trim($sterm), $specific_field['code']); |
@@ -1523,15 +1523,15 @@ discard block |
||
1523 | 1523 | $xapian_data = array( |
1524 | 1524 | SE_COURSE_ID => $course_id, |
1525 | 1525 | SE_TOOL_ID => TOOL_QUIZ, |
1526 | - SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id), |
|
1527 | - SE_USER => (int)api_get_user_id(), |
|
1526 | + SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id), |
|
1527 | + SE_USER => (int) api_get_user_id(), |
|
1528 | 1528 | ); |
1529 | 1529 | $ic_slide->xapian_data = serialize($xapian_data); |
1530 | - $exercise_description = $all_specific_terms .' '. $this->description; |
|
1530 | + $exercise_description = $all_specific_terms.' '.$this->description; |
|
1531 | 1531 | $ic_slide->addValue("content", $exercise_description); |
1532 | 1532 | |
1533 | 1533 | $di = new ChamiloIndexer(); |
1534 | - isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english'; |
|
1534 | + isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english'; |
|
1535 | 1535 | $di->connectDb(NULL, NULL, $lang); |
1536 | 1536 | $di->addChunk($ic_slide); |
1537 | 1537 | |
@@ -1550,7 +1550,7 @@ discard block |
||
1550 | 1550 | function search_engine_edit() |
1551 | 1551 | { |
1552 | 1552 | // update search enchine and its values table if enabled |
1553 | - if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) { |
|
1553 | + if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) { |
|
1554 | 1554 | $course_id = api_get_course_id(); |
1555 | 1555 | |
1556 | 1556 | // actually, it consists on delete terms from db, |
@@ -1562,9 +1562,9 @@ discard block |
||
1562 | 1562 | $res = Database::query($sql); |
1563 | 1563 | |
1564 | 1564 | if (Database::num_rows($res) > 0) { |
1565 | - require_once(api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'); |
|
1566 | - require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php'); |
|
1567 | - require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'); |
|
1565 | + require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'); |
|
1566 | + require_once(api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php'); |
|
1567 | + require_once(api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'); |
|
1568 | 1568 | |
1569 | 1569 | $se_ref = Database::fetch_array($res); |
1570 | 1570 | $specific_fields = get_specific_field_list(); |
@@ -1575,7 +1575,7 @@ discard block |
||
1575 | 1575 | delete_all_specific_field_value($course_id, $specific_field['id'], TOOL_QUIZ, $this->id); |
1576 | 1576 | if (isset($_REQUEST[$specific_field['code']])) { |
1577 | 1577 | $sterms = trim($_REQUEST[$specific_field['code']]); |
1578 | - $all_specific_terms .= ' '. $sterms; |
|
1578 | + $all_specific_terms .= ' '.$sterms; |
|
1579 | 1579 | $sterms = explode(',', $sterms); |
1580 | 1580 | foreach ($sterms as $sterm) { |
1581 | 1581 | $ic_slide->addTerm(trim($sterm), $specific_field['code']); |
@@ -1591,17 +1591,17 @@ discard block |
||
1591 | 1591 | $xapian_data = array( |
1592 | 1592 | SE_COURSE_ID => $course_id, |
1593 | 1593 | SE_TOOL_ID => TOOL_QUIZ, |
1594 | - SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id), |
|
1595 | - SE_USER => (int)api_get_user_id(), |
|
1594 | + SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id), |
|
1595 | + SE_USER => (int) api_get_user_id(), |
|
1596 | 1596 | ); |
1597 | 1597 | $ic_slide->xapian_data = serialize($xapian_data); |
1598 | - $exercise_description = $all_specific_terms .' '. $this->description; |
|
1598 | + $exercise_description = $all_specific_terms.' '.$this->description; |
|
1599 | 1599 | $ic_slide->addValue("content", $exercise_description); |
1600 | 1600 | |
1601 | 1601 | $di = new ChamiloIndexer(); |
1602 | - isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english'; |
|
1602 | + isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english'; |
|
1603 | 1603 | $di->connectDb(NULL, NULL, $lang); |
1604 | - $di->remove_document((int)$se_ref['search_did']); |
|
1604 | + $di->remove_document((int) $se_ref['search_did']); |
|
1605 | 1605 | $di->addChunk($ic_slide); |
1606 | 1606 | |
1607 | 1607 | //index and return search engine document id |
@@ -1626,7 +1626,7 @@ discard block |
||
1626 | 1626 | function search_engine_delete() |
1627 | 1627 | { |
1628 | 1628 | // remove from search engine if enabled |
1629 | - if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian') ) { |
|
1629 | + if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) { |
|
1630 | 1630 | $course_id = api_get_course_id(); |
1631 | 1631 | $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF); |
1632 | 1632 | $sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s AND ref_id_second_level IS NULL LIMIT 1'; |
@@ -1634,19 +1634,19 @@ discard block |
||
1634 | 1634 | $res = Database::query($sql); |
1635 | 1635 | if (Database::num_rows($res) > 0) { |
1636 | 1636 | $row = Database::fetch_array($res); |
1637 | - require_once(api_get_path(LIBRARY_PATH) .'search/ChamiloIndexer.class.php'); |
|
1637 | + require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'); |
|
1638 | 1638 | $di = new ChamiloIndexer(); |
1639 | - $di->remove_document((int)$row['search_did']); |
|
1639 | + $di->remove_document((int) $row['search_did']); |
|
1640 | 1640 | unset($di); |
1641 | 1641 | $tbl_quiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION); |
1642 | - foreach ( $this->questionList as $question_i) { |
|
1642 | + foreach ($this->questionList as $question_i) { |
|
1643 | 1643 | $sql = 'SELECT type FROM %s WHERE id=%s'; |
1644 | 1644 | $sql = sprintf($sql, $tbl_quiz_question, $question_i); |
1645 | 1645 | $qres = Database::query($sql); |
1646 | 1646 | if (Database::num_rows($qres) > 0) { |
1647 | 1647 | $qrow = Database::fetch_array($qres); |
1648 | 1648 | $objQuestion = Question::getInstance($qrow['type']); |
1649 | - $objQuestion = Question::read((int)$question_i); |
|
1649 | + $objQuestion = Question::read((int) $question_i); |
|
1650 | 1650 | $objQuestion->search_engine_edit($this->id, FALSE, TRUE); |
1651 | 1651 | unset($objQuestion); |
1652 | 1652 | } |
@@ -1657,7 +1657,7 @@ discard block |
||
1657 | 1657 | Database::query($sql); |
1658 | 1658 | |
1659 | 1659 | // remove terms from db |
1660 | - require_once api_get_path(LIBRARY_PATH) .'specific_fields_manager.lib.php'; |
|
1660 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
1661 | 1661 | delete_all_values_for_item($course_id, TOOL_QUIZ, $this->id); |
1662 | 1662 | } |
1663 | 1663 | } |
@@ -1752,7 +1752,7 @@ discard block |
||
1752 | 1752 | */ |
1753 | 1753 | public function copy_exercise() |
1754 | 1754 | { |
1755 | - $exercise_obj= new Exercise(); |
|
1755 | + $exercise_obj = new Exercise(); |
|
1756 | 1756 | $exercise_obj = $this; |
1757 | 1757 | |
1758 | 1758 | // force the creation of a new exercise |
@@ -1824,25 +1824,25 @@ discard block |
||
1824 | 1824 | $lp_id = 0; |
1825 | 1825 | } |
1826 | 1826 | if (empty($lp_item_id)) { |
1827 | - $lp_item_id = 0; |
|
1827 | + $lp_item_id = 0; |
|
1828 | 1828 | } |
1829 | 1829 | if (empty($lp_item_view_id)) { |
1830 | 1830 | $lp_item_view_id = 0; |
1831 | 1831 | } |
1832 | - $condition = ' WHERE exe_exo_id = ' . "'" . $this->id . "'" .' AND |
|
1833 | - exe_user_id = ' . "'" . api_get_user_id() . "'" . ' AND |
|
1834 | - c_id = ' . api_get_course_int_id() . ' AND |
|
1835 | - status = ' . "'" . Database::escape_string($status). "'" . ' AND |
|
1836 | - orig_lp_id = ' . "'" . $lp_id . "'" . ' AND |
|
1837 | - orig_lp_item_id = ' . "'" . $lp_item_id . "'" . ' AND |
|
1838 | - orig_lp_item_view_id = ' . "'" . $lp_item_view_id . "'" . ' AND |
|
1839 | - session_id = ' . "'" . api_get_session_id() . "' LIMIT 1"; //Adding limit 1 just in case |
|
1832 | + $condition = ' WHERE exe_exo_id = '."'".$this->id."'".' AND |
|
1833 | + exe_user_id = ' . "'".api_get_user_id()."'".' AND |
|
1834 | + c_id = ' . api_get_course_int_id().' AND |
|
1835 | + status = ' . "'".Database::escape_string($status)."'".' AND |
|
1836 | + orig_lp_id = ' . "'".$lp_id."'".' AND |
|
1837 | + orig_lp_item_id = ' . "'".$lp_item_id."'".' AND |
|
1838 | + orig_lp_item_view_id = ' . "'".$lp_item_view_id."'".' AND |
|
1839 | + session_id = ' . "'".api_get_session_id()."' LIMIT 1"; //Adding limit 1 just in case |
|
1840 | 1840 | |
1841 | 1841 | $sql_track = 'SELECT * FROM '.$track_exercises.$condition; |
1842 | 1842 | |
1843 | 1843 | $result = Database::query($sql_track); |
1844 | 1844 | $new_array = array(); |
1845 | - if (Database::num_rows($result) > 0 ) { |
|
1845 | + if (Database::num_rows($result) > 0) { |
|
1846 | 1846 | $new_array = Database::fetch_array($result, 'ASSOC'); |
1847 | 1847 | $new_array['num_exe'] = Database::num_rows($result); |
1848 | 1848 | } |
@@ -1885,12 +1885,12 @@ discard block |
||
1885 | 1885 | $questionList = array_map('intval', $questionList); |
1886 | 1886 | |
1887 | 1887 | $params = array( |
1888 | - 'exe_exo_id' => $this->id , |
|
1888 | + 'exe_exo_id' => $this->id, |
|
1889 | 1889 | 'exe_user_id' => api_get_user_id(), |
1890 | 1890 | 'c_id' => api_get_course_int_id(), |
1891 | 1891 | 'status' => 'incomplete', |
1892 | 1892 | 'session_id' => api_get_session_id(), |
1893 | - 'data_tracking' => implode(',', $questionList) , |
|
1893 | + 'data_tracking' => implode(',', $questionList), |
|
1894 | 1894 | 'start_date' => api_get_utc_datetime(), |
1895 | 1895 | 'orig_lp_id' => $safe_lp_id, |
1896 | 1896 | 'orig_lp_item_id' => $safe_lp_item_id, |
@@ -1922,7 +1922,7 @@ discard block |
||
1922 | 1922 | $nbrQuestions = $this->get_count_question_list(); |
1923 | 1923 | |
1924 | 1924 | $all_button = $html = $label = ''; |
1925 | - $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']):null; |
|
1925 | + $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']) : null; |
|
1926 | 1926 | |
1927 | 1927 | if ($this->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT && $this->type == ONE_PER_PAGE) { |
1928 | 1928 | $urlTitle = get_lang('ContinueTest'); |
@@ -1933,7 +1933,7 @@ discard block |
||
1933 | 1933 | |
1934 | 1934 | $html .= Display::url( |
1935 | 1935 | $urlTitle, |
1936 | - 'exercise_submit_modal.php?' . http_build_query([ |
|
1936 | + 'exercise_submit_modal.php?'.http_build_query([ |
|
1937 | 1937 | 'learnpath_id' => $safe_lp_id, |
1938 | 1938 | 'learnpath_item_id' => $safe_lp_item_id, |
1939 | 1939 | 'learnpath_item_view_id' => $safe_lp_item_view_id, |
@@ -1950,7 +1950,7 @@ discard block |
||
1950 | 1950 | 'data-size' => 'md' |
1951 | 1951 | ] |
1952 | 1952 | ); |
1953 | - $html .='<br />'; |
|
1953 | + $html .= '<br />'; |
|
1954 | 1954 | } else { |
1955 | 1955 | // User |
1956 | 1956 | if (api_is_allowed_to_session_edit()) { |
@@ -1975,7 +1975,7 @@ discard block |
||
1975 | 1975 | |
1976 | 1976 | //Next question |
1977 | 1977 | if (!empty($questions_in_media)) { |
1978 | - $questions_in_media = "['".implode("','",$questions_in_media)."']"; |
|
1978 | + $questions_in_media = "['".implode("','", $questions_in_media)."']"; |
|
1979 | 1979 | $all_button .= ' <a href="javascript://" class="'.$class.'" onclick="save_question_list('.$questions_in_media.'); ">'.$label.'</a>'; |
1980 | 1980 | } else { |
1981 | 1981 | $all_button .= ' <a href="javascript://" class="'.$class.'" onclick="save_now('.$question_id.', \'\', \''.$currentAnswer.'\'); ">'.$label.'</a>'; |
@@ -1993,7 +1993,7 @@ discard block |
||
1993 | 1993 | } |
1994 | 1994 | $class .= ' question-validate-btn'; // used to select it with jquery |
1995 | 1995 | $all_button = ' <a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>'; |
1996 | - $all_button .= ' ' . Display::span(null, ['id' => 'save_all_reponse']); |
|
1996 | + $all_button .= ' '.Display::span(null, ['id' => 'save_all_reponse']); |
|
1997 | 1997 | $html .= $all_button; |
1998 | 1998 | } |
1999 | 1999 | } |
@@ -2233,8 +2233,8 @@ discard block |
||
2233 | 2233 | $params = array(); |
2234 | 2234 | $params['course_id'] = $course_id; |
2235 | 2235 | $params['session_id'] = api_get_session_id(); |
2236 | - $params['user_id'] = isset($exe_info['exe_user_id'])? $exe_info['exe_user_id'] : api_get_user_id(); |
|
2237 | - $params['exercise_id'] = isset($exe_info['exe_exo_id'])? $exe_info['exe_exo_id'] : $this->id; |
|
2236 | + $params['user_id'] = isset($exe_info['exe_user_id']) ? $exe_info['exe_user_id'] : api_get_user_id(); |
|
2237 | + $params['exercise_id'] = isset($exe_info['exe_exo_id']) ? $exe_info['exe_exo_id'] : $this->id; |
|
2238 | 2238 | $params['question_id'] = $questionId; |
2239 | 2239 | $params['exe_id'] = isset($exe_info['exe_id']) ? $exe_info['exe_id'] : $exeId; |
2240 | 2240 | |
@@ -2276,10 +2276,10 @@ discard block |
||
2276 | 2276 | $answer = $objAnswerTmp->selectAnswer($answerId); |
2277 | 2277 | $answerComment = $objAnswerTmp->selectComment($answerId); |
2278 | 2278 | $answerCorrect = $objAnswerTmp->isCorrect($answerId); |
2279 | - $answerWeighting = (float)$objAnswerTmp->selectWeighting($answerId); |
|
2279 | + $answerWeighting = (float) $objAnswerTmp->selectWeighting($answerId); |
|
2280 | 2280 | $answerAutoId = $objAnswerTmp->selectAutoId($answerId); |
2281 | 2281 | |
2282 | - $answer_correct_array[$answerId] = (bool)$answerCorrect; |
|
2282 | + $answer_correct_array[$answerId] = (bool) $answerCorrect; |
|
2283 | 2283 | |
2284 | 2284 | if ($debug) { |
2285 | 2285 | error_log("answer auto id: $answerAutoId "); |
@@ -2288,7 +2288,7 @@ discard block |
||
2288 | 2288 | |
2289 | 2289 | // Delineation |
2290 | 2290 | $delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1); |
2291 | - $answer_delineation_destination=$objAnswerTmp->selectDestination(1); |
|
2291 | + $answer_delineation_destination = $objAnswerTmp->selectDestination(1); |
|
2292 | 2292 | |
2293 | 2293 | switch ($answerType) { |
2294 | 2294 | // for unique answer |
@@ -2301,7 +2301,7 @@ discard block |
||
2301 | 2301 | exe_id = '".$exeId."' AND |
2302 | 2302 | question_id= '".$questionId."'"; |
2303 | 2303 | $result = Database::query($sql); |
2304 | - $choice = Database::result($result,0,"answer"); |
|
2304 | + $choice = Database::result($result, 0, "answer"); |
|
2305 | 2305 | |
2306 | 2306 | $studentChoice = $choice == $answerAutoId ? 1 : 0; |
2307 | 2307 | if ($studentChoice) { |
@@ -2352,7 +2352,7 @@ discard block |
||
2352 | 2352 | } else { |
2353 | 2353 | // If no result then the user just hit don't know |
2354 | 2354 | $studentChoice = 3; |
2355 | - $questionScore += $doubt_score; |
|
2355 | + $questionScore += $doubt_score; |
|
2356 | 2356 | } |
2357 | 2357 | $totalScore = $questionScore; |
2358 | 2358 | break; |
@@ -2368,17 +2368,17 @@ discard block |
||
2368 | 2368 | } |
2369 | 2369 | |
2370 | 2370 | $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; |
2371 | - $real_answers[$answerId] = (bool)$studentChoice; |
|
2371 | + $real_answers[$answerId] = (bool) $studentChoice; |
|
2372 | 2372 | |
2373 | 2373 | if ($studentChoice) { |
2374 | - $questionScore +=$answerWeighting; |
|
2374 | + $questionScore += $answerWeighting; |
|
2375 | 2375 | } |
2376 | 2376 | } else { |
2377 | 2377 | $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; |
2378 | - $real_answers[$answerId] = (bool)$studentChoice; |
|
2378 | + $real_answers[$answerId] = (bool) $studentChoice; |
|
2379 | 2379 | |
2380 | 2380 | if (isset($studentChoice)) { |
2381 | - $questionScore += $answerWeighting; |
|
2381 | + $questionScore += $answerWeighting; |
|
2382 | 2382 | } |
2383 | 2383 | } |
2384 | 2384 | $totalScore += $answerWeighting; |
@@ -2396,16 +2396,16 @@ discard block |
||
2396 | 2396 | $choice[$ind] = 1; |
2397 | 2397 | } |
2398 | 2398 | $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; |
2399 | - $real_answers[$answerId] = (bool)$studentChoice; |
|
2399 | + $real_answers[$answerId] = (bool) $studentChoice; |
|
2400 | 2400 | if ($studentChoice) { |
2401 | - $questionScore +=$answerWeighting; |
|
2401 | + $questionScore += $answerWeighting; |
|
2402 | 2402 | } |
2403 | 2403 | } else { |
2404 | 2404 | $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; |
2405 | 2405 | if (isset($studentChoice)) { |
2406 | 2406 | $questionScore += $answerWeighting; |
2407 | 2407 | } |
2408 | - $real_answers[$answerId] = (bool)$studentChoice; |
|
2408 | + $real_answers[$answerId] = (bool) $studentChoice; |
|
2409 | 2409 | } |
2410 | 2410 | $totalScore += $answerWeighting; |
2411 | 2411 | if ($debug) error_log("studentChoice: $studentChoice"); |
@@ -2417,7 +2417,7 @@ discard block |
||
2417 | 2417 | $resultans = Database::query($sql); |
2418 | 2418 | while ($row = Database::fetch_array($resultans)) { |
2419 | 2419 | $ind = $row['answer']; |
2420 | - $result = explode(':',$ind); |
|
2420 | + $result = explode(':', $ind); |
|
2421 | 2421 | if (isset($result[0])) { |
2422 | 2422 | $my_answer_id = isset($result[0]) ? $result[0] : ''; |
2423 | 2423 | $option = isset($result[1]) ? $result[1] : ''; |
@@ -2538,10 +2538,10 @@ discard block |
||
2538 | 2538 | } |
2539 | 2539 | // adds the piece of text that is before the blank |
2540 | 2540 | //and ends with '[' into a general storage array |
2541 | - $real_text[] = api_substr($temp, 0, $pos +1); |
|
2542 | - $answer .= api_substr($temp, 0, $pos +1); |
|
2541 | + $real_text[] = api_substr($temp, 0, $pos + 1); |
|
2542 | + $answer .= api_substr($temp, 0, $pos + 1); |
|
2543 | 2543 | //take the string remaining (after the last "[" we found) |
2544 | - $temp = api_substr($temp, $pos +1); |
|
2544 | + $temp = api_substr($temp, $pos + 1); |
|
2545 | 2545 | // quit the loop if there are no more blanks, and update $pos to the position of next ']' |
2546 | 2546 | if (($pos = api_strpos($temp, ']')) === false) { |
2547 | 2547 | // adds the end of the text |
@@ -2577,7 +2577,7 @@ discard block |
||
2577 | 2577 | //put the contents of the [] answer tag into correct_tags[] |
2578 | 2578 | $correct_tags[] = api_substr($temp, 0, $pos); |
2579 | 2579 | $j++; |
2580 | - $temp = api_substr($temp, $pos +1); |
|
2580 | + $temp = api_substr($temp, $pos + 1); |
|
2581 | 2581 | } |
2582 | 2582 | $answer = ''; |
2583 | 2583 | $real_correct_tags = $correct_tags; |
@@ -2600,7 +2600,7 @@ discard block |
||
2600 | 2600 | } elseif (!empty($user_tags[$i])) { |
2601 | 2601 | // else if the word entered by the student IS NOT the same as the one defined by the professor |
2602 | 2602 | // adds the word in red at the end of the string, and strikes it |
2603 | - $answer .= '<font color="red"><s>' . $user_tags[$i] . '</s></font>'; |
|
2603 | + $answer .= '<font color="red"><s>'.$user_tags[$i].'</s></font>'; |
|
2604 | 2604 | } else { |
2605 | 2605 | // adds a tabulation if no word has been typed by the student |
2606 | 2606 | $answer .= ''; // remove that causes issue |
@@ -2619,17 +2619,17 @@ discard block |
||
2619 | 2619 | } elseif (!empty ($user_tags[$i])) { |
2620 | 2620 | // else if the word entered by the student IS NOT the same as the one defined by the professor |
2621 | 2621 | // adds the word in red at the end of the string, and strikes it |
2622 | - $answer .= '<font color="red"><s>' . $user_tags[$i] . '</s></font>'; |
|
2622 | + $answer .= '<font color="red"><s>'.$user_tags[$i].'</s></font>'; |
|
2623 | 2623 | } else { |
2624 | 2624 | // adds a tabulation if no word has been typed by the student |
2625 | - $answer .= ''; // remove that causes issue |
|
2625 | + $answer .= ''; // remove that causes issue |
|
2626 | 2626 | } |
2627 | 2627 | } |
2628 | 2628 | |
2629 | 2629 | // adds the correct word, followed by ] to close the blank |
2630 | - $answer .= ' / <font color="green"><b>' . $real_correct_tags[$i] . '</b></font>]'; |
|
2631 | - if (isset($real_text[$i +1])) { |
|
2632 | - $answer .= $real_text[$i +1]; |
|
2630 | + $answer .= ' / <font color="green"><b>'.$real_correct_tags[$i].'</b></font>]'; |
|
2631 | + if (isset($real_text[$i + 1])) { |
|
2632 | + $answer .= $real_text[$i + 1]; |
|
2633 | 2633 | } |
2634 | 2634 | } |
2635 | 2635 | } else { |
@@ -2763,10 +2763,10 @@ discard block |
||
2763 | 2763 | } |
2764 | 2764 | // adds the piece of text that is before the blank |
2765 | 2765 | //and ends with '[' into a general storage array |
2766 | - $realText[] = api_substr($temp, 0, $pos +1); |
|
2767 | - $answer .= api_substr($temp, 0, $pos +1); |
|
2766 | + $realText[] = api_substr($temp, 0, $pos + 1); |
|
2767 | + $answer .= api_substr($temp, 0, $pos + 1); |
|
2768 | 2768 | //take the string remaining (after the last "[" we found) |
2769 | - $temp = api_substr($temp, $pos +1); |
|
2769 | + $temp = api_substr($temp, $pos + 1); |
|
2770 | 2770 | // quit the loop if there are no more blanks, and update $pos to the position of next ']' |
2771 | 2771 | if (($pos = api_strpos($temp, ']')) === false) { |
2772 | 2772 | // adds the end of the text |
@@ -2800,7 +2800,7 @@ discard block |
||
2800 | 2800 | //put the contents of the [] answer tag into correct_tags[] |
2801 | 2801 | $correctTags[] = api_substr($temp, 0, $pos); |
2802 | 2802 | $j++; |
2803 | - $temp = api_substr($temp, $pos +1); |
|
2803 | + $temp = api_substr($temp, $pos + 1); |
|
2804 | 2804 | } |
2805 | 2805 | $answer = ''; |
2806 | 2806 | $realCorrectTags = $correctTags; |
@@ -2820,22 +2820,22 @@ discard block |
||
2820 | 2820 | } elseif (!empty($userTags[$i])) { |
2821 | 2821 | // else if the word entered by the student IS NOT the same as the one defined by the professor |
2822 | 2822 | // adds the word in red at the end of the string, and strikes it |
2823 | - $answer .= '<font color="red"><s>' . $userTags[$i] . '</s></font>'; |
|
2823 | + $answer .= '<font color="red"><s>'.$userTags[$i].'</s></font>'; |
|
2824 | 2824 | } else { |
2825 | 2825 | // adds a tabulation if no word has been typed by the student |
2826 | 2826 | $answer .= ''; // remove that causes issue |
2827 | 2827 | } |
2828 | 2828 | // adds the correct word, followed by ] to close the blank |
2829 | - $answer .= ' / <font color="green"><b>' . $realCorrectTags[$i] . '</b></font>]'; |
|
2830 | - if (isset($realText[$i +1])) { |
|
2831 | - $answer .= $realText[$i +1]; |
|
2829 | + $answer .= ' / <font color="green"><b>'.$realCorrectTags[$i].'</b></font>]'; |
|
2830 | + if (isset($realText[$i + 1])) { |
|
2831 | + $answer .= $realText[$i + 1]; |
|
2832 | 2832 | } |
2833 | 2833 | } |
2834 | 2834 | break; |
2835 | 2835 | // for free answer |
2836 | 2836 | case FREE_ANSWER: |
2837 | 2837 | if ($from_database) { |
2838 | - $query = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT." |
|
2838 | + $query = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT." |
|
2839 | 2839 | WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'"; |
2840 | 2840 | $resq = Database::query($query); |
2841 | 2841 | $data = Database::fetch_array($resq); |
@@ -2846,9 +2846,9 @@ discard block |
||
2846 | 2846 | $questionScore = $data['marks']; |
2847 | 2847 | |
2848 | 2848 | if ($questionScore == -1) { |
2849 | - $totalScore+= 0; |
|
2849 | + $totalScore += 0; |
|
2850 | 2850 | } else { |
2851 | - $totalScore+= $questionScore; |
|
2851 | + $totalScore += $questionScore; |
|
2852 | 2852 | } |
2853 | 2853 | if ($questionScore == '') { |
2854 | 2854 | $questionScore = 0; |
@@ -2869,14 +2869,14 @@ discard block |
||
2869 | 2869 | $query = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT." |
2870 | 2870 | WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'"; |
2871 | 2871 | $resq = Database::query($query); |
2872 | - $choice = Database::result($resq,0,'answer'); |
|
2872 | + $choice = Database::result($resq, 0, 'answer'); |
|
2873 | 2873 | $choice = str_replace('\r\n', '', $choice); |
2874 | 2874 | $choice = stripslashes($choice); |
2875 | - $questionScore = Database::result($resq,0,"marks"); |
|
2876 | - if ($questionScore==-1) { |
|
2877 | - $totalScore+=0; |
|
2875 | + $questionScore = Database::result($resq, 0, "marks"); |
|
2876 | + if ($questionScore == -1) { |
|
2877 | + $totalScore += 0; |
|
2878 | 2878 | } else { |
2879 | - $totalScore+=$questionScore; |
|
2879 | + $totalScore += $questionScore; |
|
2880 | 2880 | } |
2881 | 2881 | $arrques = $questionName; |
2882 | 2882 | $arrans = $choice; |
@@ -2921,7 +2921,7 @@ discard block |
||
2921 | 2921 | |
2922 | 2922 | while ($a_answers = Database::fetch_array($res_answers)) { |
2923 | 2923 | $i_answer_id = $a_answers['id']; //3 |
2924 | - $s_answer_label = $a_answers['answer']; // your daddy - your mother |
|
2924 | + $s_answer_label = $a_answers['answer']; // your daddy - your mother |
|
2925 | 2925 | $i_answer_correct_answer = $a_answers['correct']; //1 - 2 |
2926 | 2926 | $i_answer_id_auto = $a_answers['id_auto']; // 3 - 4 |
2927 | 2927 | |
@@ -2973,8 +2973,8 @@ discard block |
||
2973 | 2973 | |
2974 | 2974 | if ($show_result) { |
2975 | 2975 | echo '<tr>'; |
2976 | - echo '<td>' . $s_answer_label . '</td>'; |
|
2977 | - echo '<td>' . $user_answer; |
|
2976 | + echo '<td>'.$s_answer_label.'</td>'; |
|
2977 | + echo '<td>'.$user_answer; |
|
2978 | 2978 | |
2979 | 2979 | if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) { |
2980 | 2980 | if (isset($real_list[$i_answer_correct_answer])) { |
@@ -3083,7 +3083,7 @@ discard block |
||
3083 | 3083 | if ($from_database) { |
3084 | 3084 | // getting the user answer |
3085 | 3085 | $TBL_TRACK_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT); |
3086 | - $query = "SELECT hotspot_correct, hotspot_coordinate |
|
3086 | + $query = "SELECT hotspot_correct, hotspot_coordinate |
|
3087 | 3087 | FROM $TBL_TRACK_HOTSPOT |
3088 | 3088 | WHERE |
3089 | 3089 | hotspot_exe_id = '".$exeId."' AND |
@@ -3091,20 +3091,20 @@ discard block |
||
3091 | 3091 | hotspot_answer_id='1'"; |
3092 | 3092 | //by default we take 1 because it's a delineation |
3093 | 3093 | $resq = Database::query($query); |
3094 | - $row = Database::fetch_array($resq,'ASSOC'); |
|
3094 | + $row = Database::fetch_array($resq, 'ASSOC'); |
|
3095 | 3095 | |
3096 | 3096 | $choice = $row['hotspot_correct']; |
3097 | 3097 | $user_answer = $row['hotspot_coordinate']; |
3098 | 3098 | |
3099 | 3099 | // THIS is very important otherwise the poly_compile will throw an error!! |
3100 | 3100 | // round-up the coordinates |
3101 | - $coords = explode('/',$user_answer); |
|
3101 | + $coords = explode('/', $user_answer); |
|
3102 | 3102 | $user_array = ''; |
3103 | 3103 | foreach ($coords as $coord) { |
3104 | - list($x,$y) = explode(';',$coord); |
|
3104 | + list($x, $y) = explode(';', $coord); |
|
3105 | 3105 | $user_array .= round($x).';'.round($y).'/'; |
3106 | 3106 | } |
3107 | - $user_array = substr($user_array,0,-1); |
|
3107 | + $user_array = substr($user_array, 0, -1); |
|
3108 | 3108 | } else { |
3109 | 3109 | if (!empty($studentChoice)) { |
3110 | 3110 | $newquestionList[] = $questionId; |
@@ -3114,13 +3114,13 @@ discard block |
||
3114 | 3114 | $studentChoice = $choice[$answerId]; |
3115 | 3115 | $questionScore += $answerWeighting; |
3116 | 3116 | |
3117 | - if ($hotspot_delineation_result[1]==1) { |
|
3117 | + if ($hotspot_delineation_result[1] == 1) { |
|
3118 | 3118 | $totalScore += $answerWeighting; //adding the total |
3119 | 3119 | } |
3120 | 3120 | } |
3121 | 3121 | } |
3122 | - $_SESSION['hotspot_coord'][1] = $delineation_cord; |
|
3123 | - $_SESSION['hotspot_dest'][1] = $answer_delineation_destination; |
|
3122 | + $_SESSION['hotspot_coord'][1] = $delineation_cord; |
|
3123 | + $_SESSION['hotspot_dest'][1] = $answer_delineation_destination; |
|
3124 | 3124 | break; |
3125 | 3125 | } // end switch Answertype |
3126 | 3126 | |
@@ -3178,7 +3178,7 @@ discard block |
||
3178 | 3178 | $results_disabled |
3179 | 3179 | ); |
3180 | 3180 | //} |
3181 | - } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) { |
|
3181 | + } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { |
|
3182 | 3182 | // if ($origin!='learnpath') { |
3183 | 3183 | ExerciseShowFunctions::display_multiple_answer_combination_true_false( |
3184 | 3184 | $feedback_type, |
@@ -3195,11 +3195,11 @@ discard block |
||
3195 | 3195 | //} |
3196 | 3196 | } elseif ($answerType == FILL_IN_BLANKS) { |
3197 | 3197 | //if ($origin!='learnpath') { |
3198 | - ExerciseShowFunctions::display_fill_in_blanks_answer($feedback_type, $answer,0,0, $results_disabled); |
|
3198 | + ExerciseShowFunctions::display_fill_in_blanks_answer($feedback_type, $answer, 0, 0, $results_disabled); |
|
3199 | 3199 | // } |
3200 | 3200 | } elseif ($answerType == CALCULATED_ANSWER) { |
3201 | 3201 | //if ($origin!='learnpath') { |
3202 | - ExerciseShowFunctions::display_calculated_answer($feedback_type, $answer,0,0); |
|
3202 | + ExerciseShowFunctions::display_calculated_answer($feedback_type, $answer, 0, 0); |
|
3203 | 3203 | // } |
3204 | 3204 | } elseif ($answerType == FREE_ANSWER) { |
3205 | 3205 | //if($origin != 'learnpath') { |
@@ -3246,13 +3246,13 @@ discard block |
||
3246 | 3246 | $user_answer = $_SESSION['exerciseResultCoordinates'][$questionId]; |
3247 | 3247 | |
3248 | 3248 | //round-up the coordinates |
3249 | - $coords = explode('/',$user_answer); |
|
3249 | + $coords = explode('/', $user_answer); |
|
3250 | 3250 | $user_array = ''; |
3251 | 3251 | foreach ($coords as $coord) { |
3252 | - list($x,$y) = explode(';',$coord); |
|
3252 | + list($x, $y) = explode(';', $coord); |
|
3253 | 3253 | $user_array .= round($x).';'.round($y).'/'; |
3254 | 3254 | } |
3255 | - $user_array = substr($user_array,0,-1); |
|
3255 | + $user_array = substr($user_array, 0, -1); |
|
3256 | 3256 | |
3257 | 3257 | if ($next) { |
3258 | 3258 | |
@@ -3279,7 +3279,7 @@ discard block |
||
3279 | 3279 | //$overlap = round(polygons_overlap($poly_answer,$poly_user)); |
3280 | 3280 | // //this is an area in pixels |
3281 | 3281 | if ($debug > 0) { |
3282 | - error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0); |
|
3282 | + error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0); |
|
3283 | 3283 | } |
3284 | 3284 | |
3285 | 3285 | if ($overlap < 1) { |
@@ -3292,43 +3292,43 @@ discard block |
||
3292 | 3292 | // that is overlapped by the user's polygon |
3293 | 3293 | $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100); |
3294 | 3294 | if ($debug > 1) { |
3295 | - error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0); |
|
3295 | + error_log(__LINE__.' - Final overlap is '.$final_overlap, 0); |
|
3296 | 3296 | } |
3297 | 3297 | // the final missing area is the percentage of the initial polygon |
3298 | 3298 | // that is not overlapped by the user's polygon |
3299 | 3299 | $final_missing = 100 - $final_overlap; |
3300 | 3300 | if ($debug > 1) { |
3301 | - error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0); |
|
3301 | + error_log(__LINE__.' - Final missing is '.$final_missing, 0); |
|
3302 | 3302 | } |
3303 | 3303 | // the final excess area is the percentage of the initial polygon's size |
3304 | 3304 | // that is covered by the user's polygon outside of the initial polygon |
3305 | 3305 | $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100); |
3306 | 3306 | if ($debug > 1) { |
3307 | - error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0); |
|
3307 | + error_log(__LINE__.' - Final excess is '.$final_excess, 0); |
|
3308 | 3308 | } |
3309 | 3309 | } |
3310 | 3310 | |
3311 | 3311 | //checking the destination parameters parsing the "@@" |
3312 | - $destination_items= explode('@@', $answerDestination); |
|
3312 | + $destination_items = explode('@@', $answerDestination); |
|
3313 | 3313 | $threadhold_total = $destination_items[0]; |
3314 | - $threadhold_items=explode(';',$threadhold_total); |
|
3314 | + $threadhold_items = explode(';', $threadhold_total); |
|
3315 | 3315 | $threadhold1 = $threadhold_items[0]; // overlap |
3316 | 3316 | $threadhold2 = $threadhold_items[1]; // excess |
3317 | - $threadhold3 = $threadhold_items[2]; //missing |
|
3317 | + $threadhold3 = $threadhold_items[2]; //missing |
|
3318 | 3318 | |
3319 | 3319 | // if is delineation |
3320 | - if ($answerId===1) { |
|
3320 | + if ($answerId === 1) { |
|
3321 | 3321 | //setting colors |
3322 | - if ($final_overlap>=$threadhold1) { |
|
3323 | - $overlap_color=true; //echo 'a'; |
|
3322 | + if ($final_overlap >= $threadhold1) { |
|
3323 | + $overlap_color = true; //echo 'a'; |
|
3324 | 3324 | } |
3325 | 3325 | //echo $excess.'-'.$threadhold2; |
3326 | - if ($final_excess<=$threadhold2) { |
|
3327 | - $excess_color=true; //echo 'b'; |
|
3326 | + if ($final_excess <= $threadhold2) { |
|
3327 | + $excess_color = true; //echo 'b'; |
|
3328 | 3328 | } |
3329 | 3329 | //echo '--------'.$missing.'-'.$threadhold3; |
3330 | - if ($final_missing<=$threadhold3) { |
|
3331 | - $missing_color=true; //echo 'c'; |
|
3330 | + if ($final_missing <= $threadhold3) { |
|
3331 | + $missing_color = true; //echo 'c'; |
|
3332 | 3332 | } |
3333 | 3333 | |
3334 | 3334 | // if pass |
@@ -3337,67 +3337,67 @@ discard block |
||
3337 | 3337 | $final_missing <= $threadhold3 && |
3338 | 3338 | $final_excess <= $threadhold2 |
3339 | 3339 | ) { |
3340 | - $next=1; //go to the oars |
|
3341 | - $result_comment=get_lang('Acceptable'); |
|
3342 | - $final_answer = 1; // do not update with update_exercise_attempt |
|
3340 | + $next = 1; //go to the oars |
|
3341 | + $result_comment = get_lang('Acceptable'); |
|
3342 | + $final_answer = 1; // do not update with update_exercise_attempt |
|
3343 | 3343 | } else { |
3344 | - $next=0; |
|
3345 | - $result_comment=get_lang('Unacceptable'); |
|
3346 | - $comment=$answerDestination=$objAnswerTmp->selectComment(1); |
|
3347 | - $answerDestination=$objAnswerTmp->selectDestination(1); |
|
3344 | + $next = 0; |
|
3345 | + $result_comment = get_lang('Unacceptable'); |
|
3346 | + $comment = $answerDestination = $objAnswerTmp->selectComment(1); |
|
3347 | + $answerDestination = $objAnswerTmp->selectDestination(1); |
|
3348 | 3348 | //checking the destination parameters parsing the "@@" |
3349 | - $destination_items= explode('@@', $answerDestination); |
|
3349 | + $destination_items = explode('@@', $answerDestination); |
|
3350 | 3350 | } |
3351 | - } elseif($answerId>1) { |
|
3351 | + } elseif ($answerId > 1) { |
|
3352 | 3352 | if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') { |
3353 | - if ($debug>0) { |
|
3354 | - error_log(__LINE__.' - answerId is of type noerror',0); |
|
3353 | + if ($debug > 0) { |
|
3354 | + error_log(__LINE__.' - answerId is of type noerror', 0); |
|
3355 | 3355 | } |
3356 | 3356 | //type no error shouldn't be treated |
3357 | 3357 | $next = 1; |
3358 | 3358 | continue; |
3359 | 3359 | } |
3360 | - if ($debug>0) { |
|
3361 | - error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0); |
|
3360 | + if ($debug > 0) { |
|
3361 | + error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0); |
|
3362 | 3362 | } |
3363 | 3363 | //check the intersection between the oar and the user |
3364 | 3364 | //echo 'user'; print_r($x_user_list); print_r($y_user_list); |
3365 | 3365 | //echo 'official';print_r($x_list);print_r($y_list); |
3366 | 3366 | //$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list); |
3367 | - $inter= $result['success']; |
|
3367 | + $inter = $result['success']; |
|
3368 | 3368 | |
3369 | 3369 | //$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId); |
3370 | - $delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId); |
|
3370 | + $delineation_cord = $objAnswerTmp->selectHotspotCoordinates($answerId); |
|
3371 | 3371 | |
3372 | - $poly_answer = convert_coordinates($delineation_cord,'|'); |
|
3373 | - $max_coord = poly_get_max($poly_user,$poly_answer); |
|
3374 | - $poly_answer_compiled = poly_compile($poly_answer,$max_coord); |
|
3375 | - $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord); |
|
3372 | + $poly_answer = convert_coordinates($delineation_cord, '|'); |
|
3373 | + $max_coord = poly_get_max($poly_user, $poly_answer); |
|
3374 | + $poly_answer_compiled = poly_compile($poly_answer, $max_coord); |
|
3375 | + $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord); |
|
3376 | 3376 | |
3377 | 3377 | if ($overlap == false) { |
3378 | 3378 | //all good, no overlap |
3379 | 3379 | $next = 1; |
3380 | 3380 | continue; |
3381 | 3381 | } else { |
3382 | - if ($debug>0) { |
|
3383 | - error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0); |
|
3382 | + if ($debug > 0) { |
|
3383 | + error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0); |
|
3384 | 3384 | } |
3385 | 3385 | $organs_at_risk_hit++; |
3386 | 3386 | //show the feedback |
3387 | - $next=0; |
|
3388 | - $comment=$answerDestination=$objAnswerTmp->selectComment($answerId); |
|
3389 | - $answerDestination=$objAnswerTmp->selectDestination($answerId); |
|
3390 | - |
|
3391 | - $destination_items= explode('@@', $answerDestination); |
|
3392 | - $try_hotspot=$destination_items[1]; |
|
3393 | - $lp_hotspot=$destination_items[2]; |
|
3394 | - $select_question_hotspot=$destination_items[3]; |
|
3395 | - $url_hotspot=$destination_items[4]; |
|
3387 | + $next = 0; |
|
3388 | + $comment = $answerDestination = $objAnswerTmp->selectComment($answerId); |
|
3389 | + $answerDestination = $objAnswerTmp->selectDestination($answerId); |
|
3390 | + |
|
3391 | + $destination_items = explode('@@', $answerDestination); |
|
3392 | + $try_hotspot = $destination_items[1]; |
|
3393 | + $lp_hotspot = $destination_items[2]; |
|
3394 | + $select_question_hotspot = $destination_items[3]; |
|
3395 | + $url_hotspot = $destination_items[4]; |
|
3396 | 3396 | } |
3397 | 3397 | } |
3398 | 3398 | } else { // the first delineation feedback |
3399 | - if ($debug>0) { |
|
3400 | - error_log(__LINE__.' first',0); |
|
3399 | + if ($debug > 0) { |
|
3400 | + error_log(__LINE__.' first', 0); |
|
3401 | 3401 | } |
3402 | 3402 | } |
3403 | 3403 | } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) { |
@@ -3405,7 +3405,7 @@ discard block |
||
3405 | 3405 | echo Display::tag('td', $answerMatching[$answerId]); |
3406 | 3406 | echo Display::tag( |
3407 | 3407 | 'td', |
3408 | - "$user_answer / " . Display::tag( |
|
3408 | + "$user_answer / ".Display::tag( |
|
3409 | 3409 | 'strong', |
3410 | 3410 | $answerMatching[$answerCorrect], |
3411 | 3411 | ['style' => 'color: #008000; font-weight: bold;'] |
@@ -3545,7 +3545,7 @@ discard block |
||
3545 | 3545 | $exeId, |
3546 | 3546 | $questionId, |
3547 | 3547 | $nano |
3548 | - ) . '</td> |
|
3548 | + ).'</td> |
|
3549 | 3549 | </tr> |
3550 | 3550 | </table>'; |
3551 | 3551 | break; |
@@ -3604,7 +3604,7 @@ discard block |
||
3604 | 3604 | |
3605 | 3605 | //$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels |
3606 | 3606 | if ($debug > 0) { |
3607 | - error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0); |
|
3607 | + error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0); |
|
3608 | 3608 | } |
3609 | 3609 | if ($overlap < 1) { |
3610 | 3610 | //shortcut to avoid complicated calculations |
@@ -3615,17 +3615,17 @@ discard block |
||
3615 | 3615 | // the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon |
3616 | 3616 | $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100); |
3617 | 3617 | if ($debug > 1) { |
3618 | - error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0); |
|
3618 | + error_log(__LINE__.' - Final overlap is '.$final_overlap, 0); |
|
3619 | 3619 | } |
3620 | 3620 | // the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon |
3621 | 3621 | $final_missing = 100 - $final_overlap; |
3622 | 3622 | if ($debug > 1) { |
3623 | - error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0); |
|
3623 | + error_log(__LINE__.' - Final missing is '.$final_missing, 0); |
|
3624 | 3624 | } |
3625 | 3625 | // the final excess area is the percentage of the initial polygon's size that is covered by the user's polygon outside of the initial polygon |
3626 | 3626 | $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100); |
3627 | 3627 | if ($debug > 1) { |
3628 | - error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0); |
|
3628 | + error_log(__LINE__.' - Final excess is '.$final_excess, 0); |
|
3629 | 3629 | } |
3630 | 3630 | } |
3631 | 3631 | |
@@ -3635,7 +3635,7 @@ discard block |
||
3635 | 3635 | $threadhold_items = explode(';', $threadhold_total); |
3636 | 3636 | $threadhold1 = $threadhold_items[0]; // overlap |
3637 | 3637 | $threadhold2 = $threadhold_items[1]; // excess |
3638 | - $threadhold3 = $threadhold_items[2]; //missing |
|
3638 | + $threadhold3 = $threadhold_items[2]; //missing |
|
3639 | 3639 | // if is delineation |
3640 | 3640 | if ($answerId === 1) { |
3641 | 3641 | //setting colors |
@@ -3667,14 +3667,14 @@ discard block |
||
3667 | 3667 | } elseif ($answerId > 1) { |
3668 | 3668 | if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') { |
3669 | 3669 | if ($debug > 0) { |
3670 | - error_log(__LINE__ . ' - answerId is of type noerror', 0); |
|
3670 | + error_log(__LINE__.' - answerId is of type noerror', 0); |
|
3671 | 3671 | } |
3672 | 3672 | //type no error shouldn't be treated |
3673 | 3673 | $next = 1; |
3674 | 3674 | continue; |
3675 | 3675 | } |
3676 | 3676 | if ($debug > 0) { |
3677 | - error_log(__LINE__ . ' - answerId is >1 so we\'re probably in OAR', 0); |
|
3677 | + error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0); |
|
3678 | 3678 | } |
3679 | 3679 | //check the intersection between the oar and the user |
3680 | 3680 | //echo 'user'; print_r($x_user_list); print_r($y_user_list); |
@@ -3688,7 +3688,7 @@ discard block |
||
3688 | 3688 | $poly_answer = convert_coordinates($delineation_cord, '|'); |
3689 | 3689 | $max_coord = poly_get_max($poly_user, $poly_answer); |
3690 | 3690 | $poly_answer_compiled = poly_compile($poly_answer, $max_coord); |
3691 | - $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord); |
|
3691 | + $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord); |
|
3692 | 3692 | |
3693 | 3693 | if ($overlap == false) { |
3694 | 3694 | //all good, no overlap |
@@ -3696,7 +3696,7 @@ discard block |
||
3696 | 3696 | continue; |
3697 | 3697 | } else { |
3698 | 3698 | if ($debug > 0) { |
3699 | - error_log(__LINE__ . ' - Overlap is ' . $overlap . ': OAR hit', 0); |
|
3699 | + error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0); |
|
3700 | 3700 | } |
3701 | 3701 | $organs_at_risk_hit++; |
3702 | 3702 | //show the feedback |
@@ -3708,12 +3708,12 @@ discard block |
||
3708 | 3708 | $try_hotspot = $destination_items[1]; |
3709 | 3709 | $lp_hotspot = $destination_items[2]; |
3710 | 3710 | $select_question_hotspot = $destination_items[3]; |
3711 | - $url_hotspot=$destination_items[4]; |
|
3711 | + $url_hotspot = $destination_items[4]; |
|
3712 | 3712 | } |
3713 | 3713 | } |
3714 | 3714 | } else { // the first delineation feedback |
3715 | 3715 | if ($debug > 0) { |
3716 | - error_log(__LINE__ . ' first', 0); |
|
3716 | + error_log(__LINE__.' first', 0); |
|
3717 | 3717 | } |
3718 | 3718 | } |
3719 | 3719 | break; |
@@ -3735,7 +3735,7 @@ discard block |
||
3735 | 3735 | echo Display::tag('td', $answerMatching[$answerId]); |
3736 | 3736 | echo Display::tag( |
3737 | 3737 | 'td', |
3738 | - "$user_answer / " . Display::tag( |
|
3738 | + "$user_answer / ".Display::tag( |
|
3739 | 3739 | 'strong', |
3740 | 3740 | $answerMatching[$answerCorrect], |
3741 | 3741 | ['style' => 'color: #008000; font-weight: bold;'] |
@@ -3821,7 +3821,7 @@ discard block |
||
3821 | 3821 | // we use the results from the session (from_db=0) |
3822 | 3822 | // TODO Change this, because it is wrong to show the user |
3823 | 3823 | // some results that haven't been stored in the database yet |
3824 | - if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION ) { |
|
3824 | + if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION) { |
|
3825 | 3825 | |
3826 | 3826 | if ($debug) error_log('$from AND this is a hotspot kind of question '); |
3827 | 3827 | |
@@ -3830,19 +3830,19 @@ discard block |
||
3830 | 3830 | if ($answerType == HOT_SPOT_DELINEATION) { |
3831 | 3831 | if (0) { |
3832 | 3832 | if ($overlap_color) { |
3833 | - $overlap_color='green'; |
|
3833 | + $overlap_color = 'green'; |
|
3834 | 3834 | } else { |
3835 | - $overlap_color='red'; |
|
3835 | + $overlap_color = 'red'; |
|
3836 | 3836 | } |
3837 | 3837 | if ($missing_color) { |
3838 | - $missing_color='green'; |
|
3838 | + $missing_color = 'green'; |
|
3839 | 3839 | } else { |
3840 | - $missing_color='red'; |
|
3840 | + $missing_color = 'red'; |
|
3841 | 3841 | } |
3842 | 3842 | if ($excess_color) { |
3843 | - $excess_color='green'; |
|
3843 | + $excess_color = 'green'; |
|
3844 | 3844 | } else { |
3845 | - $excess_color='red'; |
|
3845 | + $excess_color = 'red'; |
|
3846 | 3846 | } |
3847 | 3847 | if (!is_numeric($final_overlap)) { |
3848 | 3848 | $final_overlap = 0; |
@@ -3854,33 +3854,33 @@ discard block |
||
3854 | 3854 | $final_excess = 0; |
3855 | 3855 | } |
3856 | 3856 | |
3857 | - if ($final_overlap>100) { |
|
3857 | + if ($final_overlap > 100) { |
|
3858 | 3858 | $final_overlap = 100; |
3859 | 3859 | } |
3860 | 3860 | |
3861 | - $table_resume='<table class="data_table"> |
|
3861 | + $table_resume = '<table class="data_table"> |
|
3862 | 3862 | <tr class="row_odd" > |
3863 | 3863 | <td></td> |
3864 | - <td ><b>' . get_lang('Requirements') . '</b></td> |
|
3865 | - <td><b>' . get_lang('YourAnswer') . '</b></td> |
|
3864 | + <td ><b>' . get_lang('Requirements').'</b></td> |
|
3865 | + <td><b>' . get_lang('YourAnswer').'</b></td> |
|
3866 | 3866 | </tr> |
3867 | 3867 | <tr class="row_even"> |
3868 | - <td><b>' . get_lang('Overlap') . '</b></td> |
|
3869 | - <td>' . get_lang('Min') . ' ' . $threadhold1 . '</td> |
|
3870 | - <td><div style="color:' . $overlap_color . '">' |
|
3871 | - . (($final_overlap < 0) ? 0 : intval($final_overlap)) . '</div></td> |
|
3868 | + <td><b>' . get_lang('Overlap').'</b></td> |
|
3869 | + <td>' . get_lang('Min').' '.$threadhold1.'</td> |
|
3870 | + <td><div style="color:' . $overlap_color.'">' |
|
3871 | + . (($final_overlap < 0) ? 0 : intval($final_overlap)).'</div></td> |
|
3872 | 3872 | </tr> |
3873 | 3873 | <tr> |
3874 | - <td><b>' . get_lang('Excess') . '</b></td> |
|
3875 | - <td>' . get_lang('Max') . ' ' . $threadhold2 . '</td> |
|
3876 | - <td><div style="color:' . $excess_color . '">' |
|
3877 | - . (($final_excess < 0) ? 0 : intval($final_excess)) . '</div></td> |
|
3874 | + <td><b>' . get_lang('Excess').'</b></td> |
|
3875 | + <td>' . get_lang('Max').' '.$threadhold2.'</td> |
|
3876 | + <td><div style="color:' . $excess_color.'">' |
|
3877 | + . (($final_excess < 0) ? 0 : intval($final_excess)).'</div></td> |
|
3878 | 3878 | </tr> |
3879 | 3879 | <tr class="row_even"> |
3880 | - <td><b>' . get_lang('Missing') . '</b></td> |
|
3881 | - <td>' . get_lang('Max') . ' ' . $threadhold3 . '</td> |
|
3882 | - <td><div style="color:' . $missing_color . '">' |
|
3883 | - . (($final_missing < 0) ? 0 : intval($final_missing)) . '</div></td> |
|
3880 | + <td><b>' . get_lang('Missing').'</b></td> |
|
3881 | + <td>' . get_lang('Max').' '.$threadhold3.'</td> |
|
3882 | + <td><div style="color:' . $missing_color.'">' |
|
3883 | + . (($final_missing < 0) ? 0 : intval($final_missing)).'</div></td> |
|
3884 | 3884 | </tr> |
3885 | 3885 | </table>'; |
3886 | 3886 | if ($next == 0) { |
@@ -3895,20 +3895,20 @@ discard block |
||
3895 | 3895 | $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers); |
3896 | 3896 | } |
3897 | 3897 | |
3898 | - echo '<h1><div style="color:#333;">' . get_lang('Feedback') . '</div></h1> |
|
3898 | + echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1> |
|
3899 | 3899 | <p style="text-align:center">'; |
3900 | 3900 | |
3901 | - $message = '<p>' . get_lang('YourDelineation') . '</p>'; |
|
3901 | + $message = '<p>'.get_lang('YourDelineation').'</p>'; |
|
3902 | 3902 | $message .= $table_resume; |
3903 | - $message .= '<br />' . get_lang('ResultIs') . ' ' . $result_comment . '<br />'; |
|
3903 | + $message .= '<br />'.get_lang('ResultIs').' '.$result_comment.'<br />'; |
|
3904 | 3904 | if ($organs_at_risk_hit > 0) { |
3905 | - $message .= '<p><b>' . get_lang('OARHit') . '</b></p>'; |
|
3905 | + $message .= '<p><b>'.get_lang('OARHit').'</b></p>'; |
|
3906 | 3906 | } |
3907 | - $message .='<p>' . $comment . '</p>'; |
|
3907 | + $message .= '<p>'.$comment.'</p>'; |
|
3908 | 3908 | echo $message; |
3909 | 3909 | } else { |
3910 | 3910 | echo $hotspot_delineation_result[0]; //prints message |
3911 | - $from_database = 1; // the hotspot_solution.swf needs this variable |
|
3911 | + $from_database = 1; // the hotspot_solution.swf needs this variable |
|
3912 | 3912 | } |
3913 | 3913 | |
3914 | 3914 | //save the score attempts |
@@ -3930,20 +3930,20 @@ discard block |
||
3930 | 3930 | $exerciseResultCoordinates[$quesId] |
3931 | 3931 | ); |
3932 | 3932 | } else { |
3933 | - if ($final_answer==0) { |
|
3933 | + if ($final_answer == 0) { |
|
3934 | 3934 | $questionScore = 0; |
3935 | - $answer=0; |
|
3935 | + $answer = 0; |
|
3936 | 3936 | Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0); |
3937 | 3937 | if (is_array($exerciseResultCoordinates[$quesId])) { |
3938 | - foreach($exerciseResultCoordinates[$quesId] as $idx => $val) { |
|
3939 | - Event::saveExerciseAttemptHotspot($exeId,$quesId,$idx,0,$val); |
|
3938 | + foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) { |
|
3939 | + Event::saveExerciseAttemptHotspot($exeId, $quesId, $idx, 0, $val); |
|
3940 | 3940 | } |
3941 | 3941 | } |
3942 | 3942 | } else { |
3943 | 3943 | Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0); |
3944 | 3944 | if (is_array($exerciseResultCoordinates[$quesId])) { |
3945 | - foreach($exerciseResultCoordinates[$quesId] as $idx => $val) { |
|
3946 | - Event::saveExerciseAttemptHotspot($exeId,$quesId,$idx,$choice[$idx],$val); |
|
3945 | + foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) { |
|
3946 | + Event::saveExerciseAttemptHotspot($exeId, $quesId, $idx, $choice[$idx], $val); |
|
3947 | 3947 | } |
3948 | 3948 | } |
3949 | 3949 | } |
@@ -3962,7 +3962,7 @@ discard block |
||
3962 | 3962 | echo " |
3963 | 3963 | <tr> |
3964 | 3964 | <td colspan=\"2\"> |
3965 | - <p><em>" . get_lang('HotSpot') . "</em></p> |
|
3965 | + <p><em>" . get_lang('HotSpot')."</em></p> |
|
3966 | 3966 | |
3967 | 3967 | <div id=\"hotspot-solution-$questionId\"></div> |
3968 | 3968 | |
@@ -4000,7 +4000,7 @@ discard block |
||
4000 | 4000 | |
4001 | 4001 | if ($saved_results) { |
4002 | 4002 | if ($debug) error_log("Save question results $saved_results"); |
4003 | - if ($debug) error_log(print_r($choice ,1 )); |
|
4003 | + if ($debug) error_log(print_r($choice, 1)); |
|
4004 | 4004 | |
4005 | 4005 | if (empty($choice)) { |
4006 | 4006 | $choice = 0; |
@@ -4012,14 +4012,14 @@ discard block |
||
4012 | 4012 | $ans = $reply[$i]; |
4013 | 4013 | Event::saveQuestionAttempt( |
4014 | 4014 | $questionScore, |
4015 | - $ans . ':' . $choice[$ans], |
|
4015 | + $ans.':'.$choice[$ans], |
|
4016 | 4016 | $quesId, |
4017 | 4017 | $exeId, |
4018 | 4018 | $i, |
4019 | 4019 | $this->id |
4020 | 4020 | ); |
4021 | 4021 | if ($debug) { |
4022 | - error_log('result =>' . $questionScore . ' ' . $ans . ':' . $choice[$ans]); |
|
4022 | + error_log('result =>'.$questionScore.' '.$ans.':'.$choice[$ans]); |
|
4023 | 4023 | } |
4024 | 4024 | } |
4025 | 4025 | } else { |
@@ -4030,7 +4030,7 @@ discard block |
||
4030 | 4030 | $reply = array_keys($choice); |
4031 | 4031 | |
4032 | 4032 | if ($debug) { |
4033 | - error_log("reply " . print_r($reply, 1) . ""); |
|
4033 | + error_log("reply ".print_r($reply, 1).""); |
|
4034 | 4034 | } |
4035 | 4035 | for ($i = 0; $i < sizeof($reply); $i++) { |
4036 | 4036 | $ans = $reply[$i]; |
@@ -4089,7 +4089,7 @@ discard block |
||
4089 | 4089 | |
4090 | 4090 | Event::saveQuestionAttempt($questionScore, implode('|', $answer), $quesId, $exeId, 0, $this->id); |
4091 | 4091 | } else { |
4092 | - Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0,$this->id); |
|
4092 | + Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id); |
|
4093 | 4093 | } |
4094 | 4094 | } |
4095 | 4095 | |
@@ -4099,8 +4099,8 @@ discard block |
||
4099 | 4099 | |
4100 | 4100 | if ($saved_results) { |
4101 | 4101 | $stat_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
4102 | - $sql = 'UPDATE ' . $stat_table . ' SET |
|
4103 | - exe_result = exe_result + ' . floatval($questionScore) . ' |
|
4102 | + $sql = 'UPDATE '.$stat_table.' SET |
|
4103 | + exe_result = exe_result + ' . floatval($questionScore).' |
|
4104 | 4104 | WHERE exe_id = ' . $exeId; |
4105 | 4105 | if ($debug) error_log($sql); |
4106 | 4106 | Database::query($sql); |
@@ -4124,7 +4124,7 @@ discard block |
||
4124 | 4124 | */ |
4125 | 4125 | public function send_mail_notification_for_exam($question_list_answers, $origin, $exe_id) |
4126 | 4126 | { |
4127 | - if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) { |
|
4127 | + if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) { |
|
4128 | 4128 | return null; |
4129 | 4129 | } |
4130 | 4130 | // Email configuration settings |
@@ -4175,7 +4175,7 @@ discard block |
||
4175 | 4175 | $msg = str_replace("#course#", $courseInfo['name'], $msg1); |
4176 | 4176 | |
4177 | 4177 | if ($origin != 'learnpath') { |
4178 | - $msg.= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
|
4178 | + $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
|
4179 | 4179 | } |
4180 | 4180 | $msg1 = str_replace("#url#", $url_email, $msg); |
4181 | 4181 | $mail_content = $msg1; |
@@ -4204,7 +4204,7 @@ discard block |
||
4204 | 4204 | */ |
4205 | 4205 | function send_notification_for_open_questions($question_list_answers, $origin, $exe_id) |
4206 | 4206 | { |
4207 | - if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) { |
|
4207 | + if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) { |
|
4208 | 4208 | return null; |
4209 | 4209 | } |
4210 | 4210 | // Email configuration settings |
@@ -4267,11 +4267,11 @@ discard block |
||
4267 | 4267 | $msg .= '</table><br />'; |
4268 | 4268 | |
4269 | 4269 | |
4270 | - $msg1 = str_replace("#exercise#", $this->exercise, $msg); |
|
4271 | - $msg = str_replace("#firstName#", $user_info['firstname'],$msg1); |
|
4272 | - $msg1 = str_replace("#lastName#", $user_info['lastname'],$msg); |
|
4273 | - $msg = str_replace("#mail#", $user_info['email'],$msg1); |
|
4274 | - $msg = str_replace("#course#", $course_info['name'],$msg1); |
|
4270 | + $msg1 = str_replace("#exercise#", $this->exercise, $msg); |
|
4271 | + $msg = str_replace("#firstName#", $user_info['firstname'], $msg1); |
|
4272 | + $msg1 = str_replace("#lastName#", $user_info['lastname'], $msg); |
|
4273 | + $msg = str_replace("#mail#", $user_info['email'], $msg1); |
|
4274 | + $msg = str_replace("#course#", $course_info['name'], $msg1); |
|
4275 | 4275 | |
4276 | 4276 | if ($origin != 'learnpath') { |
4277 | 4277 | $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
@@ -4300,7 +4300,7 @@ discard block |
||
4300 | 4300 | |
4301 | 4301 | function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id) |
4302 | 4302 | { |
4303 | - if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) { |
|
4303 | + if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) { |
|
4304 | 4304 | return null; |
4305 | 4305 | } |
4306 | 4306 | // Email configuration settings |
@@ -4324,7 +4324,7 @@ discard block |
||
4324 | 4324 | $answer_type = $item['answer_type']; |
4325 | 4325 | |
4326 | 4326 | if (!empty($question) && !empty($answer) && $answer_type == ORAL_EXPRESSION) { |
4327 | - $oral_question_list.='<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">' |
|
4327 | + $oral_question_list .= '<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">' |
|
4328 | 4328 | .'<tr>' |
4329 | 4329 | .'<td width="220" valign="top" bgcolor="#E5EDF8"> '.get_lang('Question').'</td>' |
4330 | 4330 | .'<td width="473" valign="top" bgcolor="#F3F3F3">'.$question.'</td>' |
@@ -4357,7 +4357,7 @@ discard block |
||
4357 | 4357 | .'<td> #mail#</td>' |
4358 | 4358 | .'</tr>' |
4359 | 4359 | .'</table>'; |
4360 | - $msg .= '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'),$oral_question_list).'<br />'; |
|
4360 | + $msg .= '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'), $oral_question_list).'<br />'; |
|
4361 | 4361 | $msg1 = str_replace("#exercise#", $this->exercise, $msg); |
4362 | 4362 | $msg = str_replace("#firstName#", $user_info['firstname'], $msg1); |
4363 | 4363 | $msg1 = str_replace("#lastName#", $user_info['lastname'], $msg); |
@@ -4365,7 +4365,7 @@ discard block |
||
4365 | 4365 | $msg = str_replace("#course#", $course_info['name'], $msg1); |
4366 | 4366 | |
4367 | 4367 | if ($origin != 'learnpath') { |
4368 | - $msg.= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
|
4368 | + $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
|
4369 | 4369 | } |
4370 | 4370 | $msg1 = str_replace("#url#", $url_email, $msg); |
4371 | 4371 | $mail_content = $msg1; |
@@ -4431,10 +4431,10 @@ discard block |
||
4431 | 4431 | } |
4432 | 4432 | $html = '<div class="question-result">'; |
4433 | 4433 | $html .= Display::page_header( |
4434 | - Display::return_icon('test-quiz.png', get_lang('Result'),null, ICON_SIZE_MEDIUM).' '.$this->exercise.' : '.get_lang('Result') |
|
4434 | + Display::return_icon('test-quiz.png', get_lang('Result'), null, ICON_SIZE_MEDIUM).' '.$this->exercise.' : '.get_lang('Result') |
|
4435 | 4435 | ); |
4436 | 4436 | $html .= Display::description($array); |
4437 | - $html .="</div>"; |
|
4437 | + $html .= "</div>"; |
|
4438 | 4438 | return $html; |
4439 | 4439 | } |
4440 | 4440 | |
@@ -4551,7 +4551,7 @@ discard block |
||
4551 | 4551 | false, |
4552 | 4552 | $objExercise->selectPropagateNeg() |
4553 | 4553 | ); |
4554 | - $totalScore += $question_result['score']; |
|
4554 | + $totalScore += $question_result['score']; |
|
4555 | 4555 | } |
4556 | 4556 | |
4557 | 4557 | if ($objExercise->selectPropagateNeg() == 0 && $totalScore < 0) { |
@@ -4695,7 +4695,7 @@ discard block |
||
4695 | 4695 | } |
4696 | 4696 | } |
4697 | 4697 | |
4698 | - if (!empty($message)){ |
|
4698 | + if (!empty($message)) { |
|
4699 | 4699 | $message = Display::return_message($message, 'warning', false); |
4700 | 4700 | } |
4701 | 4701 | |
@@ -4709,7 +4709,7 @@ discard block |
||
4709 | 4709 | { |
4710 | 4710 | $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM); |
4711 | 4711 | $sql = "SELECT max_score FROM $TBL_LP_ITEM |
4712 | - WHERE c_id = {$this->course_id} AND item_type = '" . TOOL_QUIZ . "' AND path = '{$this->id}'"; |
|
4712 | + WHERE c_id = {$this->course_id} AND item_type = '".TOOL_QUIZ."' AND path = '{$this->id}'"; |
|
4713 | 4713 | $result = Database::query($sql); |
4714 | 4714 | if (Database::num_rows($result) > 0) { |
4715 | 4715 | return true; |
@@ -4875,7 +4875,7 @@ discard block |
||
4875 | 4875 | $sql_track = "SELECT * FROM $track_exercises WHERE exe_id = $exe_id "; |
4876 | 4876 | $result = Database::query($sql_track); |
4877 | 4877 | $new_array = array(); |
4878 | - if (Database::num_rows($result) > 0 ) { |
|
4878 | + if (Database::num_rows($result) > 0) { |
|
4879 | 4879 | $new_array = Database::fetch_array($result, 'ASSOC'); |
4880 | 4880 | |
4881 | 4881 | $new_array['duration'] = null; |
@@ -4887,11 +4887,11 @@ discard block |
||
4887 | 4887 | $start_date = api_strtotime($start_date, 'UTC'); |
4888 | 4888 | $end_date = api_strtotime($end_date, 'UTC'); |
4889 | 4889 | if ($start_date && $end_date) { |
4890 | - $mytime = $end_date- $start_date; |
|
4890 | + $mytime = $end_date - $start_date; |
|
4891 | 4891 | $new_learnpath_item = new learnpathItem(null); |
4892 | 4892 | $time_attemp = $new_learnpath_item->get_scorm_time('js', $mytime); |
4893 | 4893 | $h = get_lang('h'); |
4894 | - $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp); |
|
4894 | + $time_attemp = str_replace('NaN', '00'.$h.'00\'00"', $time_attemp); |
|
4895 | 4895 | $new_array['duration'] = $time_attemp; |
4896 | 4896 | } |
4897 | 4897 | } |
@@ -4913,7 +4913,7 @@ discard block |
||
4913 | 4913 | $result = Database::query($sql); |
4914 | 4914 | } |
4915 | 4915 | } else { |
4916 | - $remind_list = explode(',',$exercise_info['questions_to_check']); |
|
4916 | + $remind_list = explode(',', $exercise_info['questions_to_check']); |
|
4917 | 4917 | |
4918 | 4918 | $remind_list_string = ''; |
4919 | 4919 | if ($action == 'add') { |
@@ -4925,7 +4925,7 @@ discard block |
||
4925 | 4925 | } |
4926 | 4926 | $remind_list_string = implode(',', $remind_list); |
4927 | 4927 | } |
4928 | - } elseif ($action == 'delete') { |
|
4928 | + } elseif ($action == 'delete') { |
|
4929 | 4929 | if (!empty($remind_list)) { |
4930 | 4930 | if (in_array($question_id, $remind_list)) { |
4931 | 4931 | $remind_list = array_flip($remind_list); |
@@ -5026,7 +5026,7 @@ discard block |
||
5026 | 5026 | public function get_max_score() |
5027 | 5027 | { |
5028 | 5028 | $out_max_score = 0; |
5029 | - $tab_question_list = $this->selectQuestionList(true); // list of question's id !!! the array key start at 1 !!! |
|
5029 | + $tab_question_list = $this->selectQuestionList(true); // list of question's id !!! the array key start at 1 !!! |
|
5030 | 5030 | // test is randomQuestions - see field random of test |
5031 | 5031 | if ($this->random > 0 && $this->randomByCat == 0) { |
5032 | 5032 | $nb_random_questions = $this->random; |
@@ -538,10 +538,11 @@ discard block |
||
538 | 538 | */ |
539 | 539 | public function isInList($questionId) |
540 | 540 | { |
541 | - if (is_array($this->questionList)) |
|
542 | - return in_array($questionId,$this->questionList); |
|
543 | - else |
|
544 | - return false; |
|
541 | + if (is_array($this->questionList)) { |
|
542 | + return in_array($questionId,$this->questionList); |
|
543 | + } else { |
|
544 | + return false; |
|
545 | + } |
|
545 | 546 | } |
546 | 547 | |
547 | 548 | /** |
@@ -1227,10 +1228,11 @@ discard block |
||
1227 | 1228 | |
1228 | 1229 | $var = Exercise::selectTimeLimit(); |
1229 | 1230 | |
1230 | - if (($this->start_time != '0000-00-00 00:00:00')) |
|
1231 | - $form->addElement('html','<div id="start_date_div" style="display:block;">'); |
|
1232 | - else |
|
1233 | - $form->addElement('html','<div id="start_date_div" style="display:none;">'); |
|
1231 | + if (($this->start_time != '0000-00-00 00:00:00')) { |
|
1232 | + $form->addElement('html','<div id="start_date_div" style="display:block;">'); |
|
1233 | + } else { |
|
1234 | + $form->addElement('html','<div id="start_date_div" style="display:none;">'); |
|
1235 | + } |
|
1234 | 1236 | |
1235 | 1237 | $form->addElement('date_time_picker', 'start_time'); |
1236 | 1238 | |
@@ -1238,10 +1240,11 @@ discard block |
||
1238 | 1240 | |
1239 | 1241 | $form->addElement('checkbox', 'activate_end_date_check', null , get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()')); |
1240 | 1242 | |
1241 | - if (($this->end_time != '0000-00-00 00:00:00')) |
|
1242 | - $form->addElement('html','<div id="end_date_div" style="display:block;">'); |
|
1243 | - else |
|
1244 | - $form->addElement('html','<div id="end_date_div" style="display:none;">'); |
|
1243 | + if (($this->end_time != '0000-00-00 00:00:00')) { |
|
1244 | + $form->addElement('html','<div id="end_date_div" style="display:block;">'); |
|
1245 | + } else { |
|
1246 | + $form->addElement('html','<div id="end_date_div" style="display:none;">'); |
|
1247 | + } |
|
1245 | 1248 | |
1246 | 1249 | $form->addElement('date_time_picker', 'end_time'); |
1247 | 1250 | $form->addElement('html','</div>'); |
@@ -2268,7 +2271,9 @@ discard block |
||
2268 | 2271 | $organs_at_risk_hit = 0; |
2269 | 2272 | $questionScore = 0; |
2270 | 2273 | |
2271 | - if ($debug) error_log('Start answer loop '); |
|
2274 | + if ($debug) { |
|
2275 | + error_log('Start answer loop '); |
|
2276 | + } |
|
2272 | 2277 | |
2273 | 2278 | $answer_correct_array = array(); |
2274 | 2279 | |
@@ -2383,7 +2388,9 @@ discard block |
||
2383 | 2388 | } |
2384 | 2389 | $totalScore += $answerWeighting; |
2385 | 2390 | |
2386 | - if ($debug) error_log("studentChoice: $studentChoice"); |
|
2391 | + if ($debug) { |
|
2392 | + error_log("studentChoice: $studentChoice"); |
|
2393 | + } |
|
2387 | 2394 | break; |
2388 | 2395 | case GLOBAL_MULTIPLE_ANSWER: |
2389 | 2396 | if ($from_database) { |
@@ -2408,7 +2415,9 @@ discard block |
||
2408 | 2415 | $real_answers[$answerId] = (bool)$studentChoice; |
2409 | 2416 | } |
2410 | 2417 | $totalScore += $answerWeighting; |
2411 | - if ($debug) error_log("studentChoice: $studentChoice"); |
|
2418 | + if ($debug) { |
|
2419 | + error_log("studentChoice: $studentChoice"); |
|
2420 | + } |
|
2412 | 2421 | break; |
2413 | 2422 | case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE: |
2414 | 2423 | if ($from_database) { |
@@ -3125,9 +3134,13 @@ discard block |
||
3125 | 3134 | } // end switch Answertype |
3126 | 3135 | |
3127 | 3136 | if ($show_result) { |
3128 | - if ($debug) error_log('show result '.$show_result); |
|
3137 | + if ($debug) { |
|
3138 | + error_log('show result '.$show_result); |
|
3139 | + } |
|
3129 | 3140 | if ($from == 'exercise_result') { |
3130 | - if ($debug) error_log('Showing questions $from '.$from); |
|
3141 | + if ($debug) { |
|
3142 | + error_log('Showing questions $from '.$from); |
|
3143 | + } |
|
3131 | 3144 | //display answers (if not matching type, or if the answer is correct) |
3132 | 3145 | if ( |
3133 | 3146 | !in_array( |
@@ -3415,7 +3428,9 @@ discard block |
||
3415 | 3428 | } |
3416 | 3429 | } |
3417 | 3430 | } else { |
3418 | - if ($debug) error_log('Showing questions $from '.$from); |
|
3431 | + if ($debug) { |
|
3432 | + error_log('Showing questions $from '.$from); |
|
3433 | + } |
|
3419 | 3434 | |
3420 | 3435 | switch ($answerType) { |
3421 | 3436 | case UNIQUE_ANSWER: |
@@ -3747,10 +3762,14 @@ discard block |
||
3747 | 3762 | } |
3748 | 3763 | } |
3749 | 3764 | } |
3750 | - if ($debug) error_log(' ------ '); |
|
3765 | + if ($debug) { |
|
3766 | + error_log(' ------ '); |
|
3767 | + } |
|
3751 | 3768 | } // end for that loops over all answers of the current question |
3752 | 3769 | |
3753 | - if ($debug) error_log('-- end answer loop --'); |
|
3770 | + if ($debug) { |
|
3771 | + error_log('-- end answer loop --'); |
|
3772 | + } |
|
3754 | 3773 | |
3755 | 3774 | $final_answer = true; |
3756 | 3775 | |
@@ -3823,7 +3842,9 @@ discard block |
||
3823 | 3842 | // some results that haven't been stored in the database yet |
3824 | 3843 | if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION ) { |
3825 | 3844 | |
3826 | - if ($debug) error_log('$from AND this is a hotspot kind of question '); |
|
3845 | + if ($debug) { |
|
3846 | + error_log('$from AND this is a hotspot kind of question '); |
|
3847 | + } |
|
3827 | 3848 | |
3828 | 3849 | $my_exe_id = 0; |
3829 | 3850 | $from_database = 0; |
@@ -3999,8 +4020,12 @@ discard block |
||
3999 | 4020 | // stored by exercise_results.php (using the session) |
4000 | 4021 | |
4001 | 4022 | if ($saved_results) { |
4002 | - if ($debug) error_log("Save question results $saved_results"); |
|
4003 | - if ($debug) error_log(print_r($choice ,1 )); |
|
4023 | + if ($debug) { |
|
4024 | + error_log("Save question results $saved_results"); |
|
4025 | + } |
|
4026 | + if ($debug) { |
|
4027 | + error_log(print_r($choice ,1 )); |
|
4028 | + } |
|
4004 | 4029 | |
4005 | 4030 | if (empty($choice)) { |
4006 | 4031 | $choice = 0; |
@@ -4102,7 +4127,9 @@ discard block |
||
4102 | 4127 | $sql = 'UPDATE ' . $stat_table . ' SET |
4103 | 4128 | exe_result = exe_result + ' . floatval($questionScore) . ' |
4104 | 4129 | WHERE exe_id = ' . $exeId; |
4105 | - if ($debug) error_log($sql); |
|
4130 | + if ($debug) { |
|
4131 | + error_log($sql); |
|
4132 | + } |
|
4106 | 4133 | Database::query($sql); |
4107 | 4134 | } |
4108 | 4135 |
@@ -10,6 +10,10 @@ |
||
10 | 10 | if ( count( get_included_files() ) == 1 ) die( '---' ); |
11 | 11 | |
12 | 12 | if (!function_exists('mime_content_type')) { |
13 | + |
|
14 | + /** |
|
15 | + * @param string $filename |
|
16 | + */ |
|
13 | 17 | function mime_content_type($filename) { |
14 | 18 | return DocumentManager::file_get_mime_type((string)$filename); |
15 | 19 | } |
@@ -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 |
@@ -7,11 +7,11 @@ discard block |
||
7 | 7 | * @package chamilo.exercise |
8 | 8 | */ |
9 | 9 | |
10 | -if ( count( get_included_files() ) == 1 ) die( '---' ); |
|
10 | +if (count(get_included_files()) == 1) die('---'); |
|
11 | 11 | |
12 | 12 | if (!function_exists('mime_content_type')) { |
13 | 13 | function mime_content_type($filename) { |
14 | - return DocumentManager::file_get_mime_type((string)$filename); |
|
14 | + return DocumentManager::file_get_mime_type((string) $filename); |
|
15 | 15 | } |
16 | 16 | } |
17 | 17 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function setAnswer() |
27 | 27 | { |
28 | - switch($this->type) |
|
28 | + switch ($this->type) |
|
29 | 29 | { |
30 | 30 | case MCUA : |
31 | 31 | $answer = new AikenAnswerMultipleChoice($this->id); |
@@ -7,7 +7,9 @@ |
||
7 | 7 | * @package chamilo.exercise |
8 | 8 | */ |
9 | 9 | |
10 | -if ( count( get_included_files() ) == 1 ) die( '---' ); |
|
10 | +if ( count( get_included_files() ) == 1 ) { |
|
11 | + die( '---' ); |
|
12 | +} |
|
11 | 13 | |
12 | 14 | if (!function_exists('mime_content_type')) { |
13 | 15 | function mime_content_type($filename) { |
@@ -55,6 +55,8 @@ discard block |
||
55 | 55 | * Gets the uploaded file (from $_FILES) and unzip it to the given directory |
56 | 56 | * @param string The directory where to do the work |
57 | 57 | * @param string The path of the temporary directory where the exercise was uploaded and unzipped |
58 | + * @param string $baseWorkDir |
|
59 | + * @param string $uploadPath |
|
58 | 60 | * @return bool True on success, false on failure |
59 | 61 | */ |
60 | 62 | function get_and_unzip_uploaded_exercise($baseWorkDir, $uploadPath) { |
@@ -229,7 +231,10 @@ discard block |
||
229 | 231 | * @param string Path to the directory with the file to be parsed (without final /) |
230 | 232 | * @param string Name of the last directory part for the file (without /) |
231 | 233 | * @param string Name of the file to be parsed (including extension) |
232 | - * @return mixed True on success, error message on error |
|
234 | + * @param string $exercisePath |
|
235 | + * @param string $file |
|
236 | + * @param string $questionFile |
|
237 | + * @return string|boolean True on success, error message on error |
|
233 | 238 | * @assert ('','','') === false |
234 | 239 | */ |
235 | 240 | function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile) { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $dir .= '/'; |
26 | 26 | |
27 | 27 | do { |
28 | - $path = $dir . $prefix . mt_rand(0, 9999999); |
|
28 | + $path = $dir.$prefix.mt_rand(0, 9999999); |
|
29 | 29 | } while (!mkdir($path, $mode)); |
30 | 30 | |
31 | 31 | return $path; |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | function aiken_display_form($msg = '') { |
39 | 39 | $name_tools = get_lang('ImportAikenQuiz'); |
40 | 40 | $form = '<div class="actions">'; |
41 | - $form .= '<a href="exercise.php?show=test">' . Display :: return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
41 | + $form .= '<a href="exercise.php?show=test">'.Display :: return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
42 | 42 | $form .= '</div>'; |
43 | 43 | $form .= $msg; |
44 | - $form_validator = new FormValidator('aiken_upload', 'post',api_get_self()."?".api_get_cidreq(), null, array('enctype' => 'multipart/form-data') ); |
|
44 | + $form_validator = new FormValidator('aiken_upload', 'post', api_get_self()."?".api_get_cidreq(), null, array('enctype' => 'multipart/form-data')); |
|
45 | 45 | $form_validator->addElement('header', $name_tools); |
46 | 46 | $form_validator->addElement('text', 'total_weight', get_lang('TotalWeight')); |
47 | 47 | $form_validator->addElement('file', 'userFile', get_lang('DownloadFile')); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | global $record_item_body; |
90 | 90 | // used to specify the question directory where files could be found in relation in any question |
91 | 91 | global $questionTempDir; |
92 | - $archive_path = api_get_path(SYS_ARCHIVE_PATH) . 'aiken'; |
|
92 | + $archive_path = api_get_path(SYS_ARCHIVE_PATH).'aiken'; |
|
93 | 93 | $baseWorkDir = $archive_path; |
94 | 94 | |
95 | 95 | if (!is_dir($baseWorkDir)) { |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | |
131 | 131 | // Parse every subdirectory to search txt question files |
132 | 132 | while (false !== ($file = readdir($exerciseHandle))) { |
133 | - if (is_dir($baseWorkDir . '/' . $file) && $file != "." && $file != "..") { |
|
133 | + if (is_dir($baseWorkDir.'/'.$file) && $file != "." && $file != "..") { |
|
134 | 134 | //find each manifest for each question repository found |
135 | - $questionHandle = opendir($baseWorkDir . '/' . $file); |
|
135 | + $questionHandle = opendir($baseWorkDir.'/'.$file); |
|
136 | 136 | while (false !== ($questionFile = readdir($questionHandle))) { |
137 | 137 | if (preg_match('/.txt$/i', $questionFile)) { |
138 | 138 | $result = aiken_parse_file( |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $result = 'NoTxtFileFoundInTheZip'; |
155 | 155 | } |
156 | 156 | |
157 | - if ($result !== true ) { |
|
157 | + if ($result !== true) { |
|
158 | 158 | return $result; |
159 | 159 | } |
160 | 160 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | // Delete the temp dir where the exercise was unzipped |
218 | - my_delete($baseWorkDir . $uploadPath); |
|
218 | + my_delete($baseWorkDir.$uploadPath); |
|
219 | 219 | $operation = $last_exercise_id; |
220 | 220 | } |
221 | 221 | |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile) { |
236 | 236 | global $questionTempDir; |
237 | 237 | |
238 | - $questionTempDir = $exercisePath . '/' . $file . '/'; |
|
239 | - $questionFilePath = $questionTempDir . $questionFile; |
|
238 | + $questionTempDir = $exercisePath.'/'.$file.'/'; |
|
239 | + $questionFilePath = $questionTempDir.$questionFile; |
|
240 | 240 | |
241 | 241 | if (!is_file($questionFilePath)) { |
242 | 242 | return 'FileNotFound'; |
@@ -248,13 +248,13 @@ discard block |
||
248 | 248 | $answers_array = array(); |
249 | 249 | $new_question = true; |
250 | 250 | foreach ($data as $line => $info) { |
251 | - if ($question_index > 0 && $new_question == true && preg_match('/^(\r)?\n/',$info)) { |
|
251 | + if ($question_index > 0 && $new_question == true && preg_match('/^(\r)?\n/', $info)) { |
|
252 | 252 | // double empty line |
253 | 253 | continue; |
254 | 254 | } |
255 | 255 | $new_question = false; |
256 | 256 | //make sure it is transformed from iso-8859-1 to utf-8 if in that form |
257 | - if (!mb_check_encoding($info,'utf-8') && mb_check_encoding($info,'iso-8859-1')) { |
|
257 | + if (!mb_check_encoding($info, 'utf-8') && mb_check_encoding($info, 'iso-8859-1')) { |
|
258 | 258 | $info = utf8_encode($info); |
259 | 259 | } |
260 | 260 | $exercise_info['question'][$question_index]['type'] = 'MCUA'; |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | } elseif (preg_match('/^ETIQUETAS:\s?([A-Z])\s?/', $info, $matches)) { |
287 | 287 | //TAGS for chamilo >= 1.10 (Spanish e-ducativa format) |
288 | 288 | $exercise_info['question'][$question_index]['answer_tags'] = explode(',', $matches[1]); |
289 | - } elseif (preg_match('/^(\r)?\n/',$info)) { |
|
289 | + } elseif (preg_match('/^(\r)?\n/', $info)) { |
|
290 | 290 | //moving to next question (tolerate \r\n or just \n) |
291 | 291 | if (empty($exercise_info['question'][$question_index]['correct_answers'])) { |
292 | 292 | error_log('Aiken: Error in question index '.$question_index.': no correct answer defined'); |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | $exercise_info['question'][$question_index]['title'] = $info; |
307 | 307 | } else { |
308 | 308 | //Question itself (use a 100-chars long title and a larger description) |
309 | - $exercise_info['question'][$question_index]['title'] = trim(substr($info, 0, 100)) . '...'; |
|
309 | + $exercise_info['question'][$question_index]['title'] = trim(substr($info, 0, 100)).'...'; |
|
310 | 310 | $exercise_info['question'][$question_index]['description'] = $info; |
311 | 311 | } |
312 | 312 | } else { |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | } |
317 | 317 | $total_questions = count($exercise_info['question']); |
318 | 318 | $total_weight = (!empty($_POST['total_weight'])) ? intval($_POST['total_weight']) : 20; |
319 | - foreach ($exercise_info['question'] as $key => $question) { |
|
319 | + foreach ($exercise_info['question'] as $key => $question) { |
|
320 | 320 | $exercise_info['question'][$key]['weighting'][current(array_keys($exercise_info['question'][$key]['weighting']))] = $total_weight / $total_questions; |
321 | 321 | } |
322 | 322 | return true; |
@@ -10,8 +10,9 @@ discard block |
||
10 | 10 | /** |
11 | 11 | * Security check |
12 | 12 | */ |
13 | -if (count(get_included_files()) == 1) |
|
13 | +if (count(get_included_files()) == 1) { |
|
14 | 14 | die('---'); |
15 | +} |
|
15 | 16 | |
16 | 17 | /** |
17 | 18 | * Creates a temporary directory |
@@ -21,8 +22,9 @@ discard block |
||
21 | 22 | * @return string |
22 | 23 | */ |
23 | 24 | function tempdir($dir, $prefix = 'tmp', $mode = 0777) { |
24 | - if (substr($dir, -1) != '/') |
|
25 | - $dir .= '/'; |
|
25 | + if (substr($dir, -1) != '/') { |
|
26 | + $dir .= '/'; |
|
27 | + } |
|
26 | 28 | |
27 | 29 | do { |
28 | 30 | $path = $dir . $prefix . mt_rand(0, 9999999); |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | } |
79 | 79 | } |
80 | 80 | /** |
81 | - * Main function to import the Aiken exercise |
|
82 | - * @return mixed True on success, error message on failure |
|
83 | - */ |
|
81 | + * Main function to import the Aiken exercise |
|
82 | + * @return mixed True on success, error message on failure |
|
83 | + */ |
|
84 | 84 | function aiken_import_exercise($file) |
85 | 85 | { |
86 | 86 | global $exercise_info; |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $correct_answer_index = array_search($matches[1], $answers_array); |
282 | 282 | $exercise_info['question'][$question_index]['title'] = $matches[1]; |
283 | 283 | } elseif (preg_match('/^TAGS:\s?([A-Z])\s?/', $info, $matches)) { |
284 | - //TAGS for chamilo >= 1.10 |
|
284 | + //TAGS for chamilo >= 1.10 |
|
285 | 285 | $exercise_info['question'][$question_index]['answer_tags'] = explode(',', $matches[1]); |
286 | 286 | } elseif (preg_match('/^ETIQUETAS:\s?([A-Z])\s?/', $info, $matches)) { |
287 | 287 | //TAGS for chamilo >= 1.10 (Spanish e-ducativa format) |
@@ -30,6 +30,8 @@ discard block |
||
30 | 30 | * Unzip the exercise in the temp folder |
31 | 31 | * @param string The path of the temporary directory where the exercise was uploaded and unzipped |
32 | 32 | * @param string |
33 | + * @param string $baseWorkDir |
|
34 | + * @param string $uploadPath |
|
33 | 35 | * @return bool |
34 | 36 | */ |
35 | 37 | function get_and_unzip_uploaded_exercise($baseWorkDir, $uploadPath) |
@@ -217,9 +219,9 @@ discard block |
||
217 | 219 | |
218 | 220 | /** |
219 | 221 | * Parses a given XML file and fills global arrays with the elements |
220 | - * @param $exercisePath |
|
221 | - * @param $file |
|
222 | - * @param $questionFile |
|
222 | + * @param string $exercisePath |
|
223 | + * @param string $file |
|
224 | + * @param string $questionFile |
|
223 | 225 | * @return bool |
224 | 226 | */ |
225 | 227 | function parse_file($exercisePath, $file, $questionFile) |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | } |
21 | 21 | |
22 | 22 | do { |
23 | - $path = $dir . $prefix . mt_rand(0, 9999999); |
|
23 | + $path = $dir.$prefix.mt_rand(0, 9999999); |
|
24 | 24 | } while (!mkdir($path, $mode)); |
25 | 25 | |
26 | 26 | return $path; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | // used to specify the question directory where files could be found in relation in any question |
75 | 75 | global $questionTempDir; |
76 | 76 | |
77 | - $archive_path = api_get_path(SYS_ARCHIVE_PATH) . 'qti2'; |
|
77 | + $archive_path = api_get_path(SYS_ARCHIVE_PATH).'qti2'; |
|
78 | 78 | $baseWorkDir = $archive_path; |
79 | 79 | |
80 | 80 | if (!is_dir($baseWorkDir)) { |
@@ -118,14 +118,14 @@ discard block |
||
118 | 118 | // parse every subdirectory to search xml question files |
119 | 119 | while (false !== ($file = readdir($exerciseHandle))) { |
120 | 120 | |
121 | - if (is_dir($baseWorkDir . '/' . $file) && $file != "." && $file != "..") { |
|
121 | + if (is_dir($baseWorkDir.'/'.$file) && $file != "." && $file != "..") { |
|
122 | 122 | |
123 | 123 | // Find each manifest for each question repository found |
124 | - $questionHandle = opendir($baseWorkDir . '/' . $file); |
|
124 | + $questionHandle = opendir($baseWorkDir.'/'.$file); |
|
125 | 125 | while (false !== ($questionFile = readdir($questionHandle))) { |
126 | 126 | if (preg_match('/.xml$/i', $questionFile)) { |
127 | 127 | $result = parse_file($baseWorkDir, $file, $questionFile); |
128 | - $filePath = $baseWorkDir . $file; |
|
128 | + $filePath = $baseWorkDir.$file; |
|
129 | 129 | $file_found = true; |
130 | 130 | } |
131 | 131 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | // Else ignore file |
135 | 135 | $result = parse_file($baseWorkDir, '', $file); |
136 | - $filePath = $baseWorkDir . '/' . $file; |
|
136 | + $filePath = $baseWorkDir.'/'.$file; |
|
137 | 137 | $file_found = true; |
138 | 138 | } |
139 | 139 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | } |
201 | 201 | |
202 | 202 | // delete the temp dir where the exercise was unzipped |
203 | - my_delete($baseWorkDir . $uploadPath); |
|
203 | + my_delete($baseWorkDir.$uploadPath); |
|
204 | 204 | return $last_exercise_id; |
205 | 205 | } |
206 | 206 | |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | global $record_item_body; |
229 | 229 | global $questionTempDir; |
230 | 230 | |
231 | - $questionTempDir = $exercisePath . '/' . $file . '/'; |
|
232 | - $questionFilePath = $questionTempDir . $questionFile; |
|
231 | + $questionTempDir = $exercisePath.'/'.$file.'/'; |
|
232 | + $questionFilePath = $questionTempDir.$questionFile; |
|
233 | 233 | |
234 | 234 | if (!($fp = fopen($questionFilePath, 'r'))) { |
235 | 235 | Display:: display_error_message(get_lang('Error opening question\'s XML file')); |
@@ -326,10 +326,10 @@ discard block |
||
326 | 326 | if ($record_item_body) { |
327 | 327 | |
328 | 328 | if ((!in_array($current_element, $non_HTML_tag_to_avoid))) { |
329 | - $current_question_item_body .= "<" . $name; |
|
329 | + $current_question_item_body .= "<".$name; |
|
330 | 330 | |
331 | 331 | foreach ($attributes as $attribute_name => $attribute_value) { |
332 | - $current_question_item_body .= " " . $attribute_name . "=\"" . $attribute_value . "\""; |
|
332 | + $current_question_item_body .= " ".$attribute_name."=\"".$attribute_value."\""; |
|
333 | 333 | } |
334 | 334 | $current_question_item_body .= ">"; |
335 | 335 | } else { |
@@ -338,11 +338,11 @@ discard block |
||
338 | 338 | |
339 | 339 | if ($current_element == 'INLINECHOICEINTERACTION') { |
340 | 340 | |
341 | - $current_question_item_body .= "**claroline_start**" . $attributes['RESPONSEIDENTIFIER'] . "**claroline_end**"; |
|
341 | + $current_question_item_body .= "**claroline_start**".$attributes['RESPONSEIDENTIFIER']."**claroline_end**"; |
|
342 | 342 | } |
343 | 343 | if ($current_element == 'TEXTENTRYINTERACTION') { |
344 | 344 | $correct_answer_value = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id]; |
345 | - $current_question_item_body .= "[" . $correct_answer_value . "]"; |
|
345 | + $current_question_item_body .= "[".$correct_answer_value."]"; |
|
346 | 346 | |
347 | 347 | } |
348 | 348 | if ($current_element == 'BR') { |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | //treat the record of the full content of itembody tag : |
458 | 458 | |
459 | 459 | if ($record_item_body && (!in_array($current_element, $non_HTML_tag_to_avoid))) { |
460 | - $current_question_item_body .= "</" . $name . ">"; |
|
460 | + $current_question_item_body .= "</".$name.">"; |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | switch ($name) { |
@@ -515,14 +515,14 @@ discard block |
||
515 | 515 | if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'])) { |
516 | 516 | $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] = trim($data); |
517 | 517 | } else { |
518 | - $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= '' . trim($data); |
|
518 | + $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= ''.trim($data); |
|
519 | 519 | } |
520 | 520 | break; |
521 | 521 | case 'FEEDBACKINLINE': |
522 | 522 | if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'])) { |
523 | 523 | $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] = trim($data); |
524 | 524 | } else { |
525 | - $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] .= ' ' . trim($data); |
|
525 | + $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] .= ' '.trim($data); |
|
526 | 526 | } |
527 | 527 | break; |
528 | 528 | case 'SIMPLEASSOCIABLECHOICE': |
@@ -546,8 +546,8 @@ discard block |
||
546 | 546 | $answer_identifier = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id]; |
547 | 547 | if ($current_inlinechoice_id == $answer_identifier) { |
548 | 548 | $current_question_item_body = str_replace( |
549 | - "**claroline_start**" . $current_answer_id . "**claroline_end**", |
|
550 | - "[" . $data . "]", |
|
549 | + "**claroline_start**".$current_answer_id."**claroline_end**", |
|
550 | + "[".$data."]", |
|
551 | 551 | $current_question_item_body |
552 | 552 | ); |
553 | 553 | } else { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * Constructor. |
34 | 34 | * |
35 | - * @param $question Ims2Question object we want to export. |
|
35 | + * @param Ims2Question $question Ims2Question object we want to export. |
|
36 | 36 | */ |
37 | 37 | function ImsAssessmentItem($question) |
38 | 38 | { |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * This is a default behaviour, some classes may want to override this. |
102 | 102 | * |
103 | 103 | * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
104 | - * @return A string, the XML flow for an Item. |
|
104 | + * @return string string, the XML flow for an Item. |
|
105 | 105 | */ |
106 | 106 | function export($standalone = false) |
107 | 107 | { |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | |
155 | 155 | /** |
156 | 156 | * Constructor. |
157 | - * @param $exe The Exercise instance to export |
|
157 | + * @param Exercise $exe The Exercise instance to export |
|
158 | 158 | * @author Amand Tihon <[email protected]> |
159 | 159 | */ |
160 | 160 | function ImsSection($exe) |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * Export the exercise in IMS/QTI. |
240 | 240 | * |
241 | 241 | * @param bool $standalone Wether it should include XML tag and DTD line. |
242 | - * @return a string containing the XML flow |
|
242 | + * @return string string containing the XML flow |
|
243 | 243 | * @author Amand Tihon <[email protected]> |
244 | 244 | */ |
245 | 245 | function export($standalone) |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * This is a default behaviour, some classes may want to override this. |
384 | 384 | * |
385 | 385 | * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
386 | - * @return A string, the XML flow for an Item. |
|
386 | + * @return string string, the XML flow for an Item. |
|
387 | 387 | * @author Amand Tihon <[email protected]> |
388 | 388 | */ |
389 | 389 | function export($standalone = False) |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * |
418 | 418 | * @param int $exerciseId The exercise to export |
419 | 419 | * @param boolean $standalone Wether it should include XML tag and DTD line. |
420 | - * @return The XML as a string, or an empty string if there's no exercise with given ID. |
|
420 | + * @return string XML as a string, or an empty string if there's no exercise with given ID. |
|
421 | 421 | */ |
422 | 422 | function export_exercise_to_qti($exerciseId, $standalone = true) |
423 | 423 | { |
@@ -474,6 +474,9 @@ discard block |
||
474 | 474 | return htmlspecialchars($text); |
475 | 475 | } |
476 | 476 | |
477 | +/** |
|
478 | + * @param string $text |
|
479 | + */ |
|
477 | 480 | function cleanAttribute($text) |
478 | 481 | { |
479 | 482 | return $text; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | /** |
9 | 9 | * Code |
10 | 10 | */ |
11 | -require dirname(__FILE__) . '/qti2_classes.php'; |
|
11 | +require dirname(__FILE__).'/qti2_classes.php'; |
|
12 | 12 | /** |
13 | 13 | * Classes |
14 | 14 | */ |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | { |
39 | 39 | $this->question = $question; |
40 | 40 | $this->answer = $this->question->setAnswer(); |
41 | - $this->questionIdent = "QST_" . $question->id ; |
|
41 | + $this->questionIdent = "QST_".$question->id; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | function start_item_body() |
75 | 75 | { |
76 | - return ' <itemBody>' . "\n"; |
|
76 | + return ' <itemBody>'."\n"; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | function add_response_processing() |
94 | 94 | { |
95 | - return ' <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>' . "\n"; |
|
95 | + return ' <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>'."\n"; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $head = $foot = ""; |
109 | 109 | |
110 | 110 | if ($standalone) { |
111 | - $head = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . "\n"; |
|
111 | + $head = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'."\n"; |
|
112 | 112 | } |
113 | 113 | //TODO understand why answer might be a non-object sometimes |
114 | 114 | if (!is_object($this->answer)) { |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | |
165 | 165 | function start_section() |
166 | 166 | { |
167 | - $out = '<section ident="EXO_' . $this->exercise->selectId() . '" title="' .cleanAttribute(formatExerciseQtiDescription($this->exercise->selectTitle())) . '">' . "\n"; |
|
167 | + $out = '<section ident="EXO_'.$this->exercise->selectId().'" title="'.cleanAttribute(formatExerciseQtiDescription($this->exercise->selectTitle())).'">'."\n"; |
|
168 | 168 | return $out; |
169 | 169 | } |
170 | 170 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | // return exercise duration in ISO8601 format. |
181 | 181 | $minutes = floor($max_time / 60); |
182 | 182 | $seconds = $max_time % 60; |
183 | - return '<duration>PT' . $minutes . 'M' . $seconds . "S</duration>\n"; |
|
183 | + return '<duration>PT'.$minutes.'M'.$seconds."S</duration>\n"; |
|
184 | 184 | } else { |
185 | 185 | return ''; |
186 | 186 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | function export_presentation() |
194 | 194 | { |
195 | 195 | $out = "<presentation_material><flow_mat><material>\n" |
196 | - . " <mattext><![CDATA[" . formatExerciseQtiDescription($this->exercise->selectDescription()) . "]]></mattext>\n" |
|
196 | + . " <mattext><![CDATA[".formatExerciseQtiDescription($this->exercise->selectDescription())."]]></mattext>\n" |
|
197 | 197 | . "</material></flow_mat></presentation_material>\n"; |
198 | 198 | return $out; |
199 | 199 | } |
@@ -207,14 +207,14 @@ discard block |
||
207 | 207 | { |
208 | 208 | $out = ''; |
209 | 209 | if ($n = $this->exercise->getShuffle()) { |
210 | - $out.= "<selection_ordering>" |
|
210 | + $out .= "<selection_ordering>" |
|
211 | 211 | . " <selection>\n" |
212 | - . " <selection_number>" . $n . "</selection_number>\n" |
|
212 | + . " <selection_number>".$n."</selection_number>\n" |
|
213 | 213 | . " </selection>\n" |
214 | 214 | . ' <order order_type="Random" />' |
215 | 215 | . "\n</selection_ordering>\n"; |
216 | 216 | } else { |
217 | - $out.= '<selection_ordering sequence_type="Normal">' . "\n" |
|
217 | + $out .= '<selection_ordering sequence_type="Normal">'."\n" |
|
218 | 218 | . " <selection />\n" |
219 | 219 | . "</selection_ordering>\n"; |
220 | 220 | } |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | { |
247 | 247 | $head = $foot = ""; |
248 | 248 | if ($standalone) { |
249 | - $head = '<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>' . "\n" |
|
250 | - . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
249 | + $head = '<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>'."\n" |
|
250 | + . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">'."\n" |
|
251 | 251 | . "<questestinterop>\n"; |
252 | 252 | $foot = "</questestinterop>\n"; |
253 | 253 | } |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | { |
309 | 309 | $this->question = $question; |
310 | 310 | $this->answer = $question->answer; |
311 | - $this->questionIdent = "QST_" . $question->selectId() ; |
|
311 | + $this->questionIdent = "QST_".$question->selectId(); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | */ |
321 | 321 | function start_item() |
322 | 322 | { |
323 | - return '<item title="' . cleanAttribute(formatExerciseQtiDescription($this->question->selectTitle())) . '" ident="' . $this->questionIdent . '">' . "\n"; |
|
323 | + return '<item title="'.cleanAttribute(formatExerciseQtiDescription($this->question->selectTitle())).'" ident="'.$this->questionIdent.'">'."\n"; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | */ |
344 | 344 | function start_presentation() |
345 | 345 | { |
346 | - return '<presentation label="' . $this->questionIdent . '"><flow>' . "\n" |
|
347 | - . '<material><mattext>' . formatExerciseQtiDescription($this->question->selectDescription()) . "</mattext></material>\n"; |
|
346 | + return '<presentation label="'.$this->questionIdent.'"><flow>'."\n" |
|
347 | + . '<material><mattext>'.formatExerciseQtiDescription($this->question->selectDescription())."</mattext></material>\n"; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | */ |
365 | 365 | function start_processing() |
366 | 366 | { |
367 | - return '<resprocessing><outcomes><decvar vartype="Integer" defaultval="0" /></outcomes>' . "\n"; |
|
367 | + return '<resprocessing><outcomes><decvar vartype="Integer" defaultval="0" /></outcomes>'."\n"; |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
@@ -392,8 +392,8 @@ discard block |
||
392 | 392 | $head = $foot = ""; |
393 | 393 | |
394 | 394 | if ($standalone) { |
395 | - $head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>' . "\n" |
|
396 | - . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
395 | + $head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>'."\n" |
|
396 | + . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">'."\n" |
|
397 | 397 | . "<questestinterop>\n"; |
398 | 398 | $foot = "</questestinterop>\n"; |
399 | 399 | } |
@@ -447,9 +447,9 @@ discard block |
||
447 | 447 | $question->type = $qst->type; |
448 | 448 | $question->question = $qst->question; |
449 | 449 | $question->description = $qst->description; |
450 | - $question->weighting=$qst->weighting; |
|
451 | - $question->position=$qst->position; |
|
452 | - $question->picture=$qst->picture; |
|
450 | + $question->weighting = $qst->weighting; |
|
451 | + $question->position = $qst->position; |
|
452 | + $question->picture = $qst->picture; |
|
453 | 453 | $ims = new ImsAssessmentItem($question); |
454 | 454 | |
455 | 455 | return $ims->export($standalone); |
@@ -1,16 +1,16 @@ 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]> |
|
6 | - * @package chamilo.exercise |
|
7 | - */ |
|
4 | + * @author Claro Team <[email protected]> |
|
5 | + * @author Yannick Warnier <[email protected]> |
|
6 | + * @package chamilo.exercise |
|
7 | + */ |
|
8 | 8 | /** |
9 | - * Code |
|
10 | - */ |
|
9 | + * Code |
|
10 | + */ |
|
11 | 11 | require dirname(__FILE__) . '/qti2_classes.php'; |
12 | 12 | /** |
13 | - * Classes |
|
13 | + * Classes |
|
14 | 14 | */ |
15 | 15 | |
16 | 16 | /** |
@@ -34,21 +34,21 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @param $question Ims2Question object we want to export. |
36 | 36 | */ |
37 | - function ImsAssessmentItem($question) |
|
38 | - { |
|
37 | + function ImsAssessmentItem($question) |
|
38 | + { |
|
39 | 39 | $this->question = $question; |
40 | 40 | $this->answer = $this->question->setAnswer(); |
41 | 41 | $this->questionIdent = "QST_" . $question->id ; |
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * Start the XML flow. |
|
46 | - * |
|
47 | - * This opens the <item> block, with correct attributes. |
|
48 | - * |
|
49 | - */ |
|
50 | - function start_item() |
|
51 | - { |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * Start the XML flow. |
|
46 | + * |
|
47 | + * This opens the <item> block, with correct attributes. |
|
48 | + * |
|
49 | + */ |
|
50 | + function start_item() |
|
51 | + { |
|
52 | 52 | $string = '<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1" |
53 | 53 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
54 | 54 | xsi:schemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p1 imsqti_v2p1.xsd" |
@@ -56,55 +56,55 @@ discard block |
||
56 | 56 | title="'.htmlspecialchars(formatExerciseQtiTitle($this->question->selectTitle())).'">'."\n"; |
57 | 57 | |
58 | 58 | return $string; |
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * End the XML flow, closing the </item> tag. |
|
63 | - * |
|
64 | - */ |
|
65 | - function end_item() |
|
66 | - { |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * End the XML flow, closing the </item> tag. |
|
63 | + * |
|
64 | + */ |
|
65 | + function end_item() |
|
66 | + { |
|
67 | 67 | return "</assessmentItem>\n"; |
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Start the itemBody |
|
72 | - * |
|
73 | - */ |
|
74 | - function start_item_body() |
|
75 | - { |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Start the itemBody |
|
72 | + * |
|
73 | + */ |
|
74 | + function start_item_body() |
|
75 | + { |
|
76 | 76 | return ' <itemBody>' . "\n"; |
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * End the itemBody part. |
|
81 | - * |
|
82 | - */ |
|
83 | - function end_item_body() |
|
84 | - { |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * End the itemBody part. |
|
81 | + * |
|
82 | + */ |
|
83 | + function end_item_body() |
|
84 | + { |
|
85 | 85 | return " </itemBody>\n"; |
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * add the response processing template used. |
|
90 | - * |
|
91 | - */ |
|
92 | - |
|
93 | - function add_response_processing() |
|
94 | - { |
|
95 | - return ' <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>' . "\n"; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * Export the question as an IMS/QTI Item. |
|
100 | - * |
|
101 | - * This is a default behaviour, some classes may want to override this. |
|
102 | - * |
|
103 | - * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
104 | - * @return A string, the XML flow for an Item. |
|
105 | - */ |
|
106 | - function export($standalone = false) |
|
107 | - { |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * add the response processing template used. |
|
90 | + * |
|
91 | + */ |
|
92 | + |
|
93 | + function add_response_processing() |
|
94 | + { |
|
95 | + return ' <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>' . "\n"; |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * Export the question as an IMS/QTI Item. |
|
100 | + * |
|
101 | + * This is a default behaviour, some classes may want to override this. |
|
102 | + * |
|
103 | + * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
104 | + * @return A string, the XML flow for an Item. |
|
105 | + */ |
|
106 | + function export($standalone = false) |
|
107 | + { |
|
108 | 108 | $head = $foot = ""; |
109 | 109 | |
110 | 110 | if ($standalone) { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | .$foot; |
132 | 132 | |
133 | 133 | return $res; |
134 | - } |
|
134 | + } |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | function export_presentation() |
194 | 194 | { |
195 | 195 | $out = "<presentation_material><flow_mat><material>\n" |
196 | - . " <mattext><![CDATA[" . formatExerciseQtiDescription($this->exercise->selectDescription()) . "]]></mattext>\n" |
|
197 | - . "</material></flow_mat></presentation_material>\n"; |
|
196 | + . " <mattext><![CDATA[" . formatExerciseQtiDescription($this->exercise->selectDescription()) . "]]></mattext>\n" |
|
197 | + . "</material></flow_mat></presentation_material>\n"; |
|
198 | 198 | return $out; |
199 | 199 | } |
200 | 200 | |
@@ -208,15 +208,15 @@ discard block |
||
208 | 208 | $out = ''; |
209 | 209 | if ($n = $this->exercise->getShuffle()) { |
210 | 210 | $out.= "<selection_ordering>" |
211 | - . " <selection>\n" |
|
212 | - . " <selection_number>" . $n . "</selection_number>\n" |
|
213 | - . " </selection>\n" |
|
214 | - . ' <order order_type="Random" />' |
|
215 | - . "\n</selection_ordering>\n"; |
|
211 | + . " <selection>\n" |
|
212 | + . " <selection_number>" . $n . "</selection_number>\n" |
|
213 | + . " </selection>\n" |
|
214 | + . ' <order order_type="Random" />' |
|
215 | + . "\n</selection_ordering>\n"; |
|
216 | 216 | } else { |
217 | 217 | $out.= '<selection_ordering sequence_type="Normal">' . "\n" |
218 | - . " <selection />\n" |
|
219 | - . "</selection_ordering>\n"; |
|
218 | + . " <selection />\n" |
|
219 | + . "</selection_ordering>\n"; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | return $out; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | { |
231 | 231 | $out = ""; |
232 | 232 | foreach ($this->exercise->selectQuestionList() as $q) { |
233 | - $out .= export_question_qti($q, false); |
|
233 | + $out .= export_question_qti($q, false); |
|
234 | 234 | } |
235 | 235 | return $out; |
236 | 236 | } |
@@ -247,18 +247,18 @@ discard block |
||
247 | 247 | $head = $foot = ""; |
248 | 248 | if ($standalone) { |
249 | 249 | $head = '<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>' . "\n" |
250 | - . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
251 | - . "<questestinterop>\n"; |
|
250 | + . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
251 | + . "<questestinterop>\n"; |
|
252 | 252 | $foot = "</questestinterop>\n"; |
253 | 253 | } |
254 | 254 | $out = $head |
255 | - . $this->start_section() |
|
256 | - . $this->export_duration() |
|
257 | - . $this->export_presentation() |
|
258 | - . $this->export_ordering() |
|
259 | - . $this->export_questions() |
|
260 | - . $this->end_section() |
|
261 | - . $foot; |
|
255 | + . $this->start_section() |
|
256 | + . $this->export_duration() |
|
257 | + . $this->export_presentation() |
|
258 | + . $this->export_ordering() |
|
259 | + . $this->export_questions() |
|
260 | + . $this->end_section() |
|
261 | + . $foot; |
|
262 | 262 | |
263 | 263 | return $out; |
264 | 264 | } |
@@ -304,97 +304,97 @@ discard block |
||
304 | 304 | * @param $question The Question object we want to export. |
305 | 305 | * @author Anamd Tihon |
306 | 306 | */ |
307 | - function ImsItem($question) |
|
308 | - { |
|
307 | + function ImsItem($question) |
|
308 | + { |
|
309 | 309 | $this->question = $question; |
310 | 310 | $this->answer = $question->answer; |
311 | 311 | $this->questionIdent = "QST_" . $question->selectId() ; |
312 | - } |
|
313 | - |
|
314 | - /** |
|
315 | - * Start the XML flow. |
|
316 | - * |
|
317 | - * This opens the <item> block, with correct attributes. |
|
318 | - * |
|
319 | - * @author Amand Tihon <[email protected]> |
|
320 | - */ |
|
321 | - function start_item() |
|
322 | - { |
|
312 | + } |
|
313 | + |
|
314 | + /** |
|
315 | + * Start the XML flow. |
|
316 | + * |
|
317 | + * This opens the <item> block, with correct attributes. |
|
318 | + * |
|
319 | + * @author Amand Tihon <[email protected]> |
|
320 | + */ |
|
321 | + function start_item() |
|
322 | + { |
|
323 | 323 | return '<item title="' . cleanAttribute(formatExerciseQtiDescription($this->question->selectTitle())) . '" ident="' . $this->questionIdent . '">' . "\n"; |
324 | - } |
|
325 | - |
|
326 | - /** |
|
327 | - * End the XML flow, closing the </item> tag. |
|
328 | - * |
|
329 | - * @author Amand Tihon <[email protected]> |
|
330 | - */ |
|
331 | - function end_item() |
|
332 | - { |
|
324 | + } |
|
325 | + |
|
326 | + /** |
|
327 | + * End the XML flow, closing the </item> tag. |
|
328 | + * |
|
329 | + * @author Amand Tihon <[email protected]> |
|
330 | + */ |
|
331 | + function end_item() |
|
332 | + { |
|
333 | 333 | return "</item>\n"; |
334 | - } |
|
335 | - |
|
336 | - /** |
|
337 | - * Create the opening, with the question itself. |
|
338 | - * |
|
339 | - * This means it opens the <presentation> but doesn't close it, as this is the role of end_presentation(). |
|
340 | - * In between, the export_responses from the subclass should have been called. |
|
341 | - * |
|
342 | - * @author Amand Tihon <[email protected]> |
|
343 | - */ |
|
344 | - function start_presentation() |
|
345 | - { |
|
334 | + } |
|
335 | + |
|
336 | + /** |
|
337 | + * Create the opening, with the question itself. |
|
338 | + * |
|
339 | + * This means it opens the <presentation> but doesn't close it, as this is the role of end_presentation(). |
|
340 | + * In between, the export_responses from the subclass should have been called. |
|
341 | + * |
|
342 | + * @author Amand Tihon <[email protected]> |
|
343 | + */ |
|
344 | + function start_presentation() |
|
345 | + { |
|
346 | 346 | return '<presentation label="' . $this->questionIdent . '"><flow>' . "\n" |
347 | - . '<material><mattext>' . formatExerciseQtiDescription($this->question->selectDescription()) . "</mattext></material>\n"; |
|
348 | - } |
|
349 | - |
|
350 | - /** |
|
351 | - * End the </presentation> part, opened by export_header. |
|
352 | - * |
|
353 | - * @author Amand Tihon <[email protected]> |
|
354 | - */ |
|
355 | - function end_presentation() |
|
356 | - { |
|
347 | + . '<material><mattext>' . formatExerciseQtiDescription($this->question->selectDescription()) . "</mattext></material>\n"; |
|
348 | + } |
|
349 | + |
|
350 | + /** |
|
351 | + * End the </presentation> part, opened by export_header. |
|
352 | + * |
|
353 | + * @author Amand Tihon <[email protected]> |
|
354 | + */ |
|
355 | + function end_presentation() |
|
356 | + { |
|
357 | 357 | return "</flow></presentation>\n"; |
358 | - } |
|
359 | - |
|
360 | - /** |
|
361 | - * Start the response processing, and declare the default variable, SCORE, at 0 in the outcomes. |
|
362 | - * |
|
363 | - * @author Amand Tihon <[email protected]> |
|
364 | - */ |
|
365 | - function start_processing() |
|
366 | - { |
|
358 | + } |
|
359 | + |
|
360 | + /** |
|
361 | + * Start the response processing, and declare the default variable, SCORE, at 0 in the outcomes. |
|
362 | + * |
|
363 | + * @author Amand Tihon <[email protected]> |
|
364 | + */ |
|
365 | + function start_processing() |
|
366 | + { |
|
367 | 367 | return '<resprocessing><outcomes><decvar vartype="Integer" defaultval="0" /></outcomes>' . "\n"; |
368 | - } |
|
369 | - |
|
370 | - /** |
|
371 | - * End the response processing part. |
|
372 | - * |
|
373 | - * @author Amand Tihon <[email protected]> |
|
374 | - */ |
|
375 | - function end_processing() |
|
376 | - { |
|
368 | + } |
|
369 | + |
|
370 | + /** |
|
371 | + * End the response processing part. |
|
372 | + * |
|
373 | + * @author Amand Tihon <[email protected]> |
|
374 | + */ |
|
375 | + function end_processing() |
|
376 | + { |
|
377 | 377 | return "</resprocessing>\n"; |
378 | - } |
|
379 | - |
|
380 | - /** |
|
381 | - * Export the question as an IMS/QTI Item. |
|
382 | - * |
|
383 | - * This is a default behaviour, some classes may want to override this. |
|
384 | - * |
|
385 | - * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
386 | - * @return A string, the XML flow for an Item. |
|
387 | - * @author Amand Tihon <[email protected]> |
|
388 | - */ |
|
389 | - function export($standalone = False) |
|
390 | - { |
|
378 | + } |
|
379 | + |
|
380 | + /** |
|
381 | + * Export the question as an IMS/QTI Item. |
|
382 | + * |
|
383 | + * This is a default behaviour, some classes may want to override this. |
|
384 | + * |
|
385 | + * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
386 | + * @return A string, the XML flow for an Item. |
|
387 | + * @author Amand Tihon <[email protected]> |
|
388 | + */ |
|
389 | + function export($standalone = False) |
|
390 | + { |
|
391 | 391 | global $charset; |
392 | 392 | $head = $foot = ""; |
393 | 393 | |
394 | 394 | if ($standalone) { |
395 | 395 | $head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>' . "\n" |
396 | - . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
397 | - . "<questestinterop>\n"; |
|
396 | + . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n" |
|
397 | + . "<questestinterop>\n"; |
|
398 | 398 | $foot = "</questestinterop>\n"; |
399 | 399 | } |
400 | 400 | |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | . $this->answer->imsExportFeedback($this->questionIdent) |
410 | 410 | . $this->end_item() |
411 | 411 | . $foot; |
412 | - } |
|
412 | + } |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
@@ -447,9 +447,9 @@ discard block |
||
447 | 447 | $question->type = $qst->type; |
448 | 448 | $question->question = $qst->question; |
449 | 449 | $question->description = $qst->description; |
450 | - $question->weighting=$qst->weighting; |
|
451 | - $question->position=$qst->position; |
|
452 | - $question->picture=$qst->picture; |
|
450 | + $question->weighting=$qst->weighting; |
|
451 | + $question->position=$qst->position; |
|
452 | + $question->picture=$qst->picture; |
|
453 | 453 | $ims = new ImsAssessmentItem($question); |
454 | 454 | |
455 | 455 | return $ims->export($standalone); |
@@ -27,6 +27,7 @@ discard block |
||
27 | 27 | * @param int The JavaScript ID for this question. |
28 | 28 | * Due to the nature of interactions, we must have a natural sequence for |
29 | 29 | * questions in the generated JavaScript. |
30 | + * @param integer $js_id |
|
30 | 31 | */ |
31 | 32 | public static function export_question($questionId, $standalone = true, $js_id) |
32 | 33 | { |
@@ -687,7 +688,7 @@ discard block |
||
687 | 688 | /** |
688 | 689 | * Constructor. |
689 | 690 | * |
690 | - * @param $question The Question object we want to export. |
|
691 | + * @param ScormQuestion $question The Question object we want to export. |
|
691 | 692 | */ |
692 | 693 | public function ScormAssessmentItem($question, $standalone = false) |
693 | 694 | { |
@@ -915,7 +916,7 @@ discard block |
||
915 | 916 | * |
916 | 917 | * @param int $exerciseId The exercise to exporte |
917 | 918 | * @param boolean $standalone Wether it should include XML tag and DTD line. |
918 | - * @return The XML as a string, or an empty string if there's no exercise with given ID. |
|
919 | + * @return string XML as a string, or an empty string if there's no exercise with given ID. |
|
919 | 920 | */ |
920 | 921 | public static function export_exercise_to_scorm($exerciseId, $standalone=true) { |
921 | 922 | $exercise = new Exercise(); |
@@ -930,7 +931,7 @@ discard block |
||
930 | 931 | |
931 | 932 | /** |
932 | 933 | * Constructor. |
933 | - * @param $exe The Exercise instance to export |
|
934 | + * @param Exercise $exe The Exercise instance to export |
|
934 | 935 | * @author Amand Tihon <[email protected]> |
935 | 936 | */ |
936 | 937 | function ScormSection($exe) { |
@@ -1091,7 +1092,7 @@ discard block |
||
1091 | 1092 | * This is a default behaviour, some classes may want to override this. |
1092 | 1093 | * |
1093 | 1094 | * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
1094 | - * @return A string, the XML flow for an Item. |
|
1095 | + * @return string string, the XML flow for an Item. |
|
1095 | 1096 | */ |
1096 | 1097 | function export() |
1097 | 1098 | { |
@@ -49,86 +49,86 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | - * Include the correct answer class and create answer |
|
53 | - */ |
|
54 | - public function setAnswer() |
|
55 | - { |
|
56 | - switch ($this->type) { |
|
57 | - case MCUA: |
|
58 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
52 | + * Include the correct answer class and create answer |
|
53 | + */ |
|
54 | + public function setAnswer() |
|
55 | + { |
|
56 | + switch ($this->type) { |
|
57 | + case MCUA: |
|
58 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
59 | 59 | $this->answer->questionJSId = $this->js_id; |
60 | - break; |
|
61 | - case MCMA: |
|
60 | + break; |
|
61 | + case MCMA: |
|
62 | 62 | case GLOBAL_MULTIPLE_ANSWER: |
63 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
63 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
64 | 64 | $this->answer->questionJSId = $this->js_id; |
65 | - break; |
|
66 | - case TF: |
|
67 | - $this->answer = new ScormAnswerTrueFalse($this->id); |
|
65 | + break; |
|
66 | + case TF: |
|
67 | + $this->answer = new ScormAnswerTrueFalse($this->id); |
|
68 | 68 | $this->answer->questionJSId = $this->js_id; |
69 | - break; |
|
70 | - case FIB: |
|
71 | - $this->answer = new ScormAnswerFillInBlanks($this->id); |
|
69 | + break; |
|
70 | + case FIB: |
|
71 | + $this->answer = new ScormAnswerFillInBlanks($this->id); |
|
72 | 72 | $this->answer->questionJSId = $this->js_id; |
73 | - break; |
|
74 | - case MATCHING: |
|
73 | + break; |
|
74 | + case MATCHING: |
|
75 | 75 | case MATCHING_DRAGGABLE: |
76 | - $this->answer = new ScormAnswerMatching($this->id); |
|
76 | + $this->answer = new ScormAnswerMatching($this->id); |
|
77 | 77 | $this->answer->questionJSId = $this->js_id; |
78 | - break; |
|
78 | + break; |
|
79 | 79 | case ORAL_EXPRESSION: |
80 | - case FREE_ANSWER: |
|
81 | - $this->answer = new ScormAnswerFree($this->id); |
|
80 | + case FREE_ANSWER: |
|
81 | + $this->answer = new ScormAnswerFree($this->id); |
|
82 | 82 | $this->answer->questionJSId = $this->js_id; |
83 | - break; |
|
84 | - case HOT_SPOT: |
|
85 | - $this->answer = new ScormAnswerHotspot($this->id); |
|
83 | + break; |
|
84 | + case HOT_SPOT: |
|
85 | + $this->answer = new ScormAnswerHotspot($this->id); |
|
86 | 86 | $this->answer->questionJSId = $this->js_id; |
87 | - break; |
|
88 | - case MULTIPLE_ANSWER_COMBINATION: |
|
89 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
87 | + break; |
|
88 | + case MULTIPLE_ANSWER_COMBINATION: |
|
89 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
90 | 90 | $this->answer->questionJSId = $this->js_id; |
91 | - break; |
|
91 | + break; |
|
92 | 92 | case HOT_SPOT_ORDER: |
93 | - $this->answer = new ScormAnswerHotspot($this->id); |
|
93 | + $this->answer = new ScormAnswerHotspot($this->id); |
|
94 | 94 | $this->answer->questionJSId = $this->js_id; |
95 | - break; |
|
96 | - case HOT_SPOT_DELINEATION: |
|
97 | - $this->answer = new ScormAnswerHotspot($this->id); |
|
95 | + break; |
|
96 | + case HOT_SPOT_DELINEATION: |
|
97 | + $this->answer = new ScormAnswerHotspot($this->id); |
|
98 | 98 | $this->answer->questionJSId = $this->js_id; |
99 | - break; |
|
100 | - default : |
|
101 | - $this->answer = null; |
|
99 | + break; |
|
100 | + default : |
|
101 | + $this->answer = null; |
|
102 | 102 | $this->answer->questionJSId = $this->js_id; |
103 | - break; |
|
104 | - } |
|
103 | + break; |
|
104 | + } |
|
105 | 105 | |
106 | - return true; |
|
107 | - } |
|
106 | + return true; |
|
107 | + } |
|
108 | 108 | |
109 | - function export() |
|
110 | - { |
|
111 | - $html = $this->getQuestionHTML(); |
|
112 | - $js = $this->getQuestionJS(); |
|
109 | + function export() |
|
110 | + { |
|
111 | + $html = $this->getQuestionHTML(); |
|
112 | + $js = $this->getQuestionJS(); |
|
113 | 113 | |
114 | - if( is_object($this->answer) ) |
|
115 | - { |
|
116 | - list($js2,$html2) = $this->answer->export(); |
|
117 | - $js .= $js2; |
|
118 | - $html .= $html2; |
|
119 | - } |
|
114 | + if( is_object($this->answer) ) |
|
115 | + { |
|
116 | + list($js2,$html2) = $this->answer->export(); |
|
117 | + $js .= $js2; |
|
118 | + $html .= $html2; |
|
119 | + } |
|
120 | 120 | |
121 | - return array($js,$html); |
|
122 | - } |
|
121 | + return array($js,$html); |
|
122 | + } |
|
123 | 123 | |
124 | 124 | function createAnswersForm($form) |
125 | 125 | { |
126 | - return true; |
|
126 | + return true; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | function processAnswersCreation($form) |
130 | 130 | { |
131 | - return true; |
|
131 | + return true; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -136,20 +136,20 @@ discard block |
||
136 | 136 | */ |
137 | 137 | function getQuestionHTML() |
138 | 138 | { |
139 | - $title = $this->selectTitle(); |
|
140 | - $description = $this->selectDescription(); |
|
141 | - $cols = 2; |
|
142 | - $s='<tr>' . |
|
143 | - '<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">' . "\n" . |
|
144 | - $title. |
|
145 | - '</td>' . "\n" . |
|
146 | - '</tr>' . "\n" . |
|
147 | - '<tr>' . "\n" . |
|
148 | - '<td valign="top" colspan="'.$cols.'">' . "\n" . |
|
149 | - '<i>'.$description.'</i>' . "\n" . |
|
150 | - '</td>' . "\n" . |
|
151 | - '</tr>' . "\n"; |
|
152 | - return $s; |
|
139 | + $title = $this->selectTitle(); |
|
140 | + $description = $this->selectDescription(); |
|
141 | + $cols = 2; |
|
142 | + $s='<tr>' . |
|
143 | + '<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">' . "\n" . |
|
144 | + $title. |
|
145 | + '</td>' . "\n" . |
|
146 | + '</tr>' . "\n" . |
|
147 | + '<tr>' . "\n" . |
|
148 | + '<td valign="top" colspan="'.$cols.'">' . "\n" . |
|
149 | + '<i>'.$description.'</i>' . "\n" . |
|
150 | + '</td>' . "\n" . |
|
151 | + '</tr>' . "\n"; |
|
152 | + return $s; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -157,16 +157,16 @@ discard block |
||
157 | 157 | */ |
158 | 158 | function getQuestionJS() |
159 | 159 | { |
160 | - //$id = $this->id; |
|
161 | - $w = $this->selectWeighting(); |
|
162 | - $s = 'questions.push('.$this->js_id.');'."\n"; |
|
163 | - if($this->type == FREE_ANSWER or $this->type == HOT_SPOT) |
|
164 | - { //put the max score to 0 to avoid discounting the points of |
|
165 | - //non-exported quiz types in the SCORM |
|
166 | - $w=0; |
|
167 | - } |
|
168 | - $s .= 'questions_score_max['.$this->js_id.'] = '.$w.";\n"; |
|
169 | - return $s; |
|
160 | + //$id = $this->id; |
|
161 | + $w = $this->selectWeighting(); |
|
162 | + $s = 'questions.push('.$this->js_id.');'."\n"; |
|
163 | + if($this->type == FREE_ANSWER or $this->type == HOT_SPOT) |
|
164 | + { //put the max score to 0 to avoid discounting the points of |
|
165 | + //non-exported quiz types in the SCORM |
|
166 | + $w=0; |
|
167 | + } |
|
168 | + $s .= 'questions_score_max['.$this->js_id.'] = '.$w.";\n"; |
|
169 | + return $s; |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
@@ -177,107 +177,107 @@ discard block |
||
177 | 177 | */ |
178 | 178 | class ScormAnswerMultipleChoice extends Answer |
179 | 179 | { |
180 | - /** |
|
181 | - * Return HTML code for possible answers |
|
180 | + /** |
|
181 | + * Return HTML code for possible answers |
|
182 | 182 | */ |
183 | - function export() |
|
184 | - { |
|
185 | - $html = ''; |
|
186 | - $js = ''; |
|
187 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
188 | - $type = $this->getQuestionType(); |
|
189 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
190 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
191 | - |
|
192 | - //not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM |
|
183 | + function export() |
|
184 | + { |
|
185 | + $html = ''; |
|
186 | + $js = ''; |
|
187 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
188 | + $type = $this->getQuestionType(); |
|
189 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
190 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
191 | + |
|
192 | + //not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM |
|
193 | 193 | //if ($type == MCMA || $type == MULTIPLE_ANSWER_COMBINATION ) { |
194 | - if ($type == MCMA ) { |
|
195 | - //$questionTypeLang = get_lang('MultipleChoiceMultipleAnswers'); |
|
196 | - $id = 1; |
|
197 | - $jstmp = ''; |
|
198 | - $jstmpc = ''; |
|
199 | - foreach( $this->answer as $i => $answer ) |
|
200 | - { |
|
201 | - $identifier = 'question_'.$this->questionJSId.'_multiple_'.$i; |
|
202 | - $html .= |
|
203 | - '<tr>' . "\n" |
|
204 | - . '<td align="center" width="5%">' . "\n" |
|
205 | - . '<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />' . "\n" |
|
206 | - . '</td>' . "\n" |
|
207 | - . '<td width="95%">' . "\n" |
|
208 | - . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
209 | - . '</td>' . "\n" |
|
210 | - . '</tr>' . "\n\n"; |
|
211 | - $jstmp .= $i.','; |
|
212 | - if($this->correct[$i]) |
|
213 | - { |
|
214 | - $jstmpc .= $i.','; |
|
215 | - } |
|
216 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
|
217 | - $id++; |
|
218 | - } |
|
219 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
220 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
221 | - if ($type == MCMA) { |
|
222 | - $js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n"; |
|
223 | - } else { |
|
224 | - $js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n"; |
|
225 | - } |
|
226 | - $js .= $jstmpw; |
|
194 | + if ($type == MCMA ) { |
|
195 | + //$questionTypeLang = get_lang('MultipleChoiceMultipleAnswers'); |
|
196 | + $id = 1; |
|
197 | + $jstmp = ''; |
|
198 | + $jstmpc = ''; |
|
199 | + foreach( $this->answer as $i => $answer ) |
|
200 | + { |
|
201 | + $identifier = 'question_'.$this->questionJSId.'_multiple_'.$i; |
|
202 | + $html .= |
|
203 | + '<tr>' . "\n" |
|
204 | + . '<td align="center" width="5%">' . "\n" |
|
205 | + . '<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />' . "\n" |
|
206 | + . '</td>' . "\n" |
|
207 | + . '<td width="95%">' . "\n" |
|
208 | + . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
209 | + . '</td>' . "\n" |
|
210 | + . '</tr>' . "\n\n"; |
|
211 | + $jstmp .= $i.','; |
|
212 | + if($this->correct[$i]) |
|
213 | + { |
|
214 | + $jstmpc .= $i.','; |
|
215 | + } |
|
216 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
|
217 | + $id++; |
|
218 | + } |
|
219 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
220 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
221 | + if ($type == MCMA) { |
|
222 | + $js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n"; |
|
223 | + } else { |
|
224 | + $js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n"; |
|
225 | + } |
|
226 | + $js .= $jstmpw; |
|
227 | 227 | } elseif ($type == MULTIPLE_ANSWER_COMBINATION) { |
228 | - //To this items we show the ThisItemIsNotExportable |
|
229 | - $qId = $this->questionJSId; |
|
230 | - $js = ''; |
|
231 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
232 | - // some javascript must be added for that kind of questions |
|
233 | - $html .= '<tr>' . "\n" |
|
234 | - . '<td>' . "\n" |
|
235 | - . '<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_exact" rows="20" cols="100"></textarea>' . "\n" |
|
236 | - . '</td>' . "\n" |
|
237 | - . '</tr>' . "\n"; |
|
238 | - $html .= '</table></td></tr>' . "\n"; |
|
239 | - // currently the exact answers cannot be displayed, so ignore the textarea |
|
240 | - $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
241 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
242 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
243 | - $js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n"; |
|
244 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
245 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
246 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
247 | - $js .= $jstmpw; |
|
248 | - return array($js,$html); |
|
228 | + //To this items we show the ThisItemIsNotExportable |
|
229 | + $qId = $this->questionJSId; |
|
230 | + $js = ''; |
|
231 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
232 | + // some javascript must be added for that kind of questions |
|
233 | + $html .= '<tr>' . "\n" |
|
234 | + . '<td>' . "\n" |
|
235 | + . '<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_exact" rows="20" cols="100"></textarea>' . "\n" |
|
236 | + . '</td>' . "\n" |
|
237 | + . '</tr>' . "\n"; |
|
238 | + $html .= '</table></td></tr>' . "\n"; |
|
239 | + // currently the exact answers cannot be displayed, so ignore the textarea |
|
240 | + $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
241 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
242 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
243 | + $js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n"; |
|
244 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
245 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
246 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
247 | + $js .= $jstmpw; |
|
248 | + return array($js,$html); |
|
249 | 249 | } else { |
250 | - //$questionTypeLang = get_lang('MultipleChoiceUniqueAnswer'); |
|
251 | - $id = 1; |
|
252 | - $jstmp = ''; |
|
253 | - $jstmpc = ''; |
|
254 | - foreach( $this->answer as $i => $answer ) |
|
255 | - { |
|
256 | - $identifier = 'question_'.$this->questionJSId.'_unique_'.$i; |
|
257 | - $identifier_name = 'question_'.$this->questionJSId.'_unique_answer'; |
|
258 | - $html .= |
|
259 | - '<tr>' . "\n" |
|
260 | - . '<td align="center" width="5%">' . "\n" |
|
261 | - . '<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="radio"/>' . "\n" |
|
262 | - . '</td>' . "\n" |
|
263 | - . '<td width="95%">' . "\n" |
|
264 | - . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
265 | - . '</td>' . "\n" |
|
266 | - . '</tr>' . "\n\n"; |
|
267 | - $jstmp .= $i.','; |
|
268 | - if($this->correct[$i]) |
|
269 | - { |
|
270 | - $jstmpc .= $i; |
|
271 | - } |
|
272 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
|
273 | - $id++; |
|
274 | - } |
|
275 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
276 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = '.$jstmpc.';'."\n"; |
|
277 | - $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';'."\n"; |
|
278 | - $js .= $jstmpw; |
|
250 | + //$questionTypeLang = get_lang('MultipleChoiceUniqueAnswer'); |
|
251 | + $id = 1; |
|
252 | + $jstmp = ''; |
|
253 | + $jstmpc = ''; |
|
254 | + foreach( $this->answer as $i => $answer ) |
|
255 | + { |
|
256 | + $identifier = 'question_'.$this->questionJSId.'_unique_'.$i; |
|
257 | + $identifier_name = 'question_'.$this->questionJSId.'_unique_answer'; |
|
258 | + $html .= |
|
259 | + '<tr>' . "\n" |
|
260 | + . '<td align="center" width="5%">' . "\n" |
|
261 | + . '<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="radio"/>' . "\n" |
|
262 | + . '</td>' . "\n" |
|
263 | + . '<td width="95%">' . "\n" |
|
264 | + . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
265 | + . '</td>' . "\n" |
|
266 | + . '</tr>' . "\n\n"; |
|
267 | + $jstmp .= $i.','; |
|
268 | + if($this->correct[$i]) |
|
269 | + { |
|
270 | + $jstmpc .= $i; |
|
271 | + } |
|
272 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
|
273 | + $id++; |
|
274 | + } |
|
275 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
276 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = '.$jstmpc.';'."\n"; |
|
277 | + $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';'."\n"; |
|
278 | + $js .= $jstmpw; |
|
279 | 279 | } |
280 | - $html .= '</table></td></tr>' . "\n"; |
|
280 | + $html .= '</table></td></tr>' . "\n"; |
|
281 | 281 | return array($js,$html); |
282 | 282 | } |
283 | 283 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | */ |
289 | 289 | class ScormAnswerTrueFalse extends Answer |
290 | 290 | { |
291 | - /** |
|
291 | + /** |
|
292 | 292 | * Return the XML flow for the possible answers. |
293 | 293 | * That's one <response_lid>, containing several <flow_label> |
294 | 294 | * |
@@ -296,46 +296,46 @@ discard block |
||
296 | 296 | */ |
297 | 297 | function export() |
298 | 298 | { |
299 | - $js = ''; |
|
300 | - $html = '<tr><td colspan="2"><table width="100%">'; |
|
301 | - $identifier = 'question_'.$this->questionJSId.'_tf'; |
|
302 | - $identifier_true = $identifier.'_true'; |
|
303 | - $identifier_false = $identifier.'_false'; |
|
304 | - $html .= |
|
305 | - '<tr>' . "\n" |
|
306 | - . '<td align="center" width="5%">' . "\n" |
|
307 | - . '<input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" ' |
|
308 | - . '/>' . "\n" |
|
309 | - . '</td>' . "\n" |
|
310 | - . '<td width="95%">' . "\n" |
|
311 | - . '<label for="'.$identifier_true.'">' . get_lang('True') . '</label>' . "\n" |
|
312 | - . '</td>' . "\n" |
|
313 | - . '</tr>' . "\n\n"; |
|
314 | - $html .= |
|
315 | - '<tr>' . "\n" |
|
316 | - . '<td align="center" width="5%">' . "\n" |
|
317 | - . '<input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" ' |
|
318 | - . '/>' . "\n" |
|
319 | - . '</td>' . "\n" |
|
320 | - . '<td width="95%">' . "\n" |
|
321 | - . '<label for="'.$identifier_false.'">' . get_lang('False') . '</label>' . "\n" |
|
322 | - . '</td>' . "\n" |
|
323 | - . '</tr>' . "\n\n"; |
|
324 | - $html .= '</table></td></tr>' . "\n"; |
|
325 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n"; |
|
326 | - $js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n"; |
|
327 | - if($this->response == 'TRUE') |
|
328 | - { |
|
329 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n"; |
|
330 | - } |
|
331 | - else |
|
332 | - { |
|
333 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n"; |
|
334 | - } |
|
335 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
336 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
337 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n"; |
|
338 | - $js .= $jstmpw; |
|
299 | + $js = ''; |
|
300 | + $html = '<tr><td colspan="2"><table width="100%">'; |
|
301 | + $identifier = 'question_'.$this->questionJSId.'_tf'; |
|
302 | + $identifier_true = $identifier.'_true'; |
|
303 | + $identifier_false = $identifier.'_false'; |
|
304 | + $html .= |
|
305 | + '<tr>' . "\n" |
|
306 | + . '<td align="center" width="5%">' . "\n" |
|
307 | + . '<input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" ' |
|
308 | + . '/>' . "\n" |
|
309 | + . '</td>' . "\n" |
|
310 | + . '<td width="95%">' . "\n" |
|
311 | + . '<label for="'.$identifier_true.'">' . get_lang('True') . '</label>' . "\n" |
|
312 | + . '</td>' . "\n" |
|
313 | + . '</tr>' . "\n\n"; |
|
314 | + $html .= |
|
315 | + '<tr>' . "\n" |
|
316 | + . '<td align="center" width="5%">' . "\n" |
|
317 | + . '<input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" ' |
|
318 | + . '/>' . "\n" |
|
319 | + . '</td>' . "\n" |
|
320 | + . '<td width="95%">' . "\n" |
|
321 | + . '<label for="'.$identifier_false.'">' . get_lang('False') . '</label>' . "\n" |
|
322 | + . '</td>' . "\n" |
|
323 | + . '</tr>' . "\n\n"; |
|
324 | + $html .= '</table></td></tr>' . "\n"; |
|
325 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n"; |
|
326 | + $js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n"; |
|
327 | + if($this->response == 'TRUE') |
|
328 | + { |
|
329 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n"; |
|
330 | + } |
|
331 | + else |
|
332 | + { |
|
333 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n"; |
|
334 | + } |
|
335 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
336 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
337 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n"; |
|
338 | + $js .= $jstmpw; |
|
339 | 339 | |
340 | 340 | return array($js,$html); |
341 | 341 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | */ |
348 | 348 | class ScormAnswerFillInBlanks extends Answer |
349 | 349 | { |
350 | - /** |
|
350 | + /** |
|
351 | 351 | * Export the text with missing words. |
352 | 352 | * |
353 | 353 | * As a side effect, it stores two lists in the class : |
@@ -355,57 +355,57 @@ discard block |
||
355 | 355 | */ |
356 | 356 | function export() |
357 | 357 | { |
358 | - global $charset; |
|
359 | - $js = ''; |
|
360 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
361 | - // get all enclosed answers |
|
362 | - $blankList = array(); |
|
363 | - // build replacement |
|
364 | - $replacementList = array(); |
|
365 | - foreach( $this->answer as $i => $answer) { |
|
366 | - $blankList[] = '['.$answer.']'; |
|
367 | - } |
|
368 | - $answerCount = count($blankList); |
|
369 | - |
|
370 | - // splits text and weightings that are joined with the character '::' |
|
371 | - list($answer,$weight)=explode('::',$answer); |
|
372 | - $weights = explode(',',$weight); |
|
373 | - // because [] is parsed here we follow this procedure: |
|
374 | - // 1. find everything between the [ and ] tags |
|
375 | - $i=1; |
|
376 | - $jstmp = ''; |
|
377 | - $jstmpc = ''; |
|
378 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
379 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
380 | - $startlocations=api_strpos($answer,'['); |
|
381 | - $endlocations=api_strpos($answer,']'); |
|
382 | - while($startlocations !== false && $endlocations !== false) { |
|
383 | - $texstring=api_substr($answer,$startlocations,($endlocations-$startlocations)+1); |
|
384 | - $answer = api_substr_replace($answer,'<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',$startlocations,($endlocations-$startlocations)+1); |
|
385 | - $jstmp .= $i.','; |
|
386 | - $jstmpc .= "'".api_htmlentities(api_substr($texstring,1,-1),ENT_QUOTES,$charset)."',"; |
|
387 | - $my_weight=explode('@',$weights[$i-1]); |
|
388 | - if (count($my_weight)==2) { |
|
389 | - $weight_db=$my_weight[0]; |
|
390 | - } else { |
|
391 | - $weight_db=$my_weight[0]; |
|
392 | - } |
|
393 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n"; |
|
394 | - $i++; |
|
395 | - $startlocations=api_strpos($answer,'['); |
|
396 | - $endlocations=api_strpos($answer,']'); |
|
397 | - } |
|
358 | + global $charset; |
|
359 | + $js = ''; |
|
360 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
361 | + // get all enclosed answers |
|
362 | + $blankList = array(); |
|
363 | + // build replacement |
|
364 | + $replacementList = array(); |
|
365 | + foreach( $this->answer as $i => $answer) { |
|
366 | + $blankList[] = '['.$answer.']'; |
|
367 | + } |
|
368 | + $answerCount = count($blankList); |
|
369 | + |
|
370 | + // splits text and weightings that are joined with the character '::' |
|
371 | + list($answer,$weight)=explode('::',$answer); |
|
372 | + $weights = explode(',',$weight); |
|
373 | + // because [] is parsed here we follow this procedure: |
|
374 | + // 1. find everything between the [ and ] tags |
|
375 | + $i=1; |
|
376 | + $jstmp = ''; |
|
377 | + $jstmpc = ''; |
|
378 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
379 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
380 | + $startlocations=api_strpos($answer,'['); |
|
381 | + $endlocations=api_strpos($answer,']'); |
|
382 | + while($startlocations !== false && $endlocations !== false) { |
|
383 | + $texstring=api_substr($answer,$startlocations,($endlocations-$startlocations)+1); |
|
384 | + $answer = api_substr_replace($answer,'<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',$startlocations,($endlocations-$startlocations)+1); |
|
385 | + $jstmp .= $i.','; |
|
386 | + $jstmpc .= "'".api_htmlentities(api_substr($texstring,1,-1),ENT_QUOTES,$charset)."',"; |
|
387 | + $my_weight=explode('@',$weights[$i-1]); |
|
388 | + if (count($my_weight)==2) { |
|
389 | + $weight_db=$my_weight[0]; |
|
390 | + } else { |
|
391 | + $weight_db=$my_weight[0]; |
|
392 | + } |
|
393 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n"; |
|
394 | + $i++; |
|
395 | + $startlocations=api_strpos($answer,'['); |
|
396 | + $endlocations=api_strpos($answer,']'); |
|
397 | + } |
|
398 | 398 | |
399 | - $html .= '<tr>' . "\n" |
|
400 | - . '<td>' . "\n" |
|
401 | - . $answer . "\n" |
|
402 | - . '</td>' . "\n" |
|
403 | - . '</tr>' . "\n"; |
|
404 | - $html .= '</table></td></tr>' . "\n"; |
|
405 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n"; |
|
406 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n"; |
|
407 | - $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n"; |
|
408 | - $js .= $jstmpw; |
|
399 | + $html .= '<tr>' . "\n" |
|
400 | + . '<td>' . "\n" |
|
401 | + . $answer . "\n" |
|
402 | + . '</td>' . "\n" |
|
403 | + . '</tr>' . "\n"; |
|
404 | + $html .= '</table></td></tr>' . "\n"; |
|
405 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n"; |
|
406 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n"; |
|
407 | + $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n"; |
|
408 | + $js .= $jstmpw; |
|
409 | 409 | return array($js,$html); |
410 | 410 | } |
411 | 411 | } |
@@ -416,101 +416,101 @@ discard block |
||
416 | 416 | */ |
417 | 417 | class ScormAnswerMatching extends Answer |
418 | 418 | { |
419 | - /** |
|
419 | + /** |
|
420 | 420 | * Export the question part as a matrix-choice, with only one possible answer per line. |
421 | 421 | * @author Amand Tihon <[email protected]> |
422 | 422 | */ |
423 | 423 | function export() |
424 | 424 | { |
425 | - $js = ''; |
|
426 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
427 | - // prepare list of right proposition to allow |
|
428 | - // - easiest display |
|
429 | - // - easiest randomisation if needed one day |
|
430 | - // (here I use array_values to change array keys from $code1 $code2 ... to 0 1 ...) |
|
431 | - if (is_array($this->rightList)) { |
|
432 | - $displayedRightList = array_values($this->rightList); |
|
433 | - } |
|
434 | - // get max length of displayed array |
|
435 | - $arrayLength = max( count($this->leftList), count($this->rightList) ); |
|
436 | - |
|
437 | - $nbrAnswers=$this->selectNbrAnswers(); |
|
438 | - $cpt1='A'; |
|
439 | - $cpt2=1; |
|
440 | - $Select=array(); |
|
441 | - $qId = $this->questionJSId; |
|
442 | - $s = ''; |
|
443 | - $jstmp = ''; |
|
444 | - $jstmpc = ''; |
|
425 | + $js = ''; |
|
426 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
427 | + // prepare list of right proposition to allow |
|
428 | + // - easiest display |
|
429 | + // - easiest randomisation if needed one day |
|
430 | + // (here I use array_values to change array keys from $code1 $code2 ... to 0 1 ...) |
|
431 | + if (is_array($this->rightList)) { |
|
432 | + $displayedRightList = array_values($this->rightList); |
|
433 | + } |
|
434 | + // get max length of displayed array |
|
435 | + $arrayLength = max( count($this->leftList), count($this->rightList) ); |
|
436 | + |
|
437 | + $nbrAnswers=$this->selectNbrAnswers(); |
|
438 | + $cpt1='A'; |
|
439 | + $cpt2=1; |
|
440 | + $Select=array(); |
|
441 | + $qId = $this->questionJSId; |
|
442 | + $s = ''; |
|
443 | + $jstmp = ''; |
|
444 | + $jstmpc = ''; |
|
445 | 445 | $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
446 | 446 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
447 | 447 | |
448 | - for($answerId=1;$answerId <= $nbrAnswers;$answerId++) { |
|
449 | - $identifier = 'question_'.$qId.'_matching_'; |
|
450 | - $answer=$this->selectAnswer($answerId); |
|
451 | - $answerCorrect=$this->isCorrect($answerId); |
|
452 | - $weight=$this->selectWeighting($answerId); |
|
453 | - $jstmp .= $answerId.','; |
|
454 | - |
|
455 | - if (!$answerCorrect) { |
|
456 | - // options (A, B, C, ...) that will be put into the list-box |
|
457 | - $Select[$answerId]['Lettre']=$cpt1; |
|
458 | - // answers that will be shown at the right side |
|
459 | - $Select[$answerId]['Reponse'] = $answer; |
|
460 | - $cpt1++; |
|
461 | - } else { |
|
462 | - $s.='<tr>'."\n"; |
|
463 | - $s.='<td width="40%" valign="top">'."\n".'<b>'.$cpt2.'</b>. '.$answer."\n</td>\n"; |
|
464 | - $s.='<td width="20%" align="center"> <select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">'; |
|
465 | - $s.=' <option value="0">--</option>'; |
|
466 | - // fills the list-box |
|
467 | - foreach($Select as $key=>$val) |
|
468 | - { |
|
469 | - $s.='<option value="'.$key.'">'.$val['Lettre'].'</option>'; |
|
470 | - } // end foreach() |
|
471 | - |
|
472 | - $s.='</select> </td>'."\n"; |
|
473 | - $s.='<td width="40%" valign="top">'; |
|
474 | - if(isset($Select[$cpt2])) $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
475 | - else $s.=' '; |
|
476 | - $s.="</td>\n</tr>\n"; |
|
477 | - |
|
478 | - $jstmpc .= '['.$answerCorrect.','.$cpt2.'],'; |
|
479 | - |
|
480 | - $my_weight=explode('@',$weight); |
|
481 | - if (count($my_weight)==2) { |
|
482 | - $weight=$my_weight[0]; |
|
483 | - } else { |
|
484 | - $weight=$my_weight[0]; |
|
485 | - } |
|
486 | - $jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n"; |
|
487 | - $cpt2++; |
|
488 | - |
|
489 | - // if the left side of the "matching" has been completely shown |
|
490 | - if($answerId == $nbrAnswers) |
|
491 | - { |
|
492 | - // if there remain answers to be shown on the right side |
|
493 | - while(isset($Select[$cpt2])) |
|
494 | - { |
|
495 | - //$s.='<tr>'."\n"; |
|
496 | - //$s.='<td colspan="2">'."\n"; |
|
497 | - //$s.='<table border="0" cellpadding="0" cellspacing="0" width="100%">'."\n"; |
|
498 | - $s.='<tr>'."\n"; |
|
499 | - $s.='<td width="60%" colspan="2"> </td>'."\n"; |
|
500 | - $s.='<td width="40%" valign="top">'; |
|
501 | - $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
502 | - $s.="</td>\n</tr>\n"; |
|
503 | - $cpt2++; |
|
504 | - } // end while() |
|
505 | - } // end if() |
|
506 | - } |
|
507 | - } |
|
508 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
509 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
510 | - $js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n"; |
|
511 | - $js .= $jstmpw; |
|
512 | - $html .= $s; |
|
513 | - $html .= '</table></td></tr>' . "\n"; |
|
448 | + for($answerId=1;$answerId <= $nbrAnswers;$answerId++) { |
|
449 | + $identifier = 'question_'.$qId.'_matching_'; |
|
450 | + $answer=$this->selectAnswer($answerId); |
|
451 | + $answerCorrect=$this->isCorrect($answerId); |
|
452 | + $weight=$this->selectWeighting($answerId); |
|
453 | + $jstmp .= $answerId.','; |
|
454 | + |
|
455 | + if (!$answerCorrect) { |
|
456 | + // options (A, B, C, ...) that will be put into the list-box |
|
457 | + $Select[$answerId]['Lettre']=$cpt1; |
|
458 | + // answers that will be shown at the right side |
|
459 | + $Select[$answerId]['Reponse'] = $answer; |
|
460 | + $cpt1++; |
|
461 | + } else { |
|
462 | + $s.='<tr>'."\n"; |
|
463 | + $s.='<td width="40%" valign="top">'."\n".'<b>'.$cpt2.'</b>. '.$answer."\n</td>\n"; |
|
464 | + $s.='<td width="20%" align="center"> <select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">'; |
|
465 | + $s.=' <option value="0">--</option>'; |
|
466 | + // fills the list-box |
|
467 | + foreach($Select as $key=>$val) |
|
468 | + { |
|
469 | + $s.='<option value="'.$key.'">'.$val['Lettre'].'</option>'; |
|
470 | + } // end foreach() |
|
471 | + |
|
472 | + $s.='</select> </td>'."\n"; |
|
473 | + $s.='<td width="40%" valign="top">'; |
|
474 | + if(isset($Select[$cpt2])) $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
475 | + else $s.=' '; |
|
476 | + $s.="</td>\n</tr>\n"; |
|
477 | + |
|
478 | + $jstmpc .= '['.$answerCorrect.','.$cpt2.'],'; |
|
479 | + |
|
480 | + $my_weight=explode('@',$weight); |
|
481 | + if (count($my_weight)==2) { |
|
482 | + $weight=$my_weight[0]; |
|
483 | + } else { |
|
484 | + $weight=$my_weight[0]; |
|
485 | + } |
|
486 | + $jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n"; |
|
487 | + $cpt2++; |
|
488 | + |
|
489 | + // if the left side of the "matching" has been completely shown |
|
490 | + if($answerId == $nbrAnswers) |
|
491 | + { |
|
492 | + // if there remain answers to be shown on the right side |
|
493 | + while(isset($Select[$cpt2])) |
|
494 | + { |
|
495 | + //$s.='<tr>'."\n"; |
|
496 | + //$s.='<td colspan="2">'."\n"; |
|
497 | + //$s.='<table border="0" cellpadding="0" cellspacing="0" width="100%">'."\n"; |
|
498 | + $s.='<tr>'."\n"; |
|
499 | + $s.='<td width="60%" colspan="2"> </td>'."\n"; |
|
500 | + $s.='<td width="40%" valign="top">'; |
|
501 | + $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
502 | + $s.="</td>\n</tr>\n"; |
|
503 | + $cpt2++; |
|
504 | + } // end while() |
|
505 | + } // end if() |
|
506 | + } |
|
507 | + } |
|
508 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
509 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
510 | + $js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n"; |
|
511 | + $js .= $jstmpw; |
|
512 | + $html .= $s; |
|
513 | + $html .= '</table></td></tr>' . "\n"; |
|
514 | 514 | |
515 | 515 | return array($js,$html); |
516 | 516 | } |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | */ |
523 | 523 | class ScormAnswerFree extends Answer |
524 | 524 | { |
525 | - /** |
|
525 | + /** |
|
526 | 526 | * Export the text with missing words. |
527 | 527 | * |
528 | 528 | * As a side effect, it stores two lists in the class : |
@@ -531,67 +531,67 @@ discard block |
||
531 | 531 | */ |
532 | 532 | function export() |
533 | 533 | { |
534 | - //$qId = $this->questionJSId; |
|
535 | - $js = ''; |
|
536 | - /*$html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
534 | + //$qId = $this->questionJSId; |
|
535 | + $js = ''; |
|
536 | + /*$html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
537 | 537 | // some javascript must be added for that kind of questions |
538 | 538 | $html .= '<tr><td> |
539 | 539 | <textarea name="question_'.$qId.'_free" id="question_'.$qId.'_free" rows="20" cols="100"></textarea> |
540 | 540 | </td> |
541 | 541 | </tr>'; |
542 | 542 | $html .= '</table></td></tr>';*/ |
543 | - // currently the free answers cannot be displayed, so ignore the textarea |
|
544 | - $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
545 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
546 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
547 | - $js .= 'questions_types['.$this->questionJSId.'] = \'free\';'."\n"; |
|
548 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
549 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
550 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
551 | - $js .= $jstmpw; |
|
543 | + // currently the free answers cannot be displayed, so ignore the textarea |
|
544 | + $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
545 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
546 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
547 | + $js .= 'questions_types['.$this->questionJSId.'] = \'free\';'."\n"; |
|
548 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
549 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
550 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
551 | + $js .= $jstmpw; |
|
552 | 552 | return array($js,$html); |
553 | 553 | } |
554 | 554 | } |
555 | 555 | /** |
556 | - * This class handles the SCORM export of hotpot questions |
|
557 | - * @package chamilo.exercise.scorm |
|
558 | - */ |
|
556 | + * This class handles the SCORM export of hotpot questions |
|
557 | + * @package chamilo.exercise.scorm |
|
558 | + */ |
|
559 | 559 | class ScormAnswerHotspot extends Answer |
560 | 560 | { |
561 | - /** |
|
562 | - * Returns the javascript code that goes with HotSpot exercises |
|
563 | - * @return string The JavaScript code |
|
564 | - */ |
|
565 | - function get_js_header() |
|
566 | - { |
|
567 | - if ($this->standalone) { |
|
568 | - $header = '<script type="text/javascript" language="javascript">'; |
|
569 | - $header .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js'); |
|
570 | - $header .= '</script>'; |
|
571 | - //because this header closes so many times the <script> tag, we have to reopen our own |
|
572 | - $header .= '<script type="text/javascript" language="javascript">'."\n"; |
|
573 | - $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
574 | - $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
575 | - $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
576 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
577 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
578 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
579 | - $header .= $jstmpw; |
|
580 | - } |
|
581 | - else |
|
582 | - { |
|
583 | - $header = ''; |
|
584 | - $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
585 | - $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
586 | - $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
587 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
588 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
589 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'."\n"; |
|
590 | - $header .= $jstmpw; |
|
591 | - } |
|
592 | - return $header; |
|
593 | - } |
|
594 | - /** |
|
561 | + /** |
|
562 | + * Returns the javascript code that goes with HotSpot exercises |
|
563 | + * @return string The JavaScript code |
|
564 | + */ |
|
565 | + function get_js_header() |
|
566 | + { |
|
567 | + if ($this->standalone) { |
|
568 | + $header = '<script type="text/javascript" language="javascript">'; |
|
569 | + $header .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js'); |
|
570 | + $header .= '</script>'; |
|
571 | + //because this header closes so many times the <script> tag, we have to reopen our own |
|
572 | + $header .= '<script type="text/javascript" language="javascript">'."\n"; |
|
573 | + $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
574 | + $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
575 | + $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
576 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
577 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
578 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
579 | + $header .= $jstmpw; |
|
580 | + } |
|
581 | + else |
|
582 | + { |
|
583 | + $header = ''; |
|
584 | + $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
585 | + $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
586 | + $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
587 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
588 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
589 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'."\n"; |
|
590 | + $header .= $jstmpw; |
|
591 | + } |
|
592 | + return $header; |
|
593 | + } |
|
594 | + /** |
|
595 | 595 | * Export the text with missing words. |
596 | 596 | * |
597 | 597 | * As a side effect, it stores two lists in the class : |
@@ -600,22 +600,22 @@ discard block |
||
600 | 600 | */ |
601 | 601 | function export() |
602 | 602 | { |
603 | - $js = $this->get_js_header(); |
|
604 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
605 | - // some javascript must be added for that kind of questions |
|
606 | - $html .= ''; |
|
603 | + $js = $this->get_js_header(); |
|
604 | + $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
605 | + // some javascript must be added for that kind of questions |
|
606 | + $html .= ''; |
|
607 | 607 | |
608 | - // Get the answers, make a list |
|
609 | - $nbrAnswers=$this->selectNbrAnswers(); |
|
608 | + // Get the answers, make a list |
|
609 | + $nbrAnswers=$this->selectNbrAnswers(); |
|
610 | 610 | |
611 | - $answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>'; |
|
612 | - for($answerId=1;$answerId <= $nbrAnswers;$answerId++) |
|
613 | - { |
|
614 | - $answer_list .= '<li>'.$this->selectAnswer($answerId).'</li>'; |
|
615 | - } |
|
616 | - $answer_list .= '</ol></div>'; |
|
611 | + $answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>'; |
|
612 | + for($answerId=1;$answerId <= $nbrAnswers;$answerId++) |
|
613 | + { |
|
614 | + $answer_list .= '<li>'.$this->selectAnswer($answerId).'</li>'; |
|
615 | + } |
|
616 | + $answer_list .= '</ol></div>'; |
|
617 | 617 | |
618 | - /* |
|
618 | + /* |
|
619 | 619 | if(!$onlyAnswers) |
620 | 620 | { |
621 | 621 | $s="<tr> |
@@ -633,11 +633,11 @@ discard block |
||
633 | 633 | } |
634 | 634 | */ |
635 | 635 | |
636 | - //$canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1'); |
|
637 | - $canClick = true; |
|
638 | - //$tes = isset($_GET['modifyAnswers']) ? '0' : '1'; |
|
639 | - //echo $tes; |
|
640 | - $relPath = api_get_path(REL_PATH); |
|
636 | + //$canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1'); |
|
637 | + $canClick = true; |
|
638 | + //$tes = isset($_GET['modifyAnswers']) ? '0' : '1'; |
|
639 | + //echo $tes; |
|
640 | + $relPath = api_get_path(REL_PATH); |
|
641 | 641 | $html .= <<<HTML |
642 | 642 | <tr> |
643 | 643 | <td> |
@@ -658,10 +658,10 @@ discard block |
||
658 | 658 | </td> |
659 | 659 | <tr> |
660 | 660 | HTML; |
661 | - $html .= '</table></td></tr>' . "\n"; |
|
661 | + $html .= '</table></td></tr>' . "\n"; |
|
662 | 662 | |
663 | - // currently the free answers cannot be displayed, so ignore the textarea |
|
664 | - $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
663 | + // currently the free answers cannot be displayed, so ignore the textarea |
|
664 | + $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
665 | 665 | return array($js,$html); |
666 | 666 | } |
667 | 667 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | { |
33 | 33 | $question = new ScormQuestion(); |
34 | 34 | $qst = $question->read($questionId); |
35 | - if( !$qst ) { |
|
35 | + if (!$qst) { |
|
36 | 36 | return ''; |
37 | 37 | } |
38 | 38 | $question->id = $qst->id; |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | $question->type = $qst->type; |
41 | 41 | $question->question = $qst->question; |
42 | 42 | $question->description = $qst->description; |
43 | - $question->weighting=$qst->weighting; |
|
44 | - $question->position=$qst->position; |
|
45 | - $question->picture=$qst->picture; |
|
43 | + $question->weighting = $qst->weighting; |
|
44 | + $question->position = $qst->position; |
|
45 | + $question->picture = $qst->picture; |
|
46 | 46 | $assessmentItem = new ScormAssessmentItem($question, $standalone); |
47 | 47 | //echo "<pre>".print_r($scorm,1)."</pre>";exit; |
48 | 48 | return $assessmentItem->export(); |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | $html = $this->getQuestionHTML(); |
112 | 112 | $js = $this->getQuestionJS(); |
113 | 113 | |
114 | - if( is_object($this->answer) ) |
|
114 | + if (is_object($this->answer)) |
|
115 | 115 | { |
116 | - list($js2,$html2) = $this->answer->export(); |
|
116 | + list($js2, $html2) = $this->answer->export(); |
|
117 | 117 | $js .= $js2; |
118 | 118 | $html .= $html2; |
119 | 119 | } |
120 | 120 | |
121 | - return array($js,$html); |
|
121 | + return array($js, $html); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | function createAnswersForm($form) |
@@ -136,19 +136,19 @@ discard block |
||
136 | 136 | */ |
137 | 137 | function getQuestionHTML() |
138 | 138 | { |
139 | - $title = $this->selectTitle(); |
|
140 | - $description = $this->selectDescription(); |
|
139 | + $title = $this->selectTitle(); |
|
140 | + $description = $this->selectDescription(); |
|
141 | 141 | $cols = 2; |
142 | - $s='<tr>' . |
|
143 | - '<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">' . "\n" . |
|
142 | + $s = '<tr>'. |
|
143 | + '<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">'."\n". |
|
144 | 144 | $title. |
145 | - '</td>' . "\n" . |
|
146 | - '</tr>' . "\n" . |
|
147 | - '<tr>' . "\n" . |
|
148 | - '<td valign="top" colspan="'.$cols.'">' . "\n" . |
|
149 | - '<i>'.$description.'</i>' . "\n" . |
|
150 | - '</td>' . "\n" . |
|
151 | - '</tr>' . "\n"; |
|
145 | + '</td>'."\n". |
|
146 | + '</tr>'."\n". |
|
147 | + '<tr>'."\n". |
|
148 | + '<td valign="top" colspan="'.$cols.'">'."\n". |
|
149 | + '<i>'.$description.'</i>'."\n". |
|
150 | + '</td>'."\n". |
|
151 | + '</tr>'."\n"; |
|
152 | 152 | return $s; |
153 | 153 | } |
154 | 154 | |
@@ -160,10 +160,10 @@ discard block |
||
160 | 160 | //$id = $this->id; |
161 | 161 | $w = $this->selectWeighting(); |
162 | 162 | $s = 'questions.push('.$this->js_id.');'."\n"; |
163 | - if($this->type == FREE_ANSWER or $this->type == HOT_SPOT) |
|
163 | + if ($this->type == FREE_ANSWER or $this->type == HOT_SPOT) |
|
164 | 164 | { //put the max score to 0 to avoid discounting the points of |
165 | 165 | //non-exported quiz types in the SCORM |
166 | - $w=0; |
|
166 | + $w = 0; |
|
167 | 167 | } |
168 | 168 | $s .= 'questions_score_max['.$this->js_id.'] = '.$w.";\n"; |
169 | 169 | return $s; |
@@ -184,40 +184,40 @@ discard block |
||
184 | 184 | { |
185 | 185 | $html = ''; |
186 | 186 | $js = ''; |
187 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
187 | + $html = '<tr><td colspan="2"><table width="100%">'."\n"; |
|
188 | 188 | $type = $this->getQuestionType(); |
189 | 189 | $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
190 | 190 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
191 | 191 | |
192 | 192 | //not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM |
193 | 193 | //if ($type == MCMA || $type == MULTIPLE_ANSWER_COMBINATION ) { |
194 | - if ($type == MCMA ) { |
|
194 | + if ($type == MCMA) { |
|
195 | 195 | //$questionTypeLang = get_lang('MultipleChoiceMultipleAnswers'); |
196 | 196 | $id = 1; |
197 | 197 | $jstmp = ''; |
198 | 198 | $jstmpc = ''; |
199 | - foreach( $this->answer as $i => $answer ) |
|
199 | + foreach ($this->answer as $i => $answer) |
|
200 | 200 | { |
201 | 201 | $identifier = 'question_'.$this->questionJSId.'_multiple_'.$i; |
202 | 202 | $html .= |
203 | - '<tr>' . "\n" |
|
204 | - . '<td align="center" width="5%">' . "\n" |
|
205 | - . '<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />' . "\n" |
|
206 | - . '</td>' . "\n" |
|
207 | - . '<td width="95%">' . "\n" |
|
208 | - . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
209 | - . '</td>' . "\n" |
|
210 | - . '</tr>' . "\n\n"; |
|
203 | + '<tr>'."\n" |
|
204 | + . '<td align="center" width="5%">'."\n" |
|
205 | + . '<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />'."\n" |
|
206 | + . '</td>'."\n" |
|
207 | + . '<td width="95%">'."\n" |
|
208 | + . '<label for="'.$identifier.'">'.$this->answer[$i].'</label>'."\n" |
|
209 | + . '</td>'."\n" |
|
210 | + . '</tr>'."\n\n"; |
|
211 | 211 | $jstmp .= $i.','; |
212 | - if($this->correct[$i]) |
|
212 | + if ($this->correct[$i]) |
|
213 | 213 | { |
214 | 214 | $jstmpc .= $i.','; |
215 | 215 | } |
216 | 216 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
217 | 217 | $id++; |
218 | 218 | } |
219 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
220 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
219 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp, 0, -1).');'."\n"; |
|
220 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc, 0, -1).');'."\n"; |
|
221 | 221 | if ($type == MCMA) { |
222 | 222 | $js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n"; |
223 | 223 | } else { |
@@ -228,14 +228,14 @@ discard block |
||
228 | 228 | //To this items we show the ThisItemIsNotExportable |
229 | 229 | $qId = $this->questionJSId; |
230 | 230 | $js = ''; |
231 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
231 | + $html = '<tr><td colspan="2"><table width="100%">'."\n"; |
|
232 | 232 | // some javascript must be added for that kind of questions |
233 | - $html .= '<tr>' . "\n" |
|
234 | - . '<td>' . "\n" |
|
235 | - . '<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_exact" rows="20" cols="100"></textarea>' . "\n" |
|
236 | - . '</td>' . "\n" |
|
237 | - . '</tr>' . "\n"; |
|
238 | - $html .= '</table></td></tr>' . "\n"; |
|
233 | + $html .= '<tr>'."\n" |
|
234 | + . '<td>'."\n" |
|
235 | + . '<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_exact" rows="20" cols="100"></textarea>'."\n" |
|
236 | + . '</td>'."\n" |
|
237 | + . '</tr>'."\n"; |
|
238 | + $html .= '</table></td></tr>'."\n"; |
|
239 | 239 | // currently the exact answers cannot be displayed, so ignore the textarea |
240 | 240 | $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
241 | 241 | $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
@@ -245,40 +245,40 @@ discard block |
||
245 | 245 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
246 | 246 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
247 | 247 | $js .= $jstmpw; |
248 | - return array($js,$html); |
|
248 | + return array($js, $html); |
|
249 | 249 | } else { |
250 | 250 | //$questionTypeLang = get_lang('MultipleChoiceUniqueAnswer'); |
251 | 251 | $id = 1; |
252 | 252 | $jstmp = ''; |
253 | 253 | $jstmpc = ''; |
254 | - foreach( $this->answer as $i => $answer ) |
|
254 | + foreach ($this->answer as $i => $answer) |
|
255 | 255 | { |
256 | 256 | $identifier = 'question_'.$this->questionJSId.'_unique_'.$i; |
257 | 257 | $identifier_name = 'question_'.$this->questionJSId.'_unique_answer'; |
258 | 258 | $html .= |
259 | - '<tr>' . "\n" |
|
260 | - . '<td align="center" width="5%">' . "\n" |
|
261 | - . '<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="radio"/>' . "\n" |
|
262 | - . '</td>' . "\n" |
|
263 | - . '<td width="95%">' . "\n" |
|
264 | - . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n" |
|
265 | - . '</td>' . "\n" |
|
266 | - . '</tr>' . "\n\n"; |
|
259 | + '<tr>'."\n" |
|
260 | + . '<td align="center" width="5%">'."\n" |
|
261 | + . '<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="radio"/>'."\n" |
|
262 | + . '</td>'."\n" |
|
263 | + . '<td width="95%">'."\n" |
|
264 | + . '<label for="'.$identifier.'">'.$this->answer[$i].'</label>'."\n" |
|
265 | + . '</td>'."\n" |
|
266 | + . '</tr>'."\n\n"; |
|
267 | 267 | $jstmp .= $i.','; |
268 | - if($this->correct[$i]) |
|
268 | + if ($this->correct[$i]) |
|
269 | 269 | { |
270 | 270 | $jstmpc .= $i; |
271 | 271 | } |
272 | 272 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n"; |
273 | 273 | $id++; |
274 | 274 | } |
275 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
275 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp, 0, -1).');'."\n"; |
|
276 | 276 | $js .= 'questions_answers_correct['.$this->questionJSId.'] = '.$jstmpc.';'."\n"; |
277 | 277 | $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';'."\n"; |
278 | 278 | $js .= $jstmpw; |
279 | 279 | } |
280 | - $html .= '</table></td></tr>' . "\n"; |
|
281 | - return array($js,$html); |
|
280 | + $html .= '</table></td></tr>'."\n"; |
|
281 | + return array($js, $html); |
|
282 | 282 | } |
283 | 283 | } |
284 | 284 | |
@@ -302,29 +302,29 @@ discard block |
||
302 | 302 | $identifier_true = $identifier.'_true'; |
303 | 303 | $identifier_false = $identifier.'_false'; |
304 | 304 | $html .= |
305 | - '<tr>' . "\n" |
|
306 | - . '<td align="center" width="5%">' . "\n" |
|
305 | + '<tr>'."\n" |
|
306 | + . '<td align="center" width="5%">'."\n" |
|
307 | 307 | . '<input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" ' |
308 | - . '/>' . "\n" |
|
309 | - . '</td>' . "\n" |
|
310 | - . '<td width="95%">' . "\n" |
|
311 | - . '<label for="'.$identifier_true.'">' . get_lang('True') . '</label>' . "\n" |
|
312 | - . '</td>' . "\n" |
|
313 | - . '</tr>' . "\n\n"; |
|
308 | + . '/>'."\n" |
|
309 | + . '</td>'."\n" |
|
310 | + . '<td width="95%">'."\n" |
|
311 | + . '<label for="'.$identifier_true.'">'.get_lang('True').'</label>'."\n" |
|
312 | + . '</td>'."\n" |
|
313 | + . '</tr>'."\n\n"; |
|
314 | 314 | $html .= |
315 | - '<tr>' . "\n" |
|
316 | - . '<td align="center" width="5%">' . "\n" |
|
315 | + '<tr>'."\n" |
|
316 | + . '<td align="center" width="5%">'."\n" |
|
317 | 317 | . '<input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" ' |
318 | - . '/>' . "\n" |
|
319 | - . '</td>' . "\n" |
|
320 | - . '<td width="95%">' . "\n" |
|
321 | - . '<label for="'.$identifier_false.'">' . get_lang('False') . '</label>' . "\n" |
|
322 | - . '</td>' . "\n" |
|
323 | - . '</tr>' . "\n\n"; |
|
324 | - $html .= '</table></td></tr>' . "\n"; |
|
318 | + . '/>'."\n" |
|
319 | + . '</td>'."\n" |
|
320 | + . '<td width="95%">'."\n" |
|
321 | + . '<label for="'.$identifier_false.'">'.get_lang('False').'</label>'."\n" |
|
322 | + . '</td>'."\n" |
|
323 | + . '</tr>'."\n\n"; |
|
324 | + $html .= '</table></td></tr>'."\n"; |
|
325 | 325 | $js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n"; |
326 | 326 | $js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n"; |
327 | - if($this->response == 'TRUE') |
|
327 | + if ($this->response == 'TRUE') |
|
328 | 328 | { |
329 | 329 | $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n"; |
330 | 330 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n"; |
338 | 338 | $js .= $jstmpw; |
339 | 339 | |
340 | - return array($js,$html); |
|
340 | + return array($js, $html); |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
@@ -357,56 +357,56 @@ discard block |
||
357 | 357 | { |
358 | 358 | global $charset; |
359 | 359 | $js = ''; |
360 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
360 | + $html = '<tr><td colspan="2"><table width="100%">'."\n"; |
|
361 | 361 | // get all enclosed answers |
362 | 362 | $blankList = array(); |
363 | 363 | // build replacement |
364 | 364 | $replacementList = array(); |
365 | - foreach( $this->answer as $i => $answer) { |
|
365 | + foreach ($this->answer as $i => $answer) { |
|
366 | 366 | $blankList[] = '['.$answer.']'; |
367 | 367 | } |
368 | 368 | $answerCount = count($blankList); |
369 | 369 | |
370 | 370 | // splits text and weightings that are joined with the character '::' |
371 | - list($answer,$weight)=explode('::',$answer); |
|
372 | - $weights = explode(',',$weight); |
|
371 | + list($answer, $weight) = explode('::', $answer); |
|
372 | + $weights = explode(',', $weight); |
|
373 | 373 | // because [] is parsed here we follow this procedure: |
374 | 374 | // 1. find everything between the [ and ] tags |
375 | - $i=1; |
|
375 | + $i = 1; |
|
376 | 376 | $jstmp = ''; |
377 | 377 | $jstmpc = ''; |
378 | 378 | $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
379 | 379 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
380 | - $startlocations=api_strpos($answer,'['); |
|
381 | - $endlocations=api_strpos($answer,']'); |
|
382 | - while($startlocations !== false && $endlocations !== false) { |
|
383 | - $texstring=api_substr($answer,$startlocations,($endlocations-$startlocations)+1); |
|
384 | - $answer = api_substr_replace($answer,'<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',$startlocations,($endlocations-$startlocations)+1); |
|
380 | + $startlocations = api_strpos($answer, '['); |
|
381 | + $endlocations = api_strpos($answer, ']'); |
|
382 | + while ($startlocations !== false && $endlocations !== false) { |
|
383 | + $texstring = api_substr($answer, $startlocations, ($endlocations - $startlocations) + 1); |
|
384 | + $answer = api_substr_replace($answer, '<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />', $startlocations, ($endlocations - $startlocations) + 1); |
|
385 | 385 | $jstmp .= $i.','; |
386 | - $jstmpc .= "'".api_htmlentities(api_substr($texstring,1,-1),ENT_QUOTES,$charset)."',"; |
|
387 | - $my_weight=explode('@',$weights[$i-1]); |
|
388 | - if (count($my_weight)==2) { |
|
389 | - $weight_db=$my_weight[0]; |
|
386 | + $jstmpc .= "'".api_htmlentities(api_substr($texstring, 1, -1), ENT_QUOTES, $charset)."',"; |
|
387 | + $my_weight = explode('@', $weights[$i - 1]); |
|
388 | + if (count($my_weight) == 2) { |
|
389 | + $weight_db = $my_weight[0]; |
|
390 | 390 | } else { |
391 | - $weight_db=$my_weight[0]; |
|
391 | + $weight_db = $my_weight[0]; |
|
392 | 392 | } |
393 | 393 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n"; |
394 | 394 | $i++; |
395 | - $startlocations=api_strpos($answer,'['); |
|
396 | - $endlocations=api_strpos($answer,']'); |
|
395 | + $startlocations = api_strpos($answer, '['); |
|
396 | + $endlocations = api_strpos($answer, ']'); |
|
397 | 397 | } |
398 | 398 | |
399 | - $html .= '<tr>' . "\n" |
|
400 | - . '<td>' . "\n" |
|
401 | - . $answer . "\n" |
|
402 | - . '</td>' . "\n" |
|
403 | - . '</tr>' . "\n"; |
|
404 | - $html .= '</table></td></tr>' . "\n"; |
|
405 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n"; |
|
406 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n"; |
|
399 | + $html .= '<tr>'."\n" |
|
400 | + . '<td>'."\n" |
|
401 | + . $answer."\n" |
|
402 | + . '</td>'."\n" |
|
403 | + . '</tr>'."\n"; |
|
404 | + $html .= '</table></td></tr>'."\n"; |
|
405 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp, 0, -1).');'."\n"; |
|
406 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc, 0, -1).');'."\n"; |
|
407 | 407 | $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n"; |
408 | 408 | $js .= $jstmpw; |
409 | - return array($js,$html); |
|
409 | + return array($js, $html); |
|
410 | 410 | } |
411 | 411 | } |
412 | 412 | |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | function export() |
424 | 424 | { |
425 | 425 | $js = ''; |
426 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
426 | + $html = '<tr><td colspan="2"><table width="100%">'."\n"; |
|
427 | 427 | // prepare list of right proposition to allow |
428 | 428 | // - easiest display |
429 | 429 | // - easiest randomisation if needed one day |
@@ -432,12 +432,12 @@ discard block |
||
432 | 432 | $displayedRightList = array_values($this->rightList); |
433 | 433 | } |
434 | 434 | // get max length of displayed array |
435 | - $arrayLength = max( count($this->leftList), count($this->rightList) ); |
|
435 | + $arrayLength = max(count($this->leftList), count($this->rightList)); |
|
436 | 436 | |
437 | - $nbrAnswers=$this->selectNbrAnswers(); |
|
438 | - $cpt1='A'; |
|
439 | - $cpt2=1; |
|
440 | - $Select=array(); |
|
437 | + $nbrAnswers = $this->selectNbrAnswers(); |
|
438 | + $cpt1 = 'A'; |
|
439 | + $cpt2 = 1; |
|
440 | + $Select = array(); |
|
441 | 441 | $qId = $this->questionJSId; |
442 | 442 | $s = ''; |
443 | 443 | $jstmp = ''; |
@@ -445,74 +445,74 @@ discard block |
||
445 | 445 | $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
446 | 446 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
447 | 447 | |
448 | - for($answerId=1;$answerId <= $nbrAnswers;$answerId++) { |
|
448 | + for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) { |
|
449 | 449 | $identifier = 'question_'.$qId.'_matching_'; |
450 | - $answer=$this->selectAnswer($answerId); |
|
451 | - $answerCorrect=$this->isCorrect($answerId); |
|
452 | - $weight=$this->selectWeighting($answerId); |
|
450 | + $answer = $this->selectAnswer($answerId); |
|
451 | + $answerCorrect = $this->isCorrect($answerId); |
|
452 | + $weight = $this->selectWeighting($answerId); |
|
453 | 453 | $jstmp .= $answerId.','; |
454 | 454 | |
455 | 455 | if (!$answerCorrect) { |
456 | 456 | // options (A, B, C, ...) that will be put into the list-box |
457 | - $Select[$answerId]['Lettre']=$cpt1; |
|
457 | + $Select[$answerId]['Lettre'] = $cpt1; |
|
458 | 458 | // answers that will be shown at the right side |
459 | 459 | $Select[$answerId]['Reponse'] = $answer; |
460 | 460 | $cpt1++; |
461 | 461 | } else { |
462 | - $s.='<tr>'."\n"; |
|
463 | - $s.='<td width="40%" valign="top">'."\n".'<b>'.$cpt2.'</b>. '.$answer."\n</td>\n"; |
|
464 | - $s.='<td width="20%" align="center"> <select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">'; |
|
465 | - $s.=' <option value="0">--</option>'; |
|
462 | + $s .= '<tr>'."\n"; |
|
463 | + $s .= '<td width="40%" valign="top">'."\n".'<b>'.$cpt2.'</b>. '.$answer."\n</td>\n"; |
|
464 | + $s .= '<td width="20%" align="center"> <select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">'; |
|
465 | + $s .= ' <option value="0">--</option>'; |
|
466 | 466 | // fills the list-box |
467 | - foreach($Select as $key=>$val) |
|
467 | + foreach ($Select as $key=>$val) |
|
468 | 468 | { |
469 | - $s.='<option value="'.$key.'">'.$val['Lettre'].'</option>'; |
|
469 | + $s .= '<option value="'.$key.'">'.$val['Lettre'].'</option>'; |
|
470 | 470 | } // end foreach() |
471 | 471 | |
472 | - $s.='</select> </td>'."\n"; |
|
473 | - $s.='<td width="40%" valign="top">'; |
|
474 | - if(isset($Select[$cpt2])) $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
475 | - else $s.=' '; |
|
476 | - $s.="</td>\n</tr>\n"; |
|
472 | + $s .= '</select> </td>'."\n"; |
|
473 | + $s .= '<td width="40%" valign="top">'; |
|
474 | + if (isset($Select[$cpt2])) $s .= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
475 | + else $s .= ' '; |
|
476 | + $s .= "</td>\n</tr>\n"; |
|
477 | 477 | |
478 | 478 | $jstmpc .= '['.$answerCorrect.','.$cpt2.'],'; |
479 | 479 | |
480 | - $my_weight=explode('@',$weight); |
|
481 | - if (count($my_weight)==2) { |
|
482 | - $weight=$my_weight[0]; |
|
480 | + $my_weight = explode('@', $weight); |
|
481 | + if (count($my_weight) == 2) { |
|
482 | + $weight = $my_weight[0]; |
|
483 | 483 | } else { |
484 | - $weight=$my_weight[0]; |
|
484 | + $weight = $my_weight[0]; |
|
485 | 485 | } |
486 | 486 | $jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n"; |
487 | 487 | $cpt2++; |
488 | 488 | |
489 | 489 | // if the left side of the "matching" has been completely shown |
490 | - if($answerId == $nbrAnswers) |
|
490 | + if ($answerId == $nbrAnswers) |
|
491 | 491 | { |
492 | 492 | // if there remain answers to be shown on the right side |
493 | - while(isset($Select[$cpt2])) |
|
493 | + while (isset($Select[$cpt2])) |
|
494 | 494 | { |
495 | 495 | //$s.='<tr>'."\n"; |
496 | 496 | //$s.='<td colspan="2">'."\n"; |
497 | 497 | //$s.='<table border="0" cellpadding="0" cellspacing="0" width="100%">'."\n"; |
498 | - $s.='<tr>'."\n"; |
|
499 | - $s.='<td width="60%" colspan="2"> </td>'."\n"; |
|
500 | - $s.='<td width="40%" valign="top">'; |
|
501 | - $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
502 | - $s.="</td>\n</tr>\n"; |
|
498 | + $s .= '<tr>'."\n"; |
|
499 | + $s .= '<td width="60%" colspan="2"> </td>'."\n"; |
|
500 | + $s .= '<td width="40%" valign="top">'; |
|
501 | + $s .= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
502 | + $s .= "</td>\n</tr>\n"; |
|
503 | 503 | $cpt2++; |
504 | 504 | } // end while() |
505 | 505 | } // end if() |
506 | 506 | } |
507 | 507 | } |
508 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
509 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
508 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp, 0, -1).');'."\n"; |
|
509 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc, 0, -1).');'."\n"; |
|
510 | 510 | $js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n"; |
511 | 511 | $js .= $jstmpw; |
512 | 512 | $html .= $s; |
513 | - $html .= '</table></td></tr>' . "\n"; |
|
513 | + $html .= '</table></td></tr>'."\n"; |
|
514 | 514 | |
515 | - return array($js,$html); |
|
515 | + return array($js, $html); |
|
516 | 516 | } |
517 | 517 | } |
518 | 518 | |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
550 | 550 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
551 | 551 | $js .= $jstmpw; |
552 | - return array($js,$html); |
|
552 | + return array($js, $html); |
|
553 | 553 | } |
554 | 554 | } |
555 | 555 | /** |
@@ -601,15 +601,15 @@ discard block |
||
601 | 601 | function export() |
602 | 602 | { |
603 | 603 | $js = $this->get_js_header(); |
604 | - $html = '<tr><td colspan="2"><table width="100%">' . "\n"; |
|
604 | + $html = '<tr><td colspan="2"><table width="100%">'."\n"; |
|
605 | 605 | // some javascript must be added for that kind of questions |
606 | 606 | $html .= ''; |
607 | 607 | |
608 | 608 | // Get the answers, make a list |
609 | - $nbrAnswers=$this->selectNbrAnswers(); |
|
609 | + $nbrAnswers = $this->selectNbrAnswers(); |
|
610 | 610 | |
611 | 611 | $answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>'; |
612 | - for($answerId=1;$answerId <= $nbrAnswers;$answerId++) |
|
612 | + for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) |
|
613 | 613 | { |
614 | 614 | $answer_list .= '<li>'.$this->selectAnswer($answerId).'</li>'; |
615 | 615 | } |
@@ -658,11 +658,11 @@ discard block |
||
658 | 658 | </td> |
659 | 659 | <tr> |
660 | 660 | HTML; |
661 | - $html .= '</table></td></tr>' . "\n"; |
|
661 | + $html .= '</table></td></tr>'."\n"; |
|
662 | 662 | |
663 | 663 | // currently the free answers cannot be displayed, so ignore the textarea |
664 | 664 | $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
665 | - return array($js,$html); |
|
665 | + return array($js, $html); |
|
666 | 666 | } |
667 | 667 | } |
668 | 668 | |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | { |
694 | 694 | $this->question = $question; |
695 | 695 | $this->question->setAnswer(); |
696 | - $this->questionIdent = "QST_" . $question->id ; |
|
696 | + $this->questionIdent = "QST_".$question->id; |
|
697 | 697 | $this->standalone = $standalone; |
698 | 698 | } |
699 | 699 | |
@@ -707,9 +707,9 @@ discard block |
||
707 | 707 | { |
708 | 708 | global $charset; |
709 | 709 | $head = ""; |
710 | - if( $this->standalone) |
|
710 | + if ($this->standalone) |
|
711 | 711 | { |
712 | - $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?>' . "\n"; |
|
712 | + $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?>'."\n"; |
|
713 | 713 | $head .= '<html>'."\n"; |
714 | 714 | } |
715 | 715 | return $head; |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | * |
721 | 721 | */ |
722 | 722 | function end_page() { |
723 | - if($this->standalone){return '</html>';} |
|
723 | + if ($this->standalone) {return '</html>'; } |
|
724 | 724 | return ''; |
725 | 725 | } |
726 | 726 | |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | * Start document header |
729 | 729 | */ |
730 | 730 | function start_header() { |
731 | - if($this->standalone){return '<head>'. "\n";} |
|
731 | + if ($this->standalone) {return '<head>'."\n"; } |
|
732 | 732 | return ''; |
733 | 733 | } |
734 | 734 | |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | */ |
756 | 756 | function end_header() |
757 | 757 | { |
758 | - if($this->standalone){return '</head>'. "\n";} |
|
758 | + if ($this->standalone) {return '</head>'."\n"; } |
|
759 | 759 | return ''; |
760 | 760 | } |
761 | 761 | /** |
@@ -775,11 +775,11 @@ discard block |
||
775 | 775 | function common_js() |
776 | 776 | { |
777 | 777 | $js = file_get_contents('../newscorm/js/api_wrapper.js'); |
778 | - $js .= 'var questions = new Array();' . "\n"; |
|
779 | - $js .= 'var questions_answers = new Array();' . "\n"; |
|
780 | - $js .= 'var questions_answers_correct = new Array();' . "\n"; |
|
781 | - $js .= 'var questions_types = new Array();' . "\n"; |
|
782 | - $js .= "\n" . |
|
778 | + $js .= 'var questions = new Array();'."\n"; |
|
779 | + $js .= 'var questions_answers = new Array();'."\n"; |
|
780 | + $js .= 'var questions_answers_correct = new Array();'."\n"; |
|
781 | + $js .= 'var questions_types = new Array();'."\n"; |
|
782 | + $js .= "\n". |
|
783 | 783 | '/** |
784 | 784 | * Assigns any event handler to any element |
785 | 785 | * @param object Element on which the event is added |
@@ -819,7 +819,7 @@ discard block |
||
819 | 819 | //$js .= 'addEvent(window,\'load\',loadPage,false);'."\n"; |
820 | 820 | //$js .= 'addEvent(window,\'unload\',unloadPage,false);'."\n"; |
821 | 821 | $js .= 'addEvent(window,\'load\',addListeners,false);'."\n"; |
822 | - if($this->standalone){return $js. "\n";} |
|
822 | + if ($this->standalone) {return $js."\n"; } |
|
823 | 823 | return ''; |
824 | 824 | } |
825 | 825 | |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | */ |
830 | 830 | function end_js() |
831 | 831 | { |
832 | - if($this->standalone){return '</script>'. "\n";} |
|
832 | + if ($this->standalone) {return '</script>'."\n"; } |
|
833 | 833 | return ''; |
834 | 834 | } |
835 | 835 | |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | */ |
840 | 840 | function start_body() |
841 | 841 | { |
842 | - if($this->standalone){return '<body>'. "\n".'<form id="dokeos_scorm_form" method="post" action="">'."\n";} |
|
842 | + if ($this->standalone) {return '<body>'."\n".'<form id="dokeos_scorm_form" method="post" action="">'."\n"; } |
|
843 | 843 | return ''; |
844 | 844 | } |
845 | 845 | |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | */ |
850 | 850 | function end_body() |
851 | 851 | { |
852 | - if($this->standalone){return '<br /><input type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form>'."\n".'</body>'. "\n";} |
|
852 | + if ($this->standalone) {return '<br /><input type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form>'."\n".'</body>'."\n"; } |
|
853 | 853 | return ''; |
854 | 854 | } |
855 | 855 | |
@@ -864,9 +864,9 @@ discard block |
||
864 | 864 | function export() |
865 | 865 | { |
866 | 866 | $js = $html = ''; |
867 | - list($js,$html) = $this->question->export(); |
|
867 | + list($js, $html) = $this->question->export(); |
|
868 | 868 | //list($js,$html) = $this->question->answer->export(); |
869 | - if($this->standalone) |
|
869 | + if ($this->standalone) |
|
870 | 870 | { |
871 | 871 | $res = $this->start_page() |
872 | 872 | . $this->start_header() |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | } |
889 | 889 | else |
890 | 890 | { |
891 | - return array($js,$html); |
|
891 | + return array($js, $html); |
|
892 | 892 | } |
893 | 893 | } |
894 | 894 | } |
@@ -917,9 +917,9 @@ discard block |
||
917 | 917 | * @param boolean $standalone Wether it should include XML tag and DTD line. |
918 | 918 | * @return The XML as a string, or an empty string if there's no exercise with given ID. |
919 | 919 | */ |
920 | - public static function export_exercise_to_scorm($exerciseId, $standalone=true) { |
|
920 | + public static function export_exercise_to_scorm($exerciseId, $standalone = true) { |
|
921 | 921 | $exercise = new Exercise(); |
922 | - if (! $exercise->read($exerciseId)) { |
|
922 | + if (!$exercise->read($exerciseId)) { |
|
923 | 923 | return ''; |
924 | 924 | } |
925 | 925 | $ims = new ScormSection($exercise); |
@@ -946,7 +946,7 @@ discard block |
||
946 | 946 | function start_page() { |
947 | 947 | global $charset; |
948 | 948 | $head = $foot = ""; |
949 | - $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?>' . "\n".'<html>'."\n"; |
|
949 | + $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?>'."\n".'<html>'."\n"; |
|
950 | 950 | return $head; |
951 | 951 | } |
952 | 952 | |
@@ -962,7 +962,7 @@ discard block |
||
962 | 962 | * Start document header |
963 | 963 | */ |
964 | 964 | function start_header() { |
965 | - return '<head>'. "\n"; |
|
965 | + return '<head>'."\n"; |
|
966 | 966 | } |
967 | 967 | |
968 | 968 | /** |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | * End document header |
985 | 985 | */ |
986 | 986 | function end_header() { |
987 | - return '</head>'. "\n"; |
|
987 | + return '</head>'."\n"; |
|
988 | 988 | } |
989 | 989 | |
990 | 990 | /** |
@@ -992,7 +992,7 @@ discard block |
||
992 | 992 | * |
993 | 993 | */ |
994 | 994 | function start_js() { |
995 | - return '<script type="text/javascript" language="javascript">'. "\n"; |
|
995 | + return '<script type="text/javascript" language="javascript">'."\n"; |
|
996 | 996 | } |
997 | 997 | |
998 | 998 | /** |
@@ -1002,11 +1002,11 @@ discard block |
||
1002 | 1002 | $js = "\n"; |
1003 | 1003 | $js .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js'); |
1004 | 1004 | $js .= file_get_contents('../newscorm/js/api_wrapper.js'); |
1005 | - $js .= 'var questions = new Array();' . "\n"; |
|
1006 | - $js .= 'var questions_answers = new Array();' . "\n"; |
|
1007 | - $js .= 'var questions_answers_correct = new Array();' . "\n"; |
|
1008 | - $js .= 'var questions_types = new Array();' . "\n"; |
|
1009 | - $js .= "\n" . |
|
1005 | + $js .= 'var questions = new Array();'."\n"; |
|
1006 | + $js .= 'var questions_answers = new Array();'."\n"; |
|
1007 | + $js .= 'var questions_answers_correct = new Array();'."\n"; |
|
1008 | + $js .= 'var questions_types = new Array();'."\n"; |
|
1009 | + $js .= "\n". |
|
1010 | 1010 | '/** |
1011 | 1011 | * Assigns any event handler to any element |
1012 | 1012 | * @param object Element on which the event is added |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | //$js .= 'addEvent(window,\'load\',loadPage,false);'."\n"; |
1054 | 1054 | //$js .= 'addEvent(window,\'unload\',unloadPage,false);'."\n"; |
1055 | 1055 | $js .= 'addEvent(window,\'load\',addListeners,false);'."\n"; |
1056 | - return $js. "\n"; |
|
1056 | + return $js."\n"; |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | /** |
@@ -1061,7 +1061,7 @@ discard block |
||
1061 | 1061 | * |
1062 | 1062 | */ |
1063 | 1063 | function end_js() { |
1064 | - return '</script>'. "\n"; |
|
1064 | + return '</script>'."\n"; |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | /** |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | */ |
1071 | 1071 | function start_body() |
1072 | 1072 | { |
1073 | - return '<body>'. "\n". |
|
1073 | + return '<body>'."\n". |
|
1074 | 1074 | '<h1>'.$this->exercise->selectTitle().'</h1><p>'.$this->exercise->selectDescription()."</p>\n". |
1075 | 1075 | '<form id="dokeos_scorm_form" method="post" action="">'."\n". |
1076 | 1076 | '<table width="100%">'."\n"; |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | */ |
1083 | 1083 | function end_body() |
1084 | 1084 | { |
1085 | - return '</table><br /><input type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form>'."\n".'</body>'. "\n"; |
|
1085 | + return '</table><br /><input type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form>'."\n".'</body>'."\n"; |
|
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | /** |
@@ -1099,11 +1099,11 @@ discard block |
||
1099 | 1099 | |
1100 | 1100 | $head = ""; |
1101 | 1101 | if ($this->standalone) { |
1102 | - $head = '<?xml version = "1.0" encoding = "' . $charset . '" standalone = "no"?>' . "\n" |
|
1103 | - . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"; |
|
1102 | + $head = '<?xml version = "1.0" encoding = "'.$charset.'" standalone = "no"?>'."\n" |
|
1103 | + . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">'."\n"; |
|
1104 | 1104 | } |
1105 | 1105 | |
1106 | - list($js,$html) = $this->export_questions(); |
|
1106 | + list($js, $html) = $this->export_questions(); |
|
1107 | 1107 | //list($js,$html) = $this->question->answer->export(); |
1108 | 1108 | $res = $this->start_page() |
1109 | 1109 | . $this->start_header() |
@@ -1134,12 +1134,12 @@ discard block |
||
1134 | 1134 | $js = $html = ""; |
1135 | 1135 | $js_id = 0; |
1136 | 1136 | foreach ($this->exercise->selectQuestionList() as $q) { |
1137 | - list($jstmp,$htmltmp)= ScormQuestion::export_question($q, false, $js_id); |
|
1137 | + list($jstmp, $htmltmp) = ScormQuestion::export_question($q, false, $js_id); |
|
1138 | 1138 | $js .= $jstmp."\n"; |
1139 | 1139 | $html .= $htmltmp."\n"; |
1140 | 1140 | ++$js_id; |
1141 | 1141 | } |
1142 | - return array($js,$html); |
|
1142 | + return array($js, $html); |
|
1143 | 1143 | } |
1144 | 1144 | } |
1145 | 1145 |
@@ -327,8 +327,7 @@ discard block |
||
327 | 327 | if($this->response == 'TRUE') |
328 | 328 | { |
329 | 329 | $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n"; |
330 | - } |
|
331 | - else |
|
330 | + } else |
|
332 | 331 | { |
333 | 332 | $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n"; |
334 | 333 | } |
@@ -471,8 +470,11 @@ discard block |
||
471 | 470 | |
472 | 471 | $s.='</select> </td>'."\n"; |
473 | 472 | $s.='<td width="40%" valign="top">'; |
474 | - if(isset($Select[$cpt2])) $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
475 | - else $s.=' '; |
|
473 | + if(isset($Select[$cpt2])) { |
|
474 | + $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
475 | + } else { |
|
476 | + $s.=' '; |
|
477 | + } |
|
476 | 478 | $s.="</td>\n</tr>\n"; |
477 | 479 | |
478 | 480 | $jstmpc .= '['.$answerCorrect.','.$cpt2.'],'; |
@@ -577,8 +579,7 @@ discard block |
||
577 | 579 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
578 | 580 | $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
579 | 581 | $header .= $jstmpw; |
580 | - } |
|
581 | - else |
|
582 | + } else |
|
582 | 583 | { |
583 | 584 | $header = ''; |
584 | 585 | $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
@@ -885,8 +886,7 @@ discard block |
||
885 | 886 | . $this->end_body() |
886 | 887 | . $this->end_page(); |
887 | 888 | return $res; |
888 | - } |
|
889 | - else |
|
889 | + } else |
|
890 | 890 | { |
891 | 891 | return array($js,$html); |
892 | 892 | } |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | * @param null $feedback_type |
416 | 416 | * @param null $counter |
417 | 417 | * @param null $score |
418 | - * @return null|string |
|
418 | + * @return string |
|
419 | 419 | */ |
420 | 420 | public function return_header($feedback_type = null, $counter = null, $score = null) |
421 | 421 | { |
@@ -429,15 +429,16 @@ discard block |
||
429 | 429 | } |
430 | 430 | |
431 | 431 | /** |
432 | - * @param $separatorStartRegexp |
|
433 | - * @param $separatorEndRegexp |
|
434 | - * @param $correctItemRegexp |
|
435 | - * @param $questionId |
|
432 | + * @param string $separatorStartRegexp |
|
433 | + * @param string $separatorEndRegexp |
|
434 | + * @param string $correctItemRegexp |
|
435 | + * @param integer $questionId |
|
436 | 436 | * @param $correctItem |
437 | 437 | * @param $attributes |
438 | - * @param $answer |
|
438 | + * @param string $answer |
|
439 | 439 | * @param $listAnswersInfo |
440 | - * @param $displayForStudent |
|
440 | + * @param boolean $displayForStudent |
|
441 | + * @param integer $inBlankNumber |
|
441 | 442 | * @return string |
442 | 443 | */ |
443 | 444 | public static function getFillTheBlankHtml( |
@@ -736,11 +737,11 @@ discard block |
||
736 | 737 | * 0 : student answer is correct |
737 | 738 | * >0 : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0) |
738 | 739 | * |
739 | - * @param $testId |
|
740 | - * @param $questionId |
|
740 | + * @param integer $testId |
|
741 | + * @param integer $questionId |
|
741 | 742 | * @param $studentsIdList |
742 | - * @param $startDate |
|
743 | - * @param $endDate |
|
743 | + * @param string $startDate |
|
744 | + * @param string $endDate |
|
744 | 745 | * @param bool $useLastAnswerredAttempt |
745 | 746 | * @return array |
746 | 747 | * ( |
@@ -917,7 +918,7 @@ discard block |
||
917 | 918 | * return $text protected for use in regexp |
918 | 919 | * @param string $text |
919 | 920 | * |
920 | - * @return mixed |
|
921 | + * @return string |
|
921 | 922 | */ |
922 | 923 | public static function getRegexpProtected($text) |
923 | 924 | { |
@@ -975,7 +976,7 @@ discard block |
||
975 | 976 | * return the start separator for answer |
976 | 977 | * @param string $number |
977 | 978 | * |
978 | - * @return mixed |
|
979 | + * @return string |
|
979 | 980 | */ |
980 | 981 | public static function getStartSeparator($number) |
981 | 982 | { |
@@ -988,7 +989,7 @@ discard block |
||
988 | 989 | * return the end separator for answer |
989 | 990 | * @param string $number |
990 | 991 | * |
991 | - * @return mixed |
|
992 | + * @return string |
|
992 | 993 | */ |
993 | 994 | public static function getEndSeparator($number) |
994 | 995 | { |
@@ -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 |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | ['id' => 'answer', 'onkeyup' => "javascript: updateBlanks(this);"], |
261 | 261 | array('ToolbarSet' => 'TestQuestionDescription') |
262 | 262 | ); |
263 | - $form->addRule('answer',get_lang('GiveText'),'required'); |
|
263 | + $form->addRule('answer', get_lang('GiveText'), 'required'); |
|
264 | 264 | |
265 | 265 | //added multiple answers |
266 | - $form->addElement('checkbox','multiple_answer','', get_lang('FillInBlankSwitchable')); |
|
266 | + $form->addElement('checkbox', 'multiple_answer', '', get_lang('FillInBlankSwitchable')); |
|
267 | 267 | $form->addElement( |
268 | 268 | 'select', |
269 | 269 | 'select_separator', |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | null, |
277 | 277 | '<input type="button" onclick="updateBlanks()" value="'.get_lang('RefreshBlanks').'" class="btn btn-default" />' |
278 | 278 | ); |
279 | - $form->addElement('html','<div id="blanks_weighting"></div>'); |
|
279 | + $form->addElement('html', '<div id="blanks_weighting"></div>'); |
|
280 | 280 | |
281 | 281 | global $text; |
282 | 282 | // setting the save button here and not in the question class.php |
283 | - $form->addElement('html','<div id="defineoneblank" style="color:#D04A66; margin-left:160px">'.get_lang('DefineBlanks').'</div>'); |
|
283 | + $form->addElement('html', '<div id="defineoneblank" style="color:#D04A66; margin-left:160px">'.get_lang('DefineBlanks').'</div>'); |
|
284 | 284 | $form->addButtonSave($text, 'submitQuestion'); |
285 | 285 | |
286 | 286 | if (!empty($this->id)) { |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | // remove spaces at the beginning and the end of text in square brackets |
321 | 321 | $answer = preg_replace_callback( |
322 | 322 | "/".$blankStartSeparatorRegexp."[^]]+".$blankEndSeparatorRegexp."/", |
323 | - function ($matches) use ($blankStartSeparator, $blankEndSeparator) { |
|
323 | + function($matches) use ($blankStartSeparator, $blankEndSeparator) { |
|
324 | 324 | $matchingResult = $matches[0]; |
325 | 325 | $matchingResult = trim($matchingResult, $blankStartSeparator); |
326 | 326 | $matchingResult = trim($matchingResult, $blankEndSeparator); |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | if ($nb > 0) { |
366 | 366 | $answer .= '::'; |
367 | 367 | // weighting |
368 | - for ($i=0; $i < $nb; ++$i) { |
|
368 | + for ($i = 0; $i < $nb; ++$i) { |
|
369 | 369 | // enter the weighting of word $i |
370 | 370 | $answer .= $form->getSubmitValue('weighting['.$i.']'); |
371 | 371 | // not the last word, add "," |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | |
379 | 379 | // input width |
380 | 380 | $answer .= ":"; |
381 | - for ($i=0; $i < $nb; ++$i) { |
|
381 | + for ($i = 0; $i < $nb; ++$i) { |
|
382 | 382 | // enter the width of input for word $i |
383 | 383 | $answer .= $form->getSubmitValue('sizeofinput['.$i.']'); |
384 | 384 | // not the last word, add "," |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | |
404 | 404 | // Allow answers order switches |
405 | 405 | $is_multiple = $form -> getSubmitValue('multiple_answer'); |
406 | - $answer.= '@'.$is_multiple; |
|
406 | + $answer .= '@'.$is_multiple; |
|
407 | 407 | |
408 | 408 | $this->save(); |
409 | 409 | $objAnswer = new Answer($this->id); |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | public function return_header($feedback_type = null, $counter = null, $score = null) |
421 | 421 | { |
422 | 422 | $header = parent::return_header($feedback_type, $counter, $score); |
423 | - $header .= '<table class="'.$this->question_table_class .'"> |
|
423 | + $header .= '<table class="'.$this->question_table_class.'"> |
|
424 | 424 | <tr> |
425 | 425 | <th>'.get_lang("Answer").'</th> |
426 | 426 | </tr>'; |
@@ -464,13 +464,13 @@ discard block |
||
464 | 464 | // if display for student, shuffle the correct answer menu |
465 | 465 | $listMenu = self::getFillTheBlankMenuAnswers($inTeacherSolution, $displayForStudent); |
466 | 466 | $result .= '<select name="choice['.$questionId.'][]">'; |
467 | - for ($k=0; $k < count($listMenu); $k++) { |
|
467 | + for ($k = 0; $k < count($listMenu); $k++) { |
|
468 | 468 | $selected = ""; |
469 | 469 | if ($correctItem == $listMenu[$k]) { |
470 | 470 | $selected = " selected=selected "; |
471 | 471 | } |
472 | 472 | // if in teacher view, display the first item by default, which is the right answer |
473 | - if ($k==0 && !$displayForStudent) { |
|
473 | + if ($k == 0 && !$displayForStudent) { |
|
474 | 474 | $selected = " selected=selected "; |
475 | 475 | } |
476 | 476 | $optionMenu .= '<option '.$selected.' value="'.$listMenu[$k].'">'.$listMenu[$k].'</option>'; |
@@ -642,10 +642,10 @@ discard block |
||
642 | 642 | if (count($listDetails) < 3) { |
643 | 643 | $listWeightings = explode(',', $listDetails[0]); |
644 | 644 | $listSizeOfInput = array(); |
645 | - for ($i=0; $i < count($listWeightings); $i++) { |
|
645 | + for ($i = 0; $i < count($listWeightings); $i++) { |
|
646 | 646 | $listSizeOfInput[] = 200; |
647 | 647 | } |
648 | - $blankSeparatorNumber = 0; // 0 is [...] |
|
648 | + $blankSeparatorNumber = 0; // 0 is [...] |
|
649 | 649 | } else { |
650 | 650 | $listWeightings = explode(',', $listDetails[0]); |
651 | 651 | $listSizeOfInput = explode(',', $listDetails[1]); |
@@ -677,9 +677,9 @@ discard block |
||
677 | 677 | // remove [ and ] in string |
678 | 678 | array_walk( |
679 | 679 | $listWords[0], |
680 | - function (&$value, $key, $tabBlankChar) { |
|
680 | + function(&$value, $key, $tabBlankChar) { |
|
681 | 681 | $trimChars = ""; |
682 | - for ($i=0; $i < count($tabBlankChar); $i++) { |
|
682 | + for ($i = 0; $i < count($tabBlankChar); $i++) { |
|
683 | 683 | $trimChars .= $tabBlankChar[$i]; |
684 | 684 | } |
685 | 685 | $value = trim($value, $trimChars); |
@@ -699,18 +699,18 @@ discard block |
||
699 | 699 | // if student answer, the second [] is the student answer, |
700 | 700 | // the third is if student scored or not |
701 | 701 | $listBrackets = array(); |
702 | - $listWords = array(); |
|
702 | + $listWords = array(); |
|
703 | 703 | |
704 | 704 | if ($isStudentAnswer) { |
705 | - for ($i=0; $i < count($listAnswerResults['tabwords']); $i++) { |
|
705 | + for ($i = 0; $i < count($listAnswerResults['tabwords']); $i++) { |
|
706 | 706 | $listBrackets[] = $listAnswerResults['tabwordsbracket'][$i]; |
707 | 707 | $listWords[] = $listAnswerResults['tabwords'][$i]; |
708 | - if ($i+1 < count($listAnswerResults['tabwords'])) { |
|
708 | + if ($i + 1 < count($listAnswerResults['tabwords'])) { |
|
709 | 709 | // should always be |
710 | 710 | $i++; |
711 | 711 | } |
712 | 712 | $listAnswerResults['studentanswer'][] = $listAnswerResults['tabwords'][$i]; |
713 | - if ($i+1 < count($listAnswerResults['tabwords'])) { |
|
713 | + if ($i + 1 < count($listAnswerResults['tabwords'])) { |
|
714 | 714 | // should always be |
715 | 715 | $i++; |
716 | 716 | } |
@@ -802,9 +802,9 @@ discard block |
||
802 | 802 | break; |
803 | 803 | default : |
804 | 804 | if (FillBlanks::isGoodStudentAnswer($tabAnswer['studentanswer'][$bracketNumber], $tabAnswer['tabwords'][$bracketNumber])) { |
805 | - $tabUserResult[$data['user_id']][$bracketNumber] = 0; // right answer |
|
805 | + $tabUserResult[$data['user_id']][$bracketNumber] = 0; // right answer |
|
806 | 806 | } else { |
807 | - $tabUserResult[$data['user_id']][$bracketNumber] = -1; // wrong answer |
|
807 | + $tabUserResult[$data['user_id']][$bracketNumber] = -1; // wrong answer |
|
808 | 808 | } |
809 | 809 | } |
810 | 810 | } else { |
@@ -812,11 +812,11 @@ discard block |
||
812 | 812 | if ($useLastAnswerredAttempt) { |
813 | 813 | // if we take into account the last answered attempt |
814 | 814 | if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) { |
815 | - $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
815 | + $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
816 | 816 | } |
817 | 817 | } else { |
818 | 818 | // we take the last attempt, even if the student answer the question before |
819 | - $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
819 | + $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered |
|
820 | 820 | } |
821 | 821 | } |
822 | 822 | } |
@@ -837,10 +837,10 @@ discard block |
||
837 | 837 | { |
838 | 838 | $outRes = 0; |
839 | 839 | // for each student in group |
840 | - foreach($resultList as $userId => $tabValue) { |
|
840 | + foreach ($resultList as $userId => $tabValue) { |
|
841 | 841 | $trouve = false; |
842 | 842 | // for each bracket, if student has at leat one answer ( choice > -2) then he pass the question |
843 | - foreach($tabValue as $i => $choice) { |
|
843 | + foreach ($tabValue as $i => $choice) { |
|
844 | 844 | if ($choice > -2 && !$trouve) { |
845 | 845 | $outRes++; |
846 | 846 | $trouve = true; |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | $separatorEnd = $listWithStudentAnswer['blankseparatorend']; |
863 | 863 | // lets rebuild the sentence with [correct answer][student answer][answer is correct] |
864 | 864 | $result = ""; |
865 | - for ($i=0; $i < count($listWithStudentAnswer['commonwords']) - 1; $i++) { |
|
865 | + for ($i = 0; $i < count($listWithStudentAnswer['commonwords']) - 1; $i++) { |
|
866 | 866 | $result .= $listWithStudentAnswer['commonwords'][$i]; |
867 | 867 | $result .= $listWithStudentAnswer['tabwordsbracket'][$i]; |
868 | 868 | $result .= $separatorStart.$listWithStudentAnswer['studentanswer'][$i].$separatorEnd; |
@@ -944,7 +944,7 @@ discard block |
||
944 | 944 | ")", |
945 | 945 | ]; |
946 | 946 | $result = $text; |
947 | - for ($i=0; $i < count($listRegexpCharacters); $i++) { |
|
947 | + for ($i = 0; $i < count($listRegexpCharacters); $i++) { |
|
948 | 948 | $result = str_replace($listRegexpCharacters[$i], "\\".$listRegexpCharacters[$i], $result); |
949 | 949 | } |
950 | 950 | |
@@ -1006,7 +1006,7 @@ discard block |
||
1006 | 1006 | { |
1007 | 1007 | $listResults = array(); |
1008 | 1008 | $fillBlanksAllowedSeparator = self::getAllowedSeparator(); |
1009 | - for ($i=0; $i < count($fillBlanksAllowedSeparator); $i++) { |
|
1009 | + for ($i = 0; $i < count($fillBlanksAllowedSeparator); $i++) { |
|
1010 | 1010 | $listResults[] = $fillBlanksAllowedSeparator[$i][0]."...".$fillBlanksAllowedSeparator[$i][1]; |
1011 | 1011 | } |
1012 | 1012 | |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | { |
1025 | 1025 | $listSeparators = self::getAllowedSeparator(); |
1026 | 1026 | $result = 0; |
1027 | - for ($i=0; $i < count($listSeparators); $i++) { |
|
1027 | + for ($i = 0; $i < count($listSeparators); $i++) { |
|
1028 | 1028 | if ($listSeparators[$i][0] == $startSeparator && |
1029 | 1029 | $listSeparators[$i][1] == $endSeparator |
1030 | 1030 | ) { |
@@ -1049,7 +1049,7 @@ discard block |
||
1049 | 1049 | |
1050 | 1050 | // rebuild the answer with good HTML style |
1051 | 1051 | // this is the student answer, right or wrong |
1052 | - for ($i=0; $i < count($listStudentAnswerInfo['studentanswer']); $i++) { |
|
1052 | + for ($i = 0; $i < count($listStudentAnswerInfo['studentanswer']); $i++) { |
|
1053 | 1053 | if ($listStudentAnswerInfo['studentscore'][$i] == 1) { |
1054 | 1054 | $listStudentAnswerInfo['studentanswer'][$i] = self::getHtmlRightAnswer( |
1055 | 1055 | $listStudentAnswerInfo['studentanswer'][$i], |
@@ -1067,7 +1067,7 @@ discard block |
||
1067 | 1067 | |
1068 | 1068 | |
1069 | 1069 | // rebuild the sentence with student answer inserted |
1070 | - for ($i=0; $i < count($listStudentAnswerInfo['commonwords']); $i++) { |
|
1070 | + for ($i = 0; $i < count($listStudentAnswerInfo['commonwords']); $i++) { |
|
1071 | 1071 | $result .= isset($listStudentAnswerInfo['commonwords'][$i]) ? $listStudentAnswerInfo['commonwords'][$i] : ''; |
1072 | 1072 | $result .= isset($listStudentAnswerInfo['studentanswer'][$i]) ? $listStudentAnswerInfo['studentanswer'][$i] : ''; |
1073 | 1073 | } |
@@ -1100,7 +1100,7 @@ discard block |
||
1100 | 1100 | $listPossibleAnswers = FillBlanks::getFillTheBlankMenuAnswers($correct, false); |
1101 | 1101 | $correctAnswerHtml .= "<span style='color: green'>".$listPossibleAnswers[0]."</span>"; |
1102 | 1102 | $correctAnswerHtml .= " <span style='font-weight:normal'>("; |
1103 | - for ($i=1; $i < count($listPossibleAnswers); $i++) { |
|
1103 | + for ($i = 1; $i < count($listPossibleAnswers); $i++) { |
|
1104 | 1104 | $correctAnswerHtml .= $listPossibleAnswers[$i]; |
1105 | 1105 | if ($i != count($listPossibleAnswers) - 1) { |
1106 | 1106 | $correctAnswerHtml .= " | "; |