diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 20b49e961c..1104da16dd 100755 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -2480,7 +2480,7 @@ class Exercise WHERE exe_id = $exeId AND question_id= ".intval($questionId); $resfill = Database::query($queryfill); - $str = Database::result($resfill,0,'answer'); + $str = Database::result($resfill, 0, 'answer'); $listStudentResults = FillBlanks::getAnswerInfo($str, true); $choice = $listStudentResults['studentanswer']; diff --git a/main/exercice/exercise.lib.php b/main/exercice/exercise.lib.php index b8bdc606d1..c06a4e3c9e 100755 --- a/main/exercice/exercise.lib.php +++ b/main/exercice/exercise.lib.php @@ -445,7 +445,7 @@ function showQuestion( list($answer) = explode('::', $answer); - //Correct answer + //Correct answers $correctAnswerList = $listAnswerInformations['tabwords']; //Student's answer @@ -455,7 +455,7 @@ function showQuestion( $studentAnswerList = $arrayStudentAnswer['studentanswer']; } - // If display the question with answer (in page exercice/admin.php) for teacher preview + // If the question must be shown with the answer (in page exercice/admin.php) for teacher preview // set the student-answer to the correct answer if ($debug_mark_answer) { $studentAnswerList = $correctAnswerList; @@ -473,9 +473,9 @@ function showQuestion( // replace / with \/ to allow the preg_replace bellow and all the regexp char $correctItemRegexp = FillBlanks::getRegexpProtected($correctItemRegexp); if (isset($studentAnswerList[$i])) { - // student already start this test and this question + // If student already started this test and answered this question, // fill the blank with his previous answers - // may be "" if student did the question, but not fill the blanks + // may be "" if student viewed the question, but did not fill the blanks $correctItem = $studentAnswerList[$i]; } $attributes["style"] = "width:".$listAnswerInformations["tabinputsize"][$i]."px"; diff --git a/main/exercice/fill_blanks.class.php b/main/exercice/fill_blanks.class.php index fcbfdc69e1..9abbf204e7 100755 --- a/main/exercice/fill_blanks.class.php +++ b/main/exercice/fill_blanks.class.php @@ -284,7 +284,7 @@ class FillBlanks 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) { global $charset; @@ -294,7 +294,7 @@ class FillBlanks extends Question $answer = api_html_entity_decode($answer, ENT_QUOTES, $charset); // remove the :: eventually written by the user - $answer = str_replace('::','',$answer); + $answer = str_replace('::', '', $answer); // remove starting and ending space and $answer = api_preg_replace("/\xc2\xa0/", " ", $answer); @@ -307,7 +307,8 @@ class FillBlanks extends Question $blankEndSeparatorRegexp = self::escapeForRegexp($blankEndSeparator); // remove spaces at the beginning and the end of text in square brackets - $answer = preg_replace_callback("/".$blankStartSeparatorRegexp."[^]]+".$blankEndSeparatorRegexp."/", + $answer = preg_replace_callback( + "/".$blankStartSeparatorRegexp."[^]]+".$blankEndSeparatorRegexp."/", function ($matches) use ($blankStartSeparator, $blankEndSeparator) { $matchingResult = $matches[0]; $matchingResult = trim($matchingResult, $blankStartSeparator); @@ -318,12 +319,12 @@ class FillBlanks extends Question $matchingResult = str_replace('/"/', "", $matchingResult); return $blankStartSeparator.$matchingResult.$blankEndSeparator; }, - $answer); + $answer + ); // get the blanks weightings $nb = preg_match_all('/'.$blankStartSeparatorRegexp.'[^'.$blankStartSeparatorRegexp.']*'.$blankEndSeparatorRegexp.'/', $answer, $blanks); - if(isset($_GET['editQuestion'])) - { + if (isset($_GET['editQuestion'])) { $this -> weighting = 0; } @@ -344,10 +345,10 @@ class FillBlanks extends Question D : input width for the word [pen] E : equal @1 if "Allow answers order switches" has been checked, @ otherwise */ - if($nb > 0) { + if ($nb > 0) { $answer .= '::'; // weighting - for($i=0 ; $i < $nb ; ++$i) { + for ($i=0; $i < $nb; ++$i) { // enter the weighting of word $i $answer .= $form->getSubmitValue('weighting['.$i.']'); // not the last word, add "," @@ -360,7 +361,7 @@ class FillBlanks extends Question // input width $answer .= ":"; - for ($i=0 ; $i < $nb ; ++$i) { + for ($i=0; $i < $nb; ++$i) { // enter the width of input for word $i $answer .= $form->getSubmitValue('sizeofinput['.$i.']'); // not the last word, add "," @@ -399,7 +400,7 @@ class FillBlanks 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 .= '