Browse Source

Minor - Format code

Julio 8 years ago
parent
commit
edc2633272

+ 9 - 10
main/exercice/calculated_answer.class.php

@@ -21,8 +21,8 @@ class CalculatedAnswer extends Question
     public function __construct()
     public function __construct()
     {
     {
         parent::__construct();
         parent::__construct();
-        $this -> type = CALCULATED_ANSWER;
-        $this -> isContent = $this-> getIsContent();
+        $this->type = CALCULATED_ANSWER;
+        $this->isContent = $this->getIsContent();
     }
     }
 
 
     /**
     /**
@@ -37,12 +37,9 @@ class CalculatedAnswer extends Question
             $objAnswer = new Answer($this->id);
             $objAnswer = new Answer($this->id);
             $preArray = explode('@@', $objAnswer->selectAnswer(1));
             $preArray = explode('@@', $objAnswer->selectAnswer(1));
             $defaults['formula'] = array_pop($preArray);
             $defaults['formula'] = array_pop($preArray);
-
             $defaults['answer'] = array_shift($preArray);
             $defaults['answer'] = array_shift($preArray);
             $defaults['answer'] = preg_replace("/\[.*\]/", "", $defaults['answer']);
             $defaults['answer'] = preg_replace("/\[.*\]/", "", $defaults['answer']);
-
             $defaults['weighting'] = $this->weighting;
             $defaults['weighting'] = $this->weighting;
-
         } else {
         } else {
             $defaults['answer'] = get_lang('DefaultTextInBlanks');
             $defaults['answer'] = get_lang('DefaultTextInBlanks');
         }
         }
@@ -149,11 +146,12 @@ class CalculatedAnswer extends Question
             )
             )
         );
         );
         $form->addElement(
         $form->addElement(
-            'label', null,
-            $notationListButton);
+            'label',
+            null,
+            $notationListButton
+        );
 
 
         $form->addElement('label', null, get_lang('FormulaExample'));
         $form->addElement('label', null, get_lang('FormulaExample'));
-
         $form->addElement('text', 'formula', get_lang('Formula'), array('id' => 'formula'));
         $form->addElement('text', 'formula', get_lang('Formula'), array('id' => 'formula'));
         $form->addRule('formula', get_lang('GiveFormula'), 'required');
         $form->addRule('formula', get_lang('GiveFormula'), 'required');
 
 
@@ -181,7 +179,7 @@ class CalculatedAnswer extends Question
      * abstract function which creates the form to create / edit the answers of the question
      * abstract function which creates the form to create / edit the answers of the question
      * @param FormValidator $form
      * @param FormValidator $form
      */
      */
-    function processAnswersCreation($form)
+    public function processAnswersCreation($form)
     {
     {
         if (!self::isAnswered()) {
         if (!self::isAnswered()) {
             $table = Database::get_course_table(TABLE_QUIZ_ANSWER);
             $table = Database::get_course_table(TABLE_QUIZ_ANSWER);
@@ -200,6 +198,7 @@ class CalculatedAnswer extends Question
             $highestValues = $form->getSubmitValue('highestValue');
             $highestValues = $form->getSubmitValue('highestValue');
             $answerVariations = $form->getSubmitValue('answerVariations');
             $answerVariations = $form->getSubmitValue('answerVariations');
             $this->weighting = $form->getSubmitValue('weighting');
             $this->weighting = $form->getSubmitValue('weighting');
+
             // Create as many answers as $answerVariations
             // Create as many answers as $answerVariations
             for ($j=0 ; $j < $answerVariations; $j++) {
             for ($j=0 ; $j < $answerVariations; $j++) {
                 $auxAnswer = $answer;
                 $auxAnswer = $answer;
@@ -247,7 +246,7 @@ class CalculatedAnswer extends Question
      * @param null $score
      * @param null $score
      * @return null|string
      * @return null|string
      */
      */
-    function return_header($feedback_type = null, $counter = null, $score = null)
+    public function return_header($feedback_type = null, $counter = null, $score = null)
     {
     {
         $header = parent::return_header($feedback_type, $counter, $score);
         $header = parent::return_header($feedback_type, $counter, $score);
         $header .= '<table class="'.$this->question_table_class .'">
         $header .= '<table class="'.$this->question_table_class .'">

+ 0 - 4
main/exercice/exercise.class.php

@@ -3280,7 +3280,6 @@ class Exercise
         if ($debug) error_log('Start answer loop ');
         if ($debug) error_log('Start answer loop ');
 
 
         $answer_correct_array = array();
         $answer_correct_array = array();
-
         $orderedHotspots = [];
         $orderedHotspots = [];
 
 
         if ($answerType == HOT_SPOT) {
         if ($answerType == HOT_SPOT) {
@@ -3294,7 +3293,6 @@ class Exercise
                     ['hotspotId' => 'ASC']
                     ['hotspotId' => 'ASC']
                 );
                 );
         }
         }
-
         for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
         for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
             $answer = $objAnswerTmp->selectAnswer($answerId);
             $answer = $objAnswerTmp->selectAnswer($answerId);
             $answerComment = $objAnswerTmp->selectComment($answerId);
             $answerComment = $objAnswerTmp->selectComment($answerId);
@@ -3757,9 +3755,7 @@ class Exercise
                             $listCorrectAnswers
                             $listCorrectAnswers
                         );
                         );
                     }
                     }
-
                     break;
                     break;
-                // for calculated answer
                 case CALCULATED_ANSWER:
                 case CALCULATED_ANSWER:
                     $answer = $objAnswerTmp->selectAnswer($_SESSION['calculatedAnswerId'][$questionId]);
                     $answer = $objAnswerTmp->selectAnswer($_SESSION['calculatedAnswerId'][$questionId]);
                     $preArray = explode('@@', $answer);
                     $preArray = explode('@@', $answer);

+ 2 - 2
main/exercice/exercise_result.php

@@ -154,7 +154,7 @@ if (!empty($exercise_stat_info)) {
 
 
 $max_score = $objExercise->get_max_score();
 $max_score = $objExercise->get_max_score();
 
 
-Display :: display_normal_message(get_lang('Saved').'<br />',false);
+Display::display_normal_message(get_lang('Saved').'<br />',false);
 
 
 // Display and save questions
 // Display and save questions
 ExerciseLib::display_question_list_by_attempt($objExercise, $exe_id, true);
 ExerciseLib::display_question_list_by_attempt($objExercise, $exe_id, true);
@@ -165,6 +165,7 @@ ExerciseLib::exercise_time_control_delete(
     $learnpath_id,
     $learnpath_id,
     $learnpath_item_id
     $learnpath_item_id
 );
 );
+
 ExerciseLib::delete_chat_exercise_session($exe_id);
 ExerciseLib::delete_chat_exercise_session($exe_id);
 
 
 if ($origin != 'learnpath') {
 if ($origin != 'learnpath') {
@@ -180,7 +181,6 @@ if ($origin != 'learnpath') {
         Session::erase('objExercise');
         Session::erase('objExercise');
         Session::erase('exe_id');
         Session::erase('exe_id');
     }
     }
-
 	Display::display_footer();
 	Display::display_footer();
 } else {
 } else {
 	$lp_mode = isset($_SESSION['lp_mode']) ? $_SESSION['lp_mode'] : null;
 	$lp_mode = isset($_SESSION['lp_mode']) ? $_SESSION['lp_mode'] : null;

+ 6 - 1
main/inc/lib/exercise.lib.php

@@ -613,6 +613,7 @@ class ExerciseLib
                     $s .= $answer;
                     $s .= $answer;
 
 
                 } elseif ($answerType == CALCULATED_ANSWER) {
                 } elseif ($answerType == CALCULATED_ANSWER) {
+
                     /*
                     /*
                      * In the CALCULATED_ANSWER test
                      * In the CALCULATED_ANSWER test
                      * you mustn't have [ and ] in the textarea
                      * you mustn't have [ and ] in the textarea
@@ -641,6 +642,7 @@ class ExerciseLib
                             );
                             );
                         }
                         }
                     }
                     }
+
                     list($answer) = explode('@@', $answer);
                     list($answer) = explode('@@', $answer);
                     // $correctAnswerList array of array with correct anwsers 0=> [0=>[\p] 1=>[plop]]
                     // $correctAnswerList array of array with correct anwsers 0=> [0=>[\p] 1=>[plop]]
                     api_preg_match_all(
                     api_preg_match_all(
@@ -648,6 +650,7 @@ class ExerciseLib
                         $answer,
                         $answer,
                         $correctAnswerList
                         $correctAnswerList
                     );
                     );
+
                     // get student answer to display it if student go back to previous calculated answer question in a test
                     // get student answer to display it if student go back to previous calculated answer question in a test
                     if (isset($user_choice[0]['answer'])) {
                     if (isset($user_choice[0]['answer'])) {
                         api_preg_match_all(
                         api_preg_match_all(
@@ -686,11 +689,13 @@ class ExerciseLib
                             $studentAnswerList[] = $answerCorrected;
                             $studentAnswerList[] = $answerCorrected;
                         }
                         }
                     }
                     }
+
                     // If display preview of answer in test view for exemple, set the student answer to the correct answers
                     // If display preview of answer in test view for exemple, set the student answer to the correct answers
                     if ($debug_mark_answer) {
                     if ($debug_mark_answer) {
                         // contain the rights answers surronded with brackets
                         // contain the rights answers surronded with brackets
                         $studentAnswerList = $correctAnswerList[0];
                         $studentAnswerList = $correctAnswerList[0];
                     }
                     }
+
                     /*
                     /*
                     Split the response by bracket
                     Split the response by bracket
                     tabComments is an array with text surrounding the text to find
                     tabComments is an array with text surrounding the text to find
@@ -3541,7 +3546,7 @@ HOTSPOT;
 
 
                 // creates a temporary Question object
                 // creates a temporary Question object
                 $objQuestionTmp = Question::read($questionId);
                 $objQuestionTmp = Question::read($questionId);
-
+                
                 // This variable came from exercise_submit_modal.php
                 // This variable came from exercise_submit_modal.php
                 ob_start();
                 ob_start();