@@ -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, |
@@ -149,14 +149,14 @@ discard block |
||
| 149 | 149 | 'last_upload_date' => $this->last_upload_date, |
| 150 | 150 | 'session_id' => api_get_session_id(), |
| 151 | 151 | 'cat_id' => 0 |
| 152 | - ]; |
|
| 152 | + ]; |
|
| 153 | 153 | |
| 154 | - $this->id = Database::insert($dropbox_cnf['tbl_file'], $params); |
|
| 155 | - if ($this->id) { |
|
| 156 | - $sql = "UPDATE ".$dropbox_cnf['tbl_file']." SET id = iid WHERE iid = {$this->id}"; |
|
| 157 | - Database::query($sql); |
|
| 158 | - } |
|
| 159 | - } |
|
| 154 | + $this->id = Database::insert($dropbox_cnf['tbl_file'], $params); |
|
| 155 | + if ($this->id) { |
|
| 156 | + $sql = "UPDATE ".$dropbox_cnf['tbl_file']." SET id = iid WHERE iid = {$this->id}"; |
|
| 157 | + Database::query($sql); |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | 161 | $sql = "SELECT count(file_id) as count |
| 162 | 162 | FROM ".$dropbox_cnf['tbl_person']." |
@@ -170,16 +170,16 @@ discard block |
||
| 170 | 170 | VALUES ($course_id, ".intval($this->id)." , ".intval($this->uploader_id).")"; |
| 171 | 171 | Database::query($sql); |
| 172 | 172 | } |
| 173 | - } |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * private function creating existing object by retreiving info from db |
|
| 177 | - * |
|
| 178 | - * @param int $id |
|
| 179 | - */ |
|
| 180 | - public function _createExistingWork($id) |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * private function creating existing object by retreiving info from db |
|
| 177 | + * |
|
| 178 | + * @param int $id |
|
| 179 | + */ |
|
| 180 | + public function _createExistingWork($id) |
|
| 181 | 181 | { |
| 182 | - $course_id = api_get_course_int_id(); |
|
| 182 | + $course_id = api_get_course_int_id(); |
|
| 183 | 183 | $dropbox_cnf = getDropboxConf(); |
| 184 | 184 | |
| 185 | 185 | $action = isset($_GET['action']) ? $_GET['action'] : null; |
@@ -229,52 +229,52 @@ discard block |
||
| 229 | 229 | } |
| 230 | 230 | $this->feedback2= $feedback2; |
| 231 | 231 | } |
| 232 | - } |
|
| 232 | + } |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | class Dropbox_SentWork extends Dropbox_Work |
| 236 | 236 | { |
| 237 | - public $recipients; //array of ['id']['name'] arrays |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * Constructor calls private functions to create a new work or retreive an existing work from DB |
|
| 241 | - * depending on the number of parameters |
|
| 242 | - * |
|
| 243 | - * @param unknown_type $arg1 |
|
| 244 | - * @param unknown_type $arg2 |
|
| 245 | - * @param unknown_type $arg3 |
|
| 246 | - * @param unknown_type $arg4 |
|
| 247 | - * @param unknown_type $arg5 |
|
| 248 | - * @param unknown_type $arg6 |
|
| 249 | - * @param unknown_type $arg7 |
|
| 250 | - * @return Dropbox_SentWork |
|
| 251 | - */ |
|
| 252 | - public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null) |
|
| 237 | + public $recipients; //array of ['id']['name'] arrays |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * Constructor calls private functions to create a new work or retreive an existing work from DB |
|
| 241 | + * depending on the number of parameters |
|
| 242 | + * |
|
| 243 | + * @param unknown_type $arg1 |
|
| 244 | + * @param unknown_type $arg2 |
|
| 245 | + * @param unknown_type $arg3 |
|
| 246 | + * @param unknown_type $arg4 |
|
| 247 | + * @param unknown_type $arg5 |
|
| 248 | + * @param unknown_type $arg6 |
|
| 249 | + * @param unknown_type $arg7 |
|
| 250 | + * @return Dropbox_SentWork |
|
| 251 | + */ |
|
| 252 | + public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null) |
|
| 253 | 253 | { |
| 254 | - if (func_num_args() > 1) { |
|
| 255 | - $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7); |
|
| 256 | - } else { |
|
| 257 | - $this->_createExistingSentWork($arg1); |
|
| 258 | - } |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - /** |
|
| 262 | - * private function creating a new SentWork object |
|
| 263 | - * |
|
| 264 | - * @param int $uploader_id |
|
| 265 | - * @param string $title |
|
| 266 | - * @param string $description |
|
| 267 | - * @param string $author |
|
| 268 | - * @param string $filename |
|
| 269 | - * @param int $filesize |
|
| 270 | - * @param array $recipient_ids |
|
| 271 | - */ |
|
| 272 | - public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids) |
|
| 254 | + if (func_num_args() > 1) { |
|
| 255 | + $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7); |
|
| 256 | + } else { |
|
| 257 | + $this->_createExistingSentWork($arg1); |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + /** |
|
| 262 | + * private function creating a new SentWork object |
|
| 263 | + * |
|
| 264 | + * @param int $uploader_id |
|
| 265 | + * @param string $title |
|
| 266 | + * @param string $description |
|
| 267 | + * @param string $author |
|
| 268 | + * @param string $filename |
|
| 269 | + * @param int $filesize |
|
| 270 | + * @param array $recipient_ids |
|
| 271 | + */ |
|
| 272 | + public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids) |
|
| 273 | 273 | { |
| 274 | 274 | $dropbox_cnf = getDropboxConf(); |
| 275 | 275 | $_course = api_get_course_info(); |
| 276 | 276 | |
| 277 | - // Call constructor of Dropbox_Work object |
|
| 277 | + // Call constructor of Dropbox_Work object |
|
| 278 | 278 | parent::__construct( |
| 279 | 279 | $uploader_id, |
| 280 | 280 | $title, |
@@ -284,31 +284,31 @@ discard block |
||
| 284 | 284 | $filesize |
| 285 | 285 | ); |
| 286 | 286 | |
| 287 | - $course_id = api_get_course_int_id(); |
|
| 288 | - |
|
| 289 | - // Do sanity checks on recipient_ids array & property fillin |
|
| 290 | - // The sanity check for ex-coursemembers is already done in base constructor |
|
| 291 | - settype($uploader_id, 'integer') or die(get_lang('GeneralError').' (code 208)'); // Set $uploader_id to correct type |
|
| 287 | + $course_id = api_get_course_int_id(); |
|
| 292 | 288 | |
| 293 | - $justSubmit = false; |
|
| 294 | - if ( is_int($recipient_ids)) { |
|
| 295 | - $justSubmit = true; |
|
| 296 | - $recipient_ids = array($recipient_ids + $this->id); |
|
| 297 | - } elseif ( count($recipient_ids) == 0) { |
|
| 298 | - $justSubmit = true; |
|
| 299 | - $recipient_ids = array($uploader_id); |
|
| 300 | - } |
|
| 289 | + // Do sanity checks on recipient_ids array & property fillin |
|
| 290 | + // The sanity check for ex-coursemembers is already done in base constructor |
|
| 291 | + settype($uploader_id, 'integer') or die(get_lang('GeneralError').' (code 208)'); // Set $uploader_id to correct type |
|
| 292 | + |
|
| 293 | + $justSubmit = false; |
|
| 294 | + if ( is_int($recipient_ids)) { |
|
| 295 | + $justSubmit = true; |
|
| 296 | + $recipient_ids = array($recipient_ids + $this->id); |
|
| 297 | + } elseif ( count($recipient_ids) == 0) { |
|
| 298 | + $justSubmit = true; |
|
| 299 | + $recipient_ids = array($uploader_id); |
|
| 300 | + } |
|
| 301 | 301 | |
| 302 | - if (! is_array($recipient_ids) || count($recipient_ids) == 0) { |
|
| 303 | - die(get_lang('GeneralError').' (code 209)'); |
|
| 304 | - } |
|
| 302 | + if (! is_array($recipient_ids) || count($recipient_ids) == 0) { |
|
| 303 | + die(get_lang('GeneralError').' (code 209)'); |
|
| 304 | + } |
|
| 305 | 305 | |
| 306 | - foreach ($recipient_ids as $rec) { |
|
| 307 | - if (empty($rec)) die(get_lang('GeneralError').' (code 210)'); |
|
| 308 | - //if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course |
|
| 309 | - //this check is done when validating submitted data |
|
| 310 | - $this->recipients[] = array('id' => $rec, 'name' => getUserNameFromId($rec)); |
|
| 311 | - } |
|
| 306 | + foreach ($recipient_ids as $rec) { |
|
| 307 | + if (empty($rec)) die(get_lang('GeneralError').' (code 210)'); |
|
| 308 | + //if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course |
|
| 309 | + //this check is done when validating submitted data |
|
| 310 | + $this->recipients[] = array('id' => $rec, 'name' => getUserNameFromId($rec)); |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | 313 | $table_post = $dropbox_cnf['tbl_post']; |
| 314 | 314 | $table_person = $dropbox_cnf['tbl_person']; |
@@ -317,13 +317,13 @@ discard block |
||
| 317 | 317 | $user = api_get_user_id(); |
| 318 | 318 | $now = api_get_utc_datetime(); |
| 319 | 319 | |
| 320 | - // Insert data in dropbox_post and dropbox_person table for each recipient |
|
| 321 | - foreach ($this->recipients as $rec) { |
|
| 320 | + // Insert data in dropbox_post and dropbox_person table for each recipient |
|
| 321 | + foreach ($this->recipients as $rec) { |
|
| 322 | 322 | $file_id = (int)$this->id; |
| 323 | 323 | $user_id = (int)$rec['id']; |
| 324 | - $sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id) |
|
| 324 | + $sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id) |
|
| 325 | 325 | VALUES ($course_id, $file_id, $user_id, $session_id, '$now', 0)"; |
| 326 | - Database::query($sql); |
|
| 326 | + Database::query($sql); |
|
| 327 | 327 | // If work already exists no error is generated |
| 328 | 328 | |
| 329 | 329 | /** |
@@ -340,13 +340,13 @@ discard block |
||
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - // Update item_property table for each recipient |
|
| 344 | - if (($ownerid = $this->uploader_id) > $dropbox_cnf['mailingIdBase']) { |
|
| 345 | - $ownerid = getUserOwningThisMailing($ownerid); |
|
| 346 | - } |
|
| 347 | - if (($recipid = $rec["id"]) > $dropbox_cnf['mailingIdBase']) { |
|
| 348 | - $recipid = $ownerid; // mailing file recipient = mailing id, not a person |
|
| 349 | - } |
|
| 343 | + // Update item_property table for each recipient |
|
| 344 | + if (($ownerid = $this->uploader_id) > $dropbox_cnf['mailingIdBase']) { |
|
| 345 | + $ownerid = getUserOwningThisMailing($ownerid); |
|
| 346 | + } |
|
| 347 | + if (($recipid = $rec["id"]) > $dropbox_cnf['mailingIdBase']) { |
|
| 348 | + $recipid = $ownerid; // mailing file recipient = mailing id, not a person |
|
| 349 | + } |
|
| 350 | 350 | api_item_property_update( |
| 351 | 351 | $_course, |
| 352 | 352 | TOOL_DROPBOX, |
@@ -356,92 +356,92 @@ discard block |
||
| 356 | 356 | null, |
| 357 | 357 | $recipid |
| 358 | 358 | ); |
| 359 | - } |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * private function creating existing object by retreiving info from db |
|
| 364 | - * |
|
| 365 | - * @param unknown_type $id |
|
| 366 | - */ |
|
| 367 | - public function _createExistingSentWork($id) |
|
| 359 | + } |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + /** |
|
| 363 | + * private function creating existing object by retreiving info from db |
|
| 364 | + * |
|
| 365 | + * @param unknown_type $id |
|
| 366 | + */ |
|
| 367 | + public function _createExistingSentWork($id) |
|
| 368 | 368 | { |
| 369 | 369 | $dropbox_cnf = getDropboxConf(); |
| 370 | 370 | $id = intval($id); |
| 371 | 371 | |
| 372 | - $course_id = api_get_course_int_id(); |
|
| 372 | + $course_id = api_get_course_int_id(); |
|
| 373 | 373 | |
| 374 | - // Call constructor of Dropbox_Work object |
|
| 375 | - parent::__construct($id); |
|
| 374 | + // Call constructor of Dropbox_Work object |
|
| 375 | + parent::__construct($id); |
|
| 376 | 376 | |
| 377 | - // Fill in recipients array |
|
| 378 | - $this->recipients = array(); |
|
| 379 | - $sql = "SELECT dest_user_id, feedback_date, feedback |
|
| 377 | + // Fill in recipients array |
|
| 378 | + $this->recipients = array(); |
|
| 379 | + $sql = "SELECT dest_user_id, feedback_date, feedback |
|
| 380 | 380 | FROM ".$dropbox_cnf['tbl_post']." |
| 381 | 381 | WHERE c_id = $course_id AND file_id = ".intval($id).""; |
| 382 | 382 | $result = Database::query($sql); |
| 383 | - while ($res = Database::fetch_array($result, 'ASSOC')) { |
|
| 384 | - |
|
| 385 | - // Check for deleted users |
|
| 386 | - $dest_user_id = $res['dest_user_id']; |
|
| 387 | - $user_info = api_get_user_info($dest_user_id); |
|
| 388 | - //$this->category = $res['cat_id']; |
|
| 389 | - if (!$user_info) { |
|
| 390 | - $this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', '')); |
|
| 391 | - } else { |
|
| 392 | - $this->recipients[] = array( |
|
| 383 | + while ($res = Database::fetch_array($result, 'ASSOC')) { |
|
| 384 | + |
|
| 385 | + // Check for deleted users |
|
| 386 | + $dest_user_id = $res['dest_user_id']; |
|
| 387 | + $user_info = api_get_user_info($dest_user_id); |
|
| 388 | + //$this->category = $res['cat_id']; |
|
| 389 | + if (!$user_info) { |
|
| 390 | + $this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', '')); |
|
| 391 | + } else { |
|
| 392 | + $this->recipients[] = array( |
|
| 393 | 393 | 'id' => $dest_user_id, |
| 394 | 394 | 'name' => $user_info['complete_name'], |
| 395 | 395 | 'user_id' => $dest_user_id, |
| 396 | - 'feedback_date' => $res['feedback_date'], |
|
| 396 | + 'feedback_date' => $res['feedback_date'], |
|
| 397 | 397 | 'feedback' => $res['feedback'] |
| 398 | 398 | ); |
| 399 | - } |
|
| 400 | - } |
|
| 401 | - } |
|
| 399 | + } |
|
| 400 | + } |
|
| 401 | + } |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | class Dropbox_Person |
| 405 | 405 | { |
| 406 | - // The receivedWork and the sentWork arrays are sorted. |
|
| 407 | - public $receivedWork; // an array of Dropbox_Work objects |
|
| 408 | - public $sentWork; // an array of Dropbox_SentWork objects |
|
| 409 | - |
|
| 410 | - public $userId = 0; |
|
| 411 | - public $isCourseAdmin = false; |
|
| 412 | - public $isCourseTutor = false; |
|
| 413 | - public $_orderBy = ''; // private property that determines by which field |
|
| 414 | - |
|
| 415 | - /** |
|
| 416 | - * Constructor for recreating the Dropbox_Person object |
|
| 417 | - * |
|
| 418 | - * @param int $userId |
|
| 419 | - * @param bool $isCourseAdmin |
|
| 420 | - * @param bool $isCourseTutor |
|
| 421 | - * @return Dropbox_Person |
|
| 422 | - */ |
|
| 423 | - public function __construct($userId, $isCourseAdmin, $isCourseTutor) |
|
| 406 | + // The receivedWork and the sentWork arrays are sorted. |
|
| 407 | + public $receivedWork; // an array of Dropbox_Work objects |
|
| 408 | + public $sentWork; // an array of Dropbox_SentWork objects |
|
| 409 | + |
|
| 410 | + public $userId = 0; |
|
| 411 | + public $isCourseAdmin = false; |
|
| 412 | + public $isCourseTutor = false; |
|
| 413 | + public $_orderBy = ''; // private property that determines by which field |
|
| 414 | + |
|
| 415 | + /** |
|
| 416 | + * Constructor for recreating the Dropbox_Person object |
|
| 417 | + * |
|
| 418 | + * @param int $userId |
|
| 419 | + * @param bool $isCourseAdmin |
|
| 420 | + * @param bool $isCourseTutor |
|
| 421 | + * @return Dropbox_Person |
|
| 422 | + */ |
|
| 423 | + public function __construct($userId, $isCourseAdmin, $isCourseTutor) |
|
| 424 | 424 | { |
| 425 | - $course_id = api_get_course_int_id(); |
|
| 425 | + $course_id = api_get_course_int_id(); |
|
| 426 | 426 | |
| 427 | - // Fill in properties |
|
| 427 | + // Fill in properties |
|
| 428 | 428 | $this->userId = $userId; |
| 429 | 429 | $this->isCourseAdmin = $isCourseAdmin; |
| 430 | 430 | $this->isCourseTutor = $isCourseTutor; |
| 431 | 431 | $this->receivedWork = array(); |
| 432 | 432 | $this->sentWork = array(); |
| 433 | 433 | |
| 434 | - // Note: perhaps include an ex coursemember check to delete old files |
|
| 434 | + // Note: perhaps include an ex coursemember check to delete old files |
|
| 435 | 435 | |
| 436 | - $session_id = api_get_session_id(); |
|
| 437 | - $condition_session = api_get_session_condition($session_id); |
|
| 436 | + $session_id = api_get_session_id(); |
|
| 437 | + $condition_session = api_get_session_condition($session_id); |
|
| 438 | 438 | |
| 439 | - $post_tbl = Database::get_course_table(TABLE_DROPBOX_POST); |
|
| 440 | - $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON); |
|
| 441 | - $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE); |
|
| 439 | + $post_tbl = Database::get_course_table(TABLE_DROPBOX_POST); |
|
| 440 | + $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON); |
|
| 441 | + $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE); |
|
| 442 | 442 | |
| 443 | 443 | // Find all entries where this person is the recipient |
| 444 | - $sql = "SELECT DISTINCT r.file_id, r.cat_id |
|
| 444 | + $sql = "SELECT DISTINCT r.file_id, r.cat_id |
|
| 445 | 445 | FROM $post_tbl r |
| 446 | 446 | INNER JOIN $person_tbl p |
| 447 | 447 | ON (r.file_id = p.file_id AND r.c_id = $course_id AND p.c_id = $course_id ) |
@@ -450,12 +450,12 @@ discard block |
||
| 450 | 450 | r.dest_user_id = ".intval($this->userId)." $condition_session "; |
| 451 | 451 | |
| 452 | 452 | $result = Database::query($sql); |
| 453 | - while ($res = Database::fetch_array($result)) { |
|
| 454 | - $temp = new Dropbox_Work($res['file_id']); |
|
| 455 | - $temp->category = $res['cat_id']; |
|
| 456 | - $this->receivedWork[] = $temp; |
|
| 457 | - } |
|
| 458 | - // Find all entries where this person is the sender/uploader |
|
| 453 | + while ($res = Database::fetch_array($result)) { |
|
| 454 | + $temp = new Dropbox_Work($res['file_id']); |
|
| 455 | + $temp->category = $res['cat_id']; |
|
| 456 | + $this->receivedWork[] = $temp; |
|
| 457 | + } |
|
| 458 | + // Find all entries where this person is the sender/uploader |
|
| 459 | 459 | $sql = "SELECT DISTINCT f.id |
| 460 | 460 | FROM $file_tbl f |
| 461 | 461 | INNER JOIN $person_tbl p |
@@ -466,260 +466,260 @@ discard block |
||
| 466 | 466 | $condition_session |
| 467 | 467 | "; |
| 468 | 468 | $result = Database::query($sql); |
| 469 | - while ($res = Database::fetch_array($result)) { |
|
| 470 | - $this->sentWork[] = new Dropbox_SentWork($res['id']); |
|
| 471 | - } |
|
| 472 | - } |
|
| 473 | - |
|
| 474 | - /** |
|
| 475 | - * This private method is used by the usort function in the |
|
| 476 | - * orderSentWork and orderReceivedWork methods. |
|
| 477 | - * It compares 2 work-objects by 1 of the properties of that object, dictated by the |
|
| 478 | - * private property _orderBy |
|
| 479 | - * |
|
| 480 | - * @param unknown_type $a |
|
| 481 | - * @param unknown_type $b |
|
| 482 | - * @return -1, 0 or 1 dependent of the result of the comparison. |
|
| 483 | - */ |
|
| 484 | - function _cmpWork($a, $b) |
|
| 469 | + while ($res = Database::fetch_array($result)) { |
|
| 470 | + $this->sentWork[] = new Dropbox_SentWork($res['id']); |
|
| 471 | + } |
|
| 472 | + } |
|
| 473 | + |
|
| 474 | + /** |
|
| 475 | + * This private method is used by the usort function in the |
|
| 476 | + * orderSentWork and orderReceivedWork methods. |
|
| 477 | + * It compares 2 work-objects by 1 of the properties of that object, dictated by the |
|
| 478 | + * private property _orderBy |
|
| 479 | + * |
|
| 480 | + * @param unknown_type $a |
|
| 481 | + * @param unknown_type $b |
|
| 482 | + * @return -1, 0 or 1 dependent of the result of the comparison. |
|
| 483 | + */ |
|
| 484 | + function _cmpWork($a, $b) |
|
| 485 | 485 | { |
| 486 | - $sort = $this->_orderBy; |
|
| 487 | - $aval = $a->$sort; |
|
| 488 | - $bval = $b->$sort; |
|
| 489 | - if ($sort == 'recipients') { |
|
| 490 | - // The recipients property is an array so we do the comparison based |
|
| 491 | - // on the first item of the recipients array |
|
| 492 | - $aval = $aval[0]['name']; |
|
| 493 | - $bval = $bval[0]['name']; |
|
| 494 | - } |
|
| 495 | - if ($sort == 'filesize') { // Filesize is not a string, so we use other comparison technique |
|
| 496 | - return $aval < $bval ? -1 : 1; |
|
| 497 | - } elseif ($sort == 'title') { // Natural order for sorting titles is more "human-friendly" |
|
| 498 | - return api_strnatcmp($aval, $bval); |
|
| 499 | - } else { |
|
| 500 | - return api_strcasecmp($aval, $bval); |
|
| 501 | - } |
|
| 502 | - } |
|
| 503 | - |
|
| 504 | - /** |
|
| 505 | - * A method that sorts the objects in the sentWork array, dependent on the $sort parameter. |
|
| 506 | - * $sort can be lastDate, firstDate, title, size, ... |
|
| 507 | - * |
|
| 508 | - * @param unknown_type $sort |
|
| 509 | - */ |
|
| 510 | - function orderSentWork($sort) |
|
| 486 | + $sort = $this->_orderBy; |
|
| 487 | + $aval = $a->$sort; |
|
| 488 | + $bval = $b->$sort; |
|
| 489 | + if ($sort == 'recipients') { |
|
| 490 | + // The recipients property is an array so we do the comparison based |
|
| 491 | + // on the first item of the recipients array |
|
| 492 | + $aval = $aval[0]['name']; |
|
| 493 | + $bval = $bval[0]['name']; |
|
| 494 | + } |
|
| 495 | + if ($sort == 'filesize') { // Filesize is not a string, so we use other comparison technique |
|
| 496 | + return $aval < $bval ? -1 : 1; |
|
| 497 | + } elseif ($sort == 'title') { // Natural order for sorting titles is more "human-friendly" |
|
| 498 | + return api_strnatcmp($aval, $bval); |
|
| 499 | + } else { |
|
| 500 | + return api_strcasecmp($aval, $bval); |
|
| 501 | + } |
|
| 502 | + } |
|
| 503 | + |
|
| 504 | + /** |
|
| 505 | + * A method that sorts the objects in the sentWork array, dependent on the $sort parameter. |
|
| 506 | + * $sort can be lastDate, firstDate, title, size, ... |
|
| 507 | + * |
|
| 508 | + * @param unknown_type $sort |
|
| 509 | + */ |
|
| 510 | + function orderSentWork($sort) |
|
| 511 | 511 | { |
| 512 | - switch($sort) { |
|
| 513 | - case 'lastDate': |
|
| 514 | - $this->_orderBy = 'last_upload_date'; |
|
| 515 | - break; |
|
| 516 | - case 'firstDate': |
|
| 517 | - $this->_orderBy = 'upload_date'; |
|
| 518 | - break; |
|
| 519 | - case 'title': |
|
| 520 | - $this->_orderBy = 'title'; |
|
| 521 | - break; |
|
| 522 | - case 'size': |
|
| 523 | - $this->_orderBy = 'filesize'; |
|
| 524 | - break; |
|
| 525 | - case 'author': |
|
| 526 | - $this->_orderBy = 'author'; |
|
| 527 | - break; |
|
| 528 | - case 'recipient': |
|
| 529 | - $this->_orderBy = 'recipients'; |
|
| 530 | - break; |
|
| 531 | - default: |
|
| 532 | - $this->_orderBy = 'last_upload_date'; |
|
| 533 | - } |
|
| 534 | - |
|
| 535 | - usort($this->sentWork, array($this, '_cmpWork')); |
|
| 536 | - } |
|
| 537 | - |
|
| 538 | - /** |
|
| 539 | - * method that sorts the objects in the receivedWork array, dependent on the $sort parameter. |
|
| 540 | - * $sort can be lastDate, firstDate, title, size, ... |
|
| 541 | - * @param unknown_type $sort |
|
| 542 | - */ |
|
| 543 | - function orderReceivedWork($sort) |
|
| 512 | + switch($sort) { |
|
| 513 | + case 'lastDate': |
|
| 514 | + $this->_orderBy = 'last_upload_date'; |
|
| 515 | + break; |
|
| 516 | + case 'firstDate': |
|
| 517 | + $this->_orderBy = 'upload_date'; |
|
| 518 | + break; |
|
| 519 | + case 'title': |
|
| 520 | + $this->_orderBy = 'title'; |
|
| 521 | + break; |
|
| 522 | + case 'size': |
|
| 523 | + $this->_orderBy = 'filesize'; |
|
| 524 | + break; |
|
| 525 | + case 'author': |
|
| 526 | + $this->_orderBy = 'author'; |
|
| 527 | + break; |
|
| 528 | + case 'recipient': |
|
| 529 | + $this->_orderBy = 'recipients'; |
|
| 530 | + break; |
|
| 531 | + default: |
|
| 532 | + $this->_orderBy = 'last_upload_date'; |
|
| 533 | + } |
|
| 534 | + |
|
| 535 | + usort($this->sentWork, array($this, '_cmpWork')); |
|
| 536 | + } |
|
| 537 | + |
|
| 538 | + /** |
|
| 539 | + * method that sorts the objects in the receivedWork array, dependent on the $sort parameter. |
|
| 540 | + * $sort can be lastDate, firstDate, title, size, ... |
|
| 541 | + * @param unknown_type $sort |
|
| 542 | + */ |
|
| 543 | + function orderReceivedWork($sort) |
|
| 544 | 544 | { |
| 545 | - switch($sort) { |
|
| 546 | - case 'lastDate': |
|
| 547 | - $this->_orderBy = 'last_upload_date'; |
|
| 548 | - break; |
|
| 549 | - case 'firstDate': |
|
| 550 | - $this->_orderBy = 'upload_date'; |
|
| 551 | - break; |
|
| 552 | - case 'title': |
|
| 553 | - $this->_orderBy = 'title'; |
|
| 554 | - break; |
|
| 555 | - case 'size': |
|
| 556 | - $this->_orderBy = 'filesize'; |
|
| 557 | - break; |
|
| 558 | - case 'author': |
|
| 559 | - $this->_orderBy = 'author'; |
|
| 560 | - break; |
|
| 561 | - case 'sender': |
|
| 562 | - $this->_orderBy = 'uploaderName'; |
|
| 563 | - break; |
|
| 564 | - default: |
|
| 565 | - $this->_orderBy = 'last_upload_date'; |
|
| 566 | - } |
|
| 567 | - |
|
| 568 | - usort($this->receivedWork, array($this, '_cmpWork')); |
|
| 569 | - } |
|
| 570 | - |
|
| 571 | - /** |
|
| 572 | - * Deletes all the received work of this person |
|
| 573 | - */ |
|
| 574 | - function deleteAllReceivedWork() |
|
| 545 | + switch($sort) { |
|
| 546 | + case 'lastDate': |
|
| 547 | + $this->_orderBy = 'last_upload_date'; |
|
| 548 | + break; |
|
| 549 | + case 'firstDate': |
|
| 550 | + $this->_orderBy = 'upload_date'; |
|
| 551 | + break; |
|
| 552 | + case 'title': |
|
| 553 | + $this->_orderBy = 'title'; |
|
| 554 | + break; |
|
| 555 | + case 'size': |
|
| 556 | + $this->_orderBy = 'filesize'; |
|
| 557 | + break; |
|
| 558 | + case 'author': |
|
| 559 | + $this->_orderBy = 'author'; |
|
| 560 | + break; |
|
| 561 | + case 'sender': |
|
| 562 | + $this->_orderBy = 'uploaderName'; |
|
| 563 | + break; |
|
| 564 | + default: |
|
| 565 | + $this->_orderBy = 'last_upload_date'; |
|
| 566 | + } |
|
| 567 | + |
|
| 568 | + usort($this->receivedWork, array($this, '_cmpWork')); |
|
| 569 | + } |
|
| 570 | + |
|
| 571 | + /** |
|
| 572 | + * Deletes all the received work of this person |
|
| 573 | + */ |
|
| 574 | + function deleteAllReceivedWork() |
|
| 575 | 575 | { |
| 576 | - $course_id = api_get_course_int_id(); |
|
| 576 | + $course_id = api_get_course_int_id(); |
|
| 577 | 577 | $dropbox_cnf = getDropboxConf(); |
| 578 | - // Delete entries in person table concerning received works |
|
| 579 | - foreach ($this->receivedWork as $w) { |
|
| 578 | + // Delete entries in person table concerning received works |
|
| 579 | + foreach ($this->receivedWork as $w) { |
|
| 580 | 580 | $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']." |
| 581 | 581 | WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'"; |
| 582 | - Database::query($sql); |
|
| 583 | - } |
|
| 582 | + Database::query($sql); |
|
| 583 | + } |
|
| 584 | 584 | // Check for unused files |
| 585 | - removeUnusedFiles(); |
|
| 586 | - } |
|
| 585 | + removeUnusedFiles(); |
|
| 586 | + } |
|
| 587 | 587 | |
| 588 | - /** |
|
| 589 | - * Deletes all the received categories and work of this person |
|
| 590 | - */ |
|
| 591 | - function deleteReceivedWorkFolder($id) |
|
| 588 | + /** |
|
| 589 | + * Deletes all the received categories and work of this person |
|
| 590 | + */ |
|
| 591 | + function deleteReceivedWorkFolder($id) |
|
| 592 | 592 | { |
| 593 | 593 | $dropbox_cnf = getDropboxConf(); |
| 594 | 594 | $course_id = api_get_course_int_id(); |
| 595 | 595 | |
| 596 | - $id = intval($id); |
|
| 597 | - $sql = "DELETE FROM ".$dropbox_cnf['tbl_file']." |
|
| 596 | + $id = intval($id); |
|
| 597 | + $sql = "DELETE FROM ".$dropbox_cnf['tbl_file']." |
|
| 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_category']." |
|
| 599 | + if (!Database::query($sql)) return false; |
|
| 600 | + $sql = "DELETE FROM ".$dropbox_cnf['tbl_category']." |
|
| 601 | 601 | WHERE c_id = $course_id AND cat_id = '".$id."' "; |
| 602 | - if (!Database::query($sql)) return false; |
|
| 603 | - $sql = "DELETE FROM ".$dropbox_cnf['tbl_post']." |
|
| 602 | + if (!Database::query($sql)) return false; |
|
| 603 | + $sql = "DELETE FROM ".$dropbox_cnf['tbl_post']." |
|
| 604 | 604 | WHERE c_id = $course_id AND cat_id = '".$id."' "; |
| 605 | - if (!Database::query($sql)) return false; |
|
| 606 | - return true; |
|
| 607 | - } |
|
| 608 | - |
|
| 609 | - /** |
|
| 610 | - * Deletes a received dropbox file of this person with id=$id |
|
| 611 | - * |
|
| 612 | - * @param integer $id |
|
| 613 | - */ |
|
| 614 | - function deleteReceivedWork($id) |
|
| 605 | + if (!Database::query($sql)) return false; |
|
| 606 | + return true; |
|
| 607 | + } |
|
| 608 | + |
|
| 609 | + /** |
|
| 610 | + * Deletes a received dropbox file of this person with id=$id |
|
| 611 | + * |
|
| 612 | + * @param integer $id |
|
| 613 | + */ |
|
| 614 | + function deleteReceivedWork($id) |
|
| 615 | 615 | { |
| 616 | - $course_id = api_get_course_int_id(); |
|
| 616 | + $course_id = api_get_course_int_id(); |
|
| 617 | 617 | $dropbox_cnf = getDropboxConf(); |
| 618 | - $id = intval($id); |
|
| 619 | - |
|
| 620 | - // index check |
|
| 621 | - $found = false; |
|
| 622 | - foreach ($this->receivedWork as $w) { |
|
| 623 | - if ($w->id == $id) { |
|
| 624 | - $found = true; |
|
| 625 | - break; |
|
| 626 | - } |
|
| 627 | - } |
|
| 628 | - |
|
| 629 | - if (!$found) { |
|
| 630 | - if (!$this->deleteReceivedWorkFolder($id)) { |
|
| 631 | - die(get_lang('GeneralError').' (code 216)'); |
|
| 632 | - } |
|
| 633 | - } |
|
| 634 | - // Delete entries in person table concerning received works |
|
| 618 | + $id = intval($id); |
|
| 619 | + |
|
| 620 | + // index check |
|
| 621 | + $found = false; |
|
| 622 | + foreach ($this->receivedWork as $w) { |
|
| 623 | + if ($w->id == $id) { |
|
| 624 | + $found = true; |
|
| 625 | + break; |
|
| 626 | + } |
|
| 627 | + } |
|
| 628 | + |
|
| 629 | + if (!$found) { |
|
| 630 | + if (!$this->deleteReceivedWorkFolder($id)) { |
|
| 631 | + die(get_lang('GeneralError').' (code 216)'); |
|
| 632 | + } |
|
| 633 | + } |
|
| 634 | + // Delete entries in person table concerning received works |
|
| 635 | 635 | $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']." |
| 636 | 636 | WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'"; |
| 637 | - Database::query($sql); |
|
| 638 | - removeUnusedFiles(); // Check for unused files |
|
| 639 | - } |
|
| 640 | - |
|
| 641 | - /** |
|
| 642 | - * Deletes all the sent dropbox files of this person |
|
| 643 | - */ |
|
| 644 | - function deleteAllSentWork() |
|
| 637 | + Database::query($sql); |
|
| 638 | + removeUnusedFiles(); // Check for unused files |
|
| 639 | + } |
|
| 640 | + |
|
| 641 | + /** |
|
| 642 | + * Deletes all the sent dropbox files of this person |
|
| 643 | + */ |
|
| 644 | + function deleteAllSentWork() |
|
| 645 | 645 | { |
| 646 | - $course_id = api_get_course_int_id(); |
|
| 646 | + $course_id = api_get_course_int_id(); |
|
| 647 | 647 | $dropbox_cnf = getDropboxConf(); |
| 648 | - //delete entries in person table concerning sent works |
|
| 649 | - foreach ($this->sentWork as $w) { |
|
| 648 | + //delete entries in person table concerning sent works |
|
| 649 | + foreach ($this->sentWork as $w) { |
|
| 650 | 650 | $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']." |
| 651 | 651 | WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'"; |
| 652 | - Database::query($sql); |
|
| 653 | - removeMoreIfMailing($w->id); |
|
| 654 | - } |
|
| 655 | - removeUnusedFiles(); // Check for unused files |
|
| 656 | - } |
|
| 657 | - |
|
| 658 | - /** |
|
| 659 | - * Deletes a sent dropbox file of this person with id=$id |
|
| 660 | - * |
|
| 661 | - * @param unknown_type $id |
|
| 662 | - */ |
|
| 663 | - function deleteSentWork($id) |
|
| 652 | + Database::query($sql); |
|
| 653 | + removeMoreIfMailing($w->id); |
|
| 654 | + } |
|
| 655 | + removeUnusedFiles(); // Check for unused files |
|
| 656 | + } |
|
| 657 | + |
|
| 658 | + /** |
|
| 659 | + * Deletes a sent dropbox file of this person with id=$id |
|
| 660 | + * |
|
| 661 | + * @param unknown_type $id |
|
| 662 | + */ |
|
| 663 | + function deleteSentWork($id) |
|
| 664 | 664 | { |
| 665 | - $course_id = api_get_course_int_id(); |
|
| 665 | + $course_id = api_get_course_int_id(); |
|
| 666 | 666 | $dropbox_cnf = getDropboxConf(); |
| 667 | 667 | |
| 668 | - $id = intval($id); |
|
| 669 | - |
|
| 670 | - // index check |
|
| 671 | - $found = false; |
|
| 672 | - foreach ($this->sentWork as $w) { |
|
| 673 | - if ($w->id == $id) { |
|
| 674 | - $found = true; |
|
| 675 | - break; |
|
| 676 | - } |
|
| 677 | - } |
|
| 678 | - if (!$found) { |
|
| 679 | - if (!$this->deleteReceivedWorkFolder($id)) { |
|
| 680 | - die(get_lang('GeneralError').' (code 219)'); |
|
| 681 | - } |
|
| 682 | - } |
|
| 683 | - //$file_id = $this->sentWork[$index]->id; |
|
| 684 | - // Delete entries in person table concerning sent works |
|
| 668 | + $id = intval($id); |
|
| 669 | + |
|
| 670 | + // index check |
|
| 671 | + $found = false; |
|
| 672 | + foreach ($this->sentWork as $w) { |
|
| 673 | + if ($w->id == $id) { |
|
| 674 | + $found = true; |
|
| 675 | + break; |
|
| 676 | + } |
|
| 677 | + } |
|
| 678 | + if (!$found) { |
|
| 679 | + if (!$this->deleteReceivedWorkFolder($id)) { |
|
| 680 | + die(get_lang('GeneralError').' (code 219)'); |
|
| 681 | + } |
|
| 682 | + } |
|
| 683 | + //$file_id = $this->sentWork[$index]->id; |
|
| 684 | + // Delete entries in person table concerning sent works |
|
| 685 | 685 | $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']." |
| 686 | 686 | WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'"; |
| 687 | - Database::query($sql); |
|
| 688 | - removeMoreIfMailing($id); |
|
| 689 | - removeUnusedFiles(); // Check for unused files |
|
| 690 | - } |
|
| 691 | - |
|
| 692 | - /** |
|
| 693 | - * Updates feedback for received work of this person with id=$id |
|
| 694 | - * |
|
| 695 | - * @param string $id |
|
| 696 | - * @param string $text |
|
| 697 | - */ |
|
| 698 | - function updateFeedback($id, $text) |
|
| 687 | + Database::query($sql); |
|
| 688 | + removeMoreIfMailing($id); |
|
| 689 | + removeUnusedFiles(); // Check for unused files |
|
| 690 | + } |
|
| 691 | + |
|
| 692 | + /** |
|
| 693 | + * Updates feedback for received work of this person with id=$id |
|
| 694 | + * |
|
| 695 | + * @param string $id |
|
| 696 | + * @param string $text |
|
| 697 | + */ |
|
| 698 | + function updateFeedback($id, $text) |
|
| 699 | 699 | { |
| 700 | - $course_id = api_get_course_int_id(); |
|
| 700 | + $course_id = api_get_course_int_id(); |
|
| 701 | 701 | $_course = api_get_course_info(); |
| 702 | 702 | $dropbox_cnf = getDropboxConf(); |
| 703 | 703 | |
| 704 | - $id = intval($id); |
|
| 705 | - |
|
| 706 | - // index check |
|
| 707 | - $found = false; |
|
| 708 | - $wi = -1; |
|
| 709 | - foreach ($this->receivedWork as $w) { |
|
| 710 | - $wi++; |
|
| 711 | - if ($w->id == $id){ |
|
| 712 | - $found = true; |
|
| 713 | - break; |
|
| 714 | - } // foreach (... as $wi -> $w) gives error 221! (no idea why...) |
|
| 715 | - } |
|
| 716 | - if (!$found) { |
|
| 717 | - die(get_lang('GeneralError').' (code 221)'); |
|
| 718 | - } |
|
| 719 | - |
|
| 720 | - $feedback_date = api_get_utc_datetime(); |
|
| 721 | - $this->receivedWork[$wi]->feedback_date = $feedback_date; |
|
| 722 | - $this->receivedWork[$wi]->feedback = $text; |
|
| 704 | + $id = intval($id); |
|
| 705 | + |
|
| 706 | + // index check |
|
| 707 | + $found = false; |
|
| 708 | + $wi = -1; |
|
| 709 | + foreach ($this->receivedWork as $w) { |
|
| 710 | + $wi++; |
|
| 711 | + if ($w->id == $id){ |
|
| 712 | + $found = true; |
|
| 713 | + break; |
|
| 714 | + } // foreach (... as $wi -> $w) gives error 221! (no idea why...) |
|
| 715 | + } |
|
| 716 | + if (!$found) { |
|
| 717 | + die(get_lang('GeneralError').' (code 221)'); |
|
| 718 | + } |
|
| 719 | + |
|
| 720 | + $feedback_date = api_get_utc_datetime(); |
|
| 721 | + $this->receivedWork[$wi]->feedback_date = $feedback_date; |
|
| 722 | + $this->receivedWork[$wi]->feedback = $text; |
|
| 723 | 723 | |
| 724 | 724 | $params = [ |
| 725 | 725 | 'feedback_date' => $feedback_date, |
@@ -737,11 +737,11 @@ discard block |
||
| 737 | 737 | ] |
| 738 | 738 | ); |
| 739 | 739 | |
| 740 | - // Update item_property table |
|
| 740 | + // Update item_property table |
|
| 741 | 741 | |
| 742 | - if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $dropbox_cnf['mailingIdBase']) { |
|
| 743 | - $ownerid = getUserOwningThisMailing($ownerid); |
|
| 744 | - } |
|
| 742 | + if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $dropbox_cnf['mailingIdBase']) { |
|
| 743 | + $ownerid = getUserOwningThisMailing($ownerid); |
|
| 744 | + } |
|
| 745 | 745 | api_item_property_update( |
| 746 | 746 | $_course, |
| 747 | 747 | TOOL_DROPBOX, |
@@ -752,31 +752,31 @@ discard block |
||
| 752 | 752 | $ownerid |
| 753 | 753 | ); |
| 754 | 754 | |
| 755 | - } |
|
| 755 | + } |
|
| 756 | 756 | |
| 757 | - /** |
|
| 758 | - * Filter the received work |
|
| 759 | - * @param string $type |
|
| 760 | - * @param string $value |
|
| 761 | - */ |
|
| 762 | - function filter_received_work($type, $value) |
|
| 757 | + /** |
|
| 758 | + * Filter the received work |
|
| 759 | + * @param string $type |
|
| 760 | + * @param string $value |
|
| 761 | + */ |
|
| 762 | + function filter_received_work($type, $value) |
|
| 763 | 763 | { |
| 764 | 764 | $dropbox_cnf = getDropboxConf(); |
| 765 | - $new_received_work = array(); |
|
| 766 | - foreach ($this->receivedWork as $work) { |
|
| 767 | - switch ($type) { |
|
| 768 | - case 'uploader_id': |
|
| 769 | - if ($work->uploader_id == $value || |
|
| 770 | - ($work->uploader_id > $dropbox_cnf['mailingIdBase'] && |
|
| 765 | + $new_received_work = array(); |
|
| 766 | + foreach ($this->receivedWork as $work) { |
|
| 767 | + switch ($type) { |
|
| 768 | + case 'uploader_id': |
|
| 769 | + if ($work->uploader_id == $value || |
|
| 770 | + ($work->uploader_id > $dropbox_cnf['mailingIdBase'] && |
|
| 771 | 771 | getUserOwningThisMailing($work->uploader_id) == $value) |
| 772 | 772 | ) { |
| 773 | - $new_received_work[] = $work; |
|
| 774 | - } |
|
| 775 | - break; |
|
| 776 | - default: |
|
| 777 | - $new_received_work[] = $work; |
|
| 778 | - } |
|
| 779 | - } |
|
| 780 | - $this->receivedWork = $new_received_work; |
|
| 781 | - } |
|
| 773 | + $new_received_work[] = $work; |
|
| 774 | + } |
|
| 775 | + break; |
|
| 776 | + default: |
|
| 777 | + $new_received_work[] = $work; |
|
| 778 | + } |
|
| 779 | + } |
|
| 780 | + $this->receivedWork = $new_received_work; |
|
| 781 | + } |
|
| 782 | 782 | } |
@@ -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 | } |
@@ -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) { |
@@ -10,9 +10,9 @@ discard block |
||
| 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 | |
@@ -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); |
@@ -281,7 +281,7 @@ |
||
| 281 | 281 | $correct_answer_index = array_search($matches[1], $answers_array); |
| 282 | 282 | $exercise_info['question'][$question_index]['title'] = $matches[1]; |
| 283 | 283 | } elseif (preg_match('/^TAGS:\s?([A-Z])\s?/', $info, $matches)) { |
| 284 | - //TAGS for chamilo >= 1.10 |
|
| 284 | + //TAGS for chamilo >= 1.10 |
|
| 285 | 285 | $exercise_info['question'][$question_index]['answer_tags'] = explode(',', $matches[1]); |
| 286 | 286 | } elseif (preg_match('/^ETIQUETAS:\s?([A-Z])\s?/', $info, $matches)) { |
| 287 | 287 | //TAGS for chamilo >= 1.10 (Spanish e-ducativa format) |
@@ -30,6 +30,8 @@ discard block |
||
| 30 | 30 | * Unzip the exercise in the temp folder |
| 31 | 31 | * @param string The path of the temporary directory where the exercise was uploaded and unzipped |
| 32 | 32 | * @param string |
| 33 | + * @param string $baseWorkDir |
|
| 34 | + * @param string $uploadPath |
|
| 33 | 35 | * @return bool |
| 34 | 36 | */ |
| 35 | 37 | function get_and_unzip_uploaded_exercise($baseWorkDir, $uploadPath) |
@@ -217,9 +219,9 @@ discard block |
||
| 217 | 219 | |
| 218 | 220 | /** |
| 219 | 221 | * Parses a given XML file and fills global arrays with the elements |
| 220 | - * @param $exercisePath |
|
| 221 | - * @param $file |
|
| 222 | - * @param $questionFile |
|
| 222 | + * @param string $exercisePath |
|
| 223 | + * @param string $file |
|
| 224 | + * @param string $questionFile |
|
| 223 | 225 | * @return bool |
| 224 | 226 | */ |
| 225 | 227 | function parse_file($exercisePath, $file, $questionFile) |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | do { |
| 23 | - $path = $dir . $prefix . mt_rand(0, 9999999); |
|
| 23 | + $path = $dir.$prefix.mt_rand(0, 9999999); |
|
| 24 | 24 | } while (!mkdir($path, $mode)); |
| 25 | 25 | |
| 26 | 26 | return $path; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | // used to specify the question directory where files could be found in relation in any question |
| 75 | 75 | global $questionTempDir; |
| 76 | 76 | |
| 77 | - $archive_path = api_get_path(SYS_ARCHIVE_PATH) . 'qti2'; |
|
| 77 | + $archive_path = api_get_path(SYS_ARCHIVE_PATH).'qti2'; |
|
| 78 | 78 | $baseWorkDir = $archive_path; |
| 79 | 79 | |
| 80 | 80 | if (!is_dir($baseWorkDir)) { |
@@ -118,14 +118,14 @@ discard block |
||
| 118 | 118 | // parse every subdirectory to search xml question files |
| 119 | 119 | while (false !== ($file = readdir($exerciseHandle))) { |
| 120 | 120 | |
| 121 | - if (is_dir($baseWorkDir . '/' . $file) && $file != "." && $file != "..") { |
|
| 121 | + if (is_dir($baseWorkDir.'/'.$file) && $file != "." && $file != "..") { |
|
| 122 | 122 | |
| 123 | 123 | // Find each manifest for each question repository found |
| 124 | - $questionHandle = opendir($baseWorkDir . '/' . $file); |
|
| 124 | + $questionHandle = opendir($baseWorkDir.'/'.$file); |
|
| 125 | 125 | while (false !== ($questionFile = readdir($questionHandle))) { |
| 126 | 126 | if (preg_match('/.xml$/i', $questionFile)) { |
| 127 | 127 | $result = parse_file($baseWorkDir, $file, $questionFile); |
| 128 | - $filePath = $baseWorkDir . $file; |
|
| 128 | + $filePath = $baseWorkDir.$file; |
|
| 129 | 129 | $file_found = true; |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | // Else ignore file |
| 135 | 135 | $result = parse_file($baseWorkDir, '', $file); |
| 136 | - $filePath = $baseWorkDir . '/' . $file; |
|
| 136 | + $filePath = $baseWorkDir.'/'.$file; |
|
| 137 | 137 | $file_found = true; |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | // delete the temp dir where the exercise was unzipped |
| 203 | - my_delete($baseWorkDir . $uploadPath); |
|
| 203 | + my_delete($baseWorkDir.$uploadPath); |
|
| 204 | 204 | return $last_exercise_id; |
| 205 | 205 | } |
| 206 | 206 | |
@@ -228,8 +228,8 @@ discard block |
||
| 228 | 228 | global $record_item_body; |
| 229 | 229 | global $questionTempDir; |
| 230 | 230 | |
| 231 | - $questionTempDir = $exercisePath . '/' . $file . '/'; |
|
| 232 | - $questionFilePath = $questionTempDir . $questionFile; |
|
| 231 | + $questionTempDir = $exercisePath.'/'.$file.'/'; |
|
| 232 | + $questionFilePath = $questionTempDir.$questionFile; |
|
| 233 | 233 | |
| 234 | 234 | if (!($fp = fopen($questionFilePath, 'r'))) { |
| 235 | 235 | Display:: display_error_message(get_lang('Error opening question\'s XML file')); |
@@ -326,10 +326,10 @@ discard block |
||
| 326 | 326 | if ($record_item_body) { |
| 327 | 327 | |
| 328 | 328 | if ((!in_array($current_element, $non_HTML_tag_to_avoid))) { |
| 329 | - $current_question_item_body .= "<" . $name; |
|
| 329 | + $current_question_item_body .= "<".$name; |
|
| 330 | 330 | |
| 331 | 331 | foreach ($attributes as $attribute_name => $attribute_value) { |
| 332 | - $current_question_item_body .= " " . $attribute_name . "=\"" . $attribute_value . "\""; |
|
| 332 | + $current_question_item_body .= " ".$attribute_name."=\"".$attribute_value."\""; |
|
| 333 | 333 | } |
| 334 | 334 | $current_question_item_body .= ">"; |
| 335 | 335 | } else { |
@@ -338,11 +338,11 @@ discard block |
||
| 338 | 338 | |
| 339 | 339 | if ($current_element == 'INLINECHOICEINTERACTION') { |
| 340 | 340 | |
| 341 | - $current_question_item_body .= "**claroline_start**" . $attributes['RESPONSEIDENTIFIER'] . "**claroline_end**"; |
|
| 341 | + $current_question_item_body .= "**claroline_start**".$attributes['RESPONSEIDENTIFIER']."**claroline_end**"; |
|
| 342 | 342 | } |
| 343 | 343 | if ($current_element == 'TEXTENTRYINTERACTION') { |
| 344 | 344 | $correct_answer_value = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id]; |
| 345 | - $current_question_item_body .= "[" . $correct_answer_value . "]"; |
|
| 345 | + $current_question_item_body .= "[".$correct_answer_value."]"; |
|
| 346 | 346 | |
| 347 | 347 | } |
| 348 | 348 | if ($current_element == 'BR') { |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | //treat the record of the full content of itembody tag : |
| 458 | 458 | |
| 459 | 459 | if ($record_item_body && (!in_array($current_element, $non_HTML_tag_to_avoid))) { |
| 460 | - $current_question_item_body .= "</" . $name . ">"; |
|
| 460 | + $current_question_item_body .= "</".$name.">"; |
|
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | switch ($name) { |
@@ -515,14 +515,14 @@ discard block |
||
| 515 | 515 | if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'])) { |
| 516 | 516 | $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] = trim($data); |
| 517 | 517 | } else { |
| 518 | - $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= '' . trim($data); |
|
| 518 | + $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= ''.trim($data); |
|
| 519 | 519 | } |
| 520 | 520 | break; |
| 521 | 521 | case 'FEEDBACKINLINE': |
| 522 | 522 | if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'])) { |
| 523 | 523 | $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] = trim($data); |
| 524 | 524 | } else { |
| 525 | - $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] .= ' ' . trim($data); |
|
| 525 | + $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] .= ' '.trim($data); |
|
| 526 | 526 | } |
| 527 | 527 | break; |
| 528 | 528 | case 'SIMPLEASSOCIABLECHOICE': |
@@ -546,8 +546,8 @@ discard block |
||
| 546 | 546 | $answer_identifier = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id]; |
| 547 | 547 | if ($current_inlinechoice_id == $answer_identifier) { |
| 548 | 548 | $current_question_item_body = str_replace( |
| 549 | - "**claroline_start**" . $current_answer_id . "**claroline_end**", |
|
| 550 | - "[" . $data . "]", |
|
| 549 | + "**claroline_start**".$current_answer_id."**claroline_end**", |
|
| 550 | + "[".$data."]", |
|
| 551 | 551 | $current_question_item_body |
| 552 | 552 | ); |
| 553 | 553 | } else { |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * Constructor. |
| 34 | 34 | * |
| 35 | - * @param $question Ims2Question object we want to export. |
|
| 35 | + * @param Ims2Question $question Ims2Question object we want to export. |
|
| 36 | 36 | */ |
| 37 | 37 | function ImsAssessmentItem($question) |
| 38 | 38 | { |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * This is a default behaviour, some classes may want to override this. |
| 102 | 102 | * |
| 103 | 103 | * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
| 104 | - * @return A string, the XML flow for an Item. |
|
| 104 | + * @return string string, the XML flow for an Item. |
|
| 105 | 105 | */ |
| 106 | 106 | function export($standalone = false) |
| 107 | 107 | { |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | /** |
| 156 | 156 | * Constructor. |
| 157 | - * @param $exe The Exercise instance to export |
|
| 157 | + * @param Exercise $exe The Exercise instance to export |
|
| 158 | 158 | * @author Amand Tihon <[email protected]> |
| 159 | 159 | */ |
| 160 | 160 | function ImsSection($exe) |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * Export the exercise in IMS/QTI. |
| 240 | 240 | * |
| 241 | 241 | * @param bool $standalone Wether it should include XML tag and DTD line. |
| 242 | - * @return a string containing the XML flow |
|
| 242 | + * @return string string containing the XML flow |
|
| 243 | 243 | * @author Amand Tihon <[email protected]> |
| 244 | 244 | */ |
| 245 | 245 | function export($standalone) |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | * This is a default behaviour, some classes may want to override this. |
| 384 | 384 | * |
| 385 | 385 | * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
| 386 | - * @return A string, the XML flow for an Item. |
|
| 386 | + * @return string string, the XML flow for an Item. |
|
| 387 | 387 | * @author Amand Tihon <[email protected]> |
| 388 | 388 | */ |
| 389 | 389 | function export($standalone = False) |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | * |
| 418 | 418 | * @param int $exerciseId The exercise to export |
| 419 | 419 | * @param boolean $standalone Wether it should include XML tag and DTD line. |
| 420 | - * @return The XML as a string, or an empty string if there's no exercise with given ID. |
|
| 420 | + * @return string XML as a string, or an empty string if there's no exercise with given ID. |
|
| 421 | 421 | */ |
| 422 | 422 | function export_exercise_to_qti($exerciseId, $standalone = true) |
| 423 | 423 | { |
@@ -474,6 +474,9 @@ discard block |
||
| 474 | 474 | return htmlspecialchars($text); |
| 475 | 475 | } |
| 476 | 476 | |
| 477 | +/** |
|
| 478 | + * @param string $text |
|
| 479 | + */ |
|
| 477 | 480 | function cleanAttribute($text) |
| 478 | 481 | { |
| 479 | 482 | return $text; |
@@ -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 | { |
@@ -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 | } |
@@ -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,24 +531,24 @@ 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 | } |
@@ -558,40 +558,40 @@ discard block |
||
| 558 | 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 | } |
@@ -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 .= " | "; |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * Sets the comment in the database for a particular path. |
| 95 | 95 | * @param string File path |
| 96 | 96 | * @param string Comment to set |
| 97 | - * @return string Result of the database operation (Database::query will output some message directly on error anyway) |
|
| 97 | + * @return Doctrine\DBAL\Driver\Statement|null Result of the database operation (Database::query will output some message directly on error anyway) |
|
| 98 | 98 | */ |
| 99 | 99 | function SetComment($path, $comment) |
| 100 | 100 | { |
@@ -112,6 +112,7 @@ discard block |
||
| 112 | 112 | /** |
| 113 | 113 | * Reads the file contents into a string. |
| 114 | 114 | * @param string Urlencoded path |
| 115 | + * @param string $full_file_path |
|
| 115 | 116 | * @return string The file contents or false on security error |
| 116 | 117 | */ |
| 117 | 118 | function ReadFileCont($full_file_path) |
@@ -257,6 +258,7 @@ discard block |
||
| 257 | 258 | * Searches for a node in the given array. |
| 258 | 259 | * @param reference Reference to the array to search |
| 259 | 260 | * @param string Node we are looking for in the array |
| 261 | + * @param string $node |
|
| 260 | 262 | * @return mixed Node name or false if not found |
| 261 | 263 | */ |
| 262 | 264 | function myarraysearch(&$array, $node) |
@@ -316,6 +318,8 @@ discard block |
||
| 316 | 318 | * Fills the folder name up to a certain length with "0". |
| 317 | 319 | * @param string Original folder name |
| 318 | 320 | * @param integer Length to reach |
| 321 | + * @param integer $name |
|
| 322 | + * @param integer $nsize |
|
| 319 | 323 | * @return string Modified folder name |
| 320 | 324 | */ |
| 321 | 325 | function FillFolderName($name, $nsize) |
@@ -344,7 +344,7 @@ |
||
| 344 | 344 | if (is_dir($full_name)) { |
| 345 | 345 | $filelist[] = $file; |
| 346 | 346 | } |
| 347 | - } |
|
| 347 | + } |
|
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | if ($title == '') { |
| 67 | 67 | $title = basename($fname); |
| 68 | 68 | } |
| 69 | - return (string)$title; |
|
| 69 | + return (string) $title; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | if ($src == '') { |
| 177 | 177 | return ''; |
| 178 | 178 | } else { |
| 179 | - $tmp_src = basename($src) ; |
|
| 179 | + $tmp_src = basename($src); |
|
| 180 | 180 | if ($tmp_src == '') { |
| 181 | 181 | return $src; |
| 182 | 182 | } else { |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | { |
| 199 | 199 | // Select src tag from img tag. |
| 200 | 200 | $match = array(); |
| 201 | - preg_match("|(src=\".*\" )|U", $imgtag, $match); //src |
|
| 201 | + preg_match("|(src=\".*\" )|U", $imgtag, $match); //src |
|
| 202 | 202 | list($key, $srctag) = each($match); |
| 203 | 203 | $src = substr($srctag, 5, (strlen($srctag) - 7)); |
| 204 | 204 | if (stristr($src, 'http') === false) { |
@@ -230,8 +230,8 @@ discard block |
||
| 230 | 230 | while (list($key, $imgtag) = each($match)) { |
| 231 | 231 | $imgname = GetImgName($imgtag); |
| 232 | 232 | if ($imgname != '' && !in_array($imgname, $imgparams)) { |
| 233 | - array_push($imgparams, $imgname); // name (+ type) of the images in the html test |
|
| 234 | - $imgcount = $imgcount + 1; // number of images in the html test |
|
| 233 | + array_push($imgparams, $imgname); // name (+ type) of the images in the html test |
|
| 234 | + $imgcount = $imgcount + 1; // number of images in the html test |
|
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | } |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | if ($file != '..') { |
| 405 | 405 | $full_name = $folder.'/'.$file; |
| 406 | 406 | if (is_dir($full_name)) { |
| 407 | - $dflag = 1; // first directory |
|
| 407 | + $dflag = 1; // first directory |
|
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | 410 | } |
@@ -18,6 +18,7 @@ |
||
| 18 | 18 | * Gets the results of all students (or just one student if access is limited) |
| 19 | 19 | * @param string The document path (for HotPotatoes retrieval) |
| 20 | 20 | * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null |
| 21 | + * @param string $document_path |
|
| 21 | 22 | */ |
| 22 | 23 | public function getExercisesReporting($document_path, $hotpotato_name) |
| 23 | 24 | { |
@@ -14,14 +14,14 @@ discard block |
||
| 14 | 14 | //stores the results |
| 15 | 15 | private $results = array(); |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Gets the results of all students (or just one student if access is limited) |
|
| 19 | - * @param string The document path (for HotPotatoes retrieval) |
|
| 20 | - * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null |
|
| 21 | - */ |
|
| 22 | - public function getExercisesReporting($document_path, $hotpotato_name) |
|
| 17 | + /** |
|
| 18 | + * Gets the results of all students (or just one student if access is limited) |
|
| 19 | + * @param string The document path (for HotPotatoes retrieval) |
|
| 20 | + * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null |
|
| 21 | + */ |
|
| 22 | + public function getExercisesReporting($document_path, $hotpotato_name) |
|
| 23 | 23 | { |
| 24 | - $return = array(); |
|
| 24 | + $return = array(); |
|
| 25 | 25 | $TBL_USER = Database::get_main_table(TABLE_MAIN_USER); |
| 26 | 26 | $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); |
| 27 | 27 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $hotpotato_name = Database::escape_string($hotpotato_name); |
| 34 | 34 | |
| 35 | 35 | if (!empty($exercise_id)) { |
| 36 | - $session_id_and .= " AND exe_exo_id = $exercise_id "; |
|
| 36 | + $session_id_and .= " AND exe_exo_id = $exercise_id "; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | if (empty($user_id)) { |
@@ -110,25 +110,25 @@ discard block |
||
| 110 | 110 | $this->results = $return; |
| 111 | 111 | |
| 112 | 112 | return true; |
| 113 | - } |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * Exports the complete report as a CSV file |
|
| 118 | - * @param string Document path inside the document tool |
|
| 119 | - * @param integer Optional user ID |
|
| 120 | - * @param boolean Whether to include user fields or not |
|
| 121 | - * @return boolean False on error |
|
| 122 | - */ |
|
| 123 | - public function exportCompleteReportCSV($document_path='', $hotpotato_name) |
|
| 116 | + /** |
|
| 117 | + * Exports the complete report as a CSV file |
|
| 118 | + * @param string Document path inside the document tool |
|
| 119 | + * @param integer Optional user ID |
|
| 120 | + * @param boolean Whether to include user fields or not |
|
| 121 | + * @return boolean False on error |
|
| 122 | + */ |
|
| 123 | + public function exportCompleteReportCSV($document_path='', $hotpotato_name) |
|
| 124 | 124 | { |
| 125 | - global $charset; |
|
| 126 | - $this->getExercisesReporting($document_path, $hotpotato_name); |
|
| 127 | - $filename = 'exercise_results_'.date('YmdGis').'.csv'; |
|
| 128 | - if (!empty($user_id)) { |
|
| 129 | - $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv'; |
|
| 130 | - } |
|
| 131 | - $data = ''; |
|
| 125 | + global $charset; |
|
| 126 | + $this->getExercisesReporting($document_path, $hotpotato_name); |
|
| 127 | + $filename = 'exercise_results_'.date('YmdGis').'.csv'; |
|
| 128 | + if (!empty($user_id)) { |
|
| 129 | + $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv'; |
|
| 130 | + } |
|
| 131 | + $data = ''; |
|
| 132 | 132 | |
| 133 | 133 | if (api_is_western_name_order()) { |
| 134 | 134 | if(!empty($this->results[0]['first_name'])) { |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | $data .= get_lang('Email').';'; |
| 149 | 149 | |
| 150 | - /*if ($export_user_fields) { |
|
| 150 | + /*if ($export_user_fields) { |
|
| 151 | 151 | //show user fields section with a big th colspan that spans over all fields |
| 152 | 152 | $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
| 153 | 153 | $num = count($extra_user_fields); |
@@ -156,25 +156,25 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | }*/ |
| 158 | 158 | |
| 159 | - $data .= get_lang('Title').';'; |
|
| 160 | - $data .= get_lang('StartDate').';'; |
|
| 161 | - $data .= get_lang('Score').';'; |
|
| 162 | - $data .= get_lang('Total').';'; |
|
| 163 | - $data .= "\n"; |
|
| 159 | + $data .= get_lang('Title').';'; |
|
| 160 | + $data .= get_lang('StartDate').';'; |
|
| 161 | + $data .= get_lang('Score').';'; |
|
| 162 | + $data .= get_lang('Total').';'; |
|
| 163 | + $data .= "\n"; |
|
| 164 | 164 | |
| 165 | - //results |
|
| 166 | - foreach($this->results as $row) { |
|
| 165 | + //results |
|
| 166 | + foreach($this->results as $row) { |
|
| 167 | 167 | if (api_is_western_name_order()) { |
| 168 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
| 169 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
| 168 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
| 169 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
| 170 | 170 | } else { |
| 171 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
| 172 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
| 171 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
| 172 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';'; |
| 176 | 176 | |
| 177 | - /*if ($export_user_fields) { |
|
| 177 | + /*if ($export_user_fields) { |
|
| 178 | 178 | //show user fields data, if any, for this user |
| 179 | 179 | $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
| 180 | 180 | foreach($user_fields_values as $value) { |
@@ -182,40 +182,40 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | }*/ |
| 184 | 184 | |
| 185 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';'; |
|
| 186 | - $data .= str_replace("\r\n",' ',$row['exe_date']).';'; |
|
| 187 | - $data .= str_replace("\r\n",' ',$row['result']).';'; |
|
| 188 | - $data .= str_replace("\r\n",' ',$row['max']).';'; |
|
| 189 | - $data .= "\n"; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - //output the results |
|
| 193 | - $len = strlen($data); |
|
| 194 | - header('Content-type: application/octet-stream'); |
|
| 195 | - header('Content-Type: application/force-download'); |
|
| 196 | - header('Content-length: '.$len); |
|
| 197 | - if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) { |
|
| 198 | - header('Content-Disposition: filename= '.$filename); |
|
| 199 | - } else { |
|
| 200 | - header('Content-Disposition: attachment; filename= '.$filename); |
|
| 201 | - } |
|
| 202 | - if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { |
|
| 203 | - header('Pragma: '); |
|
| 204 | - header('Cache-Control: '); |
|
| 205 | - header('Cache-Control: public'); // IE cannot download from sessions without a cache |
|
| 206 | - } |
|
| 207 | - header('Content-Description: '.$filename); |
|
| 208 | - header('Content-transfer-encoding: binary'); |
|
| 209 | - // @todo add this utf-8 header for all csv files |
|
| 210 | - echo "\xEF\xBB\xBF"; // force utf-8 header of csv file |
|
| 211 | - echo $data; |
|
| 212 | - return true; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * Exports the complete report as an XLS file |
|
| 217 | - * @return boolean False on error |
|
| 218 | - */ |
|
| 185 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';'; |
|
| 186 | + $data .= str_replace("\r\n",' ',$row['exe_date']).';'; |
|
| 187 | + $data .= str_replace("\r\n",' ',$row['result']).';'; |
|
| 188 | + $data .= str_replace("\r\n",' ',$row['max']).';'; |
|
| 189 | + $data .= "\n"; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + //output the results |
|
| 193 | + $len = strlen($data); |
|
| 194 | + header('Content-type: application/octet-stream'); |
|
| 195 | + header('Content-Type: application/force-download'); |
|
| 196 | + header('Content-length: '.$len); |
|
| 197 | + if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) { |
|
| 198 | + header('Content-Disposition: filename= '.$filename); |
|
| 199 | + } else { |
|
| 200 | + header('Content-Disposition: attachment; filename= '.$filename); |
|
| 201 | + } |
|
| 202 | + if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { |
|
| 203 | + header('Pragma: '); |
|
| 204 | + header('Cache-Control: '); |
|
| 205 | + header('Cache-Control: public'); // IE cannot download from sessions without a cache |
|
| 206 | + } |
|
| 207 | + header('Content-Description: '.$filename); |
|
| 208 | + header('Content-transfer-encoding: binary'); |
|
| 209 | + // @todo add this utf-8 header for all csv files |
|
| 210 | + echo "\xEF\xBB\xBF"; // force utf-8 header of csv file |
|
| 211 | + echo $data; |
|
| 212 | + return true; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * Exports the complete report as an XLS file |
|
| 217 | + * @return boolean False on error |
|
| 218 | + */ |
|
| 219 | 219 | public function exportCompleteReportXLS( |
| 220 | 220 | $document_path = '', |
| 221 | 221 | $user_id = null, |
@@ -224,37 +224,37 @@ discard block |
||
| 224 | 224 | $exercise_id = 0, |
| 225 | 225 | $hotpotato_name = null |
| 226 | 226 | ) { |
| 227 | - global $charset; |
|
| 228 | - $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name); |
|
| 229 | - $filename = 'exercise_results_'.api_get_local_time().'.xls'; |
|
| 230 | - if (!empty($user_id)) { |
|
| 231 | - $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls'; |
|
| 232 | - } |
|
| 227 | + global $charset; |
|
| 228 | + $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name); |
|
| 229 | + $filename = 'exercise_results_'.api_get_local_time().'.xls'; |
|
| 230 | + if (!empty($user_id)) { |
|
| 231 | + $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls'; |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | 234 | $spreadsheet = new PHPExcel(); |
| 235 | 235 | $spreadsheet->setActiveSheetIndex(0); |
| 236 | 236 | $worksheet = $spreadsheet->getActiveSheet(); |
| 237 | 237 | |
| 238 | 238 | |
| 239 | - $line = 0; |
|
| 240 | - $column = 0; //skip the first column (row titles) |
|
| 239 | + $line = 0; |
|
| 240 | + $column = 0; //skip the first column (row titles) |
|
| 241 | 241 | |
| 242 | - // check if exists column 'user' |
|
| 243 | - $with_column_user = false; |
|
| 244 | - foreach ($this->results as $result) { |
|
| 245 | - if (!empty($result['last_name']) && !empty($result['first_name'])) { |
|
| 246 | - $with_column_user = true; |
|
| 247 | - break; |
|
| 248 | - } |
|
| 249 | - } |
|
| 242 | + // check if exists column 'user' |
|
| 243 | + $with_column_user = false; |
|
| 244 | + foreach ($this->results as $result) { |
|
| 245 | + if (!empty($result['last_name']) && !empty($result['first_name'])) { |
|
| 246 | + $with_column_user = true; |
|
| 247 | + break; |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | - if ($with_column_user) { |
|
| 252 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Email')); |
|
| 253 | - $column++; |
|
| 251 | + if ($with_column_user) { |
|
| 252 | + $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Email')); |
|
| 253 | + $column++; |
|
| 254 | 254 | |
| 255 | 255 | if (api_is_western_name_order()) { |
| 256 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
|
| 257 | - $column++; |
|
| 256 | + $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
|
| 257 | + $column++; |
|
| 258 | 258 | $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('LastName')); |
| 259 | 259 | $column++; |
| 260 | 260 | } else { |
@@ -263,36 +263,36 @@ discard block |
||
| 263 | 263 | $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
| 264 | 264 | $column++; |
| 265 | 265 | } |
| 266 | - } |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - if ($export_user_fields) { |
|
| 269 | - //show user fields section with a big th colspan that spans over all fields |
|
| 270 | - $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
|
| 268 | + if ($export_user_fields) { |
|
| 269 | + //show user fields section with a big th colspan that spans over all fields |
|
| 270 | + $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
|
| 271 | 271 | |
| 272 | - //show the fields names for user fields |
|
| 273 | - foreach ($extra_user_fields as $field) { |
|
| 274 | - $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)); |
|
| 275 | - $column++; |
|
| 276 | - } |
|
| 277 | - } |
|
| 272 | + //show the fields names for user fields |
|
| 273 | + foreach ($extra_user_fields as $field) { |
|
| 274 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)); |
|
| 275 | + $column++; |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title')); |
|
| 280 | - $column++; |
|
| 281 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate')); |
|
| 279 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title')); |
|
| 280 | + $column++; |
|
| 281 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate')); |
|
| 282 | 282 | $column++; |
| 283 | 283 | $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('EndDate')); |
| 284 | 284 | $column++; |
| 285 | 285 | $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Duration').' ('.get_lang('MinMinutes').')'); |
| 286 | - $column++; |
|
| 287 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score')); |
|
| 288 | - $column++; |
|
| 289 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total')); |
|
| 290 | - $column++; |
|
| 286 | + $column++; |
|
| 287 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score')); |
|
| 288 | + $column++; |
|
| 289 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total')); |
|
| 290 | + $column++; |
|
| 291 | 291 | $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Status')); |
| 292 | - $line++; |
|
| 292 | + $line++; |
|
| 293 | 293 | |
| 294 | - foreach ($this->results as $row) { |
|
| 295 | - $column = 0; |
|
| 294 | + foreach ($this->results as $row) { |
|
| 295 | + $column = 0; |
|
| 296 | 296 | |
| 297 | 297 | if ($with_column_user) { |
| 298 | 298 | $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)); |
@@ -309,38 +309,38 @@ discard block |
||
| 309 | 309 | $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); |
| 310 | 310 | $column++; |
| 311 | 311 | } |
| 312 | - } |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - if ($export_user_fields) { |
|
| 315 | - //show user fields data, if any, for this user |
|
| 316 | - $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
|
| 317 | - foreach($user_fields_values as $value) { |
|
| 318 | - $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
| 319 | - $column++; |
|
| 320 | - } |
|
| 321 | - } |
|
| 314 | + if ($export_user_fields) { |
|
| 315 | + //show user fields data, if any, for this user |
|
| 316 | + $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
|
| 317 | + foreach($user_fields_values as $value) { |
|
| 318 | + $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
| 319 | + $column++; |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | 322 | |
| 323 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
| 324 | - $column++; |
|
| 325 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']); |
|
| 323 | + $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
| 324 | + $column++; |
|
| 325 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']); |
|
| 326 | 326 | $column++; |
| 327 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']); |
|
| 327 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']); |
|
| 328 | + $column++; |
|
| 329 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']); |
|
| 330 | + $column++; |
|
| 331 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']); |
|
| 332 | + $column++; |
|
| 333 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']); |
|
| 328 | 334 | $column++; |
| 329 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']); |
|
| 330 | - $column++; |
|
| 331 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']); |
|
| 332 | - $column++; |
|
| 333 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']); |
|
| 334 | - $column++; |
|
| 335 | 335 | $worksheet->SetCellValueByColumnAndRow($line,$column,$row['status']); |
| 336 | - $line++; |
|
| 337 | - } |
|
| 336 | + $line++; |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | 339 | $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename); |
| 340 | 340 | $writer = new PHPExcel_Writer_Excel2007($spreadsheet); |
| 341 | 341 | $writer->save($file); |
| 342 | 342 | DocumentManager::file_send_for_download($file, true, $filename); |
| 343 | 343 | |
| 344 | - return true; |
|
| 345 | - } |
|
| 344 | + return true; |
|
| 345 | + } |
|
| 346 | 346 | } |
@@ -23,13 +23,13 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | $return = array(); |
| 25 | 25 | $TBL_USER = Database::get_main_table(TABLE_MAIN_USER); |
| 26 | - $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); |
|
| 26 | + $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); |
|
| 27 | 27 | |
| 28 | 28 | $cid = api_get_course_id(); |
| 29 | 29 | $course_id = api_get_course_int_id(); |
| 30 | 30 | //$user_id = intval($user_id); |
| 31 | 31 | $user_id = null; |
| 32 | - $session_id_and = ' AND te.session_id = ' . api_get_session_id() . ' '; |
|
| 32 | + $session_id_and = ' AND te.session_id = '.api_get_session_id().' '; |
|
| 33 | 33 | $hotpotato_name = Database::escape_string($hotpotato_name); |
| 34 | 34 | |
| 35 | 35 | if (!empty($exercise_id)) { |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | if (empty($user_id)) { |
| 40 | - $sql="SELECT firstname as userpart1, lastname as userpart2 , |
|
| 40 | + $sql = "SELECT firstname as userpart1, lastname as userpart2 , |
|
| 41 | 41 | email, |
| 42 | 42 | tth.exe_name, |
| 43 | 43 | tth.exe_result, |
@@ -49,13 +49,13 @@ discard block |
||
| 49 | 49 | tth.exe_name = '$hotpotato_name' |
| 50 | 50 | ORDER BY tth.c_id ASC, tth.exe_date ASC"; |
| 51 | 51 | } else { |
| 52 | - $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' '; |
|
| 52 | + $user_id_and = ' AND te.exe_user_id = '.api_get_user_id().' '; |
|
| 53 | 53 | // get only this user's results |
| 54 | 54 | |
| 55 | 55 | $sql = "SELECT '', exe_name, exe_result , exe_weighting, exe_date |
| 56 | 56 | FROM $TBL_TRACK_HOTPOTATOES |
| 57 | 57 | WHERE |
| 58 | - exe_user_id = '" . $user_id . "' AND |
|
| 58 | + exe_user_id = '".$user_id."' AND |
|
| 59 | 59 | c_id = $course_id AND |
| 60 | 60 | tth.exe_name = '$hotpotato_name' |
| 61 | 61 | ORDER BY c_id ASC, exe_date ASC"; |
@@ -64,13 +64,13 @@ discard block |
||
| 64 | 64 | $results = array(); |
| 65 | 65 | |
| 66 | 66 | $resx = Database::query($sql); |
| 67 | - while ($rowx = Database::fetch_array($resx,'ASSOC')) { |
|
| 67 | + while ($rowx = Database::fetch_array($resx, 'ASSOC')) { |
|
| 68 | 68 | $results[] = $rowx; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $hpresults = array(); |
| 72 | 72 | $resx = Database::query($sql); |
| 73 | - while ($rowx = Database::fetch_array($resx,'ASSOC')) { |
|
| 73 | + while ($rowx = Database::fetch_array($resx, 'ASSOC')) { |
|
| 74 | 74 | $hpresults[] = $rowx; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -89,19 +89,19 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | // Print the Result of Hotpotatoes Tests |
| 91 | 91 | if (is_array($hpresults)) { |
| 92 | - for($i = 0; $i < sizeof($hpresults); $i++) { |
|
| 92 | + for ($i = 0; $i < sizeof($hpresults); $i++) { |
|
| 93 | 93 | $return[$i] = array(); |
| 94 | 94 | $title = GetQuizName($hpresults[$i]['exe_name'], $document_path); |
| 95 | - if ($title =='') { |
|
| 95 | + if ($title == '') { |
|
| 96 | 96 | $title = basename($hpresults[$i]['exe_name']); |
| 97 | 97 | } |
| 98 | - if(empty($user_id)) { |
|
| 98 | + if (empty($user_id)) { |
|
| 99 | 99 | $return[$i]['email'] = $hpresults[$i]['email']; |
| 100 | 100 | $return[$i]['first_name'] = $hpresults[$i]['userpart1']; |
| 101 | 101 | $return[$i]['last_name'] = $hpresults[$i]['userpart2']; |
| 102 | 102 | } |
| 103 | 103 | $return[$i]['title'] = $title; |
| 104 | - $return[$i]['exe_date'] = $hpresults[$i]['exe_date']; |
|
| 104 | + $return[$i]['exe_date'] = $hpresults[$i]['exe_date']; |
|
| 105 | 105 | |
| 106 | 106 | $return[$i]['result'] = $hpresults[$i]['exe_result']; |
| 107 | 107 | $return[$i]['max'] = $hpresults[$i]['exe_weighting']; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * @param boolean Whether to include user fields or not |
| 121 | 121 | * @return boolean False on error |
| 122 | 122 | */ |
| 123 | - public function exportCompleteReportCSV($document_path='', $hotpotato_name) |
|
| 123 | + public function exportCompleteReportCSV($document_path = '', $hotpotato_name) |
|
| 124 | 124 | { |
| 125 | 125 | global $charset; |
| 126 | 126 | $this->getExercisesReporting($document_path, $hotpotato_name); |
@@ -131,17 +131,17 @@ discard block |
||
| 131 | 131 | $data = ''; |
| 132 | 132 | |
| 133 | 133 | if (api_is_western_name_order()) { |
| 134 | - if(!empty($this->results[0]['first_name'])) { |
|
| 134 | + if (!empty($this->results[0]['first_name'])) { |
|
| 135 | 135 | $data .= get_lang('FirstName').';'; |
| 136 | 136 | } |
| 137 | - if(!empty($this->results[0]['last_name'])) { |
|
| 137 | + if (!empty($this->results[0]['last_name'])) { |
|
| 138 | 138 | $data .= get_lang('LastName').';'; |
| 139 | 139 | } |
| 140 | 140 | } else { |
| 141 | - if(!empty($this->results[0]['last_name'])) { |
|
| 141 | + if (!empty($this->results[0]['last_name'])) { |
|
| 142 | 142 | $data .= get_lang('LastName').';'; |
| 143 | 143 | } |
| 144 | - if(!empty($this->results[0]['first_name'])) { |
|
| 144 | + if (!empty($this->results[0]['first_name'])) { |
|
| 145 | 145 | $data .= get_lang('FirstName').';'; |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -163,16 +163,16 @@ discard block |
||
| 163 | 163 | $data .= "\n"; |
| 164 | 164 | |
| 165 | 165 | //results |
| 166 | - foreach($this->results as $row) { |
|
| 166 | + foreach ($this->results as $row) { |
|
| 167 | 167 | if (api_is_western_name_order()) { |
| 168 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
| 169 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
| 168 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
| 169 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
| 170 | 170 | } else { |
| 171 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
| 172 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
| 171 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
| 172 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';'; |
|
| 175 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';'; |
|
| 176 | 176 | |
| 177 | 177 | /*if ($export_user_fields) { |
| 178 | 178 | //show user fields data, if any, for this user |
@@ -182,10 +182,10 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | }*/ |
| 184 | 184 | |
| 185 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';'; |
|
| 186 | - $data .= str_replace("\r\n",' ',$row['exe_date']).';'; |
|
| 187 | - $data .= str_replace("\r\n",' ',$row['result']).';'; |
|
| 188 | - $data .= str_replace("\r\n",' ',$row['max']).';'; |
|
| 185 | + $data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';'; |
|
| 186 | + $data .= str_replace("\r\n", ' ', $row['exe_date']).';'; |
|
| 187 | + $data .= str_replace("\r\n", ' ', $row['result']).';'; |
|
| 188 | + $data .= str_replace("\r\n", ' ', $row['max']).';'; |
|
| 189 | 189 | $data .= "\n"; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | header('Content-Description: '.$filename); |
| 208 | 208 | header('Content-transfer-encoding: binary'); |
| 209 | 209 | // @todo add this utf-8 header for all csv files |
| 210 | - echo "\xEF\xBB\xBF"; // force utf-8 header of csv file |
|
| 210 | + echo "\xEF\xBB\xBF"; // force utf-8 header of csv file |
|
| 211 | 211 | echo $data; |
| 212 | 212 | return true; |
| 213 | 213 | } |
@@ -249,25 +249,25 @@ discard block |
||
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | if ($with_column_user) { |
| 252 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Email')); |
|
| 252 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Email')); |
|
| 253 | 253 | $column++; |
| 254 | 254 | |
| 255 | 255 | if (api_is_western_name_order()) { |
| 256 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
|
| 256 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('FirstName')); |
|
| 257 | 257 | $column++; |
| 258 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('LastName')); |
|
| 258 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('LastName')); |
|
| 259 | 259 | $column++; |
| 260 | 260 | } else { |
| 261 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('LastName')); |
|
| 261 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('LastName')); |
|
| 262 | 262 | $column++; |
| 263 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
|
| 263 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('FirstName')); |
|
| 264 | 264 | $column++; |
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | if ($export_user_fields) { |
| 269 | 269 | //show user fields section with a big th colspan that spans over all fields |
| 270 | - $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
|
| 270 | + $extra_user_fields = UserManager::get_extra_fields(0, 1000, 5, 'ASC', false, 1); |
|
| 271 | 271 | |
| 272 | 272 | //show the fields names for user fields |
| 273 | 273 | foreach ($extra_user_fields as $field) { |
@@ -276,63 +276,63 @@ discard block |
||
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title')); |
|
| 279 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Title')); |
|
| 280 | 280 | $column++; |
| 281 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate')); |
|
| 281 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('StartDate')); |
|
| 282 | 282 | $column++; |
| 283 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('EndDate')); |
|
| 283 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('EndDate')); |
|
| 284 | 284 | $column++; |
| 285 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Duration').' ('.get_lang('MinMinutes').')'); |
|
| 285 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Duration').' ('.get_lang('MinMinutes').')'); |
|
| 286 | 286 | $column++; |
| 287 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score')); |
|
| 287 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Score')); |
|
| 288 | 288 | $column++; |
| 289 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total')); |
|
| 289 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Total')); |
|
| 290 | 290 | $column++; |
| 291 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Status')); |
|
| 291 | + $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Status')); |
|
| 292 | 292 | $line++; |
| 293 | 293 | |
| 294 | 294 | foreach ($this->results as $row) { |
| 295 | 295 | $column = 0; |
| 296 | 296 | |
| 297 | 297 | if ($with_column_user) { |
| 298 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)); |
|
| 298 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)); |
|
| 299 | 299 | $column++; |
| 300 | 300 | |
| 301 | 301 | if (api_is_western_name_order()) { |
| 302 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); |
|
| 302 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); |
|
| 303 | 303 | $column++; |
| 304 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); |
|
| 304 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); |
|
| 305 | 305 | $column++; |
| 306 | 306 | } else { |
| 307 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); |
|
| 307 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); |
|
| 308 | 308 | $column++; |
| 309 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); |
|
| 309 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); |
|
| 310 | 310 | $column++; |
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | if ($export_user_fields) { |
| 315 | 315 | //show user fields data, if any, for this user |
| 316 | - $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
|
| 317 | - foreach($user_fields_values as $value) { |
|
| 318 | - $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
| 316 | + $user_fields_values = UserManager::get_extra_user_data($row['user_id'], false, false, false, true); |
|
| 317 | + foreach ($user_fields_values as $value) { |
|
| 318 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
| 319 | 319 | $column++; |
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
| 323 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
| 324 | 324 | $column++; |
| 325 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']); |
|
| 325 | + $worksheet->SetCellValueByColumnAndRow($line, $column, $row['start_date']); |
|
| 326 | 326 | $column++; |
| 327 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']); |
|
| 327 | + $worksheet->SetCellValueByColumnAndRow($line, $column, $row['end_date']); |
|
| 328 | 328 | $column++; |
| 329 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']); |
|
| 329 | + $worksheet->SetCellValueByColumnAndRow($line, $column, $row['duration']); |
|
| 330 | 330 | $column++; |
| 331 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']); |
|
| 331 | + $worksheet->SetCellValueByColumnAndRow($line, $column, $row['result']); |
|
| 332 | 332 | $column++; |
| 333 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']); |
|
| 333 | + $worksheet->SetCellValueByColumnAndRow($line, $column, $row['max']); |
|
| 334 | 334 | $column++; |
| 335 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['status']); |
|
| 335 | + $worksheet->SetCellValueByColumnAndRow($line, $column, $row['status']); |
|
| 336 | 336 | $line++; |
| 337 | 337 | } |
| 338 | 338 | |