Bladeren bron

Minor - Format code

Julio 8 jaren geleden
bovenliggende
commit
edc2633272

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

@@ -21,8 +21,8 @@ class CalculatedAnswer extends Question
     public function __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);
             $preArray = explode('@@', $objAnswer->selectAnswer(1));
             $defaults['formula'] = array_pop($preArray);
-
             $defaults['answer'] = array_shift($preArray);
             $defaults['answer'] = preg_replace("/\[.*\]/", "", $defaults['answer']);
-
             $defaults['weighting'] = $this->weighting;
-
         } else {
             $defaults['answer'] = get_lang('DefaultTextInBlanks');
         }
@@ -149,11 +146,12 @@ class CalculatedAnswer extends Question
             )
         );
         $form->addElement(
-            'label', null,
-            $notationListButton);
+            'label',
+            null,
+            $notationListButton
+        );
 
         $form->addElement('label', null, get_lang('FormulaExample'));
-
         $form->addElement('text', 'formula', get_lang('Formula'), array('id' => 'formula'));
         $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
      * @param FormValidator $form
      */
-    function processAnswersCreation($form)
+    public function processAnswersCreation($form)
     {
         if (!self::isAnswered()) {
             $table = Database::get_course_table(TABLE_QUIZ_ANSWER);
@@ -200,6 +198,7 @@ class CalculatedAnswer extends Question
             $highestValues = $form->getSubmitValue('highestValue');
             $answerVariations = $form->getSubmitValue('answerVariations');
             $this->weighting = $form->getSubmitValue('weighting');
+
             // Create as many answers as $answerVariations
             for ($j=0 ; $j < $answerVariations; $j++) {
                 $auxAnswer = $answer;
@@ -247,7 +246,7 @@ class CalculatedAnswer extends Question
      * @param null $score
      * @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 .= '<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 ');
 
         $answer_correct_array = array();
-
         $orderedHotspots = [];
 
         if ($answerType == HOT_SPOT) {
@@ -3294,7 +3293,6 @@ class Exercise
                     ['hotspotId' => 'ASC']
                 );
         }
-
         for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
             $answer = $objAnswerTmp->selectAnswer($answerId);
             $answerComment = $objAnswerTmp->selectComment($answerId);
@@ -3757,9 +3755,7 @@ class Exercise
                             $listCorrectAnswers
                         );
                     }
-
                     break;
-                // for calculated answer
                 case CALCULATED_ANSWER:
                     $answer = $objAnswerTmp->selectAnswer($_SESSION['calculatedAnswerId'][$questionId]);
                     $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();
 
-Display :: display_normal_message(get_lang('Saved').'<br />',false);
+Display::display_normal_message(get_lang('Saved').'<br />',false);
 
 // Display and save questions
 ExerciseLib::display_question_list_by_attempt($objExercise, $exe_id, true);
@@ -165,6 +165,7 @@ ExerciseLib::exercise_time_control_delete(
     $learnpath_id,
     $learnpath_item_id
 );
+
 ExerciseLib::delete_chat_exercise_session($exe_id);
 
 if ($origin != 'learnpath') {
@@ -180,7 +181,6 @@ if ($origin != 'learnpath') {
         Session::erase('objExercise');
         Session::erase('exe_id');
     }
-
 	Display::display_footer();
 } else {
 	$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;
 
                 } elseif ($answerType == CALCULATED_ANSWER) {
+
                     /*
                      * In the CALCULATED_ANSWER test
                      * you mustn't have [ and ] in the textarea
@@ -641,6 +642,7 @@ class ExerciseLib
                             );
                         }
                     }
+
                     list($answer) = explode('@@', $answer);
                     // $correctAnswerList array of array with correct anwsers 0=> [0=>[\p] 1=>[plop]]
                     api_preg_match_all(
@@ -648,6 +650,7 @@ class ExerciseLib
                         $answer,
                         $correctAnswerList
                     );
+
                     // get student answer to display it if student go back to previous calculated answer question in a test
                     if (isset($user_choice[0]['answer'])) {
                         api_preg_match_all(
@@ -686,11 +689,13 @@ class ExerciseLib
                             $studentAnswerList[] = $answerCorrected;
                         }
                     }
+
                     // If display preview of answer in test view for exemple, set the student answer to the correct answers
                     if ($debug_mark_answer) {
                         // contain the rights answers surronded with brackets
                         $studentAnswerList = $correctAnswerList[0];
                     }
+
                     /*
                     Split the response by bracket
                     tabComments is an array with text surrounding the text to find
@@ -3541,7 +3546,7 @@ HOTSPOT;
 
                 // creates a temporary Question object
                 $objQuestionTmp = Question::read($questionId);
-
+                
                 // This variable came from exercise_submit_modal.php
                 ob_start();