From 67a5aa7cfe9bdf68eb4331ca3631ae63b3fe8664 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 29 Mar 2017 09:10:57 +0200 Subject: [PATCH] Minor - Format code, remove unused $form->addGroup --- main/exercise/admin.php | 99 ++++++++++++++-------------- main/exercise/matching.class.php | 10 +-- main/exercise/question_admin.inc.php | 14 ++-- 3 files changed, 57 insertions(+), 66 deletions(-) diff --git a/main/exercise/admin.php b/main/exercise/admin.php index 3d381e0f55..36bb373932 100755 --- a/main/exercise/admin.php +++ b/main/exercise/admin.php @@ -4,46 +4,46 @@ use ChamiloSession as Session; /** - * Exercise administration - * This script allows to manage (create, modify) an exercise and its questions + * Exercise administration + * This script allows to manage (create, modify) an exercise and its questions * - * Following scripts are includes for a best code understanding : + * Following scripts are includes for a best code understanding : * - * - exercise.class.php : for the creation of an Exercise object - * - question.class.php : for the creation of a Question object - * - answer.class.php : for the creation of an Answer object - * - exercise.lib.php : functions used in the exercise tool - * - exercise_admin.inc.php : management of the exercise - * - question_admin.inc.php : management of a question (statement & answers) - * - statement_admin.inc.php : management of a statement - * - question_list_admin.inc.php : management of the question list + * - exercise.class.php : for the creation of an Exercise object + * - question.class.php : for the creation of a Question object + * - answer.class.php : for the creation of an Answer object + * - exercise.lib.php : functions used in the exercise tool + * - exercise_admin.inc.php : management of the exercise + * - question_admin.inc.php : management of a question (statement & answers) + * - statement_admin.inc.php : management of a statement + * - question_list_admin.inc.php : management of the question list * - * Main variables used in this script : + * Main variables used in this script : * - * - $is_allowedToEdit : set to 1 if the user is allowed to manage the exercise - * - $objExercise : exercise object - * - $objQuestion : question object - * - $objAnswer : answer object - * - $aType : array with answer types - * - $exerciseId : the exercise ID - * - $picturePath : the path of question pictures - * - $newQuestion : ask to create a new question - * - $modifyQuestion : ID of the question to modify - * - $editQuestion : ID of the question to edit - * - $submitQuestion : ask to save question modifications - * - $cancelQuestion : ask to cancel question modifications - * - $deleteQuestion : ID of the question to delete - * - $moveUp : ID of the question to move up - * - $moveDown : ID of the question to move down - * - $modifyExercise : ID of the exercise to modify - * - $submitExercise : ask to save exercise modifications - * - $cancelExercise : ask to cancel exercise modifications - * - $modifyAnswers : ID of the question which we want to modify answers for - * - $cancelAnswers : ask to cancel answer modifications - * - $buttonBack : ask to go back to the previous page in answers of type "Fill in blanks" + * - $is_allowedToEdit : set to 1 if the user is allowed to manage the exercise + * - $objExercise : exercise object + * - $objQuestion : question object + * - $objAnswer : answer object + * - $aType : array with answer types + * - $exerciseId : the exercise ID + * - $picturePath : the path of question pictures + * - $newQuestion : ask to create a new question + * - $modifyQuestion : ID of the question to modify + * - $editQuestion : ID of the question to edit + * - $submitQuestion : ask to save question modifications + * - $cancelQuestion : ask to cancel question modifications + * - $deleteQuestion : ID of the question to delete + * - $moveUp : ID of the question to move up + * - $moveDown : ID of the question to move down + * - $modifyExercise : ID of the exercise to modify + * - $submitExercise : ask to save exercise modifications + * - $cancelExercise : ask to cancel exercise modifications + * - $modifyAnswers : ID of the question which we want to modify answers for + * - $cancelAnswers : ask to cancel answer modifications + * - $buttonBack : ask to go back to the previous page in answers of type "Fill in blanks" * - * @package chamilo.exercise - * @author Olivier Brouckaert + * @package chamilo.exercise + * @author Olivier Brouckaert * Modified by Hubert Borderiou 21-10-2011 Question by category */ @@ -56,7 +56,6 @@ api_protect_course_script(true); $is_allowedToEdit = api_is_allowed_to_edit(null, true, false, false); $sessionId = api_get_session_id(); - $studentViewActive = api_is_student_view_active(); if (!$is_allowedToEdit) { api_not_allowed(true); @@ -64,15 +63,15 @@ if (!$is_allowedToEdit) { /* stripslashes POST data */ if ($_SERVER['REQUEST_METHOD'] == 'POST') { - foreach($_POST as $key=>$val) { - if(is_string($val)) { - $_POST[$key]=stripslashes($val); - } elseif(is_array($val)) { - foreach($val as $key2=>$val2) { - $_POST[$key][$key2]=stripslashes($val2); + foreach ($_POST as $key => $val) { + if (is_string($val)) { + $_POST[$key] = stripslashes($val); + } elseif (is_array($val)) { + foreach ($val as $key2 => $val2) { + $_POST[$key][$key2] = stripslashes($val2); } } - $GLOBALS[$key]=$_POST[$key]; + $GLOBALS[$key] = $_POST[$key]; } } @@ -110,7 +109,6 @@ $cancelQuestion = isset($cancelQuestion) ? $cancelQuestion : null; /* Cleaning all incomplete attempts of the admin/teacher to avoid weird problems when changing the exercise settings, number of questions, etc */ - Event::delete_all_incomplete_attempts( api_get_user_id(), $exerciseId, @@ -281,8 +279,8 @@ if ($editQuestion || $modifyQuestion || $newQuestion || $modifyAnswers) { $nameTools = get_lang('QuestionManagement'); } -if (isset($_SESSION['gradebook'])){ - $gradebook= $_SESSION['gradebook']; +if (isset($_SESSION['gradebook'])) { + $gradebook = $_SESSION['gradebook']; } if (!empty($gradebook) && $gradebook=='view') { @@ -309,10 +307,10 @@ if (!$exerciseId && $nameTools != get_lang('ExerciseManagement')) { // if the question is duplicated, disable the link of tool name if ($modifyIn == 'thisExercise') { - if ($buttonBack) { - $modifyIn='allExercises'; + if ($buttonBack) { + $modifyIn = 'allExercises'; } else { - $noPHP_SELF=true; + $noPHP_SELF = true; } } $htmlHeadXtra[] = ''; -Display::display_header($nameTools,'Exercise'); +Display::display_header($nameTools, 'Exercise'); /* if ($objExercise->exercise_was_added_in_lp) { if ($objExercise->force_edit_exercise_in_lp == true) { diff --git a/main/exercise/matching.class.php b/main/exercise/matching.class.php index 088e07df5e..db6be626a9 100755 --- a/main/exercise/matching.class.php +++ b/main/exercise/matching.class.php @@ -143,27 +143,22 @@ class Matching extends Question $form->addHtml(''); $form->addHtml("$i"); $form->addText("answer[$i]", null); - $form->addSelect( "matches[$i]", null, $matches, ['id' => 'matches_'.$i] ); - $form->addText( "weighting[$i]", null, true, ['id' => 'weighting_'.$i, 'value' => 10] ); - $form->addHtml(''); } $form->addHtml(''); - $group = array(); - $form->addGroup($group); // DISPLAY OPTIONS $html = ' @@ -198,14 +193,13 @@ class Matching extends Question } $form->addHtml('
'); - $group = array(); - global $text; + global $text; + $group = array(); // setting the save button here and not in the question class.php $group[] = $form->addButtonDelete(get_lang('DelElem'), 'lessOptions', true); $group[] = $form->addButtonCreate(get_lang('AddElem'), 'moreOptions', true); $group[] = $form->addButtonSave($text, 'submitQuestion', true); - $form->addGroup($group); if (!empty($this->id)) { diff --git a/main/exercise/question_admin.inc.php b/main/exercise/question_admin.inc.php index 30e5f26f1f..2b70444d25 100755 --- a/main/exercise/question_admin.inc.php +++ b/main/exercise/question_admin.inc.php @@ -2,11 +2,11 @@ /* For licensing terms, see /license.txt */ /** - * This script allows to manage the statements of questions. - * It is included from the script admin.php - * @package chamilo.exercise - * @author Olivier Brouckaert - * @version $Id: question_admin.inc.php 22126 2009-07-15 22:38:39Z juliomontoya $ + * This script allows to manage the statements of questions. + * It is included from the script admin.php + * @package chamilo.exercise + * @author Olivier Brouckaert + * @version $Id: question_admin.inc.php 22126 2009-07-15 22:38:39Z juliomontoya $ */ if (isset($_GET['editQuestion'])) { @@ -49,10 +49,10 @@ if (is_object($objQuestion)) { // FORM VALIDATION if (isset($_POST['submitQuestion']) && $form->validate()) { - // question + // Question $objQuestion->processCreation($form, $objExercise); - // answers + // Answers $nb_answers = isset($nb_answers) ? $nb_answers : 0; $objQuestion->processAnswersCreation($form, $nb_answers);