@@ -607,10 +607,11 @@ |
||
607 | 607 | $current_width = $current_image_size['width']; |
608 | 608 | $current_height = $current_image_size['height']; |
609 | 609 | |
610 | - if ($current_width < $Max && $current_height < $Max) |
|
611 | - return true; |
|
612 | - elseif ($current_height == "") |
|
613 | - return false; |
|
610 | + if ($current_width < $Max && $current_height < $Max) { |
|
611 | + return true; |
|
612 | + } elseif ($current_height == "") { |
|
613 | + return false; |
|
614 | + } |
|
614 | 615 | |
615 | 616 | // Resize according to height. |
616 | 617 | if ($Dimension == "height") { |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | public $type; |
23 | 23 | public $level; |
24 | 24 | public $picture; |
25 | - public $exerciseList; // array with the list of exercises which this question is in |
|
25 | + public $exerciseList; // array with the list of exercises which this question is in |
|
26 | 26 | public $category_list; |
27 | 27 | public $parent_id; |
28 | 28 | public $category; |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | 'multiple_answer_combination_true_false.class.php', |
48 | 48 | 'MultipleAnswerCombinationTrueFalse' |
49 | 49 | ), |
50 | - GLOBAL_MULTIPLE_ANSWER => array('global_multiple_answer.class.php' , 'GlobalMultipleAnswer'), |
|
51 | - CALCULATED_ANSWER => array('calculated_answer.class.php' , 'CalculatedAnswer'), |
|
50 | + GLOBAL_MULTIPLE_ANSWER => array('global_multiple_answer.class.php', 'GlobalMultipleAnswer'), |
|
51 | + CALCULATED_ANSWER => array('calculated_answer.class.php', 'CalculatedAnswer'), |
|
52 | 52 | UNIQUE_ANSWER_IMAGE => ['UniqueAnswerImage.php', 'UniqueAnswerImage'], |
53 | 53 | DRAGGABLE => ['Draggable.php', 'Draggable'], |
54 | 54 | MATCHING_DRAGGABLE => ['MatchingDraggable.php', 'MatchingDraggable'] |
@@ -107,14 +107,14 @@ discard block |
||
107 | 107 | $id = intval($id); |
108 | 108 | |
109 | 109 | if (!empty($course_id)) { |
110 | - $course_info = api_get_course_info_by_id($course_id); |
|
110 | + $course_info = api_get_course_info_by_id($course_id); |
|
111 | 111 | } else { |
112 | 112 | $course_info = api_get_course_info(); |
113 | 113 | } |
114 | 114 | |
115 | 115 | $course_id = $course_info['real_id']; |
116 | 116 | |
117 | - if (empty($course_id) || $course_id == -1 ) { |
|
117 | + if (empty($course_id) || $course_id == -1) { |
|
118 | 118 | |
119 | 119 | return false; |
120 | 120 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | public function selectPicturePath() |
270 | 270 | { |
271 | 271 | if (!empty($this->picture)) { |
272 | - return api_get_path(WEB_COURSE_PATH) . $this->course['path'] . '/document/images/' . $this->picture; |
|
272 | + return api_get_path(WEB_COURSE_PATH).$this->course['path'].'/document/images/'.$this->picture; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | return false; |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | */ |
307 | 307 | public function updateTitle($title) |
308 | 308 | { |
309 | - $this->question=$title; |
|
309 | + $this->question = $title; |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | /** |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | // DO nothing |
406 | 406 | } else { |
407 | 407 | $sql = "INSERT INTO $TBL_QUESTION_REL_CATEGORY (c_id, question_id, category_id) |
408 | - VALUES (" . api_get_course_int_id() . ", $question_id, $category_id)"; |
|
408 | + VALUES (".api_get_course_int_id().", $question_id, $category_id)"; |
|
409 | 409 | Database::query($sql); |
410 | 410 | } |
411 | 411 | } |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | $sql = "SELECT count(*) AS nb FROM $table |
433 | 433 | WHERE |
434 | 434 | question_id = $question_id AND |
435 | - c_id=" . api_get_course_int_id(); |
|
435 | + c_id=".api_get_course_int_id(); |
|
436 | 436 | $res = Database::query($sql); |
437 | 437 | $row = Database::fetch_array($res); |
438 | 438 | if ($row['nb'] > 0) { |
@@ -440,11 +440,11 @@ discard block |
||
440 | 440 | SET category_id = $category_id |
441 | 441 | WHERE |
442 | 442 | question_id = $question_id AND |
443 | - c_id = " . api_get_course_int_id(); |
|
443 | + c_id = ".api_get_course_int_id(); |
|
444 | 444 | Database::query($sql); |
445 | 445 | } else { |
446 | 446 | $sql = "INSERT INTO $table (c_id, question_id, category_id) |
447 | - VALUES (" . api_get_course_int_id().", $question_id, $category_id)"; |
|
447 | + VALUES (".api_get_course_int_id().", $question_id, $category_id)"; |
|
448 | 448 | Database::query($sql); |
449 | 449 | } |
450 | 450 | } |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | $sql = "DELETE FROM $table |
463 | 463 | WHERE |
464 | 464 | question_id = $question_id AND |
465 | - c_id = " . api_get_course_int_id(); |
|
465 | + c_id = ".api_get_course_int_id(); |
|
466 | 466 | Database::query($sql); |
467 | 467 | } |
468 | 468 | |
@@ -515,11 +515,11 @@ discard block |
||
515 | 515 | ) { |
516 | 516 | // removes old answers |
517 | 517 | $sql = "DELETE FROM $TBL_REPONSES |
518 | - WHERE c_id = $course_id AND question_id = " . intval($this->id); |
|
518 | + WHERE c_id = $course_id AND question_id = ".intval($this->id); |
|
519 | 519 | Database::query($sql); |
520 | 520 | } |
521 | 521 | |
522 | - $this->type=$type; |
|
522 | + $this->type = $type; |
|
523 | 523 | } |
524 | 524 | } |
525 | 525 | |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | if (!file_exists($picturePath)) { |
544 | 544 | if (mkdir($picturePath, api_get_permissions_for_new_directories())) { |
545 | 545 | // document path |
546 | - $documentPath = api_get_path(SYS_COURSE_PATH) . $this->course['path'] . "/document"; |
|
546 | + $documentPath = api_get_path(SYS_COURSE_PATH).$this->course['path']."/document"; |
|
547 | 547 | $path = str_replace($documentPath, '', $picturePath); |
548 | 548 | $title_path = basename($picturePath); |
549 | 549 | $doc_id = add_document($this->course, $path, 'folder', 0, $title_path); |
@@ -559,14 +559,14 @@ discard block |
||
559 | 559 | |
560 | 560 | // if the question has got an ID |
561 | 561 | if ($this->id) { |
562 | - $this->picture = 'quiz-' . $this->id . '.jpg'; |
|
562 | + $this->picture = 'quiz-'.$this->id.'.jpg'; |
|
563 | 563 | $o_img = new Image($Picture); |
564 | - $o_img->send_image($picturePath . '/' . $this->picture, -1, 'jpg'); |
|
564 | + $o_img->send_image($picturePath.'/'.$this->picture, -1, 'jpg'); |
|
565 | 565 | $document_id = add_document( |
566 | 566 | $this->course, |
567 | - '/images/' . $this->picture, |
|
567 | + '/images/'.$this->picture, |
|
568 | 568 | 'file', |
569 | - filesize($picturePath . '/' . $this->picture), |
|
569 | + filesize($picturePath.'/'.$this->picture), |
|
570 | 570 | $this->picture |
571 | 571 | ); |
572 | 572 | if ($document_id) { |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | // if the question has an ID |
601 | 601 | if ($this->id) { |
602 | 602 | // Get dimensions from current image. |
603 | - $my_image = new Image($picturePath . '/' . $this->picture); |
|
603 | + $my_image = new Image($picturePath.'/'.$this->picture); |
|
604 | 604 | |
605 | 605 | $current_image_size = $my_image->get_image_size(); |
606 | 606 | $current_width = $current_image_size['width']; |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | } |
641 | 641 | |
642 | 642 | $my_image->resize($new_width, $new_height); |
643 | - $result = $my_image->send_image($picturePath . '/' . $this->picture); |
|
643 | + $result = $my_image->send_image($picturePath.'/'.$this->picture); |
|
644 | 644 | |
645 | 645 | if ($result) { |
646 | 646 | return true; |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | $picture = $this->picture; |
666 | 666 | $this->picture = ''; |
667 | 667 | |
668 | - return @unlink($picturePath . '/' . $picture) ? true : false; |
|
668 | + return @unlink($picturePath.'/'.$picture) ? true : false; |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | return false; |
@@ -682,27 +682,27 @@ discard block |
||
682 | 682 | { |
683 | 683 | $course_id = $course_info['real_id']; |
684 | 684 | $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); |
685 | - $destination_path = api_get_path(SYS_COURSE_PATH) . $course_info['path'] . '/document/images'; |
|
686 | - $source_path = api_get_path(SYS_COURSE_PATH) . $this->course['path'] . '/document/images'; |
|
685 | + $destination_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document/images'; |
|
686 | + $source_path = api_get_path(SYS_COURSE_PATH).$this->course['path'].'/document/images'; |
|
687 | 687 | |
688 | 688 | // if the question has got an ID and if the picture exists |
689 | 689 | if ($this->id && !empty($this->picture)) { |
690 | 690 | $picture = explode('.', $this->picture); |
691 | 691 | $extension = $picture[sizeof($picture) - 1]; |
692 | - $picture = 'quiz-' . $questionId . '.' . $extension; |
|
693 | - $result = @copy($source_path . '/' . $this->picture, $destination_path . '/' . $picture) ? true : false; |
|
692 | + $picture = 'quiz-'.$questionId.'.'.$extension; |
|
693 | + $result = @copy($source_path.'/'.$this->picture, $destination_path.'/'.$picture) ? true : false; |
|
694 | 694 | // If copy was correct then add to the database |
695 | 695 | if ($result) { |
696 | 696 | $sql = "UPDATE $TBL_QUESTIONS SET |
697 | - picture = '" . Database::escape_string($picture) . "' |
|
698 | - WHERE c_id = $course_id AND id='" . intval($questionId) . "'"; |
|
697 | + picture = '".Database::escape_string($picture)."' |
|
698 | + WHERE c_id = $course_id AND id='".intval($questionId)."'"; |
|
699 | 699 | Database::query($sql); |
700 | 700 | |
701 | 701 | $document_id = add_document( |
702 | 702 | $course_info, |
703 | - '/images/' . $picture, |
|
703 | + '/images/'.$picture, |
|
704 | 704 | 'file', |
705 | - filesize($destination_path . '/' . $picture), |
|
705 | + filesize($destination_path.'/'.$picture), |
|
706 | 706 | $picture |
707 | 707 | ); |
708 | 708 | if ($document_id) { |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | $Extension = $PictureName[sizeof($PictureName) - 1]; |
738 | 738 | |
739 | 739 | // saves the picture into a temporary file |
740 | - @move_uploaded_file($Picture, $picturePath . '/tmp.' . $Extension); |
|
740 | + @move_uploaded_file($Picture, $picturePath.'/tmp.'.$Extension); |
|
741 | 741 | } |
742 | 742 | |
743 | 743 | /** |
@@ -770,15 +770,15 @@ discard block |
||
770 | 770 | |
771 | 771 | // if the question has got an ID and if the picture exists |
772 | 772 | if ($this->id) { |
773 | - if (file_exists($picturePath . '/tmp.jpg')) { |
|
773 | + if (file_exists($picturePath.'/tmp.jpg')) { |
|
774 | 774 | $Extension = 'jpg'; |
775 | - } elseif (file_exists($picturePath . '/tmp.gif')) { |
|
775 | + } elseif (file_exists($picturePath.'/tmp.gif')) { |
|
776 | 776 | $Extension = 'gif'; |
777 | - } elseif (file_exists($picturePath . '/tmp.png')) { |
|
777 | + } elseif (file_exists($picturePath.'/tmp.png')) { |
|
778 | 778 | $Extension = 'png'; |
779 | 779 | } |
780 | - $this->picture = 'quiz-' . $this->id . '.' . $Extension; |
|
781 | - return @rename($picturePath . '/tmp.' . $Extension, $picturePath . '/' . $this->picture) ? true : false; |
|
780 | + $this->picture = 'quiz-'.$this->id.'.'.$Extension; |
|
781 | + return @rename($picturePath.'/tmp.'.$Extension, $picturePath.'/'.$this->picture) ? true : false; |
|
782 | 782 | } |
783 | 783 | return false; |
784 | 784 | } |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | $category = $this->category; |
809 | 809 | |
810 | 810 | // question already exists |
811 | - if(!empty($id)) { |
|
811 | + if (!empty($id)) { |
|
812 | 812 | |
813 | 813 | $params = [ |
814 | 814 | 'question' => $question, |
@@ -854,12 +854,12 @@ discard block |
||
854 | 854 | $TBL_EXERCISE_QUESTION as test_question |
855 | 855 | WHERE |
856 | 856 | question.id = test_question.question_id AND |
857 | - test_question.exercice_id = " . intval($exerciseId) . " AND |
|
857 | + test_question.exercice_id = ".intval($exerciseId)." AND |
|
858 | 858 | question.c_id = $c_id AND |
859 | 859 | test_question.c_id = $c_id "; |
860 | - $result = Database::query($sql); |
|
861 | - $current_position = Database::result($result,0,0); |
|
862 | - $this->updatePosition($current_position+1); |
|
860 | + $result = Database::query($sql); |
|
861 | + $current_position = Database::result($result, 0, 0); |
|
862 | + $this->updatePosition($current_position + 1); |
|
863 | 863 | $position = $this->position; |
864 | 864 | |
865 | 865 | $params = [ |
@@ -955,10 +955,10 @@ discard block |
||
955 | 955 | } |
956 | 956 | } |
957 | 957 | |
958 | - public function search_engine_edit($exerciseId, $addQs=false, $rmQs=false) |
|
958 | + public function search_engine_edit($exerciseId, $addQs = false, $rmQs = false) |
|
959 | 959 | { |
960 | 960 | // update search engine and its values table if enabled |
961 | - if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) { |
|
961 | + if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) { |
|
962 | 962 | $course_id = api_get_course_id(); |
963 | 963 | // get search_did |
964 | 964 | $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF); |
@@ -976,8 +976,8 @@ discard block |
||
976 | 976 | $res = Database::query($sql); |
977 | 977 | |
978 | 978 | if (Database::num_rows($res) > 0 || $addQs) { |
979 | - require_once(api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'); |
|
980 | - require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php'); |
|
979 | + require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'); |
|
980 | + require_once(api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php'); |
|
981 | 981 | |
982 | 982 | $di = new ChamiloIndexer(); |
983 | 983 | if ($addQs) { |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | |
991 | 991 | // retrieve others exercise ids |
992 | 992 | $se_ref = Database::fetch_array($res); |
993 | - $se_doc = $di->get_document((int)$se_ref['search_did']); |
|
993 | + $se_doc = $di->get_document((int) $se_ref['search_did']); |
|
994 | 994 | if ($se_doc !== FALSE) { |
995 | 995 | if (($se_doc_data = $di->get_document_data($se_doc)) !== FALSE) { |
996 | 996 | $se_doc_data = unserialize($se_doc_data); |
@@ -1028,16 +1028,16 @@ discard block |
||
1028 | 1028 | SE_DATA => array( |
1029 | 1029 | 'type' => SE_DOCTYPE_EXERCISE_QUESTION, |
1030 | 1030 | 'exercise_ids' => $question_exercises, |
1031 | - 'question_id' => (int)$this->id |
|
1031 | + 'question_id' => (int) $this->id |
|
1032 | 1032 | ), |
1033 | - SE_USER => (int)api_get_user_id(), |
|
1033 | + SE_USER => (int) api_get_user_id(), |
|
1034 | 1034 | ); |
1035 | 1035 | $ic_slide->xapian_data = serialize($xapian_data); |
1036 | 1036 | $ic_slide->addValue("content", $this->description); |
1037 | 1037 | |
1038 | 1038 | //TODO: index answers, see also form validation on question_admin.inc.php |
1039 | 1039 | |
1040 | - $di->remove_document((int)$se_ref['search_did']); |
|
1040 | + $di->remove_document((int) $se_ref['search_did']); |
|
1041 | 1041 | $di->addChunk($ic_slide); |
1042 | 1042 | |
1043 | 1043 | //index and return search engine document id |
@@ -1116,7 +1116,7 @@ discard block |
||
1116 | 1116 | $count = $new_exercise->selectNbrQuestions(); |
1117 | 1117 | $count++; |
1118 | 1118 | $sql = "INSERT INTO $exerciseRelQuestionTable (c_id, question_id, exercice_id, question_order) |
1119 | - VALUES ({$this->course['real_id']}, " . intval($id) . ", " . intval($exerciseId) . ", '$count')"; |
|
1119 | + VALUES ({$this->course['real_id']}, ".intval($id).", ".intval($exerciseId).", '$count')"; |
|
1120 | 1120 | Database::query($sql); |
1121 | 1121 | |
1122 | 1122 | // we do not want to reindex if we had just saved adnd indexed the question |
@@ -1145,7 +1145,7 @@ discard block |
||
1145 | 1145 | $course_id = api_get_course_int_id(); |
1146 | 1146 | |
1147 | 1147 | // exercise not found |
1148 | - if($pos === false) { |
|
1148 | + if ($pos === false) { |
|
1149 | 1149 | return false; |
1150 | 1150 | } else { |
1151 | 1151 | // deletes the position in the array containing the wanted exercise ID |
@@ -1155,17 +1155,17 @@ discard block |
||
1155 | 1155 | FROM $TBL_EXERCISE_QUESTION |
1156 | 1156 | WHERE |
1157 | 1157 | c_id = $course_id |
1158 | - AND question_id = " . intval($id) . " |
|
1158 | + AND question_id = ".intval($id)." |
|
1159 | 1159 | AND exercice_id = " . intval($exerciseId); |
1160 | 1160 | $res = Database::query($sql); |
1161 | - if (Database::num_rows($res)>0) { |
|
1161 | + if (Database::num_rows($res) > 0) { |
|
1162 | 1162 | $row = Database::fetch_array($res); |
1163 | 1163 | if (!empty($row['question_order'])) { |
1164 | 1164 | $sql = "UPDATE $TBL_EXERCISE_QUESTION |
1165 | 1165 | SET question_order = question_order-1 |
1166 | 1166 | WHERE |
1167 | 1167 | c_id = $course_id |
1168 | - AND exercice_id = " . intval($exerciseId) . " |
|
1168 | + AND exercice_id = ".intval($exerciseId)." |
|
1169 | 1169 | AND question_order > " . $row['question_order']; |
1170 | 1170 | Database::query($sql); |
1171 | 1171 | } |
@@ -1174,7 +1174,7 @@ discard block |
||
1174 | 1174 | $sql = "DELETE FROM $TBL_EXERCISE_QUESTION |
1175 | 1175 | WHERE |
1176 | 1176 | c_id = $course_id |
1177 | - AND question_id = " . intval($id) . " |
|
1177 | + AND question_id = ".intval($id)." |
|
1178 | 1178 | AND exercice_id = " . intval($exerciseId); |
1179 | 1179 | Database::query($sql); |
1180 | 1180 | |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | SET question_order = question_order-1 |
1216 | 1216 | WHERE |
1217 | 1217 | c_id= $course_id |
1218 | - AND exercice_id = " . intval($row['exercice_id']) . " |
|
1218 | + AND exercice_id = ".intval($row['exercice_id'])." |
|
1219 | 1219 | AND question_order > " . $row['question_order']; |
1220 | 1220 | Database::query($sql); |
1221 | 1221 | } |
@@ -1223,22 +1223,22 @@ discard block |
||
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | $sql = "DELETE FROM $TBL_EXERCISE_QUESTION |
1226 | - WHERE c_id = $course_id AND question_id = " . $id; |
|
1226 | + WHERE c_id = $course_id AND question_id = ".$id; |
|
1227 | 1227 | Database::query($sql); |
1228 | 1228 | |
1229 | 1229 | $sql = "DELETE FROM $TBL_QUESTIONS |
1230 | - WHERE c_id = $course_id AND id = " . $id; |
|
1230 | + WHERE c_id = $course_id AND id = ".$id; |
|
1231 | 1231 | Database::query($sql); |
1232 | 1232 | |
1233 | 1233 | $sql = "DELETE FROM $TBL_REPONSES |
1234 | - WHERE c_id = $course_id AND question_id = " . $id; |
|
1234 | + WHERE c_id = $course_id AND question_id = ".$id; |
|
1235 | 1235 | Database::query($sql); |
1236 | 1236 | |
1237 | 1237 | // remove the category of this question in the question_rel_category table |
1238 | 1238 | $sql = "DELETE FROM $TBL_QUIZ_QUESTION_REL_CATEGORY |
1239 | 1239 | WHERE |
1240 | 1240 | c_id = $course_id AND |
1241 | - question_id = " . $id; |
|
1241 | + question_id = ".$id; |
|
1242 | 1242 | Database::query($sql); |
1243 | 1243 | |
1244 | 1244 | api_item_property_update( |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | if (class_exists($class_name)) { |
1408 | 1408 | return new $class_name(); |
1409 | 1409 | } else { |
1410 | - echo 'Can\'t instanciate class ' . $class_name . ' of type ' . $type; |
|
1410 | + echo 'Can\'t instanciate class '.$class_name.' of type '.$type; |
|
1411 | 1411 | } |
1412 | 1412 | } |
1413 | 1413 | } |
@@ -1449,7 +1449,7 @@ discard block |
||
1449 | 1449 | |
1450 | 1450 | // Question type |
1451 | 1451 | $answerType = isset($_REQUEST['answerType']) ? intval($_REQUEST['answerType']) : null; |
1452 | - $form->addElement('hidden','answerType', $answerType); |
|
1452 | + $form->addElement('hidden', 'answerType', $answerType); |
|
1453 | 1453 | |
1454 | 1454 | // html editor |
1455 | 1455 | $editorConfig = array( |
@@ -1457,7 +1457,7 @@ discard block |
||
1457 | 1457 | 'Height' => '150' |
1458 | 1458 | ); |
1459 | 1459 | |
1460 | - if (!api_is_allowed_to_edit(null,true)) { |
|
1460 | + if (!api_is_allowed_to_edit(null, true)) { |
|
1461 | 1461 | $editorConfig['UserStatus'] = 'student'; |
1462 | 1462 | } |
1463 | 1463 | |
@@ -1594,7 +1594,7 @@ discard block |
||
1594 | 1594 | |
1595 | 1595 | if ($feedback_type == 1) { |
1596 | 1596 | //2. but if it is a feedback DIRECT we only show the UNIQUE_ANSWER type that is currently available |
1597 | - $question_type_custom_list = array ( |
|
1597 | + $question_type_custom_list = array( |
|
1598 | 1598 | UNIQUE_ANSWER => self::$questionTypes[UNIQUE_ANSWER], |
1599 | 1599 | HOT_SPOT_DELINEATION => self::$questionTypes[HOT_SPOT_DELINEATION] |
1600 | 1600 | ); |
@@ -1610,17 +1610,17 @@ discard block |
||
1610 | 1610 | require_once $a_type[0]; |
1611 | 1611 | // get the picture of the type and the langvar which describes it |
1612 | 1612 | $img = $explanation = ''; |
1613 | - eval('$img = ' . $a_type[1] . '::$typePicture;'); |
|
1614 | - eval('$explanation = get_lang(' . $a_type[1] . '::$explanationLangVar);'); |
|
1613 | + eval('$img = '.$a_type[1].'::$typePicture;'); |
|
1614 | + eval('$explanation = get_lang('.$a_type[1].'::$explanationLangVar);'); |
|
1615 | 1615 | echo '<li>'; |
1616 | 1616 | echo '<div class="icon-image">'; |
1617 | 1617 | if ($objExercise->exercise_was_added_in_lp == true) { |
1618 | 1618 | $img = pathinfo($img); |
1619 | - $img = $img['filename'] . '_na.' . $img['extension']; |
|
1619 | + $img = $img['filename'].'_na.'.$img['extension']; |
|
1620 | 1620 | echo Display::return_icon($img, $explanation, null, ICON_SIZE_BIG); |
1621 | 1621 | } else { |
1622 | - echo '<a href="admin.php?' . api_get_cidreq() . '&newQuestion=yes&answerType=' . $i . '">' . |
|
1623 | - Display::return_icon($img, $explanation, null, ICON_SIZE_BIG) . '</a>'; |
|
1622 | + echo '<a href="admin.php?'.api_get_cidreq().'&newQuestion=yes&answerType='.$i.'">'. |
|
1623 | + Display::return_icon($img, $explanation, null, ICON_SIZE_BIG).'</a>'; |
|
1624 | 1624 | } |
1625 | 1625 | echo '</div>'; |
1626 | 1626 | echo '</li>'; |
@@ -1632,9 +1632,9 @@ discard block |
||
1632 | 1632 | echo Display::return_icon('database_na.png', get_lang('GetExistingQuestion'), null, ICON_SIZE_BIG); |
1633 | 1633 | } else { |
1634 | 1634 | if ($feedback_type == 1) { |
1635 | - echo $url = "<a href=\"question_pool.php?" . api_get_cidreq() . "&type=1&fromExercise=$exerciseId\">"; |
|
1635 | + echo $url = "<a href=\"question_pool.php?".api_get_cidreq()."&type=1&fromExercise=$exerciseId\">"; |
|
1636 | 1636 | } else { |
1637 | - echo $url = '<a href="question_pool.php?' . api_get_cidreq() . '&fromExercise=' . $exerciseId . '">'; |
|
1637 | + echo $url = '<a href="question_pool.php?'.api_get_cidreq().'&fromExercise='.$exerciseId.'">'; |
|
1638 | 1638 | } |
1639 | 1639 | echo Display::return_icon('database.png', get_lang('GetExistingQuestion'), null, ICON_SIZE_BIG); |
1640 | 1640 | } |
@@ -1771,7 +1771,7 @@ discard block |
||
1771 | 1771 | $header .= $this->show_media_content(); |
1772 | 1772 | } |
1773 | 1773 | |
1774 | - $header .= Display::page_subheader2($counter_label . ". " . $question_title); |
|
1774 | + $header .= Display::page_subheader2($counter_label.". ".$question_title); |
|
1775 | 1775 | $header .= Display::div( |
1776 | 1776 | "<div class=\"rib rib-$class\"><h3>$score_label</h3></div> <h4>{$score['result']}</h4>", |
1777 | 1777 | array('class' => 'ribbon') |
@@ -1792,7 +1792,7 @@ discard block |
||
1792 | 1792 | public function create_question( |
1793 | 1793 | $quiz_id, |
1794 | 1794 | $question_name, |
1795 | - $question_description = "" , |
|
1795 | + $question_description = "", |
|
1796 | 1796 | $max_score = 0, |
1797 | 1797 | $type = 1, |
1798 | 1798 | $level = 1 |
@@ -1862,8 +1862,8 @@ discard block |
||
1862 | 1862 | require_once $tabQuestionList[$type][0]; |
1863 | 1863 | |
1864 | 1864 | $img = $explanation = null; |
1865 | - eval('$img = ' . $tabQuestionList[$type][1] . '::$typePicture;'); |
|
1866 | - eval('$explanation = get_lang(' . $tabQuestionList[$type][1] . '::$explanationLangVar);'); |
|
1865 | + eval('$img = '.$tabQuestionList[$type][1].'::$typePicture;'); |
|
1866 | + eval('$explanation = get_lang('.$tabQuestionList[$type][1].'::$explanationLangVar);'); |
|
1867 | 1867 | return array($img, $explanation); |
1868 | 1868 | } |
1869 | 1869 | |
@@ -1927,7 +1927,7 @@ discard block |
||
1927 | 1927 | $media_list[0] = get_lang('NoMedia'); |
1928 | 1928 | |
1929 | 1929 | if (!empty($medias)) { |
1930 | - foreach($medias as $media) { |
|
1930 | + foreach ($medias as $media) { |
|
1931 | 1931 | $media_list[$media['id']] = empty($media['question']) ? get_lang('Untitled') : $media['question']; |
1932 | 1932 | } |
1933 | 1933 | } |
@@ -98,10 +98,10 @@ |
||
98 | 98 | }*/ |
99 | 99 | } |
100 | 100 | |
101 | - // This is a good answer, count + 1 for nmbr of clicks |
|
102 | - if ($answers['weighting'][$i] > 0) { |
|
103 | - $nmbrTries++; |
|
104 | - } |
|
101 | + // This is a good answer, count + 1 for nmbr of clicks |
|
102 | + if ($answers['weighting'][$i] > 0) { |
|
103 | + $nmbrTries++; |
|
104 | + } |
|
105 | 105 | |
106 | 106 | $hotSpot['coord'] = $answers['hotspot_coordinates'][$i]; |
107 | 107 | $data['hotspots'][] = $hotSpot; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | api_protect_course_script(false); |
12 | 12 | |
13 | -$isAllowedToEdit = api_is_allowed_to_edit(null,true); |
|
13 | +$isAllowedToEdit = api_is_allowed_to_edit(null, true); |
|
14 | 14 | |
15 | 15 | if (!$isAllowedToEdit) { |
16 | 16 | api_not_allowed(true); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $objQuestion = Question::read($questionId); |
23 | 23 | $_course = api_get_course_info(); |
24 | 24 | |
25 | -$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
|
25 | +$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
|
26 | 26 | |
27 | 27 | $picturePath = $documentPath.'/images'; |
28 | 28 | $pictureName = $objQuestion->selectPicture(); |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | $answers = $_SESSION['tmp_answers']; |
66 | 66 | $nbrAnswers = count($answers['answer']); |
67 | 67 | |
68 | -for ($i=1;$i <= $nbrAnswers; $i++) { |
|
68 | +for ($i = 1; $i <= $nbrAnswers; $i++) { |
|
69 | 69 | $hotSpot = []; |
70 | 70 | $hotSpot['id'] = null; |
71 | - $hotSpot['answer']= $answers['answer'][$i]; |
|
71 | + $hotSpot['answer'] = $answers['answer'][$i]; |
|
72 | 72 | |
73 | 73 | if ($answer_type == HOT_SPOT_DELINEATION) { |
74 | - if ($i==1) { |
|
74 | + if ($i == 1) { |
|
75 | 75 | $hotSpot['type'] = 'delineation'; |
76 | 76 | } else { |
77 | 77 | $hotSpot['type'] = 'oar'; |
@@ -7,4 +7,4 @@ |
||
7 | 7 | // directly to exercise.php. This redirection is enabled for 1.10.x (2015-04-21) |
8 | 8 | // The final goal of this file is to be removed in a few years time, if |
9 | 9 | // considered realistically not harmful |
10 | -require __DIR__ . '/exercise.php'; |
|
10 | +require __DIR__.'/exercise.php'; |
@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | $show_headers = isset($_REQUEST['show_headers']) ? intval($_REQUEST['show_headers']) : null; //exe id |
18 | 18 | |
19 | 19 | if ($origin == 'learnpath') { |
20 | - $show_headers = false; |
|
20 | + $show_headers = false; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | api_protect_course_script($show_headers); |
24 | 24 | |
25 | 25 | if (empty($id)) { |
26 | - api_not_allowed($show_headers); |
|
26 | + api_not_allowed($show_headers); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | $is_allowedToEdit = api_is_allowed_to_edit(null,true) || $is_courseTutor; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | // Only users can see their own results |
50 | 50 | if (!$is_allowedToEdit) { |
51 | 51 | if ($student_id != $current_user_id) { |
52 | - api_not_allowed($show_headers); |
|
52 | + api_not_allowed($show_headers); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
@@ -62,19 +62,19 @@ discard block |
||
62 | 62 | "name" => get_lang('Exercises'), |
63 | 63 | ); |
64 | 64 | $interbreadcrumb[] = array("url" => "#", "name" => get_lang('Result')); |
65 | - $this_section = SECTION_COURSES; |
|
66 | - Display::display_header(); |
|
65 | + $this_section = SECTION_COURSES; |
|
66 | + Display::display_header(); |
|
67 | 67 | } else { |
68 | 68 | $htmlHeadXtra[] = " |
69 | 69 | <style> |
70 | 70 | body { background: none;} |
71 | 71 | </style> |
72 | 72 | "; |
73 | - Display::display_reduced_header(); |
|
73 | + Display::display_reduced_header(); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | ExerciseLib::display_question_list_by_attempt($objExercise, $id, false); |
77 | 77 | |
78 | 78 | if ($show_headers) { |
79 | - Display::display_footer(); |
|
79 | + Display::display_footer(); |
|
80 | 80 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | api_not_allowed($show_headers); |
27 | 27 | } |
28 | 28 | |
29 | -$is_allowedToEdit = api_is_allowed_to_edit(null,true) || $is_courseTutor; |
|
29 | +$is_allowedToEdit = api_is_allowed_to_edit(null, true) || $is_courseTutor; |
|
30 | 30 | |
31 | 31 | //Getting results from the exe_id. This variable also contain all the information about the exercise |
32 | 32 | $track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($id); |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | -$htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">'; |
|
57 | -$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>'; |
|
56 | +$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">'; |
|
57 | +$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>'; |
|
58 | 58 | |
59 | 59 | if ($show_headers) { |
60 | 60 | $interbreadcrumb[] = array( |
@@ -7,7 +7,7 @@ |
||
7 | 7 | get_lang('MultiplicationStar')."\n". |
8 | 8 | get_lang('DivisionSlash')."\n". |
9 | 9 | get_lang('ExponentiationCircumflex')."\n". |
10 | -get_lang('ModuloPercentage') . "\n" . |
|
10 | +get_lang('ModuloPercentage')."\n". |
|
11 | 11 | "\n". |
12 | 12 | get_lang('SquareRootSqrt')."\n". |
13 | 13 | get_lang('AbsoluteValueAbs')."\n". |
@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | } |
167 | 167 | |
168 | 168 | |
169 | - /** |
|
170 | - * abstract function which creates the form to create / edit the answers of the question |
|
171 | - * @param the formvalidator instance |
|
172 | - * @param the answers number to display |
|
173 | - */ |
|
174 | - function processAnswersCreation($form) |
|
169 | + /** |
|
170 | + * abstract function which creates the form to create / edit the answers of the question |
|
171 | + * @param the formvalidator instance |
|
172 | + * @param the answers number to display |
|
173 | + */ |
|
174 | + function processAnswersCreation($form) |
|
175 | 175 | { |
176 | 176 | $questionWeighting = $nbrGoodAnswers = 0; |
177 | 177 | $objAnswer = new Answer($this->id); |
@@ -201,12 +201,12 @@ discard block |
||
201 | 201 | // sets the total weighting of the question |
202 | 202 | $this->updateWeighting($questionWeighting); |
203 | 203 | $this->save(); |
204 | - } |
|
204 | + } |
|
205 | 205 | |
206 | - function return_header($feedback_type = null, $counter = null, $score = null) |
|
206 | + function return_header($feedback_type = null, $counter = null, $score = null) |
|
207 | 207 | { |
208 | - $header = parent::return_header($feedback_type, $counter, $score); |
|
209 | - $header .= '<table class="'.$this->question_table_class .'"> |
|
208 | + $header = parent::return_header($feedback_type, $counter, $score); |
|
209 | + $header .= '<table class="'.$this->question_table_class .'"> |
|
210 | 210 | <tr> |
211 | 211 | <th>'.get_lang("Choice").'</th> |
212 | 212 | <th>'. get_lang("ExpectedChoice").'</th> |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $header .= '<th>'.get_lang("Comment").'</th>'; |
215 | 215 | $header .= '</tr>'; |
216 | 216 | return $header; |
217 | - } |
|
217 | + } |
|
218 | 218 | |
219 | 219 | |
220 | 220 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | 'Height' => '125' |
39 | 39 | ); |
40 | 40 | |
41 | - $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 4; // The previous default value was 2. See task #1759. |
|
41 | + $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 4; // The previous default value was 2. See task #1759. |
|
42 | 42 | $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0)); |
43 | 43 | |
44 | 44 | $obj_ex = $_SESSION['objExercise']; |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | $html = '<table class="table table-striped table-hover"> |
49 | 49 | <thead> |
50 | 50 | <tr> |
51 | - <th width="10">' . get_lang('Number') . '</th> |
|
52 | - <th width="10">' . get_lang('True') . '</th> |
|
53 | - <th width="50%">' . get_lang('Answer') . '</th> |
|
54 | - <th width="50%">' . get_lang('Comment') . '</th> |
|
55 | - <th width="10">' . get_lang('Weighting') . '</th> |
|
51 | + <th width="10">' . get_lang('Number').'</th> |
|
52 | + <th width="10">' . get_lang('True').'</th> |
|
53 | + <th width="50%">' . get_lang('Answer').'</th> |
|
54 | + <th width="50%">' . get_lang('Comment').'</th> |
|
55 | + <th width="10">' . get_lang('Weighting').'</th> |
|
56 | 56 | </tr> |
57 | 57 | </thead> |
58 | 58 | <tbody>'; |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | $form->addHtml('<tr>'); |
83 | 83 | |
84 | 84 | if (is_object($answer)) { |
85 | - $defaults['answer[' . $i . ']'] = $answer->answer[$i]; |
|
86 | - $defaults['comment[' . $i . ']'] = $answer->comment[$i]; |
|
87 | - $defaults['weighting[' . $i . ']'] = float_format($answer->weighting[$i], 1); |
|
88 | - $defaults['correct[' . $i . ']'] = $answer->correct[$i]; |
|
85 | + $defaults['answer['.$i.']'] = $answer->answer[$i]; |
|
86 | + $defaults['comment['.$i.']'] = $answer->comment[$i]; |
|
87 | + $defaults['weighting['.$i.']'] = float_format($answer->weighting[$i], 1); |
|
88 | + $defaults['correct['.$i.']'] = $answer->correct[$i]; |
|
89 | 89 | } else { |
90 | 90 | $defaults['answer[1]'] = get_lang('DefaultMultipleAnswer2'); |
91 | 91 | $defaults['comment[1]'] = get_lang('DefaultMultipleComment2'); |
@@ -101,38 +101,38 @@ discard block |
||
101 | 101 | |
102 | 102 | $renderer->setElementTemplate( |
103 | 103 | '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', |
104 | - 'correct[' . $i . ']' |
|
104 | + 'correct['.$i.']' |
|
105 | 105 | ); |
106 | 106 | $renderer->setElementTemplate( |
107 | 107 | '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', |
108 | - 'counter[' . $i . ']' |
|
108 | + 'counter['.$i.']' |
|
109 | 109 | ); |
110 | 110 | $renderer->setElementTemplate( |
111 | 111 | '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', |
112 | - 'answer[' . $i . ']' |
|
112 | + 'answer['.$i.']' |
|
113 | 113 | ); |
114 | 114 | $renderer->setElementTemplate( |
115 | 115 | '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', |
116 | - 'comment[' . $i . ']' |
|
116 | + 'comment['.$i.']' |
|
117 | 117 | ); |
118 | 118 | $renderer->setElementTemplate( |
119 | 119 | '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', |
120 | - 'weighting[' . $i . ']' |
|
120 | + 'weighting['.$i.']' |
|
121 | 121 | ); |
122 | 122 | |
123 | - $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"'); |
|
123 | + $answer_number = $form->addElement('text', 'counter['.$i.']', null, 'value="'.$i.'"'); |
|
124 | 124 | $answer_number->freeze(); |
125 | 125 | |
126 | - $form->addElement('checkbox', 'correct[' . $i . ']', null, null, |
|
126 | + $form->addElement('checkbox', 'correct['.$i.']', null, null, |
|
127 | 127 | 'class="checkbox" style="margin-left: 0em;"'); |
128 | - $boxes_names[] = 'correct[' . $i . ']'; |
|
128 | + $boxes_names[] = 'correct['.$i.']'; |
|
129 | 129 | |
130 | 130 | $form->addHtmlEditor("answer[$i]", null, null, true, $editorConfig); |
131 | - $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required'); |
|
131 | + $form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required'); |
|
132 | 132 | |
133 | 133 | $form->addHtmlEditor("comment[$i]", null, null, true, $editorConfig); |
134 | 134 | |
135 | - $form->addElement('text', 'weighting[' . $i . ']', null, array('style' => "width: 60px;", 'value' => '0')); |
|
135 | + $form->addElement('text', 'weighting['.$i.']', null, array('style' => "width: 60px;", 'value' => '0')); |
|
136 | 136 | $form->addHtml('</tr>'); |
137 | 137 | } |
138 | 138 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $objAnswer = new Answer($this->id); |
178 | 178 | $nb_answers = $form->getSubmitValue('nb_answers'); |
179 | 179 | |
180 | - for($i=1 ; $i <= $nb_answers ; $i++) { |
|
180 | + for ($i = 1; $i <= $nb_answers; $i++) { |
|
181 | 181 | $answer = trim(str_replace(['<p>', '</p>'], '', $form -> getSubmitValue('answer['.$i.']'))); |
182 | 182 | $comment = trim(str_replace(['<p>', '</p>'], '', $form -> getSubmitValue('comment['.$i.']'))); |
183 | 183 | $weighting = trim($form -> getSubmitValue('weighting['.$i.']')); |
@@ -189,10 +189,10 @@ discard block |
||
189 | 189 | $weighting = abs($weighting); |
190 | 190 | $weighting = -$weighting; |
191 | 191 | } |
192 | - if($weighting > 0) { |
|
192 | + if ($weighting > 0) { |
|
193 | 193 | $questionWeighting += $weighting; |
194 | 194 | } |
195 | - $objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i); |
|
195 | + $objAnswer -> createAnswer($answer, $goodAnswer, $comment, $weighting, $i); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | // saves the answers into the data base |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | function return_header($feedback_type = null, $counter = null, $score = null) |
207 | 207 | { |
208 | 208 | $header = parent::return_header($feedback_type, $counter, $score); |
209 | - $header .= '<table class="'.$this->question_table_class .'"> |
|
209 | + $header .= '<table class="'.$this->question_table_class.'"> |
|
210 | 210 | <tr> |
211 | 211 | <th>'.get_lang("Choice").'</th> |
212 | 212 | <th>'. get_lang("ExpectedChoice").'</th> |
@@ -28,10 +28,10 @@ |
||
28 | 28 | $content = ReadFileCont($full_file_path.$user_id.'.t.html'); |
29 | 29 | |
30 | 30 | if ($content == '') { |
31 | - $content = ReadFileCont($full_file_path); |
|
31 | + $content = ReadFileCont($full_file_path); |
|
32 | 32 | // Do not move this like: |
33 | - $mit = "function Finish(){"; |
|
34 | - $js_content = " |
|
33 | + $mit = "function Finish(){"; |
|
34 | + $js_content = " |
|
35 | 35 | // Code added - start |
36 | 36 | var SaveScoreVariable = 0; |
37 | 37 | function mySaveScore() { |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | $time = time(); |
15 | 15 | $doc_url = str_replace(array('../', '\\', '\\0', '..'), array('', '', '', ''), urldecode($_GET['file'])); |
16 | 16 | $cid = api_get_course_id(); |
17 | -$document_path = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document'; |
|
18 | -$document_web_path = api_get_path(WEB_COURSE_PATH) . $_course['path'] . '/document'; |
|
17 | +$document_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
|
18 | +$document_web_path = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'; |
|
19 | 19 | $origin = isset($_REQUEST['origin']) ? $_REQUEST['origin'] : null; |
20 | 20 | $learnpath_id = isset($_REQUEST['learnpath_id']) ? $_REQUEST['learnpath_id'] : null; |
21 | 21 | $learnpath_item_id = isset($_REQUEST['learnpath_item_id']) ? $_REQUEST['learnpath_item_id'] : null; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $my_file = str_replace(array('../', '\\..', '\\0', '..\\'), array('', '', '', ''), urldecode($my_file)); |
70 | 70 | |
71 | 71 | $title = GetQuizName($my_file, $documentPath); |
72 | -if ($title =='') { |
|
72 | +if ($title == '') { |
|
73 | 73 | $title = basename($my_file); |
74 | 74 | } |
75 | 75 | $nameTools = $title; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | }); |
87 | 87 | </script>'; |
88 | 88 | |
89 | -$interbreadcrumb[]= array ("url"=>"./exercise.php", "name"=> get_lang('Exercises')); |
|
89 | +$interbreadcrumb[] = array("url"=>"./exercise.php", "name"=> get_lang('Exercises')); |
|
90 | 90 | if ($origin == 'learnpath') { |
91 | 91 | Display::display_reduced_header($nameTools, "Exercise"); |
92 | 92 | } else { |
@@ -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 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @param reference Reference to the array to search |
260 | 260 | * @param string Node we are looking for in the array |
261 | 261 | * @param string $node |
262 | - * @return mixed Node name or false if not found |
|
262 | + * @return false|string Node name or false if not found |
|
263 | 263 | */ |
264 | 264 | function myarraysearch(&$array, $node) |
265 | 265 | { |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * Searches an image name into an array. |
281 | 281 | * @param reference Reference to an array to search |
282 | 282 | * @param string String to look for |
283 | - * @return mixed String given if found, false otherwise |
|
283 | + * @return false|string String given if found, false otherwise |
|
284 | 284 | * @uses myarraysearch This function is just an additional layer on the myarraysearch() function |
285 | 285 | */ |
286 | 286 | function CheckImageName(&$imgparams, $string) |
@@ -47,13 +47,13 @@ discard block |
||
47 | 47 | use ChamiloSession as Session; |
48 | 48 | |
49 | 49 | require_once '../inc/global.inc.php'; |
50 | -$current_course_tool = TOOL_QUIZ; |
|
50 | +$current_course_tool = TOOL_QUIZ; |
|
51 | 51 | $this_section = SECTION_COURSES; |
52 | 52 | |
53 | 53 | // Access control |
54 | 54 | api_protect_course_script(true); |
55 | 55 | |
56 | -$is_allowedToEdit = api_is_allowed_to_edit(null,true); |
|
56 | +$is_allowedToEdit = api_is_allowed_to_edit(null, true); |
|
57 | 57 | $sessionId = api_get_session_id(); |
58 | 58 | |
59 | 59 | if (!$is_allowedToEdit) { |
@@ -61,21 +61,21 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | /* stripslashes POST data */ |
64 | -if($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
65 | - foreach($_POST as $key=>$val) { |
|
66 | - if(is_string($val)) { |
|
67 | - $_POST[$key]=stripslashes($val); |
|
68 | - } elseif(is_array($val)) { |
|
69 | - foreach($val as $key2=>$val2) { |
|
70 | - $_POST[$key][$key2]=stripslashes($val2); |
|
64 | +if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
65 | + foreach ($_POST as $key=>$val) { |
|
66 | + if (is_string($val)) { |
|
67 | + $_POST[$key] = stripslashes($val); |
|
68 | + } elseif (is_array($val)) { |
|
69 | + foreach ($val as $key2=>$val2) { |
|
70 | + $_POST[$key][$key2] = stripslashes($val2); |
|
71 | 71 | } |
72 | 72 | } |
73 | - $GLOBALS[$key]=$_POST[$key]; |
|
73 | + $GLOBALS[$key] = $_POST[$key]; |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | 77 | if (empty($exerciseId)) { |
78 | - $exerciseId = isset($_GET['exerciseId']) ? intval($_GET['exerciseId']):'0'; |
|
78 | + $exerciseId = isset($_GET['exerciseId']) ? intval($_GET['exerciseId']) : '0'; |
|
79 | 79 | } |
80 | 80 | if (empty($newQuestion)) { |
81 | 81 | $newQuestion = isset($_GET['newQuestion']) ? $_GET['newQuestion'] : 0; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $objQuestion = $objQuestion->swapSimpleAnswerTypes(); |
124 | 124 | $_SESSION['objQuestion'] = $objQuestion; |
125 | 125 | } |
126 | -$objAnswer = isset($_SESSION['objAnswer']) ? $_SESSION['objAnswer'] : null; |
|
126 | +$objAnswer = isset($_SESSION['objAnswer']) ? $_SESSION['objAnswer'] : null; |
|
127 | 127 | |
128 | 128 | // document path |
129 | 129 | $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | if (!empty($_GET['action']) && $_GET['action'] == 'exportqti2' && !empty($_GET['questionId'])) { |
149 | 149 | require_once 'export/qti2/qti2_export.php'; |
150 | 150 | $export = export_question_qti($_GET['questionId'], true); |
151 | - $qid = (int)$_GET['questionId']; |
|
151 | + $qid = (int) $_GET['questionId']; |
|
152 | 152 | $archive_path = api_get_path(SYS_ARCHIVE_PATH); |
153 | 153 | $temp_dir_short = uniqid(); |
154 | 154 | $temp_zip_dir = $archive_path."/".$temp_dir_short; |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | if (!$fromExercise) { |
195 | 195 | // gets the right exercise ID, and if 0 creates a new exercise |
196 | 196 | if (!$exerciseId = $objExercise->selectId()) { |
197 | - $modifyExercise='yes'; |
|
197 | + $modifyExercise = 'yes'; |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | exit(); |
245 | 245 | } else { |
246 | 246 | // goes back to the question viewing |
247 | - $editQuestion=$modifyQuestion; |
|
248 | - unset($newQuestion,$modifyQuestion); |
|
247 | + $editQuestion = $modifyQuestion; |
|
248 | + unset($newQuestion, $modifyQuestion); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | // if cancelling answer creation/modification |
273 | 273 | if ($cancelAnswers) { |
274 | 274 | // goes back to the question viewing |
275 | - $editQuestion=$modifyAnswers; |
|
275 | + $editQuestion = $modifyAnswers; |
|
276 | 276 | unset($modifyAnswers); |
277 | 277 | } |
278 | 278 | $nameTools = null; |
@@ -281,27 +281,27 @@ discard block |
||
281 | 281 | $nameTools = get_lang('QuestionManagement'); |
282 | 282 | } |
283 | 283 | |
284 | -if (isset($_SESSION['gradebook'])){ |
|
285 | - $gradebook= $_SESSION['gradebook']; |
|
284 | +if (isset($_SESSION['gradebook'])) { |
|
285 | + $gradebook = $_SESSION['gradebook']; |
|
286 | 286 | } |
287 | 287 | |
288 | -if (!empty($gradebook) && $gradebook=='view') { |
|
289 | - $interbreadcrumb[]= array( |
|
288 | +if (!empty($gradebook) && $gradebook == 'view') { |
|
289 | + $interbreadcrumb[] = array( |
|
290 | 290 | 'url' => '../gradebook/'.$_SESSION['gradebook_dest'], |
291 | 291 | 'name' => get_lang('ToolGradebook') |
292 | 292 | ); |
293 | 293 | } |
294 | 294 | |
295 | -$interbreadcrumb[] = array("url" => "exercise.php","name" => get_lang('Exercises')); |
|
296 | -if (isset($_GET['newQuestion']) || isset($_GET['editQuestion']) ) { |
|
295 | +$interbreadcrumb[] = array("url" => "exercise.php", "name" => get_lang('Exercises')); |
|
296 | +if (isset($_GET['newQuestion']) || isset($_GET['editQuestion'])) { |
|
297 | 297 | $interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$objExercise->id, "name" => $objExercise->name); |
298 | 298 | } else { |
299 | 299 | $interbreadcrumb[] = array("url" => "#", "name" => $objExercise->name); |
300 | 300 | } |
301 | 301 | |
302 | 302 | // shows a link to go back to the question pool |
303 | -if (!$exerciseId && $nameTools != get_lang('ExerciseManagement')){ |
|
304 | - $interbreadcrumb[]=array( |
|
303 | +if (!$exerciseId && $nameTools != get_lang('ExerciseManagement')) { |
|
304 | + $interbreadcrumb[] = array( |
|
305 | 305 | "url" => api_get_path(WEB_CODE_PATH)."exercice/question_pool.php?fromExercise=$fromExercise&".api_get_cidreq(), |
306 | 306 | "name" => get_lang('QuestionPool') |
307 | 307 | ); |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | |
310 | 310 | // if the question is duplicated, disable the link of tool name |
311 | 311 | if ($modifyIn == 'thisExercise') { |
312 | - if($buttonBack) { |
|
313 | - $modifyIn='allExercises'; |
|
312 | + if ($buttonBack) { |
|
313 | + $modifyIn = 'allExercises'; |
|
314 | 314 | } else { |
315 | - $noPHP_SELF=true; |
|
315 | + $noPHP_SELF = true; |
|
316 | 316 | } |
317 | 317 | } |
318 | 318 | $htmlHeadXtra[] = '<script> |
@@ -344,10 +344,10 @@ discard block |
||
344 | 344 | $htmlHeadXtra[] = $template->fetch('default/exercise/submit.js.tpl'); |
345 | 345 | $htmlHeadXtra[] = api_get_js('d3/jquery.xcolor.js'); |
346 | 346 | |
347 | -$htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">'; |
|
348 | -$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>'; |
|
347 | +$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">'; |
|
348 | +$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>'; |
|
349 | 349 | |
350 | -Display::display_header($nameTools,'Exercise'); |
|
350 | +Display::display_header($nameTools, 'Exercise'); |
|
351 | 351 | /* |
352 | 352 | if ($objExercise->exercise_was_added_in_lp) { |
353 | 353 | if ($objExercise->force_edit_exercise_in_lp == true) { |
@@ -364,22 +364,22 @@ discard block |
||
364 | 364 | echo '<div class="actions">'; |
365 | 365 | if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['myid'])) |
366 | 366 | echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/admin.php?exerciseId='.$exerciseId.'&'.api_get_cidReq().'">'. |
367 | - Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
367 | + Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
368 | 368 | |
369 | - if (!isset($_GET['hotspotadmin']) && !isset($_GET['newQuestion']) && !isset($_GET['myid']) && !isset($_GET['editQuestion'])) { |
|
369 | + if (!isset($_GET['hotspotadmin']) && !isset($_GET['newQuestion']) && !isset($_GET['myid']) && !isset($_GET['editQuestion'])) { |
|
370 | 370 | echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/exercise.php?'.api_get_cidReq().'">'. |
371 | - Display::return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
371 | + Display::return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
372 | 372 | } |
373 | 373 | echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/overview.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&preview=1">'. |
374 | - Display::return_icon('preview_view.png', get_lang('Preview'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
374 | + Display::return_icon('preview_view.png', get_lang('Preview'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
375 | 375 | |
376 | 376 | echo Display::url( |
377 | - Display::return_icon('test_results.png', get_lang('Results'),'',ICON_SIZE_MEDIUM), |
|
377 | + Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_MEDIUM), |
|
378 | 378 | api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidReq().'&exerciseId='.$objExercise->id |
379 | 379 | ); |
380 | 380 | |
381 | 381 | echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'. |
382 | - Display::return_icon('settings.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
382 | + Display::return_icon('settings.png', get_lang('ModifyExercise'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
383 | 383 | |
384 | 384 | $maxScoreAllQuestions = 0; |
385 | 385 | if (!empty($objExercise->questionList)) { |
@@ -397,13 +397,13 @@ discard block |
||
397 | 397 | // we are in create a new question from question pool not in a test |
398 | 398 | echo '<div class="actions">'; |
399 | 399 | echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/admin.php?'.api_get_cidreq().'">'. |
400 | - Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
400 | + Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
401 | 401 | echo '</div>'; |
402 | 402 | } else { |
403 | 403 | // If we are in question_pool but not in an test, go back to question create in pool |
404 | 404 | echo '<div class="actions">'; |
405 | 405 | echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/question_pool.php?'.api_get_cidreq().'">'. |
406 | - Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM). |
|
406 | + Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM). |
|
407 | 407 | '</a>'; |
408 | 408 | echo '</div>'; |
409 | 409 | } |
@@ -362,9 +362,10 @@ |
||
362 | 362 | |
363 | 363 | if ($inATest) { |
364 | 364 | echo '<div class="actions">'; |
365 | - if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['myid'])) |
|
366 | - echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/admin.php?exerciseId='.$exerciseId.'&'.api_get_cidreq().'">'. |
|
365 | + if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['myid'])) { |
|
366 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/admin.php?exerciseId='.$exerciseId.'&'.api_get_cidreq().'">'. |
|
367 | 367 | Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>'; |
368 | + } |
|
368 | 369 | |
369 | 370 | if (!isset($_GET['hotspotadmin']) && !isset($_GET['newQuestion']) && !isset($_GET['myid']) && !isset($_GET['editQuestion'])) { |
370 | 371 | echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/exercise.php?'.api_get_cidreq().'">'. |