Minor - Coding conventions + comments

1.9.x
Yannick Warnier 11 years ago
parent 02d3aa4b23
commit f5578b4c5a
  1. 8
      main/exercice/exercise.lib.php
  2. 29
      main/exercice/fill_blanks.class.php

@ -445,7 +445,7 @@ function showQuestion(
list($answer) = explode('::', $answer); list($answer) = explode('::', $answer);
//Correct answer //Correct answers
$correctAnswerList = $listAnswerInformations['tabwords']; $correctAnswerList = $listAnswerInformations['tabwords'];
//Student's answer //Student's answer
@ -455,7 +455,7 @@ function showQuestion(
$studentAnswerList = $arrayStudentAnswer['studentanswer']; $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 // set the student-answer to the correct answer
if ($debug_mark_answer) { if ($debug_mark_answer) {
$studentAnswerList = $correctAnswerList; $studentAnswerList = $correctAnswerList;
@ -473,9 +473,9 @@ function showQuestion(
// replace / with \/ to allow the preg_replace bellow and all the regexp char // replace / with \/ to allow the preg_replace bellow and all the regexp char
$correctItemRegexp = FillBlanks::getRegexpProtected($correctItemRegexp); $correctItemRegexp = FillBlanks::getRegexpProtected($correctItemRegexp);
if (isset($studentAnswerList[$i])) { 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 // 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]; $correctItem = $studentAnswerList[$i];
} }
$attributes["style"] = "width:".$listAnswerInformations["tabinputsize"][$i]."px"; $attributes["style"] = "width:".$listAnswerInformations["tabinputsize"][$i]."px";

@ -284,7 +284,7 @@ class FillBlanks 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)
{ {
global $charset; global $charset;
@ -307,7 +307,8 @@ class FillBlanks extends Question
$blankEndSeparatorRegexp = self::escapeForRegexp($blankEndSeparator); $blankEndSeparatorRegexp = self::escapeForRegexp($blankEndSeparator);
// remove spaces at the beginning and the end of text in square brackets // 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) { function ($matches) use ($blankStartSeparator, $blankEndSeparator) {
$matchingResult = $matches[0]; $matchingResult = $matches[0];
$matchingResult = trim($matchingResult, $blankStartSeparator); $matchingResult = trim($matchingResult, $blankStartSeparator);
@ -318,12 +319,12 @@ class FillBlanks extends Question
$matchingResult = str_replace('/"/', "", $matchingResult); $matchingResult = str_replace('/"/', "", $matchingResult);
return $blankStartSeparator.$matchingResult.$blankEndSeparator; return $blankStartSeparator.$matchingResult.$blankEndSeparator;
}, },
$answer); $answer
);
// get the blanks weightings // get the blanks weightings
$nb = preg_match_all('/'.$blankStartSeparatorRegexp.'[^'.$blankStartSeparatorRegexp.']*'.$blankEndSeparatorRegexp.'/', $answer, $blanks); $nb = preg_match_all('/'.$blankStartSeparatorRegexp.'[^'.$blankStartSeparatorRegexp.']*'.$blankEndSeparatorRegexp.'/', $answer, $blanks);
if(isset($_GET['editQuestion'])) if (isset($_GET['editQuestion'])) {
{
$this -> weighting = 0; $this -> weighting = 0;
} }
@ -399,7 +400,7 @@ class FillBlanks 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 .'">
@ -455,6 +456,7 @@ class FillBlanks extends Question
$result .= '</select>'; $result .= '</select>';
break; break;
case self::FILL_THE_BLANK_SEVERAL_ANSWER: case self::FILL_THE_BLANK_SEVERAL_ANSWER:
//no break
case self::FILL_THE_BLANK_STANDARD: case self::FILL_THE_BLANK_STANDARD:
default: default:
$result = Display::input('text', "choice[$questionId][]", $correctItem, $attributes); $result = Display::input('text', "choice[$questionId][]", $correctItem, $attributes);
@ -465,7 +467,7 @@ class FillBlanks extends Question
/** /**
* Return an array with the differents choice avaliable when the bracket is a menu * Return an array with the different choices available when the answers between bracket show as a menu
* @param $correctAnswer * @param $correctAnswer
* @param $displayForStudent true if we want to shuffle the choices of the menu for students * @param $displayForStudent true if we want to shuffle the choices of the menu for students
* @return array * @return array
@ -482,7 +484,7 @@ class FillBlanks extends Question
/** /**
* Return the array indice of the student answer * Return the array index of the student answer
* @param $correctAnswer the menu Choice1|Choice2|Choice3 * @param $correctAnswer the menu Choice1|Choice2|Choice3
* @param $studentAnswer the student answer must be Choice1 or Choice2 or Choice3 * @param $studentAnswer the student answer must be Choice1 or Choice2 or Choice3
* @return int in the exemple 0 1 or 2 depending of the choice of the student * @return int in the exemple 0 1 or 2 depending of the choice of the student
@ -500,7 +502,7 @@ class FillBlanks extends Question
/** /**
* return the possible answer if bracket is a multiple choice menu * Return the possible answer if the answer between brackets is a multiple choice menu
* @param $correctAnswer * @param $correctAnswer
* @return array * @return array
*/ */
@ -513,8 +515,8 @@ class FillBlanks extends Question
/** /**
* Return true if student answer is right according to the correctAnswer * Return true if student answer is right according to the correctAnswer
* it is not so simple as equality, because of the type of Fill The Blank question * it is not as simple as equality, because of the type of Fill The Blank question
* eg : studentNaswer = 'Un' and correctAnswer = 'Un||1||un' * eg : studentAnswer = 'Un' and correctAnswer = 'Un||1||un'
* @param $studentAnswer the [studentanswer] of the info array of the answer field * @param $studentAnswer the [studentanswer] of the info array of the answer field
* @param $correctAnswer the [tabwords] of the info array of the answer field * @param $correctAnswer the [tabwords] of the info array of the answer field
* @return bool * @return bool
@ -622,8 +624,9 @@ class FillBlanks extends Question
if ($listAnswerResults['wordsCount'] > 0) { if ($listAnswerResults['wordsCount'] > 0) {
$listAnswerResults['tabwordsbracket'] = $listWords[0]; $listAnswerResults['tabwordsbracket'] = $listWords[0];
// remove [ and ] in string // remove [ and ] in string
array_walk($listWords[0],function (&$value, $key, $tabBlankChar) array_walk(
{ $listWords[0],
function (&$value, $key, $tabBlankChar) {
$trimChars = ""; $trimChars = "";
for ($i=0; $i < count($tabBlankChar); $i++) { for ($i=0; $i < count($tabBlankChar); $i++) {
$trimChars .= $tabBlankChar[$i]; $trimChars .= $tabBlankChar[$i];

Loading…
Cancel
Save