From a9399351b74aca9aab0b366bb5bcde07e103bb4a Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 3 Jul 2015 13:50:18 +0200 Subject: [PATCH] Minor - format code + use addFlash to show messages. --- main/exercice/exercise.class.php | 14 ++++++++++---- main/exercice/exercise_admin.php | 6 +++--- main/newscorm/learnpath.class.php | 31 +++++++++++++++++-------------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 9743ca5df3..59a34d9525 100755 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -4423,7 +4423,12 @@ class Exercise } // Checking visibility in the item_property table. - $visibility = api_get_item_visibility(api_get_course_info(), TOOL_QUIZ, $this->id, api_get_session_id()); + $visibility = api_get_item_visibility( + api_get_course_info(), + TOOL_QUIZ, + $this->id, + api_get_session_id() + ); if ($visibility == 0 || $visibility == 2) { $this->active = 0; @@ -4431,7 +4436,7 @@ class Exercise // 2. If the exercise is not active. if (empty($lp_id)) { - //2.1 LP is OFF + // 2.1 LP is OFF if ($this->active == 0) { return array( 'value' => false, @@ -4439,8 +4444,8 @@ class Exercise ); } } else { - //2.1 LP is loaded - if ($this->active == 0 AND !learnpath::is_lp_visible_for_student($lp_id, api_get_user_id())) { + // 2.1 LP is loaded + if ($this->active == 0 && !learnpath::is_lp_visible_for_student($lp_id, api_get_user_id())) { return array( 'value' => false, 'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false) @@ -4454,6 +4459,7 @@ class Exercise (!empty($this->end_time) && $this->end_time != '0000-00-00 00:00:00') ) ? true : false; + if ($limit_time_exists) { $time_now = time(); diff --git a/main/exercice/exercise_admin.php b/main/exercice/exercise_admin.php index a277fa79ee..4df70189d2 100755 --- a/main/exercice/exercise_admin.php +++ b/main/exercice/exercise_admin.php @@ -113,13 +113,13 @@ $objExercise->createForm($form); if ($form->validate()) { $objExercise->processCreation($form); if ($form->getSubmitValue('edit') == 'true') { - $message = 'ExerciseEdited'; + Display::addFlash(Display::return_message(get_lang('ExerciseEdited'))); } else { - $message = 'ExerciseAdded'; + Display::addFlash(Display::return_message(get_lang('ExerciseAdded'))); } $exercise_id = $objExercise->id; Session::erase('objExercise'); - header('Location:admin.php?message='.$message.'&exerciseId='.$exercise_id); + header('Location:admin.php?&exerciseId='.$exercise_id.'&'.api_get_cidreq()); exit; } else { // DISPLAY FORM diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index 046f218b64..15fcb1250b 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -499,14 +499,14 @@ class learnpath if (empty($max_time_allowed)) { $max_time_allowed = 0; } - $sql_count = " SELECT COUNT(id) AS num - FROM $tbl_lp_item - WHERE - c_id = $course_id AND - lp_id = " . $this->get_id() . " AND - parent_item_id = " . $parent; + $sql = "SELECT COUNT(id) AS num + FROM $tbl_lp_item + WHERE + c_id = $course_id AND + lp_id = " . $this->get_id() . " AND + parent_item_id = " . $parent; - $res_count = Database::query($sql_count); + $res_count = Database::query($sql); $row = Database :: fetch_array($res_count); $num = $row['num']; @@ -554,14 +554,17 @@ class learnpath $sql = 'SELECT SUM(ponderation) FROM ' . Database :: get_course_table(TABLE_QUIZ_QUESTION) . ' as quiz_question INNER JOIN ' . Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION) . ' as quiz_rel_question - ON quiz_question.id = quiz_rel_question.question_id - WHERE quiz_rel_question.exercice_id = '.$id." AND - quiz_question.c_id = $course_id AND - quiz_rel_question.c_id = $course_id "; + ON + quiz_question.id = quiz_rel_question.question_id AND + quiz_question.c_id = quiz_rel_question.c_id + WHERE + quiz_rel_question.exercice_id = '.$id." AND + quiz_question.c_id = $course_id AND + quiz_rel_question.c_id = $course_id "; $rsQuiz = Database::query($sql); $max_score = Database :: result($rsQuiz, 0, 0); - //Disabling the exercise if we add it inside a LP + // Disabling the exercise if we add it inside a LP $exercise = new Exercise(); $exercise->read($id); $exercise->disable(); @@ -2281,8 +2284,9 @@ class learnpath $rs = Database::query($sql); $now = time(); - if (Database::num_rows($rs)>0) { + if (Database::num_rows($rs) > 0) { $row = Database::fetch_array($rs, 'ASSOC'); + $prerequisite = $row['prerequisite']; $is_visible = true; @@ -2332,7 +2336,6 @@ class learnpath // Check if the subscription users/group to a LP is ON if (isset($row['subscribe_users']) && $row['subscribe_users'] == 1) { - // Try group $is_visible = false;