diff --git a/main/coursecopy/classes/CourseBuilder.class.php b/main/coursecopy/classes/CourseBuilder.class.php index 9ad2f0a898..8f2e4ad988 100644 --- a/main/coursecopy/classes/CourseBuilder.class.php +++ b/main/coursecopy/classes/CourseBuilder.class.php @@ -480,13 +480,14 @@ class CourseBuilder { // Building normal tests. $sql = "SELECT * FROM $table_que WHERE c_id = $course_id "; + $db_result = Database::query($sql); while ($obj = Database::fetch_object($db_result)) { $categories = Testcategory::getCategoryForQuestionWithCategoryData($obj->iid, $course_id, true); $parent_info = array(); if (isset($obj->parent_id) && !empty($obj->parent_id)) { - $parent_info = (array) Question::read($obj->parent_id, $course_id); + $parent_info = (array)Question::read($obj->parent_id, $course_id); } $question = new QuizQuestion($obj->iid, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture, $obj->level, $obj->extra, $parent_info, $categories); diff --git a/main/coursecopy/classes/CourseRestorer.class.php b/main/coursecopy/classes/CourseRestorer.class.php index f01e837e1a..9e41b70a80 100644 --- a/main/coursecopy/classes/CourseRestorer.class.php +++ b/main/coursecopy/classes/CourseRestorer.class.php @@ -41,17 +41,17 @@ class CourseRestorer /** * The course-object */ - var $course; - var $destination_course_info; + public $course; + public $destination_course_info; /** * What to do with files with same name (FILE_SKIP, FILE_RENAME or * FILE_OVERWRITE) */ - var $file_option; - var $set_tools_invisible_by_default; - var $skip_content; - var $tools_to_restore = array( + public $file_option; + public $set_tools_invisible_by_default; + public $skip_content; + public $tools_to_restore = array( 'announcements', 'attendance', 'course_descriptions', @@ -72,18 +72,18 @@ class CourseRestorer ); /** Setting per tool */ - var $tool_copy_settings = array(); + public $tool_copy_settings = array(); /** * If true adds the text "copy" in the title of an item (only for LPs right now) * * */ - var $add_text_in_items = false; + public $add_text_in_items = false; /** * Create a new CourseRestorer */ - function __construct($course) + public function __construct($course) { $this->course = $course; $course_info = api_get_course_info($this->course->code); @@ -1576,7 +1576,7 @@ class CourseRestorer $parent_id = 0; - if (isset($question->parent_info)) { + if (isset($question->parent_info) && !empty($question->parent_info)) { $question_obj = Question::readByTitle($question->parent_info['question'], $this->destination_course_id); if ($question_obj) { diff --git a/main/coursecopy/classes/CourseSelectForm.class.php b/main/coursecopy/classes/CourseSelectForm.class.php index 41ae44d307..66d24adff7 100644 --- a/main/coursecopy/classes/CourseSelectForm.class.php +++ b/main/coursecopy/classes/CourseSelectForm.class.php @@ -360,7 +360,7 @@ class CourseSelectForm //Create the resource DOCUMENT objects //Loading the results from the checkboxes of ethe javascript - $resource = $_POST['resource'][RESOURCE_DOCUMENT]; + $resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null; $course_info = api_get_course_info($course_code); $table_doc = Database::get_course_table(TABLE_DOCUMENT); @@ -471,9 +471,9 @@ class CourseSelectForm // Mark folders to import which are not selected by the user to import, // but in which a document was selected. $documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null; - if (is_array($resources)) + if (!empty($resources) && is_array($resources)) foreach($resources as $id => $obj) { - if ($obj->file_type == 'folder' && ! isset($_POST['resource'][RESOURCE_DOCUMENT][$id]) && is_array($documents)) { + if (isset($obj->file_type) && $obj->file_type == 'folder' && !isset($_POST['resource'][RESOURCE_DOCUMENT][$id]) && is_array($documents)) { foreach($documents as $id_to_check => $post_value) { $obj_to_check = $resources[$id_to_check]; $shared_path_part = substr($obj_to_check->path,0,strlen($obj->path)); @@ -485,8 +485,8 @@ class CourseSelectForm } } default : - if (is_array($resources)) { - foreach ($resources as $id => $obj) { + if (!empty($resources) && is_array($resources)) { + foreach($resources as $id => $obj) { $resource_is_used_elsewhere = $course->is_linked_resource($obj); //var_dump($obj, $resource_is_used_elsewhere); // check if document is in a quiz (audio/video) diff --git a/main/coursecopy/classes/Quiz.class.php b/main/coursecopy/classes/Quiz.class.php index 2413c4a29a..0da23340bd 100644 --- a/main/coursecopy/classes/Quiz.class.php +++ b/main/coursecopy/classes/Quiz.class.php @@ -27,7 +27,8 @@ class Quiz extends Resource */ public $obj; //question - function Quiz($obj) { + function Quiz($obj) + { $this->obj = $obj; $this->obj->quiz_type = $this->obj->type; parent::Resource($obj->iid, RESOURCE_QUIZ); @@ -36,7 +37,8 @@ class Quiz extends Resource /** * Add a question to this Quiz */ - function add_question($id, $question_order) { + function add_question($id, $question_order) + { $this->obj->question_ids[] = $id; $this->obj->question_orders[] = $question_order; } @@ -44,7 +46,8 @@ class Quiz extends Resource /** * Show this question */ - function show() { + function show() + { parent::show(); echo $this->obj->title; } diff --git a/main/coursecopy/classes/QuizQuestion.class.php b/main/coursecopy/classes/QuizQuestion.class.php index 5483ec0d45..6ae81c23cf 100644 --- a/main/coursecopy/classes/QuizQuestion.class.php +++ b/main/coursecopy/classes/QuizQuestion.class.php @@ -59,6 +59,7 @@ class QuizQuestion extends Resource public $picture; public $extra; public $categories; + public $parent_info; /** * Create a new QuizQuestion @@ -68,7 +69,8 @@ class QuizQuestion extends Resource * @param int $type * @param int $position */ - function QuizQuestion($id, $question, $description, $ponderation, $type, $position, $picture, $level, $extra, $parent_info, $categories) { + function QuizQuestion($id, $question, $description, $ponderation, $type, $position, $picture, $level, $extra, $parent_info, $categories) + { parent::Resource($id, RESOURCE_QUIZQUESTION); $this->question = $question; $this->description = $description; @@ -86,7 +88,8 @@ class QuizQuestion extends Resource /** * Add an answer to this QuizQuestion */ - function add_answer($answer_id, $answer_text, $correct, $comment, $ponderation, $position, $hotspot_coordinates, $hotspot_type) { + function add_answer($answer_id, $answer_text, $correct, $comment, $ponderation, $position, $hotspot_coordinates, $hotspot_type) + { $answer = array(); $answer['iid'] = $answer_id; $answer['answer'] = $answer_text; diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 0f5aaae176..3ebe045cd7 100644 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -4589,6 +4589,7 @@ class Exercise { $media_questions = array(); $question_list = $this->get_validated_question_list(); + if (!empty($question_list)) { foreach ($question_list as $questionId) { $objQuestionTmp = Question::read($questionId); diff --git a/main/exercice/exercise_submit.php b/main/exercice/exercise_submit.php index bfeefe7552..d8a96e6810 100644 --- a/main/exercice/exercise_submit.php +++ b/main/exercice/exercise_submit.php @@ -378,7 +378,6 @@ if (api_is_allowed_to_edit(null,true) && isset($_GET['preview']) && $_GET['previ } // 1. Loading the $objExercise variable - if (!isset($_SESSION['objExercise']) || $_SESSION['objExercise']->id != $_REQUEST['exerciseId']) { // Construction of Exercise $objExercise = new Exercise(); @@ -873,7 +872,6 @@ if ($objExercise->type == ONE_PER_PAGE) { $exercise_result = get_answered_questions_from_attempt($exe_id, $objExercise); $conditions = array(); $conditions[] = array("class" => 'remind', 'items' => $my_remind_list); - //$conditions[] = array("class" => 'not_answered', 'items' => $exercise_result, 'type' => 'negative'); $conditions[] = array("class" => 'answered', 'items' => $exercise_result); $link = api_get_self().'?'.$params.'&num='; echo Display::progress_pagination_bar($questionList, $current_question, $conditions, $link); @@ -1017,8 +1015,8 @@ if ($objExercise->review_answers) { if (!empty($error)) { Display :: display_error_message($error, false); } else { - if (!empty ($exercise_sound)) { - echo "", ", get_lang('Sound') . "; + if (!empty($exercise_sound)) { + echo "", ", get_lang('Sound') . "; } // Get number of hotspot questions for javascript validation $number_of_hotspot_questions = 0; diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 9572f5f39c..a1efd0356e 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -2047,7 +2047,7 @@ class DocumentManager $checked_files_list = array(); $checked_array_list = array(); - if (count($files_list) > 0) { + if (!empty($files_list) && count($files_list) > 0) { foreach ($files_list as $idx => $file) { if (!empty($file[0])) { if (!in_array($file[0], $checked_files_list)) {