Browse Source

Minor - format code.

jmontoyaa 7 years ago
parent
commit
ff0048170d

+ 89 - 15
main/exercise/TestCategory.php

@@ -374,7 +374,10 @@ class TestCategory
     public static function getListOfCategoriesNameForTest($exercise_id, $grouped_by_category = true)
     {
         $result = array();
-        $categories = self::getListOfCategoriesIDForTest($exercise_id, $grouped_by_category);
+        $categories = self::getListOfCategoriesIDForTest(
+            $exercise_id,
+            $grouped_by_category
+        );
 
         foreach ($categories as $catInfo) {
             $categoryId = $catInfo['id'];
@@ -461,7 +464,10 @@ class TestCategory
                 continue;
             }
 
-            $nbQuestionInThisCat = self::getNumberOfQuestionsInCategoryForTest($exerciseId, $category['id']);
+            $nbQuestionInThisCat = self::getNumberOfQuestionsInCategoryForTest(
+                $exerciseId,
+                $category['id']
+            );
 
             if ($nbQuestionInThisCat > $in_nbrandom) {
                 $count += $in_nbrandom;
@@ -604,11 +610,11 @@ class TestCategory
 
     /**
      * @param int $questionId
-     * @param int $in_display_category_name
+     * @param int $displayCategoryName
      */
-    public static function displayCategoryAndTitle($questionId, $in_display_category_name = 1)
+    public static function displayCategoryAndTitle($questionId, $displayCategoryName = 1)
     {
-        echo self::returnCategoryAndTitle($questionId, $in_display_category_name);
+        echo self::returnCategoryAndTitle($questionId, $displayCategoryName);
     }
 
     /**
@@ -727,7 +733,10 @@ class TestCategory
                 continue;
             }
 
-            $nbQuestionInThisCat = self::getNumberOfQuestionsInCategoryForTest($exerciseId, $category['id']);
+            $nbQuestionInThisCat = self::getNumberOfQuestionsInCategoryForTest(
+                $exerciseId,
+                $category['id']
+            );
 
             if ($nbQuestionInThisCat > $res_num_max) {
                 $res_num_max = $nbQuestionInThisCat;
@@ -740,7 +749,8 @@ class TestCategory
     /**
      * Returns a category summary report
      * @params int $exerciseId
-     * @params array pre filled array with the category_id, score, and weight
+     * @params array $category_list
+     * pre filled array with the category_id, score, and weight
      * example: array(1 => array('score' => '10', 'total' => 20));
      *
      * @return string
@@ -774,21 +784,75 @@ class TestCategory
         if (count($category_list) > 1) {
             foreach ($category_list as $category_id => $category_item) {
                 $table->setCellContents($row, 0, $category_name_list[$category_id]);
-                $table->setCellContents($row, 1, ExerciseLib::show_score($category_item['score'], $category_item['total'], false));
-                $table->setCellContents($row, 2, ExerciseLib::show_score($category_item['score'], $category_item['total'], true, false, true));
+                $table->setCellContents(
+                    $row,
+                    1,
+                    ExerciseLib::show_score(
+                        $category_item['score'],
+                        $category_item['total'],
+                        false
+                    )
+                );
+                $table->setCellContents(
+                    $row,
+                    2,
+                    ExerciseLib::show_score(
+                        $category_item['score'],
+                        $category_item['total'],
+                        true,
+                        false,
+                        true
+                    )
+                );
                 $row++;
             }
 
             if (!empty($none_category)) {
                 $table->setCellContents($row, 0, get_lang('None'));
-                $table->setCellContents($row, 1, ExerciseLib::show_score($none_category['score'], $none_category['total'], false));
-                $table->setCellContents($row, 2, ExerciseLib::show_score($none_category['score'], $none_category['total'], true, false, true));
+                $table->setCellContents(
+                    $row,
+                    1,
+                    ExerciseLib::show_score(
+                        $none_category['score'],
+                        $none_category['total'],
+                        false
+                    )
+                );
+                $table->setCellContents(
+                    $row,
+                    2,
+                    ExerciseLib::show_score(
+                        $none_category['score'],
+                        $none_category['total'],
+                        true,
+                        false,
+                        true
+                    )
+                );
                 $row++;
             }
             if (!empty($total)) {
                 $table->setCellContents($row, 0, get_lang('Total'));
-                $table->setCellContents($row, 1, ExerciseLib::show_score($total['score'], $total['total'], false));
-                $table->setCellContents($row, 2, ExerciseLib::show_score($total['score'], $total['total'], true, false, true));
+                $table->setCellContents(
+                    $row,
+                    1,
+                    ExerciseLib::show_score(
+                        $total['score'],
+                        $total['total'],
+                        false
+                    )
+                );
+                $table->setCellContents(
+                    $row,
+                    2,
+                    ExerciseLib::show_score(
+                        $total['score'],
+                        $total['total'],
+                        true,
+                        false,
+                        true
+                    )
+                );
             }
             return $table->toHtml();
         }
@@ -887,7 +951,12 @@ class TestCategory
         // Setting the form elements
         $form->addElement('header', $header);
         $form->addElement('hidden', 'category_id');
-        $form->addElement('text', 'category_name', get_lang('CategoryName'), array('class' => 'span6'));
+        $form->addElement(
+            'text',
+            'category_name',
+            get_lang('CategoryName'),
+            array('class' => 'span6')
+        );
         $form->add_html_editor(
             'category_description',
             get_lang('CategoryDescription'),
@@ -905,7 +974,12 @@ class TestCategory
                 '1' => get_lang('Visible'),
                 '0' => get_lang('Hidden')
         );
-        $form->addElement('select', 'visibility', get_lang('Visibility'), $options);
+        $form->addElement(
+            'select',
+            'visibility',
+            get_lang('Visibility'),
+            $options
+        );
         $script = null;
         if (!empty($this->parent_id)) {
             $parent_cat = new TestCategory();

+ 2 - 1
main/exercise/UniqueAnswerImage.php

@@ -96,7 +96,8 @@ class UniqueAnswerImage extends UniqueAnswer
 
                 $question = Question::read($questionid);
                 $selectQuestion[$questionid] = 'Q'.$key.' :'.cut(
-                    $question->selectTitle(), 20
+                    $question->selectTitle(),
+                    20
                 );
             }
         }

+ 37 - 13
main/exercise/question.class.php

@@ -479,14 +479,14 @@ abstract class Question
     {
         if (!empty($category_list)) {
             $this->deleteCategory();
-            $TBL_QUESTION_REL_CATEGORY = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
+            $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
 
             // update or add category for a question
             foreach ($category_list as $category_id) {
                 $category_id = intval($category_id);
                 $question_id = intval($this->id);
                 $sql = "SELECT count(*) AS nb
-                        FROM $TBL_QUESTION_REL_CATEGORY
+                        FROM $table
                         WHERE
                             category_id = $category_id
                             AND question_id = $question_id
@@ -496,7 +496,7 @@ abstract class Question
                 if ($row['nb'] > 0) {
                     // DO nothing
                 } else {
-                    $sql = "INSERT INTO $TBL_QUESTION_REL_CATEGORY (c_id, question_id, category_id)
+                    $sql = "INSERT INTO $table (c_id, question_id, category_id)
                             VALUES (".api_get_course_int_id().", $question_id, $category_id)";
                     Database::query($sql);
                 }
@@ -1346,7 +1346,8 @@ abstract class Question
         // if the question must be removed from all exercises
         if (!$deleteFromEx) {
             //update the question_order of each question to avoid inconsistencies
-            $sql = "SELECT exercice_id, question_order FROM $TBL_EXERCISE_QUESTION
+            $sql = "SELECT exercice_id, question_order 
+                    FROM $TBL_EXERCISE_QUESTION
                     WHERE c_id = $course_id AND question_id = ".intval($id)."";
 
             $res = Database::query($sql);
@@ -1356,9 +1357,9 @@ abstract class Question
                         $sql = "UPDATE $TBL_EXERCISE_QUESTION
                                 SET question_order = question_order-1
                                 WHERE
-                                    c_id= $course_id
-                                    AND exercice_id = ".intval($row['exercice_id'])."
-                                    AND question_order > " . $row['question_order'];
+                                    c_id = $course_id AND 
+                                    exercice_id = ".intval($row['exercice_id'])." AND 
+                                    question_order > " . $row['question_order'];
                         Database::query($sql);
                     }
                 }
@@ -1619,11 +1620,21 @@ abstract class Question
         if ($this->type != MEDIA_QUESTION) {
             // Advanced parameters
             $select_level = self::get_default_levels();
-            $form->addElement('select', 'questionLevel', get_lang('Difficulty'), $select_level);
+            $form->addElement(
+                'select',
+                'questionLevel',
+                get_lang('Difficulty'),
+                $select_level
+            );
 
             // Categories
             $tabCat = TestCategory::getCategoriesIdAndName();
-            $form->addElement('select', 'questionCategory', get_lang('Category'), $tabCat);
+            $form->addElement(
+                'select',
+                'questionCategory',
+                get_lang('Category'),
+                $tabCat
+            );
 
             global $text;
 
@@ -1821,14 +1832,24 @@ abstract class Question
         echo '<li>';
         echo '<div class="icon_image_content">';
         if ($objExercise->exercise_was_added_in_lp == true) {
-            echo Display::return_icon('database_na.png', get_lang('GetExistingQuestion'), null, ICON_SIZE_BIG);
+            echo Display::return_icon(
+                'database_na.png',
+                get_lang('GetExistingQuestion'),
+                null,
+                ICON_SIZE_BIG
+            );
         } else {
             if ($feedback_type == 1) {
                 echo $url = "<a href=\"question_pool.php?".api_get_cidreq()."&type=1&fromExercise=$exerciseId\">";
             } else {
                 echo $url = '<a href="question_pool.php?'.api_get_cidreq().'&fromExercise='.$exerciseId.'">';
             }
-            echo Display::return_icon('database.png', get_lang('GetExistingQuestion'), null, ICON_SIZE_BIG);
+            echo Display::return_icon(
+                'database.png',
+                get_lang('GetExistingQuestion'),
+                null,
+                ICON_SIZE_BIG
+            );
         }
         echo '</a>';
         echo '</div></li>';
@@ -1900,7 +1921,7 @@ abstract class Question
      * @param int $course_id
      * @return array
      */
-    static function readQuestionOption($question_id, $course_id)
+    public static function readQuestionOption($question_id, $course_id)
     {
         $table = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION);
         $result = Database::select(
@@ -1974,7 +1995,10 @@ abstract class Question
         $header .= ExerciseLib::getQuestionRibbon($class, $score_label, $score['result']);
         if ($this->type != READING_COMPREHENSION) {
             // Do not show the description (the text to read) if the question is of type READING_COMPREHENSION
-            $header .= Display::div($this->description, array('class' => 'question_description'));
+            $header .= Display::div(
+                $this->description,
+                array('class' => 'question_description')
+            );
         } else {
             if ($score['pass'] == true) {
                 $message = Display::div(

+ 34 - 5
main/exercise/question_pool.php

@@ -699,11 +699,40 @@ if ($fromExercise <= 0) {
 }
 // Display table
 $header = array(
-    array(get_lang('QuestionUpperCaseFirstLetter'), false, array("style"=>"text-align:center"), ''),
-    array(get_lang('Type'), false, array("style"=>"text-align:center"), array("style"=>"text-align:center"), ''),
-    array(get_lang('QuestionCategory'), false, array("style"=>"text-align:center"), array("style"=>"text-align:center"), ''),
-    array(get_lang('Difficulty'), false, array("style"=>"text-align:center"), array("style"=>"text-align:center"), ''),
-    array($actionLabel, false, array("style"=>"text-align:center"), array("style"=>"text-align:center"), '')
+    array(
+        get_lang('QuestionUpperCaseFirstLetter'),
+        false,
+        array("style" => "text-align:center"),
+        ''
+    ),
+    array(
+        get_lang('Type'),
+        false,
+        array("style" => "text-align:center"),
+        array("style" => "text-align:center"),
+        ''
+    ),
+    array(
+        get_lang('QuestionCategory'),
+        false,
+        array("style" => "text-align:center"),
+        array("style" => "text-align:center"),
+        ''
+    ),
+    array(
+        get_lang('Difficulty'),
+        false,
+        array("style" => "text-align:center"),
+        array("style" => "text-align:center"),
+        ''
+    ),
+    array(
+        $actionLabel,
+        false,
+        array("style" => "text-align:center"),
+        array("style" => "text-align:center"),
+        ''
+    )
 );
 
 $data = array();

+ 7 - 3
main/exercise/unique_answer_no_option.class.php

@@ -14,8 +14,8 @@ use ChamiloSession as Session;
  */
 class UniqueAnswerNoOption extends Question
 {
-	public static $typePicture = 'mcuao.png';
-	public static $explanationLangVar = 'UniqueAnswerNoOption';
+    public static $typePicture = 'mcuao.png';
+    public static $explanationLangVar = 'UniqueAnswerNoOption';
 
     /**
      * Constructor
@@ -35,7 +35,11 @@ class UniqueAnswerNoOption extends Question
         // getting the exercise list
         $obj_ex = Session::read('objExercise');
 
-        $editor_config = array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '125');
+        $editor_config = array(
+            'ToolbarSet' => 'TestProposedAnswer',
+            'Width' => '100%',
+            'Height' => '125'
+        );
         //this line define how many question by default appear when creating a choice question
         $nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 3; // The previous default value was 2. See task #1759.
         $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));