@@ -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()); |
@@ -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 |
@@ -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,23 +1306,23 @@ 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']); |
|
1317 | + $form->addElement('text', $specific_field['code'], $specific_field['name']); |
|
1318 | 1318 | $filter = array( |
1319 | 1319 | 'c_id' => api_get_course_int_id(), |
1320 | 1320 | 'field_id' => $specific_field['id'], |
1321 | 1321 | 'ref_id' => $this->id, |
1322 | - 'tool_id' => "'" . TOOL_QUIZ . "'" |
|
1322 | + 'tool_id' => "'".TOOL_QUIZ."'" |
|
1323 | 1323 | ); |
1324 | 1324 | $values = get_specific_field_values_list($filter, array('value')); |
1325 | - if ( !empty($values) ) { |
|
1325 | + if (!empty($values)) { |
|
1326 | 1326 | $arr_str_values = array(); |
1327 | 1327 | foreach ($values as $value) { |
1328 | 1328 | $arr_str_values[] = $value['value']; |
@@ -1333,8 +1333,8 @@ discard block |
||
1333 | 1333 | //$form->addElement ('html','</div>'); |
1334 | 1334 | } |
1335 | 1335 | |
1336 | - $form->addElement('html','</div>'); //End advanced setting |
|
1337 | - $form->addElement('html','</div>'); |
|
1336 | + $form->addElement('html', '</div>'); //End advanced setting |
|
1337 | + $form->addElement('html', '</div>'); |
|
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | // submit |
@@ -1354,10 +1354,10 @@ discard block |
||
1354 | 1354 | } |
1355 | 1355 | |
1356 | 1356 | // defaults |
1357 | - if ($type=='full') { |
|
1357 | + if ($type == 'full') { |
|
1358 | 1358 | if ($this->id > 0) { |
1359 | 1359 | if ($this->random > $this->selectNbrQuestions()) { |
1360 | - $defaults['randomQuestions'] = $this->selectNbrQuestions(); |
|
1360 | + $defaults['randomQuestions'] = $this->selectNbrQuestions(); |
|
1361 | 1361 | } else { |
1362 | 1362 | $defaults['randomQuestions'] = $this->random; |
1363 | 1363 | } |
@@ -1383,8 +1383,8 @@ discard block |
||
1383 | 1383 | $defaults['activate_end_date_check'] = 1; |
1384 | 1384 | } |
1385 | 1385 | |
1386 | - $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'); |
|
1387 | - $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); |
|
1386 | + $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'); |
|
1387 | + $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); |
|
1388 | 1388 | |
1389 | 1389 | // Get expired time |
1390 | 1390 | if ($this->expired_time != '0') { |
@@ -1405,7 +1405,7 @@ discard block |
||
1405 | 1405 | $defaults['text_when_finished'] = ""; |
1406 | 1406 | $defaults['start_time'] = date('Y-m-d 12:00:00'); |
1407 | 1407 | $defaults['display_category_name'] = 1; |
1408 | - $defaults['end_time'] = date('Y-m-d 12:00:00', time()+84600); |
|
1408 | + $defaults['end_time'] = date('Y-m-d 12:00:00', time() + 84600); |
|
1409 | 1409 | $defaults['pass_percentage'] = ''; |
1410 | 1410 | } |
1411 | 1411 | } else { |
@@ -1472,7 +1472,7 @@ discard block |
||
1472 | 1472 | $end_time = $form->getSubmitValue('end_time'); |
1473 | 1473 | $this->end_time = api_get_utc_datetime($end_time); |
1474 | 1474 | } else { |
1475 | - $this->end_time = '0000-00-00 00:00:00'; |
|
1475 | + $this->end_time = '0000-00-00 00:00:00'; |
|
1476 | 1476 | } |
1477 | 1477 | |
1478 | 1478 | if ($form->getSubmitValue('enabletimercontrol') == 1) { |
@@ -1485,9 +1485,9 @@ discard block |
||
1485 | 1485 | } |
1486 | 1486 | |
1487 | 1487 | if ($form->getSubmitValue('randomAnswers') == 1) { |
1488 | - $this->random_answers=1; |
|
1488 | + $this->random_answers = 1; |
|
1489 | 1489 | } else { |
1490 | - $this->random_answers=0; |
|
1490 | + $this->random_answers = 0; |
|
1491 | 1491 | } |
1492 | 1492 | $this->save($type); |
1493 | 1493 | } |
@@ -1499,9 +1499,9 @@ discard block |
||
1499 | 1499 | } |
1500 | 1500 | $course_id = api_get_course_id(); |
1501 | 1501 | |
1502 | - require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'; |
|
1503 | - require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php'; |
|
1504 | - require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
1502 | + require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'; |
|
1503 | + require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php'; |
|
1504 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
1505 | 1505 | |
1506 | 1506 | $specific_fields = get_specific_field_list(); |
1507 | 1507 | $ic_slide = new IndexableChunk(); |
@@ -1511,7 +1511,7 @@ discard block |
||
1511 | 1511 | if (isset($_REQUEST[$specific_field['code']])) { |
1512 | 1512 | $sterms = trim($_REQUEST[$specific_field['code']]); |
1513 | 1513 | if (!empty($sterms)) { |
1514 | - $all_specific_terms .= ' '. $sterms; |
|
1514 | + $all_specific_terms .= ' '.$sterms; |
|
1515 | 1515 | $sterms = explode(',', $sterms); |
1516 | 1516 | foreach ($sterms as $sterm) { |
1517 | 1517 | $ic_slide->addTerm(trim($sterm), $specific_field['code']); |
@@ -1528,15 +1528,15 @@ discard block |
||
1528 | 1528 | $xapian_data = array( |
1529 | 1529 | SE_COURSE_ID => $course_id, |
1530 | 1530 | SE_TOOL_ID => TOOL_QUIZ, |
1531 | - SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id), |
|
1532 | - SE_USER => (int)api_get_user_id(), |
|
1531 | + SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id), |
|
1532 | + SE_USER => (int) api_get_user_id(), |
|
1533 | 1533 | ); |
1534 | 1534 | $ic_slide->xapian_data = serialize($xapian_data); |
1535 | - $exercise_description = $all_specific_terms .' '. $this->description; |
|
1535 | + $exercise_description = $all_specific_terms.' '.$this->description; |
|
1536 | 1536 | $ic_slide->addValue("content", $exercise_description); |
1537 | 1537 | |
1538 | 1538 | $di = new ChamiloIndexer(); |
1539 | - isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english'; |
|
1539 | + isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english'; |
|
1540 | 1540 | $di->connectDb(NULL, NULL, $lang); |
1541 | 1541 | $di->addChunk($ic_slide); |
1542 | 1542 | |
@@ -1555,7 +1555,7 @@ discard block |
||
1555 | 1555 | function search_engine_edit() |
1556 | 1556 | { |
1557 | 1557 | // update search enchine and its values table if enabled |
1558 | - if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) { |
|
1558 | + if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) { |
|
1559 | 1559 | $course_id = api_get_course_id(); |
1560 | 1560 | |
1561 | 1561 | // actually, it consists on delete terms from db, |
@@ -1567,9 +1567,9 @@ discard block |
||
1567 | 1567 | $res = Database::query($sql); |
1568 | 1568 | |
1569 | 1569 | if (Database::num_rows($res) > 0) { |
1570 | - require_once(api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'); |
|
1571 | - require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php'); |
|
1572 | - require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'); |
|
1570 | + require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'); |
|
1571 | + require_once(api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php'); |
|
1572 | + require_once(api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'); |
|
1573 | 1573 | |
1574 | 1574 | $se_ref = Database::fetch_array($res); |
1575 | 1575 | $specific_fields = get_specific_field_list(); |
@@ -1580,7 +1580,7 @@ discard block |
||
1580 | 1580 | delete_all_specific_field_value($course_id, $specific_field['id'], TOOL_QUIZ, $this->id); |
1581 | 1581 | if (isset($_REQUEST[$specific_field['code']])) { |
1582 | 1582 | $sterms = trim($_REQUEST[$specific_field['code']]); |
1583 | - $all_specific_terms .= ' '. $sterms; |
|
1583 | + $all_specific_terms .= ' '.$sterms; |
|
1584 | 1584 | $sterms = explode(',', $sterms); |
1585 | 1585 | foreach ($sterms as $sterm) { |
1586 | 1586 | $ic_slide->addTerm(trim($sterm), $specific_field['code']); |
@@ -1596,17 +1596,17 @@ discard block |
||
1596 | 1596 | $xapian_data = array( |
1597 | 1597 | SE_COURSE_ID => $course_id, |
1598 | 1598 | SE_TOOL_ID => TOOL_QUIZ, |
1599 | - SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id), |
|
1600 | - SE_USER => (int)api_get_user_id(), |
|
1599 | + SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id), |
|
1600 | + SE_USER => (int) api_get_user_id(), |
|
1601 | 1601 | ); |
1602 | 1602 | $ic_slide->xapian_data = serialize($xapian_data); |
1603 | - $exercise_description = $all_specific_terms .' '. $this->description; |
|
1603 | + $exercise_description = $all_specific_terms.' '.$this->description; |
|
1604 | 1604 | $ic_slide->addValue("content", $exercise_description); |
1605 | 1605 | |
1606 | 1606 | $di = new ChamiloIndexer(); |
1607 | - isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english'; |
|
1607 | + isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english'; |
|
1608 | 1608 | $di->connectDb(NULL, NULL, $lang); |
1609 | - $di->remove_document((int)$se_ref['search_did']); |
|
1609 | + $di->remove_document((int) $se_ref['search_did']); |
|
1610 | 1610 | $di->addChunk($ic_slide); |
1611 | 1611 | |
1612 | 1612 | //index and return search engine document id |
@@ -1631,7 +1631,7 @@ discard block |
||
1631 | 1631 | function search_engine_delete() |
1632 | 1632 | { |
1633 | 1633 | // remove from search engine if enabled |
1634 | - if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian') ) { |
|
1634 | + if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) { |
|
1635 | 1635 | $course_id = api_get_course_id(); |
1636 | 1636 | $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF); |
1637 | 1637 | $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'; |
@@ -1639,19 +1639,19 @@ discard block |
||
1639 | 1639 | $res = Database::query($sql); |
1640 | 1640 | if (Database::num_rows($res) > 0) { |
1641 | 1641 | $row = Database::fetch_array($res); |
1642 | - require_once(api_get_path(LIBRARY_PATH) .'search/ChamiloIndexer.class.php'); |
|
1642 | + require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'); |
|
1643 | 1643 | $di = new ChamiloIndexer(); |
1644 | - $di->remove_document((int)$row['search_did']); |
|
1644 | + $di->remove_document((int) $row['search_did']); |
|
1645 | 1645 | unset($di); |
1646 | 1646 | $tbl_quiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION); |
1647 | - foreach ( $this->questionList as $question_i) { |
|
1647 | + foreach ($this->questionList as $question_i) { |
|
1648 | 1648 | $sql = 'SELECT type FROM %s WHERE id=%s'; |
1649 | 1649 | $sql = sprintf($sql, $tbl_quiz_question, $question_i); |
1650 | 1650 | $qres = Database::query($sql); |
1651 | 1651 | if (Database::num_rows($qres) > 0) { |
1652 | 1652 | $qrow = Database::fetch_array($qres); |
1653 | 1653 | $objQuestion = Question::getInstance($qrow['type']); |
1654 | - $objQuestion = Question::read((int)$question_i); |
|
1654 | + $objQuestion = Question::read((int) $question_i); |
|
1655 | 1655 | $objQuestion->search_engine_edit($this->id, FALSE, TRUE); |
1656 | 1656 | unset($objQuestion); |
1657 | 1657 | } |
@@ -1662,7 +1662,7 @@ discard block |
||
1662 | 1662 | Database::query($sql); |
1663 | 1663 | |
1664 | 1664 | // remove terms from db |
1665 | - require_once api_get_path(LIBRARY_PATH) .'specific_fields_manager.lib.php'; |
|
1665 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
1666 | 1666 | delete_all_values_for_item($course_id, TOOL_QUIZ, $this->id); |
1667 | 1667 | } |
1668 | 1668 | } |
@@ -1757,7 +1757,7 @@ discard block |
||
1757 | 1757 | */ |
1758 | 1758 | public function copy_exercise() |
1759 | 1759 | { |
1760 | - $exercise_obj= new Exercise(); |
|
1760 | + $exercise_obj = new Exercise(); |
|
1761 | 1761 | $exercise_obj = $this; |
1762 | 1762 | |
1763 | 1763 | // force the creation of a new exercise |
@@ -1829,25 +1829,25 @@ discard block |
||
1829 | 1829 | $lp_id = 0; |
1830 | 1830 | } |
1831 | 1831 | if (empty($lp_item_id)) { |
1832 | - $lp_item_id = 0; |
|
1832 | + $lp_item_id = 0; |
|
1833 | 1833 | } |
1834 | 1834 | if (empty($lp_item_view_id)) { |
1835 | 1835 | $lp_item_view_id = 0; |
1836 | 1836 | } |
1837 | - $condition = ' WHERE exe_exo_id = ' . "'" . $this->id . "'" .' AND |
|
1838 | - exe_user_id = ' . "'" . api_get_user_id() . "'" . ' AND |
|
1839 | - c_id = ' . api_get_course_int_id() . ' AND |
|
1840 | - status = ' . "'" . Database::escape_string($status). "'" . ' AND |
|
1841 | - orig_lp_id = ' . "'" . $lp_id . "'" . ' AND |
|
1842 | - orig_lp_item_id = ' . "'" . $lp_item_id . "'" . ' AND |
|
1843 | - orig_lp_item_view_id = ' . "'" . $lp_item_view_id . "'" . ' AND |
|
1844 | - session_id = ' . "'" . api_get_session_id() . "' LIMIT 1"; //Adding limit 1 just in case |
|
1837 | + $condition = ' WHERE exe_exo_id = '."'".$this->id."'".' AND |
|
1838 | + exe_user_id = ' . "'".api_get_user_id()."'".' AND |
|
1839 | + c_id = ' . api_get_course_int_id().' AND |
|
1840 | + status = ' . "'".Database::escape_string($status)."'".' AND |
|
1841 | + orig_lp_id = ' . "'".$lp_id."'".' AND |
|
1842 | + orig_lp_item_id = ' . "'".$lp_item_id."'".' AND |
|
1843 | + orig_lp_item_view_id = ' . "'".$lp_item_view_id."'".' AND |
|
1844 | + session_id = ' . "'".api_get_session_id()."' LIMIT 1"; //Adding limit 1 just in case |
|
1845 | 1845 | |
1846 | 1846 | $sql_track = 'SELECT * FROM '.$track_exercises.$condition; |
1847 | 1847 | |
1848 | 1848 | $result = Database::query($sql_track); |
1849 | 1849 | $new_array = array(); |
1850 | - if (Database::num_rows($result) > 0 ) { |
|
1850 | + if (Database::num_rows($result) > 0) { |
|
1851 | 1851 | $new_array = Database::fetch_array($result, 'ASSOC'); |
1852 | 1852 | $new_array['num_exe'] = Database::num_rows($result); |
1853 | 1853 | } |
@@ -1890,12 +1890,12 @@ discard block |
||
1890 | 1890 | $questionList = array_map('intval', $questionList); |
1891 | 1891 | |
1892 | 1892 | $params = array( |
1893 | - 'exe_exo_id' => $this->id , |
|
1893 | + 'exe_exo_id' => $this->id, |
|
1894 | 1894 | 'exe_user_id' => api_get_user_id(), |
1895 | 1895 | 'c_id' => api_get_course_int_id(), |
1896 | 1896 | 'status' => 'incomplete', |
1897 | 1897 | 'session_id' => api_get_session_id(), |
1898 | - 'data_tracking' => implode(',', $questionList) , |
|
1898 | + 'data_tracking' => implode(',', $questionList), |
|
1899 | 1899 | 'start_date' => api_get_utc_datetime(), |
1900 | 1900 | 'orig_lp_id' => $safe_lp_id, |
1901 | 1901 | 'orig_lp_item_id' => $safe_lp_item_id, |
@@ -1927,7 +1927,7 @@ discard block |
||
1927 | 1927 | $nbrQuestions = $this->get_count_question_list(); |
1928 | 1928 | |
1929 | 1929 | $all_button = $html = $label = ''; |
1930 | - $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']):null; |
|
1930 | + $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']) : null; |
|
1931 | 1931 | |
1932 | 1932 | if ($this->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT && $this->type == ONE_PER_PAGE) { |
1933 | 1933 | $urlTitle = get_lang('ContinueTest'); |
@@ -1938,7 +1938,7 @@ discard block |
||
1938 | 1938 | |
1939 | 1939 | $html .= Display::url( |
1940 | 1940 | $urlTitle, |
1941 | - 'exercise_submit_modal.php?' . http_build_query([ |
|
1941 | + 'exercise_submit_modal.php?'.http_build_query([ |
|
1942 | 1942 | 'learnpath_id' => $safe_lp_id, |
1943 | 1943 | 'learnpath_item_id' => $safe_lp_item_id, |
1944 | 1944 | 'learnpath_item_view_id' => $safe_lp_item_view_id, |
@@ -1955,7 +1955,7 @@ discard block |
||
1955 | 1955 | 'data-size' => 'md' |
1956 | 1956 | ] |
1957 | 1957 | ); |
1958 | - $html .='<br />'; |
|
1958 | + $html .= '<br />'; |
|
1959 | 1959 | } else { |
1960 | 1960 | // User |
1961 | 1961 | if (api_is_allowed_to_session_edit()) { |
@@ -1980,7 +1980,7 @@ discard block |
||
1980 | 1980 | |
1981 | 1981 | //Next question |
1982 | 1982 | if (!empty($questions_in_media)) { |
1983 | - $questions_in_media = "['".implode("','",$questions_in_media)."']"; |
|
1983 | + $questions_in_media = "['".implode("','", $questions_in_media)."']"; |
|
1984 | 1984 | $all_button .= ' <a href="javascript://" class="'.$class.'" onclick="save_question_list('.$questions_in_media.'); ">'.$label.'</a>'; |
1985 | 1985 | } else { |
1986 | 1986 | $all_button .= ' <a href="javascript://" class="'.$class.'" onclick="save_now('.$question_id.', \'\', \''.$currentAnswer.'\'); ">'.$label.'</a>'; |
@@ -1998,7 +1998,7 @@ discard block |
||
1998 | 1998 | } |
1999 | 1999 | $class .= ' question-validate-btn'; // used to select it with jquery |
2000 | 2000 | $all_button = ' <a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>'; |
2001 | - $all_button .= ' ' . Display::span(null, ['id' => 'save_all_reponse']); |
|
2001 | + $all_button .= ' '.Display::span(null, ['id' => 'save_all_reponse']); |
|
2002 | 2002 | $html .= $all_button; |
2003 | 2003 | } |
2004 | 2004 | } |
@@ -2240,8 +2240,8 @@ discard block |
||
2240 | 2240 | $params = array(); |
2241 | 2241 | $params['course_id'] = $course_id; |
2242 | 2242 | $params['session_id'] = api_get_session_id(); |
2243 | - $params['user_id'] = isset($exe_info['exe_user_id'])? $exe_info['exe_user_id'] : api_get_user_id(); |
|
2244 | - $params['exercise_id'] = isset($exe_info['exe_exo_id'])? $exe_info['exe_exo_id'] : $this->id; |
|
2243 | + $params['user_id'] = isset($exe_info['exe_user_id']) ? $exe_info['exe_user_id'] : api_get_user_id(); |
|
2244 | + $params['exercise_id'] = isset($exe_info['exe_exo_id']) ? $exe_info['exe_exo_id'] : $this->id; |
|
2245 | 2245 | $params['question_id'] = $questionId; |
2246 | 2246 | $params['exe_id'] = isset($exe_info['exe_id']) ? $exe_info['exe_id'] : $exeId; |
2247 | 2247 | |
@@ -2297,10 +2297,10 @@ discard block |
||
2297 | 2297 | $answer = $objAnswerTmp->selectAnswer($answerId); |
2298 | 2298 | $answerComment = $objAnswerTmp->selectComment($answerId); |
2299 | 2299 | $answerCorrect = $objAnswerTmp->isCorrect($answerId); |
2300 | - $answerWeighting = (float)$objAnswerTmp->selectWeighting($answerId); |
|
2300 | + $answerWeighting = (float) $objAnswerTmp->selectWeighting($answerId); |
|
2301 | 2301 | $answerAutoId = $objAnswerTmp->selectAutoId($answerId); |
2302 | 2302 | |
2303 | - $answer_correct_array[$answerId] = (bool)$answerCorrect; |
|
2303 | + $answer_correct_array[$answerId] = (bool) $answerCorrect; |
|
2304 | 2304 | |
2305 | 2305 | if ($debug) { |
2306 | 2306 | error_log("answer auto id: $answerAutoId "); |
@@ -2309,7 +2309,7 @@ discard block |
||
2309 | 2309 | |
2310 | 2310 | // Delineation |
2311 | 2311 | $delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1); |
2312 | - $answer_delineation_destination=$objAnswerTmp->selectDestination(1); |
|
2312 | + $answer_delineation_destination = $objAnswerTmp->selectDestination(1); |
|
2313 | 2313 | |
2314 | 2314 | switch ($answerType) { |
2315 | 2315 | // for unique answer |
@@ -2322,7 +2322,7 @@ discard block |
||
2322 | 2322 | exe_id = '".$exeId."' AND |
2323 | 2323 | question_id= '".$questionId."'"; |
2324 | 2324 | $result = Database::query($sql); |
2325 | - $choice = Database::result($result,0,"answer"); |
|
2325 | + $choice = Database::result($result, 0, "answer"); |
|
2326 | 2326 | |
2327 | 2327 | $studentChoice = $choice == $answerAutoId ? 1 : 0; |
2328 | 2328 | if ($studentChoice) { |
@@ -2373,7 +2373,7 @@ discard block |
||
2373 | 2373 | } else { |
2374 | 2374 | // If no result then the user just hit don't know |
2375 | 2375 | $studentChoice = 3; |
2376 | - $questionScore += $doubt_score; |
|
2376 | + $questionScore += $doubt_score; |
|
2377 | 2377 | } |
2378 | 2378 | $totalScore = $questionScore; |
2379 | 2379 | break; |
@@ -2389,17 +2389,17 @@ discard block |
||
2389 | 2389 | } |
2390 | 2390 | |
2391 | 2391 | $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; |
2392 | - $real_answers[$answerId] = (bool)$studentChoice; |
|
2392 | + $real_answers[$answerId] = (bool) $studentChoice; |
|
2393 | 2393 | |
2394 | 2394 | if ($studentChoice) { |
2395 | - $questionScore +=$answerWeighting; |
|
2395 | + $questionScore += $answerWeighting; |
|
2396 | 2396 | } |
2397 | 2397 | } else { |
2398 | 2398 | $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; |
2399 | - $real_answers[$answerId] = (bool)$studentChoice; |
|
2399 | + $real_answers[$answerId] = (bool) $studentChoice; |
|
2400 | 2400 | |
2401 | 2401 | if (isset($studentChoice)) { |
2402 | - $questionScore += $answerWeighting; |
|
2402 | + $questionScore += $answerWeighting; |
|
2403 | 2403 | } |
2404 | 2404 | } |
2405 | 2405 | $totalScore += $answerWeighting; |
@@ -2417,16 +2417,16 @@ discard block |
||
2417 | 2417 | $choice[$ind] = 1; |
2418 | 2418 | } |
2419 | 2419 | $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; |
2420 | - $real_answers[$answerId] = (bool)$studentChoice; |
|
2420 | + $real_answers[$answerId] = (bool) $studentChoice; |
|
2421 | 2421 | if ($studentChoice) { |
2422 | - $questionScore +=$answerWeighting; |
|
2422 | + $questionScore += $answerWeighting; |
|
2423 | 2423 | } |
2424 | 2424 | } else { |
2425 | 2425 | $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; |
2426 | 2426 | if (isset($studentChoice)) { |
2427 | 2427 | $questionScore += $answerWeighting; |
2428 | 2428 | } |
2429 | - $real_answers[$answerId] = (bool)$studentChoice; |
|
2429 | + $real_answers[$answerId] = (bool) $studentChoice; |
|
2430 | 2430 | } |
2431 | 2431 | $totalScore += $answerWeighting; |
2432 | 2432 | if ($debug) error_log("studentChoice: $studentChoice"); |
@@ -2438,7 +2438,7 @@ discard block |
||
2438 | 2438 | $resultans = Database::query($sql); |
2439 | 2439 | while ($row = Database::fetch_array($resultans)) { |
2440 | 2440 | $ind = $row['answer']; |
2441 | - $result = explode(':',$ind); |
|
2441 | + $result = explode(':', $ind); |
|
2442 | 2442 | if (isset($result[0])) { |
2443 | 2443 | $my_answer_id = isset($result[0]) ? $result[0] : ''; |
2444 | 2444 | $option = isset($result[1]) ? $result[1] : ''; |
@@ -2559,10 +2559,10 @@ discard block |
||
2559 | 2559 | } |
2560 | 2560 | // adds the piece of text that is before the blank |
2561 | 2561 | //and ends with '[' into a general storage array |
2562 | - $real_text[] = api_substr($temp, 0, $pos +1); |
|
2563 | - $answer .= api_substr($temp, 0, $pos +1); |
|
2562 | + $real_text[] = api_substr($temp, 0, $pos + 1); |
|
2563 | + $answer .= api_substr($temp, 0, $pos + 1); |
|
2564 | 2564 | //take the string remaining (after the last "[" we found) |
2565 | - $temp = api_substr($temp, $pos +1); |
|
2565 | + $temp = api_substr($temp, $pos + 1); |
|
2566 | 2566 | // quit the loop if there are no more blanks, and update $pos to the position of next ']' |
2567 | 2567 | if (($pos = api_strpos($temp, ']')) === false) { |
2568 | 2568 | // adds the end of the text |
@@ -2598,7 +2598,7 @@ discard block |
||
2598 | 2598 | //put the contents of the [] answer tag into correct_tags[] |
2599 | 2599 | $correct_tags[] = api_substr($temp, 0, $pos); |
2600 | 2600 | $j++; |
2601 | - $temp = api_substr($temp, $pos +1); |
|
2601 | + $temp = api_substr($temp, $pos + 1); |
|
2602 | 2602 | } |
2603 | 2603 | $answer = ''; |
2604 | 2604 | $real_correct_tags = $correct_tags; |
@@ -2621,7 +2621,7 @@ discard block |
||
2621 | 2621 | } elseif (!empty($user_tags[$i])) { |
2622 | 2622 | // else if the word entered by the student IS NOT the same as the one defined by the professor |
2623 | 2623 | // adds the word in red at the end of the string, and strikes it |
2624 | - $answer .= '<font color="red"><s>' . $user_tags[$i] . '</s></font>'; |
|
2624 | + $answer .= '<font color="red"><s>'.$user_tags[$i].'</s></font>'; |
|
2625 | 2625 | } else { |
2626 | 2626 | // adds a tabulation if no word has been typed by the student |
2627 | 2627 | $answer .= ''; // remove that causes issue |
@@ -2640,17 +2640,17 @@ discard block |
||
2640 | 2640 | } elseif (!empty ($user_tags[$i])) { |
2641 | 2641 | // else if the word entered by the student IS NOT the same as the one defined by the professor |
2642 | 2642 | // adds the word in red at the end of the string, and strikes it |
2643 | - $answer .= '<font color="red"><s>' . $user_tags[$i] . '</s></font>'; |
|
2643 | + $answer .= '<font color="red"><s>'.$user_tags[$i].'</s></font>'; |
|
2644 | 2644 | } else { |
2645 | 2645 | // adds a tabulation if no word has been typed by the student |
2646 | - $answer .= ''; // remove that causes issue |
|
2646 | + $answer .= ''; // remove that causes issue |
|
2647 | 2647 | } |
2648 | 2648 | } |
2649 | 2649 | |
2650 | 2650 | // adds the correct word, followed by ] to close the blank |
2651 | - $answer .= ' / <font color="green"><b>' . $real_correct_tags[$i] . '</b></font>]'; |
|
2652 | - if (isset($real_text[$i +1])) { |
|
2653 | - $answer .= $real_text[$i +1]; |
|
2651 | + $answer .= ' / <font color="green"><b>'.$real_correct_tags[$i].'</b></font>]'; |
|
2652 | + if (isset($real_text[$i + 1])) { |
|
2653 | + $answer .= $real_text[$i + 1]; |
|
2654 | 2654 | } |
2655 | 2655 | } |
2656 | 2656 | } else { |
@@ -2784,10 +2784,10 @@ discard block |
||
2784 | 2784 | } |
2785 | 2785 | // adds the piece of text that is before the blank |
2786 | 2786 | //and ends with '[' into a general storage array |
2787 | - $realText[] = api_substr($temp, 0, $pos +1); |
|
2788 | - $answer .= api_substr($temp, 0, $pos +1); |
|
2787 | + $realText[] = api_substr($temp, 0, $pos + 1); |
|
2788 | + $answer .= api_substr($temp, 0, $pos + 1); |
|
2789 | 2789 | //take the string remaining (after the last "[" we found) |
2790 | - $temp = api_substr($temp, $pos +1); |
|
2790 | + $temp = api_substr($temp, $pos + 1); |
|
2791 | 2791 | // quit the loop if there are no more blanks, and update $pos to the position of next ']' |
2792 | 2792 | if (($pos = api_strpos($temp, ']')) === false) { |
2793 | 2793 | // adds the end of the text |
@@ -2821,7 +2821,7 @@ discard block |
||
2821 | 2821 | //put the contents of the [] answer tag into correct_tags[] |
2822 | 2822 | $correctTags[] = api_substr($temp, 0, $pos); |
2823 | 2823 | $j++; |
2824 | - $temp = api_substr($temp, $pos +1); |
|
2824 | + $temp = api_substr($temp, $pos + 1); |
|
2825 | 2825 | } |
2826 | 2826 | $answer = ''; |
2827 | 2827 | $realCorrectTags = $correctTags; |
@@ -2841,22 +2841,22 @@ discard block |
||
2841 | 2841 | } elseif (!empty($userTags[$i])) { |
2842 | 2842 | // else if the word entered by the student IS NOT the same as the one defined by the professor |
2843 | 2843 | // adds the word in red at the end of the string, and strikes it |
2844 | - $answer .= '<font color="red"><s>' . $userTags[$i] . '</s></font>'; |
|
2844 | + $answer .= '<font color="red"><s>'.$userTags[$i].'</s></font>'; |
|
2845 | 2845 | } else { |
2846 | 2846 | // adds a tabulation if no word has been typed by the student |
2847 | 2847 | $answer .= ''; // remove that causes issue |
2848 | 2848 | } |
2849 | 2849 | // adds the correct word, followed by ] to close the blank |
2850 | - $answer .= ' / <font color="green"><b>' . $realCorrectTags[$i] . '</b></font>]'; |
|
2851 | - if (isset($realText[$i +1])) { |
|
2852 | - $answer .= $realText[$i +1]; |
|
2850 | + $answer .= ' / <font color="green"><b>'.$realCorrectTags[$i].'</b></font>]'; |
|
2851 | + if (isset($realText[$i + 1])) { |
|
2852 | + $answer .= $realText[$i + 1]; |
|
2853 | 2853 | } |
2854 | 2854 | } |
2855 | 2855 | break; |
2856 | 2856 | // for free answer |
2857 | 2857 | case FREE_ANSWER: |
2858 | 2858 | if ($from_database) { |
2859 | - $query = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT." |
|
2859 | + $query = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT." |
|
2860 | 2860 | WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'"; |
2861 | 2861 | $resq = Database::query($query); |
2862 | 2862 | $data = Database::fetch_array($resq); |
@@ -2867,9 +2867,9 @@ discard block |
||
2867 | 2867 | $questionScore = $data['marks']; |
2868 | 2868 | |
2869 | 2869 | if ($questionScore == -1) { |
2870 | - $totalScore+= 0; |
|
2870 | + $totalScore += 0; |
|
2871 | 2871 | } else { |
2872 | - $totalScore+= $questionScore; |
|
2872 | + $totalScore += $questionScore; |
|
2873 | 2873 | } |
2874 | 2874 | if ($questionScore == '') { |
2875 | 2875 | $questionScore = 0; |
@@ -2890,14 +2890,14 @@ discard block |
||
2890 | 2890 | $query = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT." |
2891 | 2891 | WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'"; |
2892 | 2892 | $resq = Database::query($query); |
2893 | - $choice = Database::result($resq,0,'answer'); |
|
2893 | + $choice = Database::result($resq, 0, 'answer'); |
|
2894 | 2894 | $choice = str_replace('\r\n', '', $choice); |
2895 | 2895 | $choice = stripslashes($choice); |
2896 | - $questionScore = Database::result($resq,0,"marks"); |
|
2897 | - if ($questionScore==-1) { |
|
2898 | - $totalScore+=0; |
|
2896 | + $questionScore = Database::result($resq, 0, "marks"); |
|
2897 | + if ($questionScore == -1) { |
|
2898 | + $totalScore += 0; |
|
2899 | 2899 | } else { |
2900 | - $totalScore+=$questionScore; |
|
2900 | + $totalScore += $questionScore; |
|
2901 | 2901 | } |
2902 | 2902 | $arrques = $questionName; |
2903 | 2903 | $arrans = $choice; |
@@ -2942,7 +2942,7 @@ discard block |
||
2942 | 2942 | |
2943 | 2943 | while ($a_answers = Database::fetch_array($res_answers)) { |
2944 | 2944 | $i_answer_id = $a_answers['id']; //3 |
2945 | - $s_answer_label = $a_answers['answer']; // your daddy - your mother |
|
2945 | + $s_answer_label = $a_answers['answer']; // your daddy - your mother |
|
2946 | 2946 | $i_answer_correct_answer = $a_answers['correct']; //1 - 2 |
2947 | 2947 | $i_answer_id_auto = $a_answers['id_auto']; // 3 - 4 |
2948 | 2948 | |
@@ -2994,8 +2994,8 @@ discard block |
||
2994 | 2994 | |
2995 | 2995 | if ($show_result) { |
2996 | 2996 | echo '<tr>'; |
2997 | - echo '<td>' . $s_answer_label . '</td>'; |
|
2998 | - echo '<td>' . $user_answer; |
|
2997 | + echo '<td>'.$s_answer_label.'</td>'; |
|
2998 | + echo '<td>'.$user_answer; |
|
2999 | 2999 | |
3000 | 3000 | if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) { |
3001 | 3001 | if (isset($real_list[$i_answer_correct_answer])) { |
@@ -3104,7 +3104,7 @@ discard block |
||
3104 | 3104 | if ($from_database) { |
3105 | 3105 | // getting the user answer |
3106 | 3106 | $TBL_TRACK_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT); |
3107 | - $query = "SELECT hotspot_correct, hotspot_coordinate |
|
3107 | + $query = "SELECT hotspot_correct, hotspot_coordinate |
|
3108 | 3108 | FROM $TBL_TRACK_HOTSPOT |
3109 | 3109 | WHERE |
3110 | 3110 | hotspot_exe_id = '".$exeId."' AND |
@@ -3112,20 +3112,20 @@ discard block |
||
3112 | 3112 | hotspot_answer_id='1'"; |
3113 | 3113 | //by default we take 1 because it's a delineation |
3114 | 3114 | $resq = Database::query($query); |
3115 | - $row = Database::fetch_array($resq,'ASSOC'); |
|
3115 | + $row = Database::fetch_array($resq, 'ASSOC'); |
|
3116 | 3116 | |
3117 | 3117 | $choice = $row['hotspot_correct']; |
3118 | 3118 | $user_answer = $row['hotspot_coordinate']; |
3119 | 3119 | |
3120 | 3120 | // THIS is very important otherwise the poly_compile will throw an error!! |
3121 | 3121 | // round-up the coordinates |
3122 | - $coords = explode('/',$user_answer); |
|
3122 | + $coords = explode('/', $user_answer); |
|
3123 | 3123 | $user_array = ''; |
3124 | 3124 | foreach ($coords as $coord) { |
3125 | - list($x,$y) = explode(';',$coord); |
|
3125 | + list($x, $y) = explode(';', $coord); |
|
3126 | 3126 | $user_array .= round($x).';'.round($y).'/'; |
3127 | 3127 | } |
3128 | - $user_array = substr($user_array,0,-1); |
|
3128 | + $user_array = substr($user_array, 0, -1); |
|
3129 | 3129 | } else { |
3130 | 3130 | if (!empty($studentChoice)) { |
3131 | 3131 | $newquestionList[] = $questionId; |
@@ -3135,13 +3135,13 @@ discard block |
||
3135 | 3135 | $studentChoice = $choice[$answerId]; |
3136 | 3136 | $questionScore += $answerWeighting; |
3137 | 3137 | |
3138 | - if ($hotspot_delineation_result[1]==1) { |
|
3138 | + if ($hotspot_delineation_result[1] == 1) { |
|
3139 | 3139 | $totalScore += $answerWeighting; //adding the total |
3140 | 3140 | } |
3141 | 3141 | } |
3142 | 3142 | } |
3143 | - $_SESSION['hotspot_coord'][1] = $delineation_cord; |
|
3144 | - $_SESSION['hotspot_dest'][1] = $answer_delineation_destination; |
|
3143 | + $_SESSION['hotspot_coord'][1] = $delineation_cord; |
|
3144 | + $_SESSION['hotspot_dest'][1] = $answer_delineation_destination; |
|
3145 | 3145 | break; |
3146 | 3146 | } // end switch Answertype |
3147 | 3147 | |
@@ -3199,7 +3199,7 @@ discard block |
||
3199 | 3199 | $results_disabled |
3200 | 3200 | ); |
3201 | 3201 | //} |
3202 | - } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) { |
|
3202 | + } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { |
|
3203 | 3203 | // if ($origin!='learnpath') { |
3204 | 3204 | ExerciseShowFunctions::display_multiple_answer_combination_true_false( |
3205 | 3205 | $feedback_type, |
@@ -3216,11 +3216,11 @@ discard block |
||
3216 | 3216 | //} |
3217 | 3217 | } elseif ($answerType == FILL_IN_BLANKS) { |
3218 | 3218 | //if ($origin!='learnpath') { |
3219 | - ExerciseShowFunctions::display_fill_in_blanks_answer($feedback_type, $answer,0,0, $results_disabled); |
|
3219 | + ExerciseShowFunctions::display_fill_in_blanks_answer($feedback_type, $answer, 0, 0, $results_disabled); |
|
3220 | 3220 | // } |
3221 | 3221 | } elseif ($answerType == CALCULATED_ANSWER) { |
3222 | 3222 | //if ($origin!='learnpath') { |
3223 | - ExerciseShowFunctions::display_calculated_answer($feedback_type, $answer,0,0); |
|
3223 | + ExerciseShowFunctions::display_calculated_answer($feedback_type, $answer, 0, 0); |
|
3224 | 3224 | // } |
3225 | 3225 | } elseif ($answerType == FREE_ANSWER) { |
3226 | 3226 | //if($origin != 'learnpath') { |
@@ -3274,13 +3274,13 @@ discard block |
||
3274 | 3274 | $user_answer = $_SESSION['exerciseResultCoordinates'][$questionId]; |
3275 | 3275 | |
3276 | 3276 | //round-up the coordinates |
3277 | - $coords = explode('/',$user_answer); |
|
3277 | + $coords = explode('/', $user_answer); |
|
3278 | 3278 | $user_array = ''; |
3279 | 3279 | foreach ($coords as $coord) { |
3280 | - list($x,$y) = explode(';',$coord); |
|
3280 | + list($x, $y) = explode(';', $coord); |
|
3281 | 3281 | $user_array .= round($x).';'.round($y).'/'; |
3282 | 3282 | } |
3283 | - $user_array = substr($user_array,0,-1); |
|
3283 | + $user_array = substr($user_array, 0, -1); |
|
3284 | 3284 | |
3285 | 3285 | if ($next) { |
3286 | 3286 | |
@@ -3307,7 +3307,7 @@ discard block |
||
3307 | 3307 | //$overlap = round(polygons_overlap($poly_answer,$poly_user)); |
3308 | 3308 | // //this is an area in pixels |
3309 | 3309 | if ($debug > 0) { |
3310 | - error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0); |
|
3310 | + error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0); |
|
3311 | 3311 | } |
3312 | 3312 | |
3313 | 3313 | if ($overlap < 1) { |
@@ -3320,43 +3320,43 @@ discard block |
||
3320 | 3320 | // that is overlapped by the user's polygon |
3321 | 3321 | $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100); |
3322 | 3322 | if ($debug > 1) { |
3323 | - error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0); |
|
3323 | + error_log(__LINE__.' - Final overlap is '.$final_overlap, 0); |
|
3324 | 3324 | } |
3325 | 3325 | // the final missing area is the percentage of the initial polygon |
3326 | 3326 | // that is not overlapped by the user's polygon |
3327 | 3327 | $final_missing = 100 - $final_overlap; |
3328 | 3328 | if ($debug > 1) { |
3329 | - error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0); |
|
3329 | + error_log(__LINE__.' - Final missing is '.$final_missing, 0); |
|
3330 | 3330 | } |
3331 | 3331 | // the final excess area is the percentage of the initial polygon's size |
3332 | 3332 | // that is covered by the user's polygon outside of the initial polygon |
3333 | 3333 | $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100); |
3334 | 3334 | if ($debug > 1) { |
3335 | - error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0); |
|
3335 | + error_log(__LINE__.' - Final excess is '.$final_excess, 0); |
|
3336 | 3336 | } |
3337 | 3337 | } |
3338 | 3338 | |
3339 | 3339 | //checking the destination parameters parsing the "@@" |
3340 | - $destination_items= explode('@@', $answerDestination); |
|
3340 | + $destination_items = explode('@@', $answerDestination); |
|
3341 | 3341 | $threadhold_total = $destination_items[0]; |
3342 | - $threadhold_items=explode(';',$threadhold_total); |
|
3342 | + $threadhold_items = explode(';', $threadhold_total); |
|
3343 | 3343 | $threadhold1 = $threadhold_items[0]; // overlap |
3344 | 3344 | $threadhold2 = $threadhold_items[1]; // excess |
3345 | - $threadhold3 = $threadhold_items[2]; //missing |
|
3345 | + $threadhold3 = $threadhold_items[2]; //missing |
|
3346 | 3346 | |
3347 | 3347 | // if is delineation |
3348 | - if ($answerId===1) { |
|
3348 | + if ($answerId === 1) { |
|
3349 | 3349 | //setting colors |
3350 | - if ($final_overlap>=$threadhold1) { |
|
3351 | - $overlap_color=true; //echo 'a'; |
|
3350 | + if ($final_overlap >= $threadhold1) { |
|
3351 | + $overlap_color = true; //echo 'a'; |
|
3352 | 3352 | } |
3353 | 3353 | //echo $excess.'-'.$threadhold2; |
3354 | - if ($final_excess<=$threadhold2) { |
|
3355 | - $excess_color=true; //echo 'b'; |
|
3354 | + if ($final_excess <= $threadhold2) { |
|
3355 | + $excess_color = true; //echo 'b'; |
|
3356 | 3356 | } |
3357 | 3357 | //echo '--------'.$missing.'-'.$threadhold3; |
3358 | - if ($final_missing<=$threadhold3) { |
|
3359 | - $missing_color=true; //echo 'c'; |
|
3358 | + if ($final_missing <= $threadhold3) { |
|
3359 | + $missing_color = true; //echo 'c'; |
|
3360 | 3360 | } |
3361 | 3361 | |
3362 | 3362 | // if pass |
@@ -3365,67 +3365,67 @@ discard block |
||
3365 | 3365 | $final_missing <= $threadhold3 && |
3366 | 3366 | $final_excess <= $threadhold2 |
3367 | 3367 | ) { |
3368 | - $next=1; //go to the oars |
|
3369 | - $result_comment=get_lang('Acceptable'); |
|
3370 | - $final_answer = 1; // do not update with update_exercise_attempt |
|
3368 | + $next = 1; //go to the oars |
|
3369 | + $result_comment = get_lang('Acceptable'); |
|
3370 | + $final_answer = 1; // do not update with update_exercise_attempt |
|
3371 | 3371 | } else { |
3372 | - $next=0; |
|
3373 | - $result_comment=get_lang('Unacceptable'); |
|
3374 | - $comment=$answerDestination=$objAnswerTmp->selectComment(1); |
|
3375 | - $answerDestination=$objAnswerTmp->selectDestination(1); |
|
3372 | + $next = 0; |
|
3373 | + $result_comment = get_lang('Unacceptable'); |
|
3374 | + $comment = $answerDestination = $objAnswerTmp->selectComment(1); |
|
3375 | + $answerDestination = $objAnswerTmp->selectDestination(1); |
|
3376 | 3376 | //checking the destination parameters parsing the "@@" |
3377 | - $destination_items= explode('@@', $answerDestination); |
|
3377 | + $destination_items = explode('@@', $answerDestination); |
|
3378 | 3378 | } |
3379 | - } elseif($answerId>1) { |
|
3379 | + } elseif ($answerId > 1) { |
|
3380 | 3380 | if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') { |
3381 | - if ($debug>0) { |
|
3382 | - error_log(__LINE__.' - answerId is of type noerror',0); |
|
3381 | + if ($debug > 0) { |
|
3382 | + error_log(__LINE__.' - answerId is of type noerror', 0); |
|
3383 | 3383 | } |
3384 | 3384 | //type no error shouldn't be treated |
3385 | 3385 | $next = 1; |
3386 | 3386 | continue; |
3387 | 3387 | } |
3388 | - if ($debug>0) { |
|
3389 | - error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0); |
|
3388 | + if ($debug > 0) { |
|
3389 | + error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0); |
|
3390 | 3390 | } |
3391 | 3391 | //check the intersection between the oar and the user |
3392 | 3392 | //echo 'user'; print_r($x_user_list); print_r($y_user_list); |
3393 | 3393 | //echo 'official';print_r($x_list);print_r($y_list); |
3394 | 3394 | //$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list); |
3395 | - $inter= $result['success']; |
|
3395 | + $inter = $result['success']; |
|
3396 | 3396 | |
3397 | 3397 | //$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId); |
3398 | - $delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId); |
|
3398 | + $delineation_cord = $objAnswerTmp->selectHotspotCoordinates($answerId); |
|
3399 | 3399 | |
3400 | - $poly_answer = convert_coordinates($delineation_cord,'|'); |
|
3401 | - $max_coord = poly_get_max($poly_user,$poly_answer); |
|
3402 | - $poly_answer_compiled = poly_compile($poly_answer,$max_coord); |
|
3403 | - $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord); |
|
3400 | + $poly_answer = convert_coordinates($delineation_cord, '|'); |
|
3401 | + $max_coord = poly_get_max($poly_user, $poly_answer); |
|
3402 | + $poly_answer_compiled = poly_compile($poly_answer, $max_coord); |
|
3403 | + $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord); |
|
3404 | 3404 | |
3405 | 3405 | if ($overlap == false) { |
3406 | 3406 | //all good, no overlap |
3407 | 3407 | $next = 1; |
3408 | 3408 | continue; |
3409 | 3409 | } else { |
3410 | - if ($debug>0) { |
|
3411 | - error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0); |
|
3410 | + if ($debug > 0) { |
|
3411 | + error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0); |
|
3412 | 3412 | } |
3413 | 3413 | $organs_at_risk_hit++; |
3414 | 3414 | //show the feedback |
3415 | - $next=0; |
|
3416 | - $comment=$answerDestination=$objAnswerTmp->selectComment($answerId); |
|
3417 | - $answerDestination=$objAnswerTmp->selectDestination($answerId); |
|
3418 | - |
|
3419 | - $destination_items= explode('@@', $answerDestination); |
|
3420 | - $try_hotspot=$destination_items[1]; |
|
3421 | - $lp_hotspot=$destination_items[2]; |
|
3422 | - $select_question_hotspot=$destination_items[3]; |
|
3423 | - $url_hotspot=$destination_items[4]; |
|
3415 | + $next = 0; |
|
3416 | + $comment = $answerDestination = $objAnswerTmp->selectComment($answerId); |
|
3417 | + $answerDestination = $objAnswerTmp->selectDestination($answerId); |
|
3418 | + |
|
3419 | + $destination_items = explode('@@', $answerDestination); |
|
3420 | + $try_hotspot = $destination_items[1]; |
|
3421 | + $lp_hotspot = $destination_items[2]; |
|
3422 | + $select_question_hotspot = $destination_items[3]; |
|
3423 | + $url_hotspot = $destination_items[4]; |
|
3424 | 3424 | } |
3425 | 3425 | } |
3426 | 3426 | } else { // the first delineation feedback |
3427 | - if ($debug>0) { |
|
3428 | - error_log(__LINE__.' first',0); |
|
3427 | + if ($debug > 0) { |
|
3428 | + error_log(__LINE__.' first', 0); |
|
3429 | 3429 | } |
3430 | 3430 | } |
3431 | 3431 | } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) { |
@@ -3433,7 +3433,7 @@ discard block |
||
3433 | 3433 | echo Display::tag('td', $answerMatching[$answerId]); |
3434 | 3434 | echo Display::tag( |
3435 | 3435 | 'td', |
3436 | - "$user_answer / " . Display::tag( |
|
3436 | + "$user_answer / ".Display::tag( |
|
3437 | 3437 | 'strong', |
3438 | 3438 | $answerMatching[$answerCorrect], |
3439 | 3439 | ['style' => 'color: #008000; font-weight: bold;'] |
@@ -3573,7 +3573,7 @@ discard block |
||
3573 | 3573 | $exeId, |
3574 | 3574 | $questionId, |
3575 | 3575 | $nano |
3576 | - ) . '</td> |
|
3576 | + ).'</td> |
|
3577 | 3577 | </tr> |
3578 | 3578 | </table>'; |
3579 | 3579 | break; |
@@ -3632,7 +3632,7 @@ discard block |
||
3632 | 3632 | |
3633 | 3633 | //$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels |
3634 | 3634 | if ($debug > 0) { |
3635 | - error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0); |
|
3635 | + error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0); |
|
3636 | 3636 | } |
3637 | 3637 | if ($overlap < 1) { |
3638 | 3638 | //shortcut to avoid complicated calculations |
@@ -3643,17 +3643,17 @@ discard block |
||
3643 | 3643 | // the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon |
3644 | 3644 | $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100); |
3645 | 3645 | if ($debug > 1) { |
3646 | - error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0); |
|
3646 | + error_log(__LINE__.' - Final overlap is '.$final_overlap, 0); |
|
3647 | 3647 | } |
3648 | 3648 | // the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon |
3649 | 3649 | $final_missing = 100 - $final_overlap; |
3650 | 3650 | if ($debug > 1) { |
3651 | - error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0); |
|
3651 | + error_log(__LINE__.' - Final missing is '.$final_missing, 0); |
|
3652 | 3652 | } |
3653 | 3653 | // 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 |
3654 | 3654 | $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100); |
3655 | 3655 | if ($debug > 1) { |
3656 | - error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0); |
|
3656 | + error_log(__LINE__.' - Final excess is '.$final_excess, 0); |
|
3657 | 3657 | } |
3658 | 3658 | } |
3659 | 3659 | |
@@ -3663,7 +3663,7 @@ discard block |
||
3663 | 3663 | $threadhold_items = explode(';', $threadhold_total); |
3664 | 3664 | $threadhold1 = $threadhold_items[0]; // overlap |
3665 | 3665 | $threadhold2 = $threadhold_items[1]; // excess |
3666 | - $threadhold3 = $threadhold_items[2]; //missing |
|
3666 | + $threadhold3 = $threadhold_items[2]; //missing |
|
3667 | 3667 | // if is delineation |
3668 | 3668 | if ($answerId === 1) { |
3669 | 3669 | //setting colors |
@@ -3695,14 +3695,14 @@ discard block |
||
3695 | 3695 | } elseif ($answerId > 1) { |
3696 | 3696 | if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') { |
3697 | 3697 | if ($debug > 0) { |
3698 | - error_log(__LINE__ . ' - answerId is of type noerror', 0); |
|
3698 | + error_log(__LINE__.' - answerId is of type noerror', 0); |
|
3699 | 3699 | } |
3700 | 3700 | //type no error shouldn't be treated |
3701 | 3701 | $next = 1; |
3702 | 3702 | continue; |
3703 | 3703 | } |
3704 | 3704 | if ($debug > 0) { |
3705 | - error_log(__LINE__ . ' - answerId is >1 so we\'re probably in OAR', 0); |
|
3705 | + error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0); |
|
3706 | 3706 | } |
3707 | 3707 | //check the intersection between the oar and the user |
3708 | 3708 | //echo 'user'; print_r($x_user_list); print_r($y_user_list); |
@@ -3716,7 +3716,7 @@ discard block |
||
3716 | 3716 | $poly_answer = convert_coordinates($delineation_cord, '|'); |
3717 | 3717 | $max_coord = poly_get_max($poly_user, $poly_answer); |
3718 | 3718 | $poly_answer_compiled = poly_compile($poly_answer, $max_coord); |
3719 | - $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord); |
|
3719 | + $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord); |
|
3720 | 3720 | |
3721 | 3721 | if ($overlap == false) { |
3722 | 3722 | //all good, no overlap |
@@ -3724,7 +3724,7 @@ discard block |
||
3724 | 3724 | continue; |
3725 | 3725 | } else { |
3726 | 3726 | if ($debug > 0) { |
3727 | - error_log(__LINE__ . ' - Overlap is ' . $overlap . ': OAR hit', 0); |
|
3727 | + error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0); |
|
3728 | 3728 | } |
3729 | 3729 | $organs_at_risk_hit++; |
3730 | 3730 | //show the feedback |
@@ -3736,12 +3736,12 @@ discard block |
||
3736 | 3736 | $try_hotspot = $destination_items[1]; |
3737 | 3737 | $lp_hotspot = $destination_items[2]; |
3738 | 3738 | $select_question_hotspot = $destination_items[3]; |
3739 | - $url_hotspot=$destination_items[4]; |
|
3739 | + $url_hotspot = $destination_items[4]; |
|
3740 | 3740 | } |
3741 | 3741 | } |
3742 | 3742 | } else { // the first delineation feedback |
3743 | 3743 | if ($debug > 0) { |
3744 | - error_log(__LINE__ . ' first', 0); |
|
3744 | + error_log(__LINE__.' first', 0); |
|
3745 | 3745 | } |
3746 | 3746 | } |
3747 | 3747 | break; |
@@ -3763,7 +3763,7 @@ discard block |
||
3763 | 3763 | echo Display::tag('td', $answerMatching[$answerId]); |
3764 | 3764 | echo Display::tag( |
3765 | 3765 | 'td', |
3766 | - "$user_answer / " . Display::tag( |
|
3766 | + "$user_answer / ".Display::tag( |
|
3767 | 3767 | 'strong', |
3768 | 3768 | $answerMatching[$answerCorrect], |
3769 | 3769 | ['style' => 'color: #008000; font-weight: bold;'] |
@@ -3849,7 +3849,7 @@ discard block |
||
3849 | 3849 | // we use the results from the session (from_db=0) |
3850 | 3850 | // TODO Change this, because it is wrong to show the user |
3851 | 3851 | // some results that haven't been stored in the database yet |
3852 | - if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION ) { |
|
3852 | + if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION) { |
|
3853 | 3853 | |
3854 | 3854 | if ($debug) error_log('$from AND this is a hotspot kind of question '); |
3855 | 3855 | |
@@ -3858,19 +3858,19 @@ discard block |
||
3858 | 3858 | if ($answerType == HOT_SPOT_DELINEATION) { |
3859 | 3859 | if (0) { |
3860 | 3860 | if ($overlap_color) { |
3861 | - $overlap_color='green'; |
|
3861 | + $overlap_color = 'green'; |
|
3862 | 3862 | } else { |
3863 | - $overlap_color='red'; |
|
3863 | + $overlap_color = 'red'; |
|
3864 | 3864 | } |
3865 | 3865 | if ($missing_color) { |
3866 | - $missing_color='green'; |
|
3866 | + $missing_color = 'green'; |
|
3867 | 3867 | } else { |
3868 | - $missing_color='red'; |
|
3868 | + $missing_color = 'red'; |
|
3869 | 3869 | } |
3870 | 3870 | if ($excess_color) { |
3871 | - $excess_color='green'; |
|
3871 | + $excess_color = 'green'; |
|
3872 | 3872 | } else { |
3873 | - $excess_color='red'; |
|
3873 | + $excess_color = 'red'; |
|
3874 | 3874 | } |
3875 | 3875 | if (!is_numeric($final_overlap)) { |
3876 | 3876 | $final_overlap = 0; |
@@ -3882,33 +3882,33 @@ discard block |
||
3882 | 3882 | $final_excess = 0; |
3883 | 3883 | } |
3884 | 3884 | |
3885 | - if ($final_overlap>100) { |
|
3885 | + if ($final_overlap > 100) { |
|
3886 | 3886 | $final_overlap = 100; |
3887 | 3887 | } |
3888 | 3888 | |
3889 | - $table_resume='<table class="data_table"> |
|
3889 | + $table_resume = '<table class="data_table"> |
|
3890 | 3890 | <tr class="row_odd" > |
3891 | 3891 | <td></td> |
3892 | - <td ><b>' . get_lang('Requirements') . '</b></td> |
|
3893 | - <td><b>' . get_lang('YourAnswer') . '</b></td> |
|
3892 | + <td ><b>' . get_lang('Requirements').'</b></td> |
|
3893 | + <td><b>' . get_lang('YourAnswer').'</b></td> |
|
3894 | 3894 | </tr> |
3895 | 3895 | <tr class="row_even"> |
3896 | - <td><b>' . get_lang('Overlap') . '</b></td> |
|
3897 | - <td>' . get_lang('Min') . ' ' . $threadhold1 . '</td> |
|
3898 | - <td><div style="color:' . $overlap_color . '">' |
|
3899 | - . (($final_overlap < 0) ? 0 : intval($final_overlap)) . '</div></td> |
|
3896 | + <td><b>' . get_lang('Overlap').'</b></td> |
|
3897 | + <td>' . get_lang('Min').' '.$threadhold1.'</td> |
|
3898 | + <td><div style="color:' . $overlap_color.'">' |
|
3899 | + . (($final_overlap < 0) ? 0 : intval($final_overlap)).'</div></td> |
|
3900 | 3900 | </tr> |
3901 | 3901 | <tr> |
3902 | - <td><b>' . get_lang('Excess') . '</b></td> |
|
3903 | - <td>' . get_lang('Max') . ' ' . $threadhold2 . '</td> |
|
3904 | - <td><div style="color:' . $excess_color . '">' |
|
3905 | - . (($final_excess < 0) ? 0 : intval($final_excess)) . '</div></td> |
|
3902 | + <td><b>' . get_lang('Excess').'</b></td> |
|
3903 | + <td>' . get_lang('Max').' '.$threadhold2.'</td> |
|
3904 | + <td><div style="color:' . $excess_color.'">' |
|
3905 | + . (($final_excess < 0) ? 0 : intval($final_excess)).'</div></td> |
|
3906 | 3906 | </tr> |
3907 | 3907 | <tr class="row_even"> |
3908 | - <td><b>' . get_lang('Missing') . '</b></td> |
|
3909 | - <td>' . get_lang('Max') . ' ' . $threadhold3 . '</td> |
|
3910 | - <td><div style="color:' . $missing_color . '">' |
|
3911 | - . (($final_missing < 0) ? 0 : intval($final_missing)) . '</div></td> |
|
3908 | + <td><b>' . get_lang('Missing').'</b></td> |
|
3909 | + <td>' . get_lang('Max').' '.$threadhold3.'</td> |
|
3910 | + <td><div style="color:' . $missing_color.'">' |
|
3911 | + . (($final_missing < 0) ? 0 : intval($final_missing)).'</div></td> |
|
3912 | 3912 | </tr> |
3913 | 3913 | </table>'; |
3914 | 3914 | if ($next == 0) { |
@@ -3923,20 +3923,20 @@ discard block |
||
3923 | 3923 | $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers); |
3924 | 3924 | } |
3925 | 3925 | |
3926 | - echo '<h1><div style="color:#333;">' . get_lang('Feedback') . '</div></h1> |
|
3926 | + echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1> |
|
3927 | 3927 | <p style="text-align:center">'; |
3928 | 3928 | |
3929 | - $message = '<p>' . get_lang('YourDelineation') . '</p>'; |
|
3929 | + $message = '<p>'.get_lang('YourDelineation').'</p>'; |
|
3930 | 3930 | $message .= $table_resume; |
3931 | - $message .= '<br />' . get_lang('ResultIs') . ' ' . $result_comment . '<br />'; |
|
3931 | + $message .= '<br />'.get_lang('ResultIs').' '.$result_comment.'<br />'; |
|
3932 | 3932 | if ($organs_at_risk_hit > 0) { |
3933 | - $message .= '<p><b>' . get_lang('OARHit') . '</b></p>'; |
|
3933 | + $message .= '<p><b>'.get_lang('OARHit').'</b></p>'; |
|
3934 | 3934 | } |
3935 | - $message .='<p>' . $comment . '</p>'; |
|
3935 | + $message .= '<p>'.$comment.'</p>'; |
|
3936 | 3936 | echo $message; |
3937 | 3937 | } else { |
3938 | 3938 | echo $hotspot_delineation_result[0]; //prints message |
3939 | - $from_database = 1; // the hotspot_solution.swf needs this variable |
|
3939 | + $from_database = 1; // the hotspot_solution.swf needs this variable |
|
3940 | 3940 | } |
3941 | 3941 | |
3942 | 3942 | //save the score attempts |
@@ -3958,20 +3958,20 @@ discard block |
||
3958 | 3958 | $exerciseResultCoordinates[$quesId] |
3959 | 3959 | ); |
3960 | 3960 | } else { |
3961 | - if ($final_answer==0) { |
|
3961 | + if ($final_answer == 0) { |
|
3962 | 3962 | $questionScore = 0; |
3963 | - $answer=0; |
|
3963 | + $answer = 0; |
|
3964 | 3964 | Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0); |
3965 | 3965 | if (is_array($exerciseResultCoordinates[$quesId])) { |
3966 | - foreach($exerciseResultCoordinates[$quesId] as $idx => $val) { |
|
3967 | - Event::saveExerciseAttemptHotspot($exeId,$quesId,$idx,0,$val); |
|
3966 | + foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) { |
|
3967 | + Event::saveExerciseAttemptHotspot($exeId, $quesId, $idx, 0, $val); |
|
3968 | 3968 | } |
3969 | 3969 | } |
3970 | 3970 | } else { |
3971 | 3971 | Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0); |
3972 | 3972 | if (is_array($exerciseResultCoordinates[$quesId])) { |
3973 | - foreach($exerciseResultCoordinates[$quesId] as $idx => $val) { |
|
3974 | - Event::saveExerciseAttemptHotspot($exeId,$quesId,$idx,$choice[$idx],$val); |
|
3973 | + foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) { |
|
3974 | + Event::saveExerciseAttemptHotspot($exeId, $quesId, $idx, $choice[$idx], $val); |
|
3975 | 3975 | } |
3976 | 3976 | } |
3977 | 3977 | } |
@@ -3990,7 +3990,7 @@ discard block |
||
3990 | 3990 | echo " |
3991 | 3991 | <tr> |
3992 | 3992 | <td colspan=\"2\"> |
3993 | - <p><em>" . get_lang('HotSpot') . "</em></p> |
|
3993 | + <p><em>" . get_lang('HotSpot')."</em></p> |
|
3994 | 3994 | |
3995 | 3995 | <div id=\"hotspot-solution-$questionId\"></div> |
3996 | 3996 | |
@@ -4028,7 +4028,7 @@ discard block |
||
4028 | 4028 | |
4029 | 4029 | if ($saved_results) { |
4030 | 4030 | if ($debug) error_log("Save question results $saved_results"); |
4031 | - if ($debug) error_log(print_r($choice ,1 )); |
|
4031 | + if ($debug) error_log(print_r($choice, 1)); |
|
4032 | 4032 | |
4033 | 4033 | if (empty($choice)) { |
4034 | 4034 | $choice = 0; |
@@ -4040,14 +4040,14 @@ discard block |
||
4040 | 4040 | $ans = $reply[$i]; |
4041 | 4041 | Event::saveQuestionAttempt( |
4042 | 4042 | $questionScore, |
4043 | - $ans . ':' . $choice[$ans], |
|
4043 | + $ans.':'.$choice[$ans], |
|
4044 | 4044 | $quesId, |
4045 | 4045 | $exeId, |
4046 | 4046 | $i, |
4047 | 4047 | $this->id |
4048 | 4048 | ); |
4049 | 4049 | if ($debug) { |
4050 | - error_log('result =>' . $questionScore . ' ' . $ans . ':' . $choice[$ans]); |
|
4050 | + error_log('result =>'.$questionScore.' '.$ans.':'.$choice[$ans]); |
|
4051 | 4051 | } |
4052 | 4052 | } |
4053 | 4053 | } else { |
@@ -4058,7 +4058,7 @@ discard block |
||
4058 | 4058 | $reply = array_keys($choice); |
4059 | 4059 | |
4060 | 4060 | if ($debug) { |
4061 | - error_log("reply " . print_r($reply, 1) . ""); |
|
4061 | + error_log("reply ".print_r($reply, 1).""); |
|
4062 | 4062 | } |
4063 | 4063 | for ($i = 0; $i < sizeof($reply); $i++) { |
4064 | 4064 | $ans = $reply[$i]; |
@@ -4117,7 +4117,7 @@ discard block |
||
4117 | 4117 | |
4118 | 4118 | Event::saveQuestionAttempt($questionScore, implode('|', $answer), $quesId, $exeId, 0, $this->id); |
4119 | 4119 | } else { |
4120 | - Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0,$this->id); |
|
4120 | + Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id); |
|
4121 | 4121 | } |
4122 | 4122 | } |
4123 | 4123 | |
@@ -4127,8 +4127,8 @@ discard block |
||
4127 | 4127 | |
4128 | 4128 | if ($saved_results) { |
4129 | 4129 | $stat_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
4130 | - $sql = 'UPDATE ' . $stat_table . ' SET |
|
4131 | - exe_result = exe_result + ' . floatval($questionScore) . ' |
|
4130 | + $sql = 'UPDATE '.$stat_table.' SET |
|
4131 | + exe_result = exe_result + ' . floatval($questionScore).' |
|
4132 | 4132 | WHERE exe_id = ' . $exeId; |
4133 | 4133 | if ($debug) error_log($sql); |
4134 | 4134 | Database::query($sql); |
@@ -4152,7 +4152,7 @@ discard block |
||
4152 | 4152 | */ |
4153 | 4153 | public function send_mail_notification_for_exam($question_list_answers, $origin, $exe_id) |
4154 | 4154 | { |
4155 | - if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) { |
|
4155 | + if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) { |
|
4156 | 4156 | return null; |
4157 | 4157 | } |
4158 | 4158 | // Email configuration settings |
@@ -4203,7 +4203,7 @@ discard block |
||
4203 | 4203 | $msg = str_replace("#course#", $courseInfo['name'], $msg1); |
4204 | 4204 | |
4205 | 4205 | if ($origin != 'learnpath') { |
4206 | - $msg.= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
|
4206 | + $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
|
4207 | 4207 | } |
4208 | 4208 | $msg1 = str_replace("#url#", $url_email, $msg); |
4209 | 4209 | $mail_content = $msg1; |
@@ -4232,7 +4232,7 @@ discard block |
||
4232 | 4232 | */ |
4233 | 4233 | function send_notification_for_open_questions($question_list_answers, $origin, $exe_id) |
4234 | 4234 | { |
4235 | - if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) { |
|
4235 | + if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) { |
|
4236 | 4236 | return null; |
4237 | 4237 | } |
4238 | 4238 | // Email configuration settings |
@@ -4295,11 +4295,11 @@ discard block |
||
4295 | 4295 | $msg .= '</table><br />'; |
4296 | 4296 | |
4297 | 4297 | |
4298 | - $msg1 = str_replace("#exercise#", $this->exercise, $msg); |
|
4299 | - $msg = str_replace("#firstName#", $user_info['firstname'],$msg1); |
|
4300 | - $msg1 = str_replace("#lastName#", $user_info['lastname'],$msg); |
|
4301 | - $msg = str_replace("#mail#", $user_info['email'],$msg1); |
|
4302 | - $msg = str_replace("#course#", $course_info['name'],$msg1); |
|
4298 | + $msg1 = str_replace("#exercise#", $this->exercise, $msg); |
|
4299 | + $msg = str_replace("#firstName#", $user_info['firstname'], $msg1); |
|
4300 | + $msg1 = str_replace("#lastName#", $user_info['lastname'], $msg); |
|
4301 | + $msg = str_replace("#mail#", $user_info['email'], $msg1); |
|
4302 | + $msg = str_replace("#course#", $course_info['name'], $msg1); |
|
4303 | 4303 | |
4304 | 4304 | if ($origin != 'learnpath') { |
4305 | 4305 | $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
@@ -4328,7 +4328,7 @@ discard block |
||
4328 | 4328 | |
4329 | 4329 | function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id) |
4330 | 4330 | { |
4331 | - if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) { |
|
4331 | + if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) { |
|
4332 | 4332 | return null; |
4333 | 4333 | } |
4334 | 4334 | // Email configuration settings |
@@ -4352,7 +4352,7 @@ discard block |
||
4352 | 4352 | $answer_type = $item['answer_type']; |
4353 | 4353 | |
4354 | 4354 | if (!empty($question) && !empty($answer) && $answer_type == ORAL_EXPRESSION) { |
4355 | - $oral_question_list.='<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">' |
|
4355 | + $oral_question_list .= '<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">' |
|
4356 | 4356 | .'<tr>' |
4357 | 4357 | .'<td width="220" valign="top" bgcolor="#E5EDF8"> '.get_lang('Question').'</td>' |
4358 | 4358 | .'<td width="473" valign="top" bgcolor="#F3F3F3">'.$question.'</td>' |
@@ -4385,7 +4385,7 @@ discard block |
||
4385 | 4385 | .'<td> #mail#</td>' |
4386 | 4386 | .'</tr>' |
4387 | 4387 | .'</table>'; |
4388 | - $msg .= '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'),$oral_question_list).'<br />'; |
|
4388 | + $msg .= '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'), $oral_question_list).'<br />'; |
|
4389 | 4389 | $msg1 = str_replace("#exercise#", $this->exercise, $msg); |
4390 | 4390 | $msg = str_replace("#firstName#", $user_info['firstname'], $msg1); |
4391 | 4391 | $msg1 = str_replace("#lastName#", $user_info['lastname'], $msg); |
@@ -4393,7 +4393,7 @@ discard block |
||
4393 | 4393 | $msg = str_replace("#course#", $course_info['name'], $msg1); |
4394 | 4394 | |
4395 | 4395 | if ($origin != 'learnpath') { |
4396 | - $msg.= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
|
4396 | + $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; |
|
4397 | 4397 | } |
4398 | 4398 | $msg1 = str_replace("#url#", $url_email, $msg); |
4399 | 4399 | $mail_content = $msg1; |
@@ -4459,10 +4459,10 @@ discard block |
||
4459 | 4459 | } |
4460 | 4460 | $html = '<div class="question-result">'; |
4461 | 4461 | $html .= Display::page_header( |
4462 | - Display::return_icon('test-quiz.png', get_lang('Result'),null, ICON_SIZE_MEDIUM).' '.$this->exercise.' : '.get_lang('Result') |
|
4462 | + Display::return_icon('test-quiz.png', get_lang('Result'), null, ICON_SIZE_MEDIUM).' '.$this->exercise.' : '.get_lang('Result') |
|
4463 | 4463 | ); |
4464 | 4464 | $html .= Display::description($array); |
4465 | - $html .="</div>"; |
|
4465 | + $html .= "</div>"; |
|
4466 | 4466 | return $html; |
4467 | 4467 | } |
4468 | 4468 | |
@@ -4579,7 +4579,7 @@ discard block |
||
4579 | 4579 | false, |
4580 | 4580 | $objExercise->selectPropagateNeg() |
4581 | 4581 | ); |
4582 | - $totalScore += $question_result['score']; |
|
4582 | + $totalScore += $question_result['score']; |
|
4583 | 4583 | } |
4584 | 4584 | |
4585 | 4585 | if ($objExercise->selectPropagateNeg() == 0 && $totalScore < 0) { |
@@ -4723,7 +4723,7 @@ discard block |
||
4723 | 4723 | } |
4724 | 4724 | } |
4725 | 4725 | |
4726 | - if (!empty($message)){ |
|
4726 | + if (!empty($message)) { |
|
4727 | 4727 | $message = Display::return_message($message, 'warning', false); |
4728 | 4728 | } |
4729 | 4729 | |
@@ -4737,7 +4737,7 @@ discard block |
||
4737 | 4737 | { |
4738 | 4738 | $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM); |
4739 | 4739 | $sql = "SELECT max_score FROM $TBL_LP_ITEM |
4740 | - WHERE c_id = {$this->course_id} AND item_type = '" . TOOL_QUIZ . "' AND path = '{$this->id}'"; |
|
4740 | + WHERE c_id = {$this->course_id} AND item_type = '".TOOL_QUIZ."' AND path = '{$this->id}'"; |
|
4741 | 4741 | $result = Database::query($sql); |
4742 | 4742 | if (Database::num_rows($result) > 0) { |
4743 | 4743 | return true; |
@@ -4903,7 +4903,7 @@ discard block |
||
4903 | 4903 | $sql_track = "SELECT * FROM $track_exercises WHERE exe_id = $exe_id "; |
4904 | 4904 | $result = Database::query($sql_track); |
4905 | 4905 | $new_array = array(); |
4906 | - if (Database::num_rows($result) > 0 ) { |
|
4906 | + if (Database::num_rows($result) > 0) { |
|
4907 | 4907 | $new_array = Database::fetch_array($result, 'ASSOC'); |
4908 | 4908 | |
4909 | 4909 | $new_array['duration'] = null; |
@@ -4915,11 +4915,11 @@ discard block |
||
4915 | 4915 | $start_date = api_strtotime($start_date, 'UTC'); |
4916 | 4916 | $end_date = api_strtotime($end_date, 'UTC'); |
4917 | 4917 | if ($start_date && $end_date) { |
4918 | - $mytime = $end_date- $start_date; |
|
4918 | + $mytime = $end_date - $start_date; |
|
4919 | 4919 | $new_learnpath_item = new learnpathItem(null); |
4920 | 4920 | $time_attemp = $new_learnpath_item->get_scorm_time('js', $mytime); |
4921 | 4921 | $h = get_lang('h'); |
4922 | - $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp); |
|
4922 | + $time_attemp = str_replace('NaN', '00'.$h.'00\'00"', $time_attemp); |
|
4923 | 4923 | $new_array['duration'] = $time_attemp; |
4924 | 4924 | } |
4925 | 4925 | } |
@@ -4941,7 +4941,7 @@ discard block |
||
4941 | 4941 | $result = Database::query($sql); |
4942 | 4942 | } |
4943 | 4943 | } else { |
4944 | - $remind_list = explode(',',$exercise_info['questions_to_check']); |
|
4944 | + $remind_list = explode(',', $exercise_info['questions_to_check']); |
|
4945 | 4945 | |
4946 | 4946 | $remind_list_string = ''; |
4947 | 4947 | if ($action == 'add') { |
@@ -4953,7 +4953,7 @@ discard block |
||
4953 | 4953 | } |
4954 | 4954 | $remind_list_string = implode(',', $remind_list); |
4955 | 4955 | } |
4956 | - } elseif ($action == 'delete') { |
|
4956 | + } elseif ($action == 'delete') { |
|
4957 | 4957 | if (!empty($remind_list)) { |
4958 | 4958 | if (in_array($question_id, $remind_list)) { |
4959 | 4959 | $remind_list = array_flip($remind_list); |
@@ -5054,7 +5054,7 @@ discard block |
||
5054 | 5054 | public function get_max_score() |
5055 | 5055 | { |
5056 | 5056 | $out_max_score = 0; |
5057 | - $tab_question_list = $this->selectQuestionList(true); // list of question's id !!! the array key start at 1 !!! |
|
5057 | + $tab_question_list = $this->selectQuestionList(true); // list of question's id !!! the array key start at 1 !!! |
|
5058 | 5058 | // test is randomQuestions - see field random of test |
5059 | 5059 | if ($this->random > 0 && $this->randomByCat == 0) { |
5060 | 5060 | $nb_random_questions = $this->random; |
@@ -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) |
@@ -1,14 +1,14 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @copyright (c) 2001-2006 Universite catholique de Louvain (UCL) |
|
4 | - * |
|
5 | - * @license http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE |
|
6 | - * |
|
7 | - * @package chamilo.exercise |
|
8 | - * |
|
9 | - * @author claro team <[email protected]> |
|
10 | - * @author Guillaume Lederer <[email protected]> |
|
11 | - */ |
|
3 | + * @copyright (c) 2001-2006 Universite catholique de Louvain (UCL) |
|
4 | + * |
|
5 | + * @license http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE |
|
6 | + * |
|
7 | + * @package chamilo.exercise |
|
8 | + * |
|
9 | + * @author claro team <[email protected]> |
|
10 | + * @author Guillaume Lederer <[email protected]> |
|
11 | + */ |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * function to create a temporary directory (SAME AS IN MODULE ADMIN) |
@@ -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; |
@@ -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); |
@@ -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); |
@@ -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 .= " | "; |